Create Zip firmware package for DFU over Bluetooth

Hi,

I'm developing an application based on the nRF52832 development kit. It is nrf52dk_nrf52832(PCA10040). I have used nRF Connect SDK (3.0.0) for the project development.

Now, I want to add a feature of DFU over Bluetooth to update the firmware. We used the Simple Management Protocol (SMP) and we could complete the DFU using the Android/iOS nRFConnect application using the *.bin file created by Zephyr.
We have a custom mobile application which is based on React Native and it only supports zip packages created using "nrfutil pkg generate" command.
Hereby, the API that using in my custom mobile Application.
import { NordicDFU, DFUEmitter } from "react-native-nordic-dfu";

 

NordicDFU.startDFU({
  deviceAddress: "12:34:56:78:90:99",
  deviceName: "Pilloxa Pillbox",
  filePath: "/data/user/0/com.nordicdfuexample/files/RNFetchBlobTmp4of.zip",
})

Is there any possible way to do DFU using a zip package?
Zephyr version: 3.0.99
Zephyr SDK version: zephyr-sdk-0.13.2
Thanks!
Parents
  • Hi Hung,

    Let me give you brief information regarding the process I am following to perform the DFU operation in V2.0.0.

    I am using the "zephyr/samples/bluetooth/peripheral" example to test the DFU. I have made changes in prj.conf file as mentioned in this document  Add DFU support to your application.

    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    
    # 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
    
    # 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
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    

    I have created a new dfu.c file for SMP Bluetooth Registration. 

    #include <init.h>
    
    #include <img_mgmt/img_mgmt.h>
    #include <os_mgmt/os_mgmt.h>
    #include <mgmt/mcumgr/smp_bt.h>
    
    #include <logging/log.h>
    LOG_MODULE_REGISTER(init_dfu);
    
    
    static int bt_smp_init(const struct device *dev)
    {
       ARG_UNUSED(dev);
       int err = 0;
    
       img_mgmt_register_group();
       os_mgmt_register_group();
    
       err = smp_bt_register();
    
       if (err) {
          LOG_ERR("SMP BT register failed (err: %d)", err);
       }
    
       return err;
    }
    
    SYS_INIT(bt_smp_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);

    Below are the compilation steps to generate dfu_application.zip and merged.hex files.

    west build -p -b nrf52dk_nrf52832 -s zephyr/samples/bluetooth/peripheral -d test-build/peripheral

    west flash  -d test-build/peripheral

    Now, I made some minor changes in the code to validate whether DFU is successfully completed or not. When I am trying to upload the dfu_application.zip file through the nRFConnect application on Android, it could complete the DFU and new firmware is running. But the same thing when I am trying to perform DFU with the same dfu_application.zip file, It couldn't perform and gives me the below error message.

     

    We are also developing a custom mobile application using React Native and we're also facing the same issue. Please suggest a solution to this issue.

    Thanks!

  • Hi Neel, 

    I have just tested on an iPhone and can see the same error that you are seeing. I will check with the team to see why that happened.

    Could you try to test with nRF Connect app and  the app_update.bin file ? I found that it worked for me on an iPhone. 
    Is there any reason you need to use the .zip file instead of the .bin file ? 

  • Hi Hung,

    Thank you for your quick response. I am good that you can reproduce the issue.

    This issue is only with the dfu_application.zip package. There is no issue with the app_update.bin file in the Android or iOS nRF Connect application.

    As I have earlier informed you that we are also developing a custom mobile application based on React Native. It only supports the ZIP package to perform the DFU operation.

    Thanks!

  • Hi Neel, 

    Please be aware that the .zip that the library in React Native is build for a different DFU protocol. It's the nRF5 SDK DFU protocol not the nRF Connect SDK protocol. 

    So if you plan to support the nRF Connect SDK DFU you would need to write the new app based on the Device Manager app that we provided. 


    The old React Native app won't be able to do DFU update to a nRF Connect SDK application. 

  • Hi Hung,

    Please let us know if any library is available for React Native which can work with nRF Connect SDK DFU operation.

    Thanks!

  • Hi Neel, 

    I am checking internally if there is React Native library available. 

    But as far as I know the only available code we have for nRF Connect DFU is the nRF Connect Device Manager app , so you may want to consider study the code of the app. 

Reply Children
No Data
Related