Skip to content

Commit

Permalink
esp32[c3|c6|h2]: Fix simple boot map_rom_segments
Browse files Browse the repository at this point in the history
Currently Simple Boot image have fixed 2 ROM segments and
2 RAM segments, then the parsing iterator must stop when all
ROM segments are found.

Signed-off-by: Almir Okato <[email protected]>
  • Loading branch information
almir-okato authored and xiaoxiang781216 committed Apr 16, 2024
1 parent 4a82838 commit f4bbe27
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions arch/risc-v/src/common/espressif/esp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,10 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
bool padding_checksum = false;
unsigned int segments = 0;
unsigned int ram_segments = 0;
unsigned int rom_segments = 0;
size_t offset = CONFIG_BOOTLOADER_OFFSET_IN_FLASH;
#endif

ets_printf("\nIROM lma: 0x%lx vma: 0x%lx size: 0x%lx\n",
(uint32_t)_image_irom_lma,
(uint32_t)_image_irom_vma,
(uint32_t)_image_irom_size);
ets_printf("DROM lma: 0x%lx vma: 0x%lx size: 0x%lx\n",
(uint32_t)_image_drom_lma,
(uint32_t)_image_drom_vma,
(uint32_t)_image_drom_size);

#ifdef CONFIG_ESPRESSIF_SIMPLE_BOOT

/* Read image header */
Expand All @@ -268,7 +260,7 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,

/* Iterate for segment information parsing */

while (segments++ < 16)
while (segments++ < 16 && rom_segments < 2)
{
/* Read segment header */

Expand Down Expand Up @@ -318,13 +310,15 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
{
app_drom_start = offset + sizeof(esp_image_segment_header_t);
app_drom_start_aligned = app_drom_start & MMU_FLASH_MASK;
rom_segments++;
}

if (IS_IROM(segment_hdr.load_addr) &&
segment_hdr.load_addr == (uint32_t)_image_irom_vma)
{
app_irom_start = offset + sizeof(esp_image_segment_header_t);
app_irom_start_aligned = app_irom_start & MMU_FLASH_MASK;
rom_segments++;
}

if (IS_SRAM(segment_hdr.load_addr))
Expand Down

0 comments on commit f4bbe27

Please sign in to comment.