-
Notifications
You must be signed in to change notification settings - Fork 819
Description
When using CONFIG_BOOT_DIRECT_XIP=y
, mcuboot works normally. When selecting CONFIG_BOOT_DIRECT_XIP_REVERT=y
, mcuboot erases the primary image after flashing it.
My requirement is to flash mcuboot only and flash application at a later stage in the product life.
Here's an overview of the steps I am taking:
Bootloader:
- Compile with
CONFIG_BOOT_DIRECT_XIP_REVERT=y
- Erase all flash and then flash bootloader
- The MCU only has bootloader in flash and no application at this point. I've added USB host functionality and mcuboot can copy a binary from an USB memory drive
Application:
- Compile with
CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT=y
- Transfer
zephyr.signed.confirmed.bin
to primary slot using USB memory drive
After transfer, mcuboot always erases the image:
[00:00:03.910,000] <inf> mcuboot: USB firmware update status: Success
[00:00:05.916,000] <inf> mcuboot: Primary slot: version=1.0.2+1000
[00:00:05.923,000] <inf> mcuboot: Image 0 Secondary slot: Image not found
[00:00:05.930,000] <dbg> mcuboot: boot_select_or_erase: Erasing faulty image in the primary slot.
[00:00:05.965,000] <inf> mcuboot: No slot to load for image 0
[00:00:05.971,000] <err> mcuboot: Unable to find bootable image
The same thing happens when I copy the non-confirmed image to the primary slot.
When debugging, the value of active_swap_state
after calling boot_read_swap_state
in function boot_select_or_erase is:
p *active_swap_state
$1 = {magic = 0x3, swap_type = 0x1, copy_done = 0x3, image_ok = 0x3, image_num = 0x0}
This causes the check of the magic number to fail.
My application flash map in the overlay file is:
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(128)>;
};
/* The MCUBoot swap-move algorithm uses the last 3 sectors
* of the primary slot0 for swap status and move.
*/
slot0_partition: partition@20000 {
label = "image-0";
reg = <0x00020000 (DT_SIZE_M(3) + DT_SIZE_K(3 * 4))>;
};
slot1_partition: partition@323000 {
label = "image-1";
reg = <0x00323000 DT_SIZE_M(3)>;
};
storage_partition: partition@623000 {
label = "storage";
reg = <0x00623000 (DT_SIZE_M(2) - DT_SIZE_K(140))>;
};
};
However, the size of zephyr.signed.confirmed.bin
is 0x300000 bytes.
Am I misunderstanding the use of XIP_REVERT?