nRF53: BT and MCUboot SINGLE_APPLICATION_SLOT cannot be combined

Combining BT in the main application, and SINGLE_APPLICATION_SLOT on an nRF53 build will cause the ` hci_rpmsg` build to fail with error:

[25/246] Generating ../../zephyr/net_core_app_update.bin, ../../zephyr/net_core_app_signed.hex, ../../zephyr/net_core_app_test_update.hex, ../../zephyr/net_core_app_moved_test_update.hex
FAILED: zephyr/net_core_app_update.bin zephyr/net_core_app_signed.hex zephyr/net_core_app_test_update.hex zephyr/net_core_app_moved_test_update.hex apps/hello_world/build/zephyr/net_core_app_update.bin apps/hello_world/build/zephyr/net_core_app_signed.hex apps/hello_world/build/zephyr/net_core_app_test_update.hex apps/hello_world/build/zephyr/net_core_app_moved_test_update.hex 
cd apps/hello_world/build/modules/mcuboot && /usr/bin/python3.10 bootloader/mcuboot/scripts/imgtool.py sign --key bootloader/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 4 --version 0.0.0+0 --pad-header --slot-size  apps/hello_world/build/hci_rpmsg/zephyr/signed_by_b0_app.hex apps/hello_world/build/zephyr/net_core_app_signed.hex && /home/vinz/zephyr-sdk-0.13.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-objcopy --input-target=ihex --output-target=binary --gap-fill=0xff apps/hello_world/build/hci_rpmsg/zephyr/signed_by_b0_app.hex apps/hello_world/build/zephyr/net_core_app_to_sign.bin && /usr/bin/python3.10 bootloader/mcuboot/scripts/imgtool.py sign --key bootloader/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 4 --version 0.0.0+0 --pad-header --slot-size  apps/hello_world/build/zephyr/net_core_app_to_sign.bin apps/hello_world/build/zephyr/net_core_app_update.bin && /usr/bin/python3.10 bootloader/mcuboot/scripts/imgtool.py sign --key bootloader/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 4 --version 0.0.0+0 --pad-header --slot-size  --pad apps/hello_world/build/hci_rpmsg/zephyr/signed_by_b0_app.hex apps/hello_world/build/zephyr/net_core_app_test_update.hex && /home/vinz/zephyr-sdk-0.13.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-objcopy --input-target=ihex --output-target=ihex --change-address=-16811520 --gap-fill=0xff apps/hello_world/build/zephyr/net_core_app_test_update.hex apps/hello_world/build/zephyr/net_core_app_moved_test_update.hex
Usage: imgtool.py sign [OPTIONS] INFILE OUTFILE
Try 'imgtool.py sign -h' for help.

Error: Invalid value for '-S' / '--slot-size': apps/hello_world/build/hci_rpmsg/zephyr/signed_by_b0_app.hex is not a valid integer. Please use code literals prefixed with 0b/0B, 0o/0O, or 0x/0X as necessary.
ninja: build stopped: subcommand failed.

Reproduced easily like this:

* Configure any main application (e.g. hello_world) and set CONFIG_BOOTLOADER_MCUBOOT=y and CONFIG_BT=y

* Configure the mcuboot bootloader (through child_image/mcuboot.conf) with: CONFIG_SINGLE_APPLICATION_SLOT=y

This makes the hci_rpmsg build fail, and it seems that the wrong value is given to the --slot-size parameter of imgtool. (no value, actually).

It seems Nordic-specific, since Partition Manager should give the slot size to scripts/west_commands/sign.py, and this somehow fails.

Parents
  • Hi,

    First of all, we found a solution! (Edit: At least to our problem, netcore is not required to be updatable!)

    We faced the exact same problem. And I think that it is a bug in the partition manager in the partition_manager.cmake file.

    We had the same problem as we reduced the size of the secondary mcuboot partition (2nd slot). We tried to reduce it to a minimum of 0x4000 and then then we got a size problem. The net core image was larger than the secondary partition, but what has the net core to do with the flash of the app core? Nothing!

    The problem is, that the slot-size of the net core is determined by PM_MCUBOOT_SECONDARY_..._SIZE. For the hci_rpmsg there is a pm_CPUNET.config file in the build folder. There, the partition was defined as PM_APP_SIZE.

    Here is a patch to fix this.

    diff --git a/cmake/partition_manager.cmake b/cmake/partition_manager.cmake
    index cb64b739c..01684d3d5 100644
    --- a/cmake/partition_manager.cmake
    +++ b/cmake/partition_manager.cmake
    @@ -555,7 +555,7 @@ to the external flash")
           set_property(
             TARGET partition_manager
             PROPERTY net_app_slot_size
    -        ${PM_MCUBOOT_SECONDARY${sec_slot_idx}_SIZE}
    +        ${PM_APP_SIZE} 
             )
         endif()
    

    This is the fix for version 1.8.0. Our project is currently on this state but I think a similar patch can be applied to newer versions of NCS.

    Best regards

    Jan

  • Hi Jan, 

    Thanks for your information. 

    who9vy said:
    The net core image was larger than the secondary partition, but what has the net core to do with the flash of the app core?

    As far as I know the way we do DFU update for the netcore is that unless you have external flash, we will receive the image of the netcore to the secondary partition of the app core. After that we will copy the image to RAM chunk by chunk then copy the chunk from RAM to the netcore. 

  • Oh yes, that may be a problem.

    It should be somehow possible to change that behaviour dependent  on a available secondary partition. 

    In our case, we do not want to update the netcore, just have the hci_rpmsg example flashed and use it.

    So, to use the DFU of the netcore, it would be advisable to have a second partition which is at least the size required for the netcore?

Reply
  • Oh yes, that may be a problem.

    It should be somehow possible to change that behaviour dependent  on a available secondary partition. 

    In our case, we do not want to update the netcore, just have the hci_rpmsg example flashed and use it.

    So, to use the DFU of the netcore, it would be advisable to have a second partition which is at least the size required for the netcore?

Children
Related