nrf52832 + DFU over BLE + External flash


We are trying to make DFU over BLE with external flash to overcome the large application size. This is what we are looking for:
- Use BLE to transfer the OTA image
- Since our application size id >250KB, planning to use an external flash to store the firmware
- Perform OTA when there is no critical task running

Environment:
- nrf52832
- nRF Connect SDK (v1.8.0)
- External flash (W25Q80DV) connected over SPI and tested successfully

We could find the guide on how to add support for DFU in the application at: devzone.nordicsemi.com/.../ncs-dfu

However, couldn't find how to use external flash for the DFU over BLE.

Could you share some sample or guide which shows OTA using BLE with external flash?

So far, we understand we need to do the following changes:
- Modify our application for DFU over Bluetooth. As mentioned in: devzone.nordicsemi.com/.../ncs-dfu
- Add a new file in our application folder pm_static.yaml and modify it.
- Add new child_image/mcuboot/prj.conf in our application. (Not sure if this is required)
- Is there any other configuration required in our application overlay file?

Thanks!

P.S. IMHO, DFU over BLE with external flash is a very common scenario and a good sample or blog around it would definitely help and may reduce some tickets. :)

Parents
  • I don't know what's wrong with devzone website, the attachment got missed in the previous comment. So, reattaching the code.

    peripheral_lbs_dfu.zip

  • Hi Edvin,

    We are still struggling with the DFU on nrf52832 with external flash. Could you please check the code and suggest what's wrong here?

    I am attaching 2 codes for reference:

    1. peripheral_lbs_dfu_flash_verified.zip

    This is the code where I verified the external flash working fine. Flash APIs are working fine, BLE advertisements and logs on the serial device are working fine.

    2. peripheral_lbs_dfu_not_working_with_dfu_changes.zip

    This is the modified code for DFU using an external flash. When I flash this from VS Code, I don't see anything on serial or BLE advertisements. It seems it is not booting at all.

    Could you please check and guide us? 

    TIA!

  • Hello,

    Sorry for the late reply. I was out of office due to illness last week, but I will look into this as soon as I can.

    Sorry for the delay.

    Best regards,

    Edvin

  • Hi Edvin,

    Thanks for the ack and I hope you are feeling well.

    Meanwhile, I've made some progress and modified the example. Now, I am able to boot and download the image but when it tries to swap from the Secondary image, it fails with "E: Image in the secondary slot is not valid!".

    Logs:

    *** Booting Zephyr OS build v2.7.0-ncs1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot*** Booting Zephyr OS build v2.7.0-ncs1  ***
    Starting Bluetooth Peripheral LBS example
    GPIO Periphal GPIO_0 initialised
    build time: May 31 2022 12:30:46
    I: 2 Sectors of 4096 bytes
    I: alloc wra: 0, fd0
    I: data wra: 0, 1c
    I: SoftDevice Controller build revision: 
    I: df c0 4e d6 1f 7c 66 09 |..N..|f.
    I: 0a f5 2b a0 98 f2 43 64 |..+...Cd
    I: 62 c5 a6 2a             |b..*    
    I: No ID address. App must call settings_load()
    Bluetooth initialized
    Advertising successfully started
    Connected
    I: Swap type: none
    I: Swap type: none
    I: Swap type: none
    I: Swap type: none
    I: Swap type: test
    I: Swap type: test
    *** Booting Zephyr OS build v2.7.0-ncs1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: test
    E: Image in the secondary slot is not valid!
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot*** Booting Zephyr OS build v2.7.0-ncs1  ***
    Starting Bluetooth Peripheral LBS example
    GPIO Periphal GPIO_0 initialised
    build time: May 31 2022 12:30:46
    I: 2 Sectors of 4096 bytes
    I: alloc wra: 0, fd0
    I: data wra: 0, 1c
    I: SoftDevice Controller build revision: 
    I: df c0 4e d6 1f 7c 66 09 |..N..|f.
    I: 0a f5 2b a0 98 f2 43 64 |..+...Cd
    I: 62 c5 a6 2a             |b..*    
    I: No ID address. App must call settings_load()
    Bluetooth initialized
    Advertising successfully started
    Connected
    I: Swap type: test
    I: Swap type: test
    I: Swap type: test
    

    Attaching the updated code for reference: peripheral_lbs_dfu_secondary_image_invalid.zip

    Here is the snapshot from the mobile application:

    Could you please check this updated code?

    Thanks!

  • Hi Edwin,

    Did you get a chance to look at this?

    Also, to add, whenever image validation fails, magic is still showing good in the logs:

     Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3

    On further digging it seems, it's failing from: https://github.com/nrfconnect/sdk-mcuboot/blob/v1.6.99-ncs1-rc1/boot/bootutil/src/tlv.c#L65

    Second issue:

    And, in the next stage when it tries to erase the flash (to prevent booting from the secondary partition), it doesn't fail but it doesn't erase the flash either. This in turn always tries to boot from a secondary image on every boot.

    Flash erase is working fine from the application. I can erase the flash from the application and in the next boot, it doesn't try to boot from the secondary partition.

    TIA!

  • Hi Edwin,

    I finally got this working on our custom board. The issue was with our custom board on how the Flash chip was powered. Because the Flash chip was controlled (ON/OFF) by the Nordic GPIO. Unless Nordic boots up and make that GPIO high flash was misbehaving. (This explains why Flash erase was not working during boot time but worked from the Application)

    We connected Flash with VCC directly (turning it ON always), and it solved the issue.

    I am attaching the code here for anyone's reference: peripheral_lbs_dfu-externalflash-w25q80dv-dfu-working-nrf52832.zip

    Code is compiled and tested on nRF52832, ncsv1.8.0 with the secondary partition on Winbond Flash (W25Q80DV)

    I just have one follow-up question: What would be the status of nRF GPIO during boot time? high/low/floating?

    Thanks!

Reply
  • Hi Edwin,

    I finally got this working on our custom board. The issue was with our custom board on how the Flash chip was powered. Because the Flash chip was controlled (ON/OFF) by the Nordic GPIO. Unless Nordic boots up and make that GPIO high flash was misbehaving. (This explains why Flash erase was not working during boot time but worked from the Application)

    We connected Flash with VCC directly (turning it ON always), and it solved the issue.

    I am attaching the code here for anyone's reference: peripheral_lbs_dfu-externalflash-w25q80dv-dfu-working-nrf52832.zip

    Code is compiled and tested on nRF52832, ncsv1.8.0 with the secondary partition on Winbond Flash (W25Q80DV)

    I just have one follow-up question: What would be the status of nRF GPIO during boot time? high/low/floating?

    Thanks!

Children
No Data
Related