esp-hal/esp32-hal/ld/link-esp32.x
Scott Mabin 3444476eb2 ESP32 DRAM linker fix
The ROM code _data_ section is loaded into the middle of the DRAM
address space, unlike the other chips where it is loaded at the end.
Therefore subtracting the previously "reserved" section from heap end
could actually corrupt the ROM data section.

For the ESP32, the DRAM block has been split into two individual
segments, with some reserved segments in the middle (addresses taken
from esp-idf). At the moment we don't use the second segment at all in
esp-hal, but we could utilize it in esp-wifi for placing the internal
allocator for example.
2023-03-24 14:49:45 +00:00

42 lines
955 B
Plaintext

/* before memory.x to allow override */
ENTRY(Reset)
INCLUDE memory.x
/* after memory.x to allow override */
PROVIDE(__pre_init = DefaultPreInit);
PROVIDE(__zero_bss = default_mem_hook);
PROVIDE(__init_data = default_mem_hook);
INCLUDE exception.x
/* map generic regions to output sections */
INCLUDE "alias.x"
/* ESP32 fixups */
INCLUDE "fixups/rtc_fast_rwdata_dummy.x"
/* END ESP32 fixups */
/* Shared sections - ordering matters */
INCLUDE "text.x"
INCLUDE "rodata.x"
INCLUDE "rwtext.x"
INCLUDE "rwdata.x"
INCLUDE "rtc_fast.x"
INCLUDE "rtc_slow.x"
INCLUDE "external.x"
/* End of Shared sections */
_heap_end = ABSOLUTE(ORIGIN(dram_seg))+LENGTH(dram_seg) - 2*STACK_SIZE;
_stack_start_cpu1 = _heap_end;
_stack_end_cpu1 = _stack_start_cpu1 + STACK_SIZE;
_stack_start_cpu0 = _stack_end_cpu1;
_stack_end_cpu0 = _stack_start_cpu0 + STACK_SIZE;
EXTERN(DefaultHandler);
EXTERN(WIFI_EVENT); /* Force inclusion of WiFi libraries */
INCLUDE "device.x"