ESP32: Fix heap initialization

This commit is contained in:
Gregory Nutt 2016-10-23 14:20:03 -06:00
parent a41c98952c
commit 9a9488ae92
5 changed files with 18 additions and 27 deletions

View File

@ -183,18 +183,14 @@ extern void g_intstackbase;
extern uint32_t _init_start; /* Start of initialization logic */
extern uint32_t _stext; /* Start of .text */
extern uint32_t _etext; /* End+1 of .text + .rodata */
extern const uint32_t _data_loaddr; /* Start of .data in FLASH */
extern uint32_t _sdata; /* Start of .data */
extern uint32_t _edata; /* End+1 of .data */
extern uint32_t _srodata; /* Start of .rodata */
extern uint32_t _erodata; /* End+1 of .rodata */
extern uint32_t _sbss; /* Start of .bss */
extern uint32_t _ebss; /* End+1 of .bss */
#ifdef CONFIG_ARCH_RAMFUNCS
extern uint32_t _sramfunc; /* Start of ramfuncs */
extern uint32_t _eramfunc; /* End+1 of ramfuncs */
extern uint32_t _ramfunc_loadaddr; /* Start of ramfuncs in FLASH */
extern uint32_t _ramfunc_sizeof; /* Size of ramfuncs */
#endif /* CONFIG_ARCH_RAMFUNCS */
#endif /* __ASSEMBLY__ */
extern uint32_t _sheap; /* Start of heap */
extern uint32_t _eheap; /* End+1 of heap */
/****************************************************************************
* Inline Functions

View File

@ -67,11 +67,13 @@
*
****************************************************************************/
#warning REVISIT heap. Do what with non-heterogeneous memory?
void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
{
board_autoled_on(LED_HEAPALLOCATE);
*heap_start = (FAR void *)g_idle_topstack;
*heap_size = CONFIG_RAM_END - g_idle_topstack;
*heap_start = (FAR void *)&_sheap;
*heap_size = (size_t)((uintptr_t)&_eheap - (uintptr_t)&_sheap);
}
/****************************************************************************

View File

@ -85,16 +85,6 @@ void IRAM_ATTR __start(void)
memset(&_sbss, 0, (&_ebss - &_sbss) * sizeof(_sbss));
#warning Missing logic: Initialize .data
#warning REVISIT heap. Do what with non-heterogeneous memory?
#warning REVISIT belongs in up_allocateheap()
#if 0
/* Initialize heap allocator */
heap_alloc_caps_init();
#endif
/* Make sure that the APP_CPU is disabled for now */
regval = getreg32(DPORT_APPCPU_CTRL_B_REG);

View File

@ -59,4 +59,4 @@ MEMORY
/* Heap ends at top of dram0_0_seg */
_heap_end = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;

View File

@ -56,7 +56,6 @@ SECTIONS
_iram_text_start = ABSOLUTE(.);
*(.iram1 .iram1.*)
*libfreertos.a:(.literal .text .literal.* .text.*)
*libphy.a:(.literal .text .literal.* .text.*)
*librtc.a:(.literal .text .literal.* .text.*)
*libpp.a:(.literal .text .literal.* .text.*)
@ -90,7 +89,7 @@ SECTIONS
.dram0.data :
{
_data_start = ABSOLUTE(.);
_sdata = ABSOLUTE(.);
KEEP(*(.data))
KEEP(*(.data.*))
KEEP(*(.gnu.linkonce.d.*))
@ -103,14 +102,14 @@ SECTIONS
KEEP(*(.gnu.linkonce.s2.*))
KEEP(*(.jcr))
*(.dram1 .dram1.*)
_data_end = ABSOLUTE(.);
_edata = ABSOLUTE(.);
. = ALIGN(4);
_heap_start = ABSOLUTE(.);
_sheap = ABSOLUTE(.);
} >dram0_0_seg
.flash.rodata :
{
_rodata_start = ABSOLUTE(.);
_srodata = ABSOLUTE(.);
*(.rodata)
*(.rodata.*)
*(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */
@ -122,7 +121,9 @@ SECTIONS
*(.gnu.linkonce.e.*)
*(.gnu.version_r)
*(.eh_frame)
. = (. + 3) & ~ 3;
/* C++ constructor and destructor tables, properly ordered: */
__init_array_start = ABSOLUTE(.);
KEEP (*crtbegin.o(.ctors))
@ -134,7 +135,9 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
/* C++ exception handlers table: */
__XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
*(.xt_except_desc)
*(.gnu.linkonce.h.*)
@ -142,7 +145,7 @@ SECTIONS
*(.xt_except_desc_end)
*(.dynamic)
*(.gnu.version_d)
_rodata_end = ABSOLUTE(.);
_erodata = ABSOLUTE(.);
/* Literals are also RO data. */
_lit4_start = ABSOLUTE(.);
*(*.lit4)