How to debug MCUboot swap failure after OTA DFU? boot_request_upgrade() has no effect

Hi everyone,

I'm facing an issue where MCUboot doesn't perform a swap after reboot, even though the DFU download to slot 1 completes successfully and boot_request_upgrade() is called.

My devices are in production and had no issues in the paste with BLE DFU update. As we update to 2.9.0 the problems starts. Some devices are not working after BLE DFU and swap back to the old version. We find it out while implementing OTA over LTE-M that the partition not swapping. There seams an issue with my swapping. The goal is to use the external flash for updating, but if the main flash works it will be good enough again.

Context:

I'm doing firmware updates via OTA DFU, and writing the upgrade request like this:

int err = boot_request_upgrade(BOOT_UPGRADE_TEST); // or int err = boot_set_pending(0);

MCUboot debug logs confirm that both the magic and swap info are written:

<dbg> mcuboot_util: boot_write_magic: writing magic; fa_id=6 off=0x77ff0 (0xfbff0)
<dbg> mcuboot_util: boot_write_swap_info: writing swap_info; fa_id=6 off=0x77fd8 (0xfbfd8), swap_type=0x2 image_num=0x0

However, after reboot, the old image from slot 0 is still running — no swap occurs.

I have CONFIG_MCUBOOT_UTIL_LOG_LEVEL_DBG=y enabled, but I’m unsure how to debug MCUboot itself (e.g., with west debug or bt) since getting not output west attach.

Note on Flash Patch:

I also experimented with:

# CONFIG_DISABLE_FLASH_PATCH=y

When I enable this config, the DFU (BLE) no longer works — so I’ve kept it disabled.

prj.conf (partial):

CONFIG_PARTITION_MANAGER_ENABLED=y
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=n
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n
CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y

pm_static.yml (simplified):

mcuboot: 0x00000 - 0x0c000
mcuboot_primary: 0x0c000 - 0x84000
mcuboot_secondary: 0x84000 - 0xfc000
settings_storage: 0xfc000 - 0x100000

My questions:

  1. What could prevent MCUboot from initiating the swap even when magic/swap_info are written? (Could a mismatch in partition maps between MCUboot and the application prevent the swap?)

  2. Is there a correct way to attach to MCUboot for runtime debugging? (e.g., debugging from reset?)

  3. Any known issues with OTA DFU + MCUboot + CONFIG_DISABLE_FLASH_PATCH?

  4. Are there additional configs I should double-check?

  5. How can I verify that MCUboot has the correct view of the flash layout?

Thanks in advance — happy to share more if needed!

Related