MCUBOOT only doesn't upgrade with CONFIG_BT_SMP enabled

I had previously existing firmware that performed a firmware upgrade using mcuboot and dfu_target. This was done over bluetooth but did not use any existing available bluetooth OTA modules. I had a custom characteristic with write, which would take the written data and feed it to mcuboot through dfu_target. This had no issues and the following config options were enabled for it to work:

CONFIG_ZCBOR=y

CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_MCUBOOT_IMG_MANAGER=y

CONFIG_FLASH_MAP_CUSTOM=y

CONFIG_STREAM_FLASH=y

CONFIG_IMG_MANAGER=y

CONFIG_DFU_TARGET=y

CONFIG_DFU_TARGET_MCUBOOT=y

I now want to introduce some features behind CONFIG_BT_SMP to my firmware, so I enabled it, but upon testing, the upgrade process no longer works. I was able to observe through debugging that the application code runs all the way to the point that I would reset the device for the mcuboot upgrade, after calling the following functions:

dfu_target_done(true)
dfu_target_schedule_update(0)

boot_request_upgrade(BOOT_UPGRADE_PERMANENT)

sys_reboot(SYS_REBOOT_WARM)

At this point, usually it would take a short while for mcuboot to upgrade the device, and it would boot into the new firmware, but when CONFIG_BT_SMP is enabled, it boots immediately into the current firmware. No amount of resetting from firmware, or using something like nrfjprog --reset will change this.

However, interestingly, if I go back into the code, and remove CONFIG_BT_SMP, setting it to N, and attempt to flash that new image, the device does not actually boot into this image. Mcuboot seemingly kicks in at some point and loads whatever was in the secondary partition, that I had written to for the dfu_target upgrade earlier. It almost seems like CONFIG_BT_SMP is suppressing mcuboot from loading the image somehow.

  • Update with some more information:

    I've attempted to OTA the device with the following config combination of what is currently loaded, and what will be upgraded to:

    1. BT_SMP=n -> BT_SMP=n | succeeds

    2. BT_SMP=y -> BT_SMP=n | fails

    3. BT_SMP=n -> BT_SMP=y | fails

    3. BT_SMP=y -> BT_SMP=y | fails

  • Hello,

    Which SDK version and Nordic chip/development kit are you working with? Are you using a partition manager file for your application? If so, could you please share the details here?

    Kind Regards,

    Abhijith

  • Hi Abhijith,

    We are using NCS 2.9.0 for the UBX EVKNINAB1 nRF52832. I had mistakenly selected 52833 when creating this ticket, my apologies.

    The pm_static.yml looks like this:

    app:
      address: 0x9200
      end_address: 0x42800
      region: flash_primary
      size: 0x39600
    mcuboot:
      address: 0x0
      end_address: 0x9000
      placement:
        align:
          end: 0x1000
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0x9000
    mcuboot_pad:
      address: 0x9000
      end_address: 0x9200
      placement:
        align:
          start: 0x1000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x9000
      end_address: 0x42800
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      sharers: 0x1
      size: 0x39800
      span: *id001
    mcuboot_primary_app:
      address: 0x9200
      end_address: 0x42800
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x39600
      span: *id002
    mcuboot_secondary:
      address: 0x42800
      end_address: 0x7c000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
        align_next: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x39800
    nvs_storage:
      address: 0x7e000
      end_address: 0x80000
      placement:
        after:
        - flash_primary
      region: flash_primary
      size: 0x2000
    settings_storage:
      address: 0x7c000
      end_address: 0x7e000
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20010000
      region: sram_primary
      size: 0x10000
  • Hello,

    I will take a look at the shared partition. However, since you’re working with SDK version 2.9.2, the bootloader configurations need to be included inside the sysbuild configuration. You’ll also need to enable CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU to support BLE DFU.

    I recommend following this Academy course for adding BLE DFU support , you can find the same sample here.

    Kind Regards,

    Abhijith

  • HI Abhijith,

    Our sysbuild config already contains the necessary SB_CONFIG_BOOTLOADER_MCUBOOT=y. Our goal was not to use the existing BLE DFU fota feature, we wanted the data to come through our custom characteristic, which we would be writing to mcuboot ourselves. This was previously working before enabling CONFIG_BT_SMP=y.

    Something we have noticed is that in the call stack here, when debugging mcuboot after requesting an upgrade, on line 546 of swap_move.c, if we have BT_SMP enabled, the conditional will fail which will result in "Not enough free space to run swap upgrade". If we do not have BT_SMP enabled, it will pass.

Related