esp-hal icon indicating copy to clipboard operation
esp-hal copied to clipboard

Explore using MCU boot as the second stage bootloader

Open MabezDev opened this issue 1 year ago • 1 comments
trafficstars

Related to #1973, we're leaning towards using MCUBOOT, but we need to explore if this is viable before we settle on it. The most important thing we need to know is can we change the ota slot addresses without forcing the user to rebuild the MCU boot project.

MabezDev avatar Oct 21 '24 12:10 MabezDev

Don't want to count my chickens before they hatch, so being purposefully a bit cryptic here 😉

Took me a few days to get going on this, unfortunately encountered a number of issues which slowed me down. However, based on some very rudimentary tests I think this should be viable.

I still have some work to do before I'm able to say for sure, but I'm hoping that I can have a better idea by end of day tomorrow. I will update this issue by early-to-mid next week with my findings.

jessebraham avatar Oct 24 '24 15:10 jessebraham

I'm able to build mcuboot and inject arbitrary values in for the required configuration values. These are stored in a contiguous block, and should be easily identifiable by tools e.g. espflash. Therefore, I believe this approach should be viable.

The next steps are:

  • Add the required linker scripts to support mcuboot in esp-hal
  • Update our tooling (i.e. espflash) to support the mcuboot image format

jessebraham avatar Nov 04 '24 11:11 jessebraham

I guess this can probably be closed? The exploration is complete, additional work needs to be done but this involves writing new linker scripts in the HAL (which IMO is outside the scope of this issue) and updating tooling (which isn't in this repository, and has its own tracking issue already).

jessebraham avatar Nov 07 '24 10:11 jessebraham

I agree, but we still need to track the linker script work - we all know how fun they are :D. Could you open a new issue for that, and perhaps include some details on how to build MCUBOOT etc so whoever works on the linkerscripts can get a head start?

After that we can close this.

MabezDev avatar Nov 07 '24 11:11 MabezDev

BTW here are the changes we had for supporting C3: https://github.com/esp-rs/esp-hal/pull/49/files#diff-f68012054272d7ce1611e965d7c6771a128c2e93fdcb4d8153cbcb9ef691062f

There is also setting up the MMU - I wonder if that was really necessary (I hope not) or not. If it is necessary, I guess ESP32 might add some fun to the task

bjoernQ avatar Nov 07 '24 11:11 bjoernQ

https://github.com/esp-rs/esp-hal/issues/2479

jessebraham avatar Nov 07 '24 12:11 jessebraham