How Can I Update Firmware through DFU Bootloader and custom mobile app

Dear All,

I am working on a Bluetooth edge device with nRF Connect Environment. we are designing a product in which mobile application and battery operated edge device both are there. I went through some Nordic blogs and videos.

here is my understanding related to firmware update through DFU Bootloader(Nordic Provided Bootloader):

1> If I wants to update the device firmware we had to stick some required tools and configuration

2> we also needs to maintain separately nrf Connect App for image file transfer.

Here is my requirement :-

1> we are having cloud network also, we need to keep the file over cloud so as soon as file will be uploaded to the cloud mobile app should sync and receive this file to its local database.

2> whenever device will be connected to the mobile app(not nRF Connect its client app), app will send a notification to edge device. Edge device should receive this file and store in its 

     in its external memory.

3> then bootloader should start and replacing the updated f/w with new f/w 

My question is:- Can DFU Bootloader(Nordic Provided DFU Bootloader) fulfil my project requirement?  if yes please provide some help.

Thanks & Regards

Sabir Khan

Parents
  • Hi Sabir,

    What you are describing is a typical use case. On the nRF side, MCUBoot is integrated in the nRF Connect SDK. See Bootloaders and Device Firmware Updates for more information about that. On the mobile phone side you will need to make your own app that gets the firmware updates from the cloud, and performs the DFU operation of the nRF. We provide a library that will handle the DFU part though (including example applications), both for iOS (iOS nRF Connect Device Manager) and Android (Android nRF Connect Device Manager).

    Einar

  • Hi Einar,

    Thanks a lot for your quick response.

    Here there are lots of material for the learning and doing same. but still I am not able to see any specific guide which is clarifying the things step by step for performing OTA . 

    can you please provide me some video link or example blog which is clarifying the things in easy manner. I am able to see some videos but that all is showing in nrf5 sdk.

    is there any difference in OTA process in nrf5 sdk and nrf connect sdk ?

    Thanks & Regards

    Sabir Khan

  • Hi Sabir,

    Thanuha said:
    can you please provide me some video link or example blog which is clarifying the things in easy manner. I am able to see some videos but that all is showing in nrf5 sdk.

    I am not aware of any video, but a colleague of me made a collection of samples with descriptions here. You can also refer to the SMP server sample (but ignore most details about signing and keys as this is handled differently in the nRF connect SDK compared to vanilla Zephyr).

    Thanuha said:
    is there any difference in OTA process in nrf5 sdk and nrf connect sdk ?

    These are fundamentally different. In the nRF Connect SDK, we provided a custom bootloader that included the transport (BLE or other) in the bootloader. In the nRF Connect SDK, we use MCUboot which does not support transports (other than serial for recovery), so that is handled by the application. The protocol is also completely different (in the nRF Connect SD we use Simple Management Protocol (SMP)).

  • Hi Einar,

    now I am able to update f/w through device manager app with smaller size of nearly 150kb code.

    I was seeing it was creating 500kbs two partitions(I am using nrf52840 ). if I was trying to compile more than 500kb size code, it was throwing errors flash and RAM overflow. my actual code size is nearly 800kb. I am also using SPI external flash(mx25l25645g) in my project

    can you please answer my few below queries.

    1> weather my above requirement can be fulfilled like nearly 800kb application can be updated through OTA on Bluetooth. I want to make slot-2 in external flash. if yes can you please provide step by step support.

    2> My bootloader and application should be in microcontroller flash memory and remaining other partitions should be in external flash. if it could be done, how to do partitioning 

    3> We are using our custom app for ios application(in react). we found a below library for DFU support for ios. please confirm weather below library should work or not for react IOS application.

    https://github.com/Pilloxa/react-native-nordic-dfu

    Thanks & Regards

    Sabir

Reply
  • Hi Einar,

    now I am able to update f/w through device manager app with smaller size of nearly 150kb code.

    I was seeing it was creating 500kbs two partitions(I am using nrf52840 ). if I was trying to compile more than 500kb size code, it was throwing errors flash and RAM overflow. my actual code size is nearly 800kb. I am also using SPI external flash(mx25l25645g) in my project

    can you please answer my few below queries.

    1> weather my above requirement can be fulfilled like nearly 800kb application can be updated through OTA on Bluetooth. I want to make slot-2 in external flash. if yes can you please provide step by step support.

    2> My bootloader and application should be in microcontroller flash memory and remaining other partitions should be in external flash. if it could be done, how to do partitioning 

    3> We are using our custom app for ios application(in react). we found a below library for DFU support for ios. please confirm weather below library should work or not for react IOS application.

    https://github.com/Pilloxa/react-native-nordic-dfu

    Thanks & Regards

    Sabir

Children
  • Hi  Sabir,

    Thanuha said:
    1> weather my above requirement can be fulfilled like nearly 800kb application can be updated through OTA on Bluetooth. I want to make slot-2 in external flash. if yes can you please provide step by step support.

    A colleago of me made a simple sample of using external flash for the second slot here. This use UART instead of BLE for transport, but that is a separate matter, so you can still refer to that sample for the external flash part (mostly the relevant parts here are in the configuration parts under child_image, but also in app.overlay).

    Thanuha said:
    2> My bootloader and application should be in microcontroller flash memory and remaining other partitions should be in external flash. if it could be done, how to do partitioning 

    Yes, this can be done. The partition manager will automatically partition the flash, and if you build with the secondary slot in the external flash, this will be automatically handled by the partition manager. You can hand-write the partitions if you like though, as explained in the partition manager documentation.

    Thanuha said:

    3> We are using our custom app for ios application(in react). we found a below library for DFU support for ios. please confirm weather below library should work or not for react IOS application.

    https://github.com/Pilloxa/react-native-nordic-dfu

    This is a project that is not maintained by Nordic (and not maintained at all anymore, it seems). It was also for the nRF5 SDK bootloader, and is not relevant in your case. We provide native DFU libraries for iOS and Android. We also have mcumgr_flutter for cross-platform projects, but that is it. The McuManager protocol is not Nordic specific though, so you could also use other implementations that suits your needs. We do not have experience with any of these, but there are some out there, for instance this one (I cannot say how well it works or how the qualify of this third party library is, though).

    Einar

  • Hi,

    I found the below Nordic link for Firmware upgrade using external Flash over SPI. I have taken Peripheral_lbs example as base code.

    https://github.com/simon-iversen/sdk-zephyr/tree/serial_dfu_ext_flash_hello_world/samples/hello_world

    but whenever I am trying to compile same its throwing errors. my query is in the link above if you see there is 1 another folder which is named as child image, its also having prj.config and .overlay file. why it is required? I wants to use secondary slot in SPI external flash that's why I am referring this.

    I have already done Firmware upgrade with the help of below link.

     Add DFU support to your application  here there is no concept of child image and all. only single file is been generated as app_update.bin. I just flashed the same code through J-Tag and after changing few line and compiling the project again generated the file and uploaded the bin file successfully through OTA(device manager app). 

    right now I am following the below steps for external flash.

    1st Step> Modify overlay file as per below:-

    2nd Step> Modify prj.config as like:-

    ##################### OTA Config #############################

    # Enable mcumgr.
    CONFIG_MCUMGR=y

    # Enable most core commands.
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y

    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
    # Allow for large Bluetooth data packets.
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_BUF_ACL_RX_SIZE=256

    # Enable the Bluetooth (unauthenticated) and shell mcumgr transports.
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n

    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y

    ################# OTA CONFIG END ######################################

    ##############
    CONFIG_GPIO=y
    CONFIG_LOG=y

    # Configure Bluetooth Low Energy.
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="NDC12345672"
    CONFIG_BT_DEVICE_APPEARANCE=0
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_LL_SOFTDEVICE=y


    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=10240

    CONFIG_I2C=y
    #CONFIG_NO_OPTIMIZATIONS=y
    CONFIG_SPI=y
    CONFIG_FLASH=y
    CONFIG_STDOUT_CONSOLE=y
    CONFIG_CBPRINTF_FP_SUPPORT=y


    3rd Step> try to Add pm_static.yml file to project directory. it is having following content.
    4th Step> but due pm_static.yml file error been generated as seen below so I just changed the name from pm_static.yml to pm.yml file. all the errors resolved.
    5th step> Flashed the code through J-Tag. no response seemed from firmware. I try to debug and put a breakpoint at main itself, It never came here. it looks like it is trapped here as below
    I was thinking if it is done successfully and responding, I will change again some lines of the code and make binary file app_update.bin and then upload through device manager app. but unfortunately I couldn't reach up to here.  
    Can you please guide me step by step which step I am doing mistake. 
    Heartly thanks in advance!!
  • Hi,

    The guides you have referred to are quite old. I suggest you refer to the examples I suggested, or just do a few changes that are needed, as explained in this post. If it does not work, perhaps you can show all your changes and the full build log / errors? (You can post code/logs in a readable way using Insert -> Code)

Related