[nrf5340/mcuboot] [sdk 3.3.0] Unable to change pm_static partition sizes, stuck on "Jumping to the first image slot"

Hi Nordic team,

I’m working on an nRF5340 project using MCUboot with the secondary slot placed on external flash.

I found a strange issue related to pm_static.yml. My original goal was to reduce the size of mcuboot_primary so that it matches the size of the external flash secondary slot. However, every time I try to reduce it, the board no longer boots.

At first I thought the issue was directly related to resizing mcuboot_primary, but later I discovered that even changing only the settings_storage partition causes the same failure.

This configuration boots correctly:

settings_storage:
  address: 0xfd000
  end_address: 0x100000
  region: flash_primary
  size: 0x3000

But this one does not boot:

settings_storage:
  address: 0xfc000
  end_address: 0x100000
  region: flash_primary
  size: 0x4000

So it seems that I cannot reduce mcuboot_primary in any way, even indirectly by enlarging another partition such as settings_storage.

When it fails, the boot log stops here:

*** Booting MCUboot v2.3.0-dev-fce4dac2e629 ***
*** Using nRF Connect SDK v3.3.0-ba167d9f3db4 ***
*** Using Zephyr OS v4.3.99-fd9204a02d52 ***
I: Starting bootloader
D: context_boot_go
D: Reading: offset=0x00000000 len=32
W: Cannot upgrade: slots have non-compatible sectors
D: boot_validate_slot: slot 0, expected_swap_type 0
D: bootutil_img_validate: flash area 0x9d7c
D: bootutil_img_hash
D: bootutil_tlv_iter_begin: type 65535, prot == 0
D: bootutil_img_validate: TLV off 542036, end 542368
D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 542036 ending at 542368
D: bootutil_tlv_iter_next: TLV 16 found at 542040 (size 32)
D: bootutil_img_validate: EXPECTED_HASH_TLV == 16
D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 542072 ending at 542368
D: bootutil_tlv_iter_next: TLV 1 found at 542076 (size 32)
D: bootutil_img_validate: EXPECTED_KEY_TLV == 1
D: bootutil_find_key
D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 542108 ending at 542368
D: bootutil_tlv_iter_next: TLV 32 found at 542112 (size 256)
D: bootutil_img_validate: EXPECTED_SIG_TLV == 32
D: bootutil_verify_sig: RSA key_id 0
D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 542368 ending at 542368
D: bootutil_tlv_iter_next: TLV 65535 not found
D: Left boot_go with success == 1
I: Bootloader chainload address offset: 0xc000
I: Image version: v0.3.2
�: Jumping to the first image slot

After "Jumping to the first image slot" the application never starts.

Is there any hidden alignment, partition-size, vector-table, or sector-layout constraint that prevents shrinking mcuboot_primary on nRF5340 when using external flash secondary slots?

mcuboot.conf:

CONFIG_BOOT_SIGNATURE_KEY_FILE="/home/gabriele/king_of_mountain/ncs/v3.0.2/bootloader/mcuboot/root-rsa-2048.pem"
CONFIG_MCUBOOT_LOG_LEVEL_DBG=y
CONFIG_BOOT_FIH_PROFILE_DEFAULT_LOW=y
# CONFIG_MAIN_STACK_SIZE=10240
# CONFIG_HW_STACK_PROTECTION=y
CONFIG_SERIAL=y
CONFIG_SPI=y
# CONFIG_SPI_NOR=y

# CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
# CONFIG_SPI_NOR_SFDP_DEVICETREE=y

CONFIG_LOG=y
CONFIG_CONSOLE=y
CONFIG_PARTITION_MANAGER_ENABLED=y
CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER=0
CONFIG_NCS_APPLICATION_BOOT_BANNER_STRING="MCUboot"
CONFIG_NRFX_GPIOTE_NUM_OF_EVT_HANDLERS=1
# CONFIG_ARM_TRUSTZONE_M=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_UART_CONSOLE=y
CONFIG_MINIMAL_LIBC=y
CONFIG_CBPRINTF_NANO=y
CONFIG_LOG_MODE_MINIMAL=y
CONFIG_LOG_DEFAULT_LEVEL=0

CONFIG_BOOTLOADER_MCUBOOT=y

# CONFIG_SPI_NRFX=y
# CONFIG_NRFX_SPIM4=y

CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y

CONFIG_MULTITHREADING=y


CONFIG_SPI_EEPROM_FLASH=y
CONFIG_SPI_EEPROM_FLASH_LOG_DEFAULT_LEVEL=4

CONFIG_BOOT_MAX_IMG_SECTORS=512
CONFIG_BOOT_SWAP_USING_MOVE=y

CONFIG_FPROTECT=y

sysbuild.conf

# STEP 1.1 - Enable MCUboot 
SB_CONFIG_BOOTLOADER_MCUBOOT=y

# STEP 1.2 - Configure bootloader to use only one slot. 
# SB_CONFIG_MCUBOOT_MODE_SINGLE_APP=y

SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y

SB_CONFIG_MCUBOOT_USE_ALL_AVAILABLE_RAM=y

SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y

SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y

Thanks.

Related