Laczen commented on issue #19994: URL: https://github.com/apache/nuttx/issues/19994#issuecomment-5597025529
> [@Laczen](https://github.com/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](https://github.com/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. Hi @almir-okato, thank you for your comment. The proposed image format is also closely related to the legacy esp-idf format. The proposed image format can be considered as a fixed location esp-idf format that is responsible for the rom mapping. As the image itself does the rom mapping it needs to know its location and this is exactly the flash offset. There is not need for a bootloader to call `fetch_rom segments_lma`, it is the image that needs it so it needs to be set in the NuttX source. I can incorporate the proposed change, but this will be a constant for the image in the end. There are indeed some extra changes required: there is no need for the image to call `bootloader_init()`, and it needs to zero the `.bss`. -- 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]
