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
  • Hi Voja,

    The beacon example should be a good starting point for making a non-connectable beacon. For DFU, I'd recommend starting with this blog post: https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader to get an overview of our solution.

    Note that you don't need to integrate anything DFU related in the app if the button is used for pin reset. In that case, you can compile the bootloader with the NRF_BL_DFU_ENTER_METHOD_PINRESET option set to '1' in sdk_config and the bootloader will enter DFU mode every time the device is reset through a pin reset. The bootloader will then stay in DFU mode for 2 minutes (default) before booting the beacon app.

    Best regards,

    Vidar

  • Hi Vidar,

    Thank you for your answer. I can not have one more button for the reset pin, so I suppose I need to integrate DFU related stuff. Do you think that nRF52810 could fit all this in the memory? As I said I need a beacon and DFU functionality. It is ok with me if only application firmware is upgradeable. 

    Best regards,
    Voja.

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

Reply Children
Related