almir-okato commented on issue #19994:
URL: https://github.com/apache/nuttx/issues/19994#issuecomment-5576184599

    @Laczen, the initial motivation for implementing Simple Boot was to have an 
app running straight after ROM bootloader, that's why its image header format 
is similar to IDFs, and reduce "overhead" for the users that don't need all the 
features provided by a bootloader like OTA or security, so it saves a bit of 
time and resources, from building the project until having it running in the 
device.
   
   From what I understood from your other PR and what you described here, also 
assuming you are using a custom second stage bootloader "bootable" as a Simple 
Boot image, it seems the issue is reusing part of `map_rom_segments` function, 
so this custom bootloader could boot another image with same Simple Boot 
*header* format.
   
   My suggestion is changing the `fetch_rom_segments_lma` (see my comment in 
your [PR](https://github.com/apache/nuttx/pull/19985/changes#r3871881515)) to 
receive the `offset` argument:
   ```
   int fetch_rom_segments_lma(uint32_t *app_irom_start,
                              uint32_t *app_drom_start,
                              size_t offset)
   ```
   
   Then on 
https://github.com/apache/nuttx/pull/19985/changes#diff-c704a8399b796e32bd41fdcb8090cd603fa5043fe30d40ca291c121247fccbf9R542-R548
 you may keep the `offset` as `CONFIG_BOOTLOADER_OFFSET_IN_FLASH` for Simple 
Boot:
   ```
   #ifdef CONFIG_ESPRESSIF_SIMPLE_BOOT
     if (fetch_rom_segments_lma(&app_irom_start, &app_drom_start, 
CONFIG_BOOTLOADER_OFFSET_IN_FLASH) != 0)
       {
         while (true);
       }
   #endif
   ```
   
   From your custom second stage bootloader (which may be implemented as a 
NuttX app, as @xiaoxiang781216 suggest), you may call `fetch_rom_segments_lma` 
with a configurable offset.
   
   Notice that probably there's more to change, because the final app you are 
booting may share the same header format as a Simple Boot image, but you'll 
need to sync memory organization, code execution path (like having something as 
`#elif CONFIG_ESPRESSIF_CUSTOM_IMAGE` for not calling `fetch_rom_segments_lma` 
on the final app `__esp_start`, etc.) and other resources between the custom 
bootloader and final app.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to