Skip to content

Commit

Permalink
soc: espressif: esp32c3: improve memory utilization
Browse files Browse the repository at this point in the history
Change the MCUboot segments layout to incread the memory
available in the application.
Add missing symbols to mcuboot.ld

Signed-off-by: Marek Matej <[email protected]>
  • Loading branch information
Marek Matej committed Jun 5, 2024
1 parent 7e0449b commit f0aa1e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions soc/espressif/esp32c3/mcuboot.ld
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ SECTIONS
/* Vectors go to IRAM */
_iram_start = ABSOLUTE(.);
_init_start = ABSOLUTE(.);
__text_region_start = ABSOLUTE(.);

KEEP(*(.exception_vectors.text));
. = ALIGN(256);
Expand Down Expand Up @@ -133,6 +134,7 @@ SECTIONS
. += 16;

_text_end = ABSOLUTE(.);
__text_region_end = ABSOLUTE(.);
_etext = .;

/* Similar to _iram_start, this symbol goes here so it is
Expand Down
16 changes: 9 additions & 7 deletions soc/espressif/esp32c3/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,23 @@
/* Base address used for calculating memory layout
* counted from Dbus backwards and back to the Ibus
*/
#define BOOTLOADER_USABLE_DRAM_END DRAM_BUFFERS_START
#define BOOTLOADER_USER_DRAM_END DRAM_BUFFERS_START

/* For safety margin between bootloader data section and startup stacks */
#define BOOTLOADER_STACK_OVERHEAD 0x0
/* These lengths can be adjusted, if necessary: */
#define BOOTLOADER_DRAM_SEG_LEN 0x9000
#define BOOTLOADER_IRAM_LOADER_SEG_LEN 0x3000
#define BOOTLOADER_IRAM_SEG_LEN 0x8000
#define BOOTLOADER_IRAM_SEG_LEN 0x9000
#define BOOTLOADER_IRAM_LOADER_SEG_LEN 0x1400

/* Start of the lower region is determined by region size and the end of the higher region */
#define BOOTLOADER_DRAM_SEG_END (BOOTLOADER_USABLE_DRAM_END + BOOTLOADER_STACK_OVERHEAD)
#define BOOTLOADER_DRAM_SEG_START (BOOTLOADER_DRAM_SEG_END - BOOTLOADER_DRAM_SEG_LEN)
#define BOOTLOADER_IRAM_LOADER_SEG_START (BOOTLOADER_DRAM_SEG_START - \
BOOTLOADER_IRAM_LOADER_SEG_LEN + IRAM_DRAM_OFFSET)
#define BOOTLOADER_IRAM_LOADER_SEG_END (BOOTLOADER_USER_DRAM_END + \
BOOTLOADER_STACK_OVERHEAD + IRAM_DRAM_OFFSET)
#define BOOTLOADER_IRAM_LOADER_SEG_START (BOOTLOADER_IRAM_LOADER_SEG_END - \
BOOTLOADER_IRAM_LOADER_SEG_LEN)
#define BOOTLOADER_IRAM_SEG_START (BOOTLOADER_IRAM_LOADER_SEG_START - BOOTLOADER_IRAM_SEG_LEN)
#define BOOTLOADER_DRAM_SEG_START (BOOTLOADER_IRAM_SEG_START - IRAM_DRAM_OFFSET - \
BOOTLOADER_DRAM_SEG_LEN)

/* Flash */
#ifdef CONFIG_FLASH_SIZE
Expand Down

0 comments on commit f0aa1e7

Please sign in to comment.