mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
87 lines
3.9 KiB
Plaintext
87 lines
3.9 KiB
Plaintext
/*
|
|
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
/** Simplified memory map for the bootloader.
|
|
* Make sure the bootloader can load into main memory without overwriting itself.
|
|
*
|
|
* ESP32-H4 ROM static data usage is as follows:
|
|
* - 0x4084d350 - 0x4085b350: Shared buffers, used in UART/USB/SPI download mode only
|
|
* - 0x4085b350 - 0x4085d350: PRO CPU stack, can be reclaimed as heap after RTOS startup
|
|
* - 0x4085d350 - 0x40860000: ROM .bss and .data (not easily reclaimable)
|
|
*
|
|
* The 2nd stage bootloader can take space up to the end of ROM shared
|
|
* buffers area (0x4085b350).
|
|
*/
|
|
|
|
/* We consider 0x4085b350 to be the last usable address for 2nd stage bootloader stack overhead, dram_seg,
|
|
* and work out iram_seg and iram_loader_seg addresses from there, backwards.
|
|
*/
|
|
|
|
/* These lengths can be adjusted, if necessary: */
|
|
bootloader_usable_dram_end = 0x4085d350;
|
|
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
|
|
bootloader_dram_seg_len = 0x5000;
|
|
bootloader_iram_loader_seg_len = 0x7000;
|
|
bootloader_iram_seg_len = 0x2D00;
|
|
|
|
/* Start of the lower region is determined by region size and the end of the higher region */
|
|
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;
|
|
bootloader_dram_seg_start = bootloader_dram_seg_end - bootloader_dram_seg_len;
|
|
bootloader_iram_loader_seg_start = bootloader_dram_seg_start - bootloader_iram_loader_seg_len;
|
|
bootloader_iram_seg_start = bootloader_iram_loader_seg_start - bootloader_iram_seg_len;
|
|
|
|
MEMORY
|
|
{
|
|
iram_seg (RWX) : org = bootloader_iram_seg_start, len = bootloader_iram_seg_len
|
|
iram_loader_seg (RWX) : org = bootloader_iram_loader_seg_start, len = bootloader_iram_loader_seg_len
|
|
dram_seg (RW) : org = bootloader_dram_seg_start, len = bootloader_dram_seg_len
|
|
}
|
|
|
|
/* The app may use RAM for static allocations up to the start of iram_loader_seg.
|
|
* If you have changed something above and this assert fails:
|
|
* 1. Check what the new value of bootloader_iram_loader_seg start is.
|
|
* 2. Update the value in this assert.
|
|
* 3. Update SRAM_SEG_END in components/esp_system/ld/esp32h4/memory.ld.in to the same value.
|
|
*/
|
|
ASSERT(bootloader_iram_loader_seg_start == 0x4084f350, "bootloader_iram_loader_seg_start inconsistent with SRAM_SEG_END");
|
|
|
|
/**
|
|
* Appendix: Memory Usage of ROM bootloader
|
|
*
|
|
* 0x4084d350 ------------------> _dram0_0_start
|
|
* | |
|
|
* | |
|
|
* | | 1. Large buffers that are only used in certain boot modes, see shared_buffers.h
|
|
* | |
|
|
* | |
|
|
* 0x4085b350 ------------------> __stack_sentry
|
|
* | |
|
|
* | | 2. Startup pro cpu stack (freed when IDF app is running)
|
|
* | |
|
|
* 0x4085d350 ------------------> __stack (pro cpu)
|
|
* | |
|
|
* | |
|
|
* | | 3. Shared memory only used in startup code or nonos/early boot*
|
|
* | | (can be freed when IDF runs)
|
|
* | |
|
|
* | |
|
|
* 0x4085fea8 ------------------> _dram0_rtos_reserved_start
|
|
* | |
|
|
* | |
|
|
* | | 4. Shared memory used in startup code and when IDF runs
|
|
* | |
|
|
* | |
|
|
* 0x4085ffb4 ------------------> _dram0_rtos_reserved_end
|
|
* | |
|
|
* 0x4085ffc4 ------------------> _data_start_interface
|
|
* | |
|
|
* | | 5. End of DRAM is the 'interface' data with constant addresses (ECO compatible)
|
|
* | |
|
|
* 0x40860000 ------------------> _data_end_interface
|
|
*/
|