boards/xtensa/esp32: Add a section in external memory to hold some BSS

data.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
Abdelatif Guettouche 2021-03-05 12:24:23 +01:00 committed by YAMAMOTO Takashi
parent b2563b99ca
commit cc23bdeca4
10 changed files with 71 additions and 0 deletions

View File

@ -131,6 +131,13 @@ config XTENSA_IMEM_REGION_SIZE
depends on XTENSA_IMEM_USE_SEPARATE_HEAP
default 0x18000
config XTENSA_EXTMEM_BSS
bool "Allow BSS section in external memory"
default n
help
Adds a section and an attribute that allows to force variables into
the external memory.
source arch/xtensa/src/lx6/Kconfig
if ARCH_CHIP_ESP32
source arch/xtensa/src/esp32/Kconfig

View File

@ -216,6 +216,8 @@ extern uint32_t _sbss; /* Start of .bss */
extern uint32_t _ebss; /* End+1 of .bss */
extern uint32_t _sheap; /* Start of heap */
extern uint32_t _eheap; /* End+1 of heap */
extern uint32_t _sbss_extmem; /* start of external memory bss */
extern uint32_t _ebss_extmem; /* End+1 of external memory bss */
/****************************************************************************
* Inline Functions

View File

@ -27,6 +27,12 @@
#ifndef __ARCH_XTENSA_SRC_COMMON_XTENSA_ATTR_H
#define __ARCH_XTENSA_SRC_COMMON_XTENSA_ATTR_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -63,4 +69,10 @@
#define RTC_RODATA_ATTR __attribute__((section(".rtc.rodata")))
/* Forces bss variable into external memory. */
#ifdef CONFIG_XTENSA_EXTMEM_BSS
# define EXT_RAM_ATTR __attribute__((section(".extmem.bss")))
#endif
#endif /* __ARCH_XTENSA_SRC_COMMON_XTENSA_ATTR_H */

View File

@ -157,6 +157,14 @@ void IRAM_ATTR __start(void)
PANIC();
# endif
}
/* Set external memory bss section to zero */
# ifdef CONFIG_XTENSA_EXTMEM_BSS
memset(&_sbss_extmem, 0,
(&_ebss_extmem - &_sbss_extmem) * sizeof(_sbss_extmem));
# endif
#endif
/* Initialize onboard resources */

View File

@ -68,6 +68,10 @@ MEMORY
rtc_slow_seg(RW) : org = 0x50000000 + CONFIG_ESP32_ULP_COPROC_RESERVE_MEM,
len = 0x1000 - CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
/* External memory, including data and text */
extmem_seg(RWX) : org = 0x3f800000, len = 0x400000
}
/* Heap ends at top of dram0_0_seg */

View File

@ -123,6 +123,16 @@ SECTIONS
_sheap = ABSOLUTE(.);
} >dram0_0_seg
/* External memory bss, from any global variable with EXT_RAM_ATTR attribute */
.extmem.bss (NOLOAD) :
{
_sbss_extmem = ABSOLUTE(.);
*(.extmem.bss .extmem.bss.*)
. = ALIGN(4);
_ebss_extmem = ABSOLUTE(.);
} > extmem_seg
.flash.rodata :
{
_srodata = ABSOLUTE(.);

View File

@ -68,6 +68,10 @@ MEMORY
rtc_slow_seg(RW) : org = 0x50000000 + CONFIG_ESP32_ULP_COPROC_RESERVE_MEM,
len = 0x1000 - CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
/* External memory, including data and text */
extmem_seg(RWX) : org = 0x3f800000, len = 0x400000
}
/* Heap ends at top of dram0_0_seg */

View File

@ -125,6 +125,16 @@ SECTIONS
_sheap = ABSOLUTE(.);
} >dram0_0_seg
/* External memory bss, from any global variable with EXT_RAM_ATTR attribute */
.extmem.bss (NOLOAD) :
{
_sbss_extmem = ABSOLUTE(.);
*(.extmem.bss .extmem.bss.*)
. = ALIGN(4);
_ebss_extmem = ABSOLUTE(.);
} > extmem_seg
.flash.rodata :
{
_srodata = ABSOLUTE(.);

View File

@ -68,6 +68,10 @@ MEMORY
rtc_slow_seg(RW) : org = 0x50000000 + CONFIG_ESP32_ULP_COPROC_RESERVE_MEM,
len = 0x1000 - CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
/* External memory, including data and text */
extmem_seg(RWX) : org = 0x3f800000, len = 0x400000
}
/* Heap ends at top of dram0_0_seg */

View File

@ -125,6 +125,16 @@ SECTIONS
_sheap = ABSOLUTE(.);
} >dram0_0_seg
/* External memory bss, from any global variable with EXT_RAM_ATTR attribute */
.extmem.bss (NOLOAD) :
{
_sbss_extmem = ABSOLUTE(.);
*(.extmem.bss .extmem.bss.*)
. = ALIGN(4);
_ebss_extmem = ABSOLUTE(.);
} > extmem_seg
.flash.rodata :
{
_srodata = ABSOLUTE(.);