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.

  • I have new observations.

    After the application flash to the board, do the first build of the image and do ota to the board, it always run normally on Device Manager App and it states Upload Complete but it's still a old app. And use the same file to OTA again, it still states Upload Complete but it still get nothing change. 

    After that, when do the second or third ...build of the image, and do ota, it  will state "There is no free slot to place the image."

    It seems it has something wrong when doing first OTA.

    "If you enable advanced settings in the Device Manager App, you can use an "image list" command. What does that show when you still load the old app?"

    "Could you use the nRF Logger app to see what more logs come before this error?"

    Does it have an IOS version?

  • Hi, the problem above is resolved when I commented out this line  

    "k_sem_take(&ble_init_ok, K_FOREVER);" in my application.
    I think the ota program is locked by semaphore.
    so it is be sure to ota successfully(it is dynamic partition, without pm_static.yml),
    but when I add the pm_static.yml, the OTA  App always states "There is no free slot to place the image."  
    and I've checked the partition.yml, it's changed correctly what I added the pm_static. 
    I'm not sure whether the use of partition is correct.
    (external flash total size is 0x400000) 
    partition.yml 
    EMPTY_0:
      address: 0xfe000
      end_address: 0x100000
      placement:
        after:
        - settings_storage
      region: flash_primary
      size: 0x2000
    app:
      address: 0x10200
      end_address: 0xfc000
      region: flash_primary
      size: 0xebe00
    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: 0xfc000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0xec000
      span: *id001
    mcuboot_primary_1:
      address: 0x0
      device: nordic_ram_flash_controller
      end_address: 0x40000
      region: ram_flash
      size: 0x40000
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0xfc000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xebe00
      span: *id002
    mcuboot_secondary:
      address: 0x310000
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0x3c0000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0xb0000
    mcuboot_secondary_1:
      address: 0x3c0000
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0x400000
      region: external_flash
      size: 0x40000
    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
    ram_flash:
      address: 0x40000
      end_address: 0x40000
      region: ram_flash
      size: 0x0
    reserved_custom_partition:
      address: 0x0
      end_address: 0x310000
      region: external_flash
      size: 0x310000
    rpmsg_nrf53_sram:
      address: 0x20070000
      end_address: 0x20080000
      placement:
        before:
        - end
      region: sram_primary
      size: 0x10000
    settings_storage:
      address: 0xfc000
      end_address: 0xfe000
      placement:
        align:
          start: 0x4000
        before:
        - end
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20002000
      end_address: 0x20070000
      region: sram_primary
      size: 0x6e000
    
    and I've checked the Nrf Logger App when it states "There is no free slot to place the image" came out
  • allenyang said:

    the problem above is resolved when I commented out this line  

    "k_sem_take(&ble_init_ok, K_FOREVER);" in my application.

    Do you ever give back that semaphore?

  • "Do you ever give back that semaphore?" 

    Maybe not. 

    However, I've resolved the partition problem, so now everything works fine. 

    Last time I only set the mcuboot secondary partition,

    but the mcuboot primary also must be set to the pm_static.yml,  

    because mcuboot primary and mcuboot secondary must be partition to the same size.

    Thanks for the help for a long time.

    Regards,

    Allen

     

  • Hi Allenyang
    I am using a module MS12SF1 (nrf5340 + nrf7002). I was also trying fota over ble using nrf7002dk_nrf5340_cpuapp_ns or nrf7002dk_nrf5340_cpuapp build configurations but as soon as I enabled the configurations related to dfu and flash the code I get nothing on the rtt viewer and also device stops advertising
    2548.peripheral_uart.zip

    This is the code I was working on
    It would be great if u can help me on this

Related