Hello, I am testing the secondary bootloader MCUBoot on the LPC55S69. For that, I followed the documentation MCUOTASBLSFWUG.
In order to update the main application (SFW) I am using the "Local FOTA" with an SD-Card.
The update works well. I can generate a new image, sign it with imgtool.py and put it in the SD Card. The SFW detects the SD Card and puts the new program in the secondary slot. At the next reboot, the SBL swap primary and secondary slots and boot on the primary slot.
In order to test the rollback mechanism, I modified some bytes of the new signed image and put the corrupted image in the SD Card. The SFW puts the new program in the secondary slot, and at the next reboot, the SBL swaps the two slots. As the binary is corrupted, SBL doesn't boot it. However, the SBL doesn't rollback to use the correct image of the secondary slot. So, the board doesn't boot anymore.
Does anyone know why? All help is welcome. Thank you.
My setup is the following:
- Last version of SBL and SFW availables on Github.
- SBL and SFW code not modified.
- Toolchain : arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.
- Parameters to generate the signed image with imgtool.py : python imgtool.py sign --key sign-rsa2048-priv.pem --encrypt enc-rsa2048-pub.pem --align 4 --version "1.3" --header-size 0x400 --pad-header --slot-size 0x30000 --max-sectors 32 sfw.bin sfw_signed.bin
Config of SBL and MCUBoot:
- Enable single image function : disabled
- Signing with RSA
- MCUBOOT_SWAP_USING_MOVE 1
- MCUBOOT_IMAGE_NUMBER 1
Config of SFW:
- Enable sfw standalone xip : disabled
- Enable from OTA
- OTA from SD Card
- OTA from u-disk : disabled
Here are the logs of the update:
Bootloader Version 1.1.0
Primary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x1
Secondary image: magic=bad, swap_type=0x0, copy_done=0x2, image_ok=0x2
Boot source: primary slot
writing copy_done; fa_id=1 off=0xlx (0xlx)
Bootloader chainload address offset: 0x20000
Reset_Handler address offset: 0x20400
Jumping to the image
hello sfw.
Current image verison: 1.3.0
SD Card updating task enable.
Hello world1.
Hello world2.
Please insert a sd card into board.
Update done, the last update type: SD Card
Write OK flag: off = 0x4fe00
Hello world1.
Hello world2.
Card inserted.
Hello world1.
Hello world2.
reading...
new img verison: 1.4.0
updating...
finished
write update type = 0x1
write magic number offset = 0x7fe00
Please remove the SD Card!
sys rst...
Hello world1.
Hello world2.
hello sbl.
Bootloader Version 1.1.0
Primary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x1
Secondary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x3
Boot source: none
Swap type: test
erasing trailer; fa_id=1
initializing status; fa_id=1
writing swap_info; fa_id=1 off=0xlx (0xlx), swap_type=0x2ffd8 image_num=0x4ffd8
writing swap_size; fa_id=1 off=0xlx (0xlx)
writing magic; fa_id=1 off=0xlx (0xlx)
erasing trailer; fa_id=2
writing copy_done; fa_id=1 off=0xlx (0xlx)
Signature verification failed, Image in the primary slot is not valid!
hello sbl.
Bootloader Version 1.1.0
Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x2
Secondary image: magic=bad, swap_type=0x0, copy_done=0x2, image_ok=0x2
Boot source: none
Swap type: none
Signature verification failed, Image in the primary slot is not valid!