NCS 3.4.0 - Thingy91X - build without SECURE_BOOT_APPCORE fails to flash

NCS 3.4.0 - Thingy91X

If I configure the sysbuild with sysbuild.conf

SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_SECURE_BOOT_APPCORE=n

it builds, but on "west flash" I get

FATAL ERROR: ???/ncs/v3.4.0/app/build/app/../signed_by_mcuboot_and_b0_app.hex does not exist. Try enabling CONFIG_BUILD_OUTPUT_HEX.

but with SB_CONFIG_SECURE_BOOT_APPCORE=n that's intended to not have that file.

I tried to analyze the issue and found in Kconfig.defconfig.nrf9151:

config SECURE_BOOT
    default y

If I change that to 'n' it work to flash and the app runs well.

Unfortunately, it's not possible to overwrite that in sysbuild.conf with

SB_CONFIG_SECURE_BOOT=n

because that results in 

error: SECURE_BOOT (defined at ???/ncs/v3.4.0/nrf/modules/../sysbuild/Kconfig.secureboot:7)
is assigned in a configuration file, but is not directly user-configurable (has no prompt). It gets
its value indirectly from other symbols

So:

why is 

config SECURE_BOOT
    default y

instead of 

config SECURE_BOOT_APPCORE
    default y

?

Parents
  • Yes, I tested this now, and I run into the same issue. I will check if this is something that should be fixed. For now you can instead run

    west flash \
      -d build/udp \
      --no-rebuild \
      --hex-file build/udp/zephyr/zephyr.signed.hex

  • :-) I guess, I know in the meantime the reason (-:.

    Not using SB_CONFIG_SECURE_BOOT_APPCORE is in NCS 3.4.0 broken!

    The cause for that is simple, very close to the issue migrating app using mcuboot to NCS 3.2.3 - issue with MCUboot image IDs automatically assigned?

    The way "zephyr/subsys/dfu/img_util/flash_img.c" assigns the ids is broken.

    It was (before NCS 3.4.0):

    #define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label)                                            \
        DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)),                   \
            FIXED_PARTITION_MTD(label)) &&                                                     \
        (FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET &&                              \
         FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET)

    #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2)
    #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition
    #else
    #if FIXED_PARTITION_EXISTS(slot1_partition) && \
        FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition)
    #define UPLOAD_FLASH_AREA_LABEL slot1_partition
    #else
    #define UPLOAD_FLASH_AREA_LABEL slot0_partition
    #endif
    #endif

    Now its:

    #define PARTITION_IS_RUNNING_APP_PARTITION(label) \
        DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label))


    #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2)
    #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition
    #else
    #if PARTITION_EXISTS(slot1_partition) && \
        PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition)
    #define UPLOAD_FLASH_AREA_LABEL slot1_partition
    #else
    #define UPLOAD_FLASH_AREA_LABEL slot0_partition
    #endif
    #endif

    So, SECURE_BOOT_APPCORE works, because of the "CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2". 

    And without it fails, because of "PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition)", the app runs on slot0_ns_partition. Using

    #if PARTITION_EXISTS(slot1_partition) && \
        PARTITION_IS_RUNNING_APP_PARTITION(slot0_ns_partition)
    #define UPLOAD_FLASH_AREA_LABEL slot1_partition

    again "works on my machine".

Reply
  • :-) I guess, I know in the meantime the reason (-:.

    Not using SB_CONFIG_SECURE_BOOT_APPCORE is in NCS 3.4.0 broken!

    The cause for that is simple, very close to the issue migrating app using mcuboot to NCS 3.2.3 - issue with MCUboot image IDs automatically assigned?

    The way "zephyr/subsys/dfu/img_util/flash_img.c" assigns the ids is broken.

    It was (before NCS 3.4.0):

    #define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label)                                            \
        DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)),                   \
            FIXED_PARTITION_MTD(label)) &&                                                     \
        (FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET &&                              \
         FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET)

    #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2)
    #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition
    #else
    #if FIXED_PARTITION_EXISTS(slot1_partition) && \
        FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition)
    #define UPLOAD_FLASH_AREA_LABEL slot1_partition
    #else
    #define UPLOAD_FLASH_AREA_LABEL slot0_partition
    #endif
    #endif

    Now its:

    #define PARTITION_IS_RUNNING_APP_PARTITION(label) \
        DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label))


    #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2)
    #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition
    #else
    #if PARTITION_EXISTS(slot1_partition) && \
        PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition)
    #define UPLOAD_FLASH_AREA_LABEL slot1_partition
    #else
    #define UPLOAD_FLASH_AREA_LABEL slot0_partition
    #endif
    #endif

    So, SECURE_BOOT_APPCORE works, because of the "CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2". 

    And without it fails, because of "PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition)", the app runs on slot0_ns_partition. Using

    #if PARTITION_EXISTS(slot1_partition) && \
        PARTITION_IS_RUNNING_APP_PARTITION(slot0_ns_partition)
    #define UPLOAD_FLASH_AREA_LABEL slot1_partition

    again "works on my machine".

Children
Related