fdcavalcanti opened a new pull request, #16735:
URL: https://github.com/apache/nuttx/pull/16735
## Summary
- documentation: update documentation for MCUBoot on Espressif devices
- arch/risc-v: change offset for SPI Flash on Espressif devices
- boards/risc-v: fixes SPI Flash for MCUBoot usage
Adds partitions required for MCUBoot usage and a sample defconfig.
- arch/xtensa: add E-Fuse support on ESP32S2
Adds support for e-fuse on ESP32S2 and fixes a gitignore issue.
- boards/xtensa: fixes SPI Flash for MCUBoot usage
Fixes partitions for MCUBoot usage.
This PR modifies SPI Flash and E-Fuse related code to support OTA using
MCUBoot.
## Impact
- Impact on user: Yes. Adds and fixes MCUBoot defconfig
(mcuboot_update_agent) so the user can execute OTA.
- Impact on build: No.
- Impact on hardware: Affects ESP32|S2|S3|C3|C6 which have Wi-Fi support.
- Impact on documentation: Yes, updates or adds sections to explain how to
build and execute OTA.
- Impact on security: No.
- Impact on compatibility: No.
## Testing
This example is valid for any of the SoCs affected. Tested on all of them
and also CI tested.
### Building
Part 1:
First build the default mcuboot_update_agent config. This image defaults to
the primary slot and already comes with Wi-Fi settings enabled.
- `./tools/configure.sh esp32-devkitc:mcuboot_update_agent`
- `make bootloader`
- `make`
- flash
Verify it boots ok and the message This is MCUBoot Update Agent image
appears before Nuttshell is ready.
Connect to Wi-Fi:
```
nsh> wapi psk wlan0 espmint123 3
nsh> wapi essid wlan0 espmint 1
nsh> renew wlan0
```
Keep the board as is and move to part 2.
Part 2:
On menuconfig, change MCUBoot target slot to the 2nd slot and modify the
MOTD as a mean to verify the new image is being used:
```
kconfig-tweak -d CONFIG_ESPRESSIF_ESPTOOL_TARGET_PRIMARY
kconfig-tweak -e CONFIG_ESPRESSIF_ESPTOOL_TARGET_SECONDARY
kconfig-tweak --set-str CONFIG_NSH_MOTD_STRING "This is MCUBoot UPDATED
image!
```
Apply the changes with `make olddefconfig` and rebuild with `make`.
This will build a binary with secondary slot as target and a custom MOTD.
### Running
At this point the board is already connected to Wi-Fi and has the primary
image flashed. To execute OTA, create a simple HTTP server on the NuttX
directory so we can access the binary remotely:
```
$ cd nuttxspace/nuttx
$ python -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
```
On the board, execute the update agent, setting the IP address to the one on
the host machine:
```
nsh> mcuboot_agent http://10.42.0.1:8000/nuttx.bin
MCUboot Update Agent example
Downloading from http://10.42.0.1:8000/nuttx.bin
Firmware Update size: 1048576 bytes
Received: 512 of 1048576 bytes [0%]
Received: 1024 of 1048576 bytes [0%]
Received: 1536 of 1048576 bytes [0%]
```
Wait until image is transferred and the board should reboot automatically:
```Received: 1048576 of 1048576 bytes [100%]
Application Image successfully downloaded!
Requested update for next boot. Restarting...
```
Nuttshell should now show the new MOTD:
```
NuttShell (NSH) NuttX-10.4.0
This is MCUBoot UPDATED image!
nsh>
```
At this point, the image is loaded but not confirmed. To make sure it won't
rollback to the previous image, you must confirm with mcuboot_confirm and
reboot the board. The OTA is now complete.
--
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]