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

BLE Background DFU function support

Hi Nordic ,

I have a nRF52840 project development based on SDK 15.3 . Now ,I need to add DFU feature there. we suppose to use background DFU here. we will use long range( coded PHY S8), and long connection parameter . 

form my study ,I can use IOT bootloader example from my bootloader.

but about the DFU function, can you give me the hint and reference for DFU function implement ?

I am not idea on how to save the New fw package during the application status now. Thanks.

Parents
  • Hi Nordic ,

    There are few more questions. 

    1. I want to use different bootloader with same app part for different usage, can I use the UICR file to implement that case?

    2. I used the FDS to save some setting config for my application, will dfu overwrite the setting ? if yes , how to protect the setting.

    Thanks

  • Hello,

    We do not deliver background BLE DFU, but I know that there are other customers that have done similar solutions, so it is possible.

    What you would want to do is to keep the bootloader, but to move the transport of the new image to the application instead of the bootloader, right?

    So you need to implement a service where you can receive the init packet and firmware image generated by nrfutil, and then find out what function in the bootloader that is usually called when the init packet or the image is transferrec. I don't know what that looks like in the IoT SDK bootloader (This is deprecated), but in the normal SDKs, bootloader, look for the nrf_dfu_validation_init_cmd_execute() function, which will validate the image that you have already transferred.

     

    Kawing said:
    1. I want to use different bootloader with same app part for different usage, can I use the UICR file to implement that case?

     I don't understand what you mean by this. 

     

    Kawing said:
    2. I used the FDS to save some setting config for my application, will dfu overwrite the setting ? if yes , how to protect the setting.

     Look for NRF_DFU_APP_DATA_AREA_SIZE in sdk_config.h. Loo kat the description for this definition:

    // <h> Misc DFU settings 
    
    //==========================================================
    // <o> NRF_DFU_APP_DATA_AREA_SIZE - The size (in bytes) of the flash area reserved for application data. 
    // <i> This area is found at the end of the application area, next to the start of
    // <i> the bootloader. This area will not be erased by the bootloader during a
    // <i> firmware upgrade. The size must be a multiple of the flash page size.
    
    #ifndef NRF_DFU_APP_DATA_AREA_SIZE
    #define NRF_DFU_APP_DATA_AREA_SIZE 12288
    #endif

    The FDS pages are always in the end of the application flash area, next to the bootloader. So make sure that this is large enough to cover your FDS pages. By default this is set to 12288 bytes, which is 3*4096, or 3 FDS pages, which is the same that the FDS use by default. If you increase this in your application, remember to increase this in your bootloader as well.

    Best regards,

    Edvin

  • Hi Edvin,

    Thanks for reply, I starting to build the project bootloader , I am using example/iot /bootloader as my BLE project , once I used the nrfjprog to grouping the softdevice and the bootloader , I found there is some problem in this new hex. can you help to checking the issue.

    I using the nRF connect to flash the software to my broad, and I found there is a black zone. and it will fail to flash. there is the log file for the fail flashing.

    Thanks.

      2020-04-15T02_03_48.453Z-log.txt

  • What are you trying to do when you get this error message? Are you trying to program the .hex file? What hex file is this?

    Are you saying that you tried to merge them using merghex? If so, did you get any error messages when trying to merge these files?

  • 1. Yes, I try to flash the .hex file. which is combine App Softdevice and the bootloader.

    2. No Error Message when merge file. 

    I generate the bootloader setting.hex by application and softdevice , and merge all bootloader, setting, Application and softdevice to one hex file. then try to flash the hex file in broad. 

    The upper picture is trying to flash the Hex file which merge the BOOTLOADER and SOFTDEVICE.

Reply
  • 1. Yes, I try to flash the .hex file. which is combine App Softdevice and the bootloader.

    2. No Error Message when merge file. 

    I generate the bootloader setting.hex by application and softdevice , and merge all bootloader, setting, Application and softdevice to one hex file. then try to flash the hex file in broad. 

    The upper picture is trying to flash the Hex file which merge the BOOTLOADER and SOFTDEVICE.

Children
  • Ok, so it is a flashing problem then, I assume. It doesn't have anything to do with OTA DFU, I assume?

    Have you tried to flash the merged hex file using nrfjprog?

    What HW are you trying to flash this to?

    I see that it is the nRF52840, but is it a Development kit, the nRF52840 dongle, or a custom PCB?

  • I am using the custom PCB with nRF52840 , but I can flash it with App.hex only before.

    Once I merge the Bootlaoder and softwdevice, it happen fail.

    Bootloader and SoftDevice can been flash independency.

  • Can you try to use nRF Command Line Tools to flash the merged hex file?

    The commands you would need to use are:

    nrfjprog --eraseall
    nrfjprog --program merged_file.hex
    nrfjprog --reset

    What happens if you try this? Does it throw any errors?

    What programmer do you use to program the custom PCB?

  • Thanks for reply , I work fine. I can flash the hex file by Command Line tools with Jlink now. 

    Then , can I back to the other issue ?

     

    Kawing said:
    1. I want to use different bootloader with same app part for different usage, can I use the UICR file to implement that case?

     I don't understand what you mean by this. 

    In my design , I would like to use the UICR register customer area to save some software setting.

    Then once the App part starting , it can get UICR->Customer[0] value to select the operation. even do the OTA , the software can working with same operation. 

    I try to adding the config file in app part. it work fine. 

    #include "cus_uicr_config.h"
    
    uint32_t get_NRF_UICR_CUSTOMER_SECTION (void)
    {
        // if register is not write , return None type .
        return (NRF_UICR->CUSTOMER[0] == 0xFFFFFFFF)?0x00:NRF_UICR->CUSTOMER[0];
    }
    

    but I try to adding the same file in bootloader part , it cannot work. my application cannot work with my setting. there is the config file I used. 

    so, my question is how can I write my UICR setting in code ?

    If I need to use bootloader function, can I adding the UICR setting in bootloader?

    Thank. 

    cus_uicr_config.h

  • Kawing said:
    but I try to adding the same file in bootloader part , it cannot work. my application cannot work with my setting. there is the config file I used. 

     What do you mean by "doesn't work". Are you not able to read the UICR? Is the value different from what you expect?

    Where do you write to the UICR register? Is the value correct if you try to read it using nrfjprog? Do you try to update it during runtime?

    You can use the command:

    nrfjprog --memrd 0x10001080

    to read UICR->CUSTOMER[0]

    For testing, you can also write to the UICR register using:

    nrfjprog --memwr 0x10001080 --val 0xDEADBEEF

    You can see the different UICR registers here.

Related