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.

  • 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.

Reply Children
  • 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.

  • HI Edvin ,

    I found the solution for my UICR issue , I can write it in my application parts at first programming.

    Then I meet other issue during my development, I would like to do the dfu transport in my application.

    1. once I program the application and SoftDevice Only, it will said error like this, 

    <error> app: No bootloader was found
    <debug> app: nrf_dfu_svci_vector_table_set() -> NRF_ERROR_NO_MEM
    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ..\..\..\usr_BLE.c:1085
    PC at: 0x00026C6D
    <error> app: End of error report

    2. if I try to merge all hex file together by mergehex tool like this .

    nrfutil settings generate  --application application.hex  --family NRF52840  --application-version 1  --bootloader-version 1  --bl-settings-version 2 --softdevice s140_SD.hex O_bootloader_setting.hex 
    
    :: Merge for Bootloader with mapping setting 
    mergehex --merge bootloader.hex O_bootloader_setting.hex --output O_Mapped_Bootloader.hex 
    
    :: Merge for Application and SoftDevice 
    mergehex --merge s140_SD.hex application.hex --output O_App_SD.hex
    
    :: Merge for Bootloader and SoftDevice
    mergehex --merge s140_SD.hex O_Mapped_Bootloader.hex --output O_Boot_SD.hex 
    
    :: Merge for Application , SoftDevice and Bootloader
    mergehex --merge  s140_SD.hex application.hex O_Mapped_Bootloader.hex --output O_Boot_App_SD.hex
    


    then , flash the new hex by jflash. I found it cannot start my application, always reboot in bootloader, 

    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> <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> <debug> app: Enter nrf_bootloader_fw_activate
    00> 
    00> <info> app: No firmware to activate.
    00> 
    00> <debug> app: App is valid
    00> 
    00> <info> nrf_dfu_settings: Settings backup not available from app.
    00> 
    00> <error> app: Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x2000B500
    00> 
    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> <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> <debug> app: Enter nrf_bootloader_fw_activate
    00> 
    00> <info> app: No firmware to activate.
    00> 
    00> <debug> app: App is valid
    00> 
    00> <info> nrf_dfu_settings: Settings backup not available from app.
    00> 
    00> <error> app: Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x2000B500
    00> 
    (Connection lost)

    I just used the ....\examples\dfu\secure_bootloader example as my bootloader.

    so I want to know what I missing to start my application with bootloader ? 

    why it cannnot boot to my application?

  • Hi Edvin , 

    There are more detail for you ,

    <method for generating hex file >

    for Bootloader's hex file ,I using the the example in folder ....\examples\dfu\secure_bootloader\pca10056_ble_debug\ , and complie the hex with key value by IAR.

    then I using the mergeHex tool to get a bootloader_w_setting.hex , which only contain the setting and bootloader

    <method for generating app and Softdevice file >

    Softdevice : copy from SDK folder .....\components\softdevice\s140\hex\ 

    Application parts  : is my development project , which has testing before . it can opeartion with softDevice, but no bootloader here .

    <methodfor programming the Chip>

    I tried to flash the 4 in1 hex (bootloader + bootloader setting + application + SoftDevice)file after merged by JFlash, then  reset and run , it perfromed fail with above debug log, always reboot in bootloader.

    I also tried to use nRF connect Programmer to loading the bootloader_w_setting.hex , softdevice and application to my board. it failed wiht same result as above log.

    please comment my process is anything missing or wrong ,thanks.

Related