Files
esp-idf/components/esp_system/ld/ld.ext_ram.sections
Mahavir Jain c566ace1f6 fix(esp_system): fixes build failure with XIP PSRAM + BSS/NoInit in external memory
Declare ext_ram_xip_seg as a distinct region overlapping drom_seg at the
same origin (the esp32s3/c5/c61/h4 pattern) instead of aliasing drom_seg,
so .ext_ram.dummy has its own location counter and .ext_ram.bss reclaims
the VMA space of NOLOAD rodata (.rodata_wlog_*), saving up to one MMU
page of PSRAM on esp32s31. No layout change on esp32p4.

Closes https://github.com/espressif/esp-idf/issues/18791
Related https://github.com/espressif/esp-idf/issues/14992
2026-07-22 16:39:25 +05:30

51 lines
1.8 KiB
Plaintext

#include "sdkconfig.h"
#include "ld.common"
#if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY || CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY
/**
* Dummy section to skip flash rodata sections in case `ext_ram_seg`
* and `flash_rodata_seg` are on the same bus.
*/
.ext_ram.dummy (NOLOAD) :
{
HIDDEN(_ext_ram_on_same_bus = ORIGIN(ext_ram_seg) == ORIGIN(flash_rodata_seg));
/**
* This must be the first section placed in `ext_ram_seg`, and `ext_ram_seg` must be
* a distinct region (not a REGION_ALIAS of `flash_rodata_seg`) so it has its own
* location counter. Otherwise NOLOAD rodata (e.g. .rodata_wlog_*) placed after
* `_rodata_reserved_end` leaves the counter past the skip target, and moving it
* backwards here is a hard linker error.
*/
. = _ext_ram_on_same_bus ? ORIGIN(ext_ram_seg) + (_rodata_reserved_end - _flash_rodata_dummy_start) : 0;
. = ALIGN(_ext_ram_on_same_bus ? _esp_mmu_page_size : 0);
} > ext_ram_seg
#if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
/* This section holds .ext_ram.bss data, and will be put in PSRAM */
.ext_ram.bss (NOLOAD) :
{
_ext_ram_bss_start = ABSOLUTE(.);
SECTION_MAPPINGS(extern_ram)
ALIGNED_SYMBOL(4, _ext_ram_bss_end)
} > ext_ram_seg
#endif // CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
#if CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY
/**
* This section holds data that won't be initialized at startup.
* This section is located in the External RAM region.
*/
.ext_ram_noinit (NOLOAD) :
{
_ext_ram_noinit_start = ABSOLUTE(.);
SECTION_MAPPINGS(extram_noinit)
*(.ext_ram_noinit*)
ALIGNED_SYMBOL(4, _ext_ram_noinit_end)
} > ext_ram_seg
#endif // CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY
#endif // CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY || CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY