Hello,
I'm, trying to configure an nrf5340 based board to use the secondary boot image on an external SPI Flash.
The flash has tree partitions:
- 0: The second boot space.
- 1: The storage partition.
- 2: A littlefs partition.
The partition has been defined in the overlay configuration file in the following way:
&w25q256jveiq0 { partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; slot1_partition: partition@0 { label = "image-1"; reg = <0x00000000 0x000f0000>; }; storage_partition: partition@f0000 { label = "storage"; reg = <0x000f0000 0x00002000>; }; lfs1_part: partition@f2000 { label = "littlefs_storage"; reg = <0x000f2000 0x00F0E000>; }; }; };
The portion of configuration regarding the external flash is the following:
# External partitions CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL=y CONFIG_PM_PARTITION_SIZE_LITTLEFS=0xF0E000 # Prevent the QSPI NOR driver to be automatically included by partition manager CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
At the first boot, typing "mcuboot" on the shell, the reported informations are the following:
rtt:~$ mcuboot swap type: none confirmed: 0 primary area (3): version: 2.0.0+0 image size: 353164 magic: unset swap type: none copy done: unset image ok: unset failed to read secondary area (1) header: -5
The error happens because the flash partition is erased, and its content is all 0xFF.
Using the Android "Device Manager" App, the secondary image can be loaded without problems.
After the load has complete (test only), the "mcuboot" shell command shows the following:
rtt:~$ mcuboot swap type: test confirmed: 0 primary area (3): version: 2.0.0+0 image size: 353164 magic: unset swap type: none copy done: unset image ok: unset secondary area (1): version: 2.0.1+0 image size: 353164 magic: good swap type: test copy done: unset image ok: unset
At this point, using the "Advanced" option in the Device Manager App, after performing a read operation, only the "Confirm" and "Erase" commands are available (the "Test" is grayed).
Pressing the "Confirm" command, nothing happens.
The same situation happens when issuing the "mcuboot confirm" command in the shell.
Following the function in the mcuboot_shell.c module with the gdb debugger, I notice that the boot_write_img_confirmed function is called.
This function calls the boot_set_confirmed function, that is commented in this way: "Marks the image with index 0 in the primary slot as confirmed."
In fact, the function calls the boot_set_confirmed_multi(0) sub-function.
At this point I'm confused: I need to confirm the image-1, not the primary image. How can I confirm the loaded image in the external flash? When using the OTA functions without the external flash, all works fine.
The Device Manager cannot perform any other operation, the only way to go back to a loadable situation is to perform an erase operation using the shell, with the command "mcuboot erase 1".
The erase function in the Device Manager do not works, it reports: "Bad state (6)".
After a successful erase operation performed with the shell, a load attempt with "test and confirm" results in the error "Image not confirmed".
Is there something wrong or missing in my configuration?
Thank you very much.