You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/04/16 16:10:03 UTC

(nuttx) branch master updated: esp32[c3|c6|h2]: Fix simple boot map_rom_segments

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new f4bbe276e1 esp32[c3|c6|h2]: Fix simple boot map_rom_segments
f4bbe276e1 is described below

commit f4bbe276e127077d4896540673b31cb020e32de8
Author: Almir Okato <al...@espressif.com>
AuthorDate: Mon Apr 15 15:16:21 2024 -0300

    esp32[c3|c6|h2]: Fix simple boot map_rom_segments
    
    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 <al...@espressif.com>
---
 arch/risc-v/src/common/espressif/esp_start.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/risc-v/src/common/espressif/esp_start.c b/arch/risc-v/src/common/espressif/esp_start.c
index cbbeffe58e..cbb45fcc8e 100644
--- a/arch/risc-v/src/common/espressif/esp_start.c
+++ b/arch/risc-v/src/common/espressif/esp_start.c
@@ -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 */
@@ -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 */
 
@@ -318,6 +310,7 @@ 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) &&
@@ -325,6 +318,7 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
         {
           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))