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.

Related