Skip to content

Commit

Permalink
Merge branch 'bugfix/static_ram_size' into 'master'
Browse files Browse the repository at this point in the history
system: fixed USE_FIXED_STATIC_RAM_SIZE option

See merge request espressif/esp-idf!21368
  • Loading branch information
jack0c committed Mar 20, 2023
2 parents 0b043f0 + 585f055 commit fdea528
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 85 deletions.
4 changes: 2 additions & 2 deletions components/esp_system/ld/esp32/memory.ld.in
Expand Up @@ -114,9 +114,9 @@ MEMORY

#if defined(CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE)
/* static data ends at defined address */
_static_data_end = 0x3FFB0000 + DRAM0_0_SEG_LEN;
_heap_start = 0x3FFB0000 + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
_heap_start = _heap_low_start;
#endif

/* Heap ends at top of dram0_0_seg */
Expand Down
5 changes: 3 additions & 2 deletions components/esp_system/ld/esp32/sections.ld.in
Expand Up @@ -404,7 +404,8 @@ SECTIONS
.dram0.heap_start (NOLOAD) :
{
. = ALIGN (8);
_heap_start = ABSOLUTE(.);
/* Lowest possible start address for the heap */
_heap_low_start = ABSOLUTE(.);
} > dram0_0_seg

/** This section will be used by the debugger and disassembler to get more information
Expand All @@ -430,5 +431,5 @@ SECTIONS
ASSERT(((_iram_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
"IRAM0 segment data does not fit.")

ASSERT(((_heap_start - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)),
ASSERT(((_heap_low_start - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)),
"DRAM segment data does not fit.")
13 changes: 1 addition & 12 deletions components/esp_system/ld/esp32c2/memory.ld.in
Expand Up @@ -20,12 +20,8 @@

#define I_D_SRAM_SIZE SRAM_DRAM_END - SRAM_DRAM_ORG

#if CONFIG_ESP32C2_USE_FIXED_STATIC_RAM_SIZE
ASSERT((CONFIG_ESP32C2_FIXED_STATIC_RAM_SIZE <= I_D_SRAM_SIZE), "Fixed static ram data does not fit.")
#define DRAM0_0_SEG_LEN CONFIG_ESP32C2_FIXED_STATIC_RAM_SIZE
#else
#define DRAM0_0_SEG_LEN I_D_SRAM_SIZE
#endif // CONFIG_ESP32C2_USE_FIXED_STATIC_RAM_SIZE

MEMORY
{
/**
Expand Down Expand Up @@ -65,13 +61,6 @@ MEMORY

}

#if CONFIG_ESP32C2_USE_FIXED_STATIC_RAM_SIZE
/* static data ends at defined address */
_static_data_end = 0x3FCA0000 + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
#endif // CONFIG_ESP32C2_USE_FIXED_STATIC_RAM_SIZE

/* Heap ends at top of dram0_0_seg */
_heap_end = 0x40000000;

Expand Down
13 changes: 1 addition & 12 deletions components/esp_system/ld/esp32c3/memory.ld.in
Expand Up @@ -38,12 +38,8 @@

#define I_D_SRAM_SIZE SRAM_DRAM_END - SRAM_DRAM_ORG

#if CONFIG_ESP32C3_USE_FIXED_STATIC_RAM_SIZE
ASSERT((CONFIG_ESP32C3_FIXED_STATIC_RAM_SIZE <= I_D_SRAM_SIZE), "Fixed static ram data does not fit.")
#define DRAM0_0_SEG_LEN CONFIG_ESP3C3_FIXED_STATIC_RAM_SIZE
#else
#define DRAM0_0_SEG_LEN I_D_SRAM_SIZE
#endif // CONFIG_ESP32C3_USE_FIXED_STATIC_RAM_SIZE

MEMORY
{
/**
Expand Down Expand Up @@ -87,13 +83,6 @@ MEMORY
rtc_iram_seg(RWX) : org = 0x50000000, len = 0x2000 - ESP_BOOTLOADER_RESERVE_RTC
}

#if CONFIG_ESP32C3_USE_FIXED_STATIC_RAM_SIZE
/* static data ends at defined address */
_static_data_end = 0x3FCA0000 + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
#endif // CONFIG_ESP32C3_USE_FIXED_STATIC_RAM_SIZE

/* Heap ends at top of dram0_0_seg */
_heap_end = 0x40000000;

Expand Down
13 changes: 1 addition & 12 deletions components/esp_system/ld/esp32c6/memory.ld.in
Expand Up @@ -45,12 +45,8 @@
#define IDRAM0_2_SEG_SIZE (CONFIG_MMU_PAGE_SIZE << 8)
#endif

#if CONFIG_ESP32C6_USE_FIXED_STATIC_RAM_SIZE
ASSERT((CONFIG_ESP32C6_FIXED_STATIC_RAM_SIZE <= I_D_SRAM_SIZE), "Fixed static ram data does not fit.")
#define DRAM0_0_SEG_LEN CONFIG_ESP3C6_FIXED_STATIC_RAM_SIZE
#else
#define DRAM0_0_SEG_LEN I_D_SRAM_SIZE
#endif // CONFIG_ESP32C6_USE_FIXED_STATIC_RAM_SIZE

MEMORY
{
/**
Expand Down Expand Up @@ -100,13 +96,6 @@ MEMORY

}

#if CONFIG_ESP32C6_USE_FIXED_STATIC_RAM_SIZE
/* static data ends at defined address */
_static_data_end = 0x40820000 + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
#endif // CONFIG_ESP32C6_USE_FIXED_STATIC_RAM_SIZE

/* Heap ends at top of dram0_0_seg */
_heap_end = 0x40000000;

Expand Down
13 changes: 1 addition & 12 deletions components/esp_system/ld/esp32h2/memory.ld.in
Expand Up @@ -45,12 +45,8 @@
#define IDRAM0_2_SEG_SIZE (CONFIG_MMU_PAGE_SIZE << 8)
#endif

#if CONFIG_ESP32H2_USE_FIXED_STATIC_RAM_SIZE
ASSERT((CONFIG_ESP32H2_FIXED_STATIC_RAM_SIZE <= I_D_SRAM_SIZE), "Fixed static ram data does not fit.")
#define DRAM0_0_SEG_LEN CONFIG_ESP32H2_FIXED_STATIC_RAM_SIZE
#else
#define DRAM0_0_SEG_LEN I_D_SRAM_SIZE
#endif // CONFIG_ESP32H2_USE_FIXED_STATIC_RAM_SIZE

MEMORY
{
/**
Expand Down Expand Up @@ -95,13 +91,6 @@ MEMORY

}

#if CONFIG_ESP32H2_USE_FIXED_STATIC_RAM_SIZE
/* static data ends at defined address */
_static_data_end = 0x40820000 + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
#endif // CONFIG_ESP32H2_USE_FIXED_STATIC_RAM_SIZE

/* Heap ends at top of dram0_0_seg */
_heap_end = 0x40000000;

Expand Down
13 changes: 1 addition & 12 deletions components/esp_system/ld/esp32h4/memory.ld.in
Expand Up @@ -34,12 +34,8 @@

#define I_D_SRAM_SIZE SRAM_DRAM_END - SRAM_DRAM_ORG

#if CONFIG_ESP32H4_USE_FIXED_STATIC_RAM_SIZE
ASSERT((CONFIG_ESP32H4_FIXED_STATIC_RAM_SIZE <= I_D_SRAM_SIZE), "Fixed static ram data does not fit.")
#define DRAM0_0_SEG_LEN CONFIG_ESP3C3_FIXED_STATIC_RAM_SIZE
#else
#define DRAM0_0_SEG_LEN I_D_SRAM_SIZE
#endif // CONFIG_ESP32H4_USE_FIXED_STATIC_RAM_SIZE

MEMORY
{
/**
Expand Down Expand Up @@ -83,13 +79,6 @@ MEMORY
rtc_iram_seg(RWX) : org = 0x50000000, len = 0x2000 - ESP_BOOTLOADER_RESERVE_RTC
}

#if CONFIG_ESP32H4_USE_FIXED_STATIC_RAM_SIZE
/* static data ends at defined address */
_static_data_end = 0x3FCA0000 + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
#endif // CONFIG_ESP32H4_USE_FIXED_STATIC_RAM_SIZE

/* Heap ends at top of dram0_0_seg */
_heap_end = 0x40000000;

Expand Down
21 changes: 8 additions & 13 deletions components/esp_system/ld/esp32s2/memory.ld.in
Expand Up @@ -50,17 +50,12 @@

#define I_D_RAM_SIZE DATA_RAM_END - DRAM_ORG

#if defined(CONFIG_ESP32S2_USE_FIXED_STATIC_RAM_SIZE)

ASSERT((CONFIG_ESP32S2_FIXED_STATIC_RAM_SIZE <= I_D_RAM_SIZE),
"Fixed static ram data does not fit.")

#define STATIC_RAM_SIZE CONFIG_ESP32S2_FIXED_STATIC_RAM_SIZE

#if CONFIG_ESP32S2_USE_FIXED_STATIC_RAM_SIZE
ASSERT((CONFIG_ESP32S2_FIXED_STATIC_RAM_SIZE <= I_D_RAM_SIZE), "Fixed static ram data does not fit.")
#define DRAM0_0_SEG_LEN CONFIG_ESP32S2_FIXED_STATIC_RAM_SIZE
#else
#define STATIC_RAM_SIZE 0
#endif

#define DRAM0_0_SEG_LEN I_D_RAM_SIZE
#endif // CONFIG_ESP32S2_USE_FIXED_STATIC_RAM_SIZE
MEMORY
{
/* All these values assume the flash cache is on, and have the blocks this uses subtracted from the length
Expand All @@ -86,7 +81,7 @@ MEMORY


/* Shared data RAM, excluding memory reserved for bootloader and ROM bss/data/stack. */
dram0_0_seg (RW) : org = DRAM_ORG, len = I_D_RAM_SIZE - STATIC_RAM_SIZE
dram0_0_seg (RW) : org = DRAM_ORG, len = DRAM0_0_SEG_LEN

#ifdef CONFIG_APP_BUILD_USE_FLASH_SECTIONS
/* Flash mapped constant data */
Expand Down Expand Up @@ -120,9 +115,9 @@ MEMORY

#if defined(CONFIG_ESP32S2_USE_FIXED_STATIC_RAM_SIZE)
/* static data ends at defined address */
_static_data_end = DRAM_ORG + STATIC_RAM_SIZE;
_heap_start = DRAM_ORG + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
_heap_start = _heap_low_start;
#endif

_heap_end = 0x40000000;
Expand Down
5 changes: 3 additions & 2 deletions components/esp_system/ld/esp32s2/sections.ld.in
Expand Up @@ -398,7 +398,8 @@ SECTIONS
.dram0.heap_start (NOLOAD) :
{
. = ALIGN (8);
_heap_start = ABSOLUTE(.);
/* Lowest possible start address for the heap */
_heap_low_start = ABSOLUTE(.);
} > dram0_0_seg

/** This section will be used by the debugger and disassembler to get more information
Expand All @@ -424,5 +425,5 @@ SECTIONS
ASSERT(((_iram_text_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
"IRAM0 segment data does not fit.")

ASSERT(((_heap_start - _data_start) <= LENGTH(dram0_0_seg)),
ASSERT(((_heap_low_start - _data_start) <= LENGTH(dram0_0_seg)),
"DRAM segment data does not fit.")
4 changes: 2 additions & 2 deletions components/esp_system/ld/esp32s3/memory.ld.in
Expand Up @@ -119,9 +119,9 @@ MEMORY

#if CONFIG_ESP32S3_USE_FIXED_STATIC_RAM_SIZE
/* static data ends at defined address */
_static_data_end = 0x3FCA0000 + DRAM0_0_SEG_LEN;
_heap_start = SRAM_DRAM_ORG + DRAM0_0_SEG_LEN;
#else
_static_data_end = _bss_end;
_heap_start = _heap_low_start;
#endif // CONFIG_ESP32S3_USE_FIXED_STATIC_RAM_SIZE

/* Heap ends at top of dram0_0_seg */
Expand Down
5 changes: 3 additions & 2 deletions components/esp_system/ld/esp32s3/sections.ld.in
Expand Up @@ -437,7 +437,8 @@ SECTIONS
.dram0.heap_start (NOLOAD) :
{
. = ALIGN (8);
_heap_start = ABSOLUTE(.);
/* Lowest possible start address for the heap */
_heap_low_start = ABSOLUTE(.);
} > dram0_0_seg

/** This section will be used by the debugger and disassembler to get more information
Expand All @@ -463,5 +464,5 @@ SECTIONS
ASSERT(((_iram_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
"IRAM0 segment data does not fit.")

ASSERT(((_heap_start - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)),
ASSERT(((_heap_low_start - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)),
"DRAM segment data does not fit.")
5 changes: 4 additions & 1 deletion components/esp_system/port/soc/esp32s2/Kconfig.memory
Expand Up @@ -21,9 +21,12 @@ menu "Memory"
config ESP32S2_FIXED_STATIC_RAM_SIZE
hex "Fixed Static RAM size"
default 0x10000
range 0 0x34000
range 0 0x34000 # Equal to I_D_SRAM_SIZE in linkerscript
depends on ESP32S2_USE_FIXED_STATIC_RAM_SIZE
help
RAM size dedicated for static variables (.data & .bss sections).
This value is less than the chips total memory, as not all of it can be used for this purpose.
E.g. parts are used by the software bootloader, and will only be available
as heap memory after app startup.

endmenu # Memory
5 changes: 4 additions & 1 deletion components/esp_system/port/soc/esp32s3/Kconfig.memory
Expand Up @@ -21,9 +21,12 @@ menu "Memory"
config ESP32S3_FIXED_STATIC_RAM_SIZE
hex "Fixed Static RAM size"
default 0x10000
range 0 0x34000
range 0 0x54700 # Equal to I_D_SRAM_SIZE in linkerscript
depends on ESP32S3_USE_FIXED_STATIC_RAM_SIZE
help
RAM size dedicated for static variables (.data & .bss sections).
This value is less than the chips total memory, as not all of it can be used for this purpose.
E.g. parts are used by the software bootloader, and will only be available
as heap memory after app startup.

endmenu # Memory

0 comments on commit fdea528

Please sign in to comment.