This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

[softdevice+zigbee] Problem with running BLE DFU on top of a zigbee running application

Hi everyone,

Currently, i am working with some zigbee devices using NRF52833 and zigbee SDK 4.1. Now, i want to use BLE DFU with it to update the firmware when needed.

There is an example of OTA zigbee server which was pretty helpful until i realized that my application can not use the same dual bank update like in the example since the size of the firmware is too big to put into 2 separate banks. So instead, it has to be a single bank update. That leads to another problem that if i use the same method with the example, the DFU is running in the application which i think is impossible to do a single bank update. So my questions are

If what i think is correct, do i have to change the bootloader to run DFU update like in the DFU example in the SDK so that when i input something it will set the GPREGRET  to 1 then reset and the bootloader will recognized the GPREGRET and turn on DFU mode like in this link infocenter.nordicsemi.com/index.jsp

If so, does using multiprotocol is still necessary because now it does not run 2 protocol at the same time. or i still have to add multiprotocol library to the firmware as well as the softdevice.

And finally, can you guys give me some hints how to add softdevice on top of a zigbee running application since softdevice blocks a lot of peripherials that i have already used like PPI, timer, FDS

Thank you and please reply soon,

Best regards,

Tu

Parents
  • Hello Tu,

    It is correct as you said, if your application is too large for dual bank, the Zigbee bootloader will not work out of the box, simply because it is designed to download the app in the background while the app is running, so you would need to fit both the old and the new application in the flash at once. 

    As I see it, you have two options:

    1: Use a temporary zigbee application that is smaller than your current application, which only does the job to receive the new application. Then perhaps you can fit both applications in the flash at once, and you don't need to have a BLE bootloader. Using a BLE bootloader would require you to program the softdevice (BLE stack) as well, so that would also require some flash.

    2: Use a BLE bootloader. As you mentioned, you need some way to tell the device to enter DFU mode. After that you can transfer the new image, with the only flash requirement being that you need to have space for the Softdevice, the bootloader and the new application.

    The advantage of the zigbee (background) DFU is that the application can download in the background, and it would only require a short reboot to swap the application. You can still use the old zigbee application while the new one is being downloaded. The draw is that the Zigbee transfer is relatively slow, compared to the BLE bootloader, which takes maximum a couple of minutes (but probably ~20-30 seconds) instead of 60 - 90 minutes. 

    As for running the "multiprotocol":

    You don't need to actually run multiprotocol in your application. If you don't need to run BLE in your application, all you need to do is to adjust the flash placement of your zigbee application, so that it starts after the softdevice. Then your application would be using Zigbee only, while the bootloader would use BLE only. 

    If you need to use BLE (e.g. to put the device in DFU mode, if you don't want to do it another way, such as a button press or a custom Zigbee command), you can do so. For that, I would recommend you to check the multiprotocol examples from the SDK. 

    Let me know what you think, and we can go from there.

    Best regards,

    Edvin

  • Hello Edwin,

    Thank you for your detailed answer, i decided to go with the second option of BLE bootloader.

    Earlier today, i tried to test the bootloader with only flashing the soft device and then the bootloader with my custom private key in, So basically, because there is no application inside, the MCU will enter DFU mode rightaway and i can flash my zip firmware package with Bluetooth through the NRF connect app from my phone. But it didn 't instead, after reset it takes like a minutes (sometimes more) to actually appear as a service on the mobile app. And even then, it is still unable to connect and the pings is very large like 15000ms. I turn on the log to see if there is any problem but it seems fine

    00> <info> app: Inside main
    00> 
    00> <debug> app: In nrf_bootloader_init
    00> 
    00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00> 
    00> <warning> nrf_dfu_settings: Resetting bootloader settings since neither the settings page nor the backup are valid (CRC error).
    00> 
    00> <debug> nrf_dfu_settings: Writing settings...
    00> 
    00> <debug> nrf_dfu_s<debug> nrf_dfu_settings: Using settings page.
    00> 
    00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <debug> app: Enter nrf_bootloader_fw_activate
    00> 
    00> <info> app: No firmware to activate.
    00> 
    00> <info> app: Boot validation failed. No valid app to boot.
    00> 
    00> <debug> app: DFU mode because app is not valid.
    00> 
    00> <info> nrf_bootloader_wdt: WDT is not enabled
    00> 
    00> <debug> app: in weak nrf_dfu_init_user
    00> 
    00> <debug> app: timer_stop (0x20002AF4)
    00> 
    00> <debug> app: timer_activate (0x20002AF4)
    00> 
    00> <info> app: Entering DFU mode.
    00> 
    00> <debug> app: Initializing transports (found: 1)
    00> 
    00> <debug> nrf_dfu_ble: Initializing BLE DFU transport
    00> 
    00> <debug> nrf_dfu_ble: Setting up vector table: 0x00072000
    00> 
    00> <debug> nrf_dfu_ble: Enabling SoftDevice.
    00> 
    00> <debug> nrf_dfu_ble: Configuring BLE stack.
    00> 
    00> <debug> nrf_dfu_ble: Enabling the BLE stack.
    00> 
    00> <debug> nrf_dfu_ble: No advertising name found
    00> 
    00> <debug> nrf_dfu_ble: Using default advertising name
    00> 
    00> <debug> nrf_dfu_ble: Advertising...
    00> 
    00> <debug> nrf_dfu_ble: BLE DFU transport initialized.
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    00> 
    00> <debug> app: Enter main loop
     

    I am using a custom board with nrf52833 in it and it does not have an external crytal to drive the clock. and the example bootloader i used is inside dfu/secured_bootloader/pca10100_s140_ble_debug. When flashing the softdevice and bootloader i use the "make" command from makefile. Since i did not change a thing in the code, i want to ask is there any way that i did it wrong or is it because of my custom board?

    Thank you and please reply soon,

    Best regards, Tu

  • Hello Tu,

    Is this log from before or after you tried to transfer the application to the nRF using the phone?

    What does it say when you try to transfer using the phone?

    You say that your nRF52833 doesn't have an external LFXTAL. Did you apply this into the applications sdk_config.h file? And did you apply it to the bootloader's sdk_config.h file?

    The definitions that you should look for and change are the following:

    #define NRF_SDH_CLOCK_LF_SRC 0
    #define NRF_SDH_CLOCK_LF_RC_CTIV 16
    #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
    #define NRF_SDH_CLOCK_LF_ACCURACY 1

    Please note the one with the accuracy. You must set this to 1 (500ppm).

    If that doesn't work, can you please let me know what nRF Connect for iOS/Android says when you try to upload the new image? What does the log from the bootloader say? And what command did you use to generate the image that you are transferring?

    Please note that the *_debug bootloader project has it's own sdk_config.h file. It is not the same as the non *_debug version.

    Best regards,

    Edvin

Reply
  • Hello Tu,

    Is this log from before or after you tried to transfer the application to the nRF using the phone?

    What does it say when you try to transfer using the phone?

    You say that your nRF52833 doesn't have an external LFXTAL. Did you apply this into the applications sdk_config.h file? And did you apply it to the bootloader's sdk_config.h file?

    The definitions that you should look for and change are the following:

    #define NRF_SDH_CLOCK_LF_SRC 0
    #define NRF_SDH_CLOCK_LF_RC_CTIV 16
    #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
    #define NRF_SDH_CLOCK_LF_ACCURACY 1

    Please note the one with the accuracy. You must set this to 1 (500ppm).

    If that doesn't work, can you please let me know what nRF Connect for iOS/Android says when you try to upload the new image? What does the log from the bootloader say? And what command did you use to generate the image that you are transferring?

    Please note that the *_debug bootloader project has it's own sdk_config.h file. It is not the same as the non *_debug version.

    Best regards,

    Edvin

Children
No Data
Related