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

beacon and firmware update example

Hi, 

I am new to Nordic BLE development and trying to create an application that has beacon functionality with firmware upgrade over the BLE with the mobile phone and Nordic DFU app. I have tried ble_app_beacon and it works quite nice, but I would like to add a firmware upgrade feature. Firmware upgrade would be triggered on the device by a button or something similar. 

So my question: Is there an example that already has this kind of features so I can take it as a starting point, and if there is no such example what do you suggest to begin with? Is the best starting point the beacon example?

Thank you.

Best regards,
Voja

Parents Reply Children
  • Hi Voja,

    Ok, you don't need to add a lot of code to the main app to make the button put the device in DFU mode. GPREGRET is a general-purpose retention register which you can use to signal the bootloader to enter DFU mode on subsequent boot. Just remember to use the Softdevice API sd_power_gpregret_set() if you're accessing the register while the Softdevice enabled because the SD sandboxes the POWER peripheral.

    //Code in main app to reset into Bootloader DFU
    
    /*
    
    BOOTLOADER_DFU_START == 0xB1. Bootloader enters dfu mode if retention register has this value on boot.
    
    */
    
    sd_power_gpregret(0, BOOTLOADER_DFU_START);
    
    /*Perform a soft reset to start the bootloader */
    
    NVIC_SystemReset();

    Best regards,

    Vidar

    Edit: On second thought: it's even easier to assign the pin to the "NRF_BL_DFU_ENTER_METHOD_BUTTON" in the bootloader. So the same pin is used to trigger a Soft reset in the app is read by the bootloader on startup. It can be a good idea to make app logic so that the pin requires a long press, etc to prevent unintended resets.

  • Hi Vidar,

    Thank you. This is realy good. And as I understand, if I can power cycle a device then I do not need to do much with beacon example, because the MCU will go to DFU state after the power cycle. 
    Also, do you think NrF52810 has enough memory for DFU functionality?

  • Yes, if you use 'NRF_BL_DFU_ENTER_METHOD_BUTTON' you can just power-cycle the board while you keep the button pressed. It should not be a problem to support DFU since you are making a Beacon app. The size limit for your app will be defined by the App start address minus the start address of the bootloader.

Related