Environment
- nRF Connect SDK v3.4.2, nRF54LM20A (nRF54LM20 DK), MCUboot from nrfconnect/sdk-mcuboot
- sysbuild conf:
SB_CONFIG_SECURE_BOOT_APPCORE=ySB_CONFIG_BOOTLOADER_MCUBOOT=ySB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER=ySB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER_BOOT_MODE_ENTRANCE=y - mcuboot conf:
CONFIG_LTO=yCONFIG_ISR_TABLES_LOCAL_DECLARATION=yCONFIG_BOOT_BANNER=nCONFIG_NCS_BOOT_BANNER=n
Problem
NSIB validates and boots MCUboot, then MCUboot faults before chainloading:
I: Starting bootloaderI: LCS-awareness disabled, skipping LCS checkE: ***** USAGE FAULT *****E: Attempt to execute undefined instructionE: Faulting instruction address (r15/pc): 0x14290E: >>> ZEPHYR FATAL ERROR 36: Unknown error on CPU 00x14290 resolves to bootutil_max_image_size() (boot/bootutil/src/bootutil_misc.c:336), reached via validate_image_slot() → boot_image_validate() → bootutil_img_validate().
Analysis
boot_image_validate() in boot/zephyr/firmware_loader.c calls bootutil_img_validate(NULL, …), i.e. passes state == NULL. That is safe upstream, where bootutil_max_image_size() starts with #if defined(MCUBOOT_FIRMWARE_LOADER) … (void) state; and never touches it.
The [nrf noup] block added in af9d2860 (“treewide: Add support for sysbuild assigned images”) sits above that guard and evaluates BOOT_CURR_IMG(state) → state->curr_img_idx. With secure boot, CONFIG_UPDATEABLE_IMAGE_NUMBER=2, so BOOT_IMAGE_NUMBER > 1 and the macro really does dereference state.
Without LTO it only reads a stray flash byte at NULL + offsetof(curr_img_idx) (UB, but “works”); with LTO the compiler turns it into udf.
Suggested fix
if (state != NULL && BOOT_CURR_IMG(state) == CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER) {or move the NSIB block below the (void) state; in the MCUBOOT_FIRMWARE_LOADER branch.