BLE OTA DFU using external flash

I'm using the NCS 2.5.2 sdk and nrf 5340 with 7002, and I want to do BLE OTA DFU using external flash.

I've found this guide Add DFU support to your application - Software - nRF Connect SDK guides - Nordic DevZone (nordicsemi.com), and successfully  done BLE OTA DFU using internal flash, just add the commands below,

#Enable MCUBOOT bootloader build in the application
CONFIG_BOOTLOADER_MCUBOOT=y
#Include MCUMGR and the dependencies in the build
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

but I don't know how to do with external flash, I've tried looking at main.c in mcuboot, and I didn't find where to modify the code.

  • It looks good to me.

    From External flash memory partitions:

    "f the external flash device is not using the QSPI NOR driver, you must enable CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK to override the Partition Manager’s external flash driver check, and the required driver must also be enabled for all applications that need it."

    Try to set that configuration, I suspect that should do it.

    I realized this as your log was complaining about QSPI drivers were missing, and this would explain why it tried to access QSPI flash while you have SPI flash in the DTS

  • Hi, I've seen the article, so I had added the line "CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK" to both prj.conf and mcuboot.conf,

    but it still has same error.

  • Ah right, it is a "feature" we have with CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU.

    This assumes that you use QSPI, and forces that.

    Instead of using CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU you should do set the configurations this config does instead.

    Then after that, I suggest that you re-check Kconfig override warnings, cause it looks like you will have some of those.

  • "Instead of using CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU you should do set the configurations this config does instead."

    After doing that,

    it really build successfully this time.

    thank you

    And I want to ask some questions about partition manager,

    In our external flash, it has some image file from 0x0 to 0x310000,

    so I need to create a pm_static.yml (copied from partition.yaml in the build folder) in the project(create outside the build folder), and set mcuboot_secondary start address to 0x310000?

    and I don't want other partitions of external flash, can I just delete it or just set size to 0?

    app:
      address: 0x10200
      end_address: 0x100000
      region: flash_primary
      size: 0xefe00
    external_flash:
      address: 0x400000
      end_address: 0x400000
      region: external_flash
      size: 0x0
    mcuboot:
      address: 0x0
      end_address: 0x10000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      placement:
        align:
          start: 0x4000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      end_address: 0x100000
      orig_span: &id001
      - app
      - mcuboot_pad
      region: flash_primary
      size: 0xf0000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x100000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xefe00
      span: *id002
    mcuboot_secondary:
      address: 0x310000
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0x400000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0xf0000
    otp:
      address: 0xff8100
      end_address: 0xff83fc
      region: otp
      size: 0x2fc
    pcd_sram:
      address: 0x20000000
      end_address: 0x20002000
      placement:
        after:
        - start
      region: sram_primary
      size: 0x2000
    rpmsg_nrf53_sram:
      address: 0x20070000
      end_address: 0x20080000
      placement:
        before:
        - end
      region: sram_primary
      size: 0x10000
    sram_primary:
      address: 0x20002000
      end_address: 0x20070000
      region: sram_primary
      size: 0x6e000
    

    pm_static.yml

    app:
      address: 0x10200
      end_address: 0x100000
      region: flash_primary
      size: 0xefe00
    external_flash:
      address: 0xf0000
      end_address: 0x400000
      region: external_flash
      size: 0x310000
    mcuboot:
      address: 0x0
      end_address: 0x10000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      placement:
        align:
          start: 0x4000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      end_address: 0x100000
      orig_span: &id001
      - app
      - mcuboot_pad
      region: flash_primary
      size: 0xf0000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x100000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xefe00
      span: *id002
    mcuboot_secondary:
      address: 0x0
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0xf0000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0xf0000
    otp:
      address: 0xff8100
      end_address: 0xff83fc
      region: otp
      size: 0x2fc
    pcd_sram:
      address: 0x20000000
      end_address: 0x20002000
      placement:
        after:
        - start
      region: sram_primary
      size: 0x2000
    rpmsg_nrf53_sram:
      address: 0x20070000
      end_address: 0x20080000
      placement:
        before:
        - end
      region: sram_primary
      size: 0x10000
    sram_primary:
      address: 0x20002000
      end_address: 0x20070000
      region: sram_primary
      size: 0x6e000
    

    partitiom.yaml

  • allenyang said:

    so I need to create a pm_static.yml (copied from partition.yaml in the build folder) in the project(create outside the build folder), and set mcuboot_secondary start address to 0x310000?

    and I don't want other partitions of external flash, can I just delete it or just set size to 0?

    Do you mean that you want to create a custom partition?

Related