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

Run a function after successful DFU

I've looked through the Devzone, but couldn't find an answer to my question.

We are looking to automate the OTA process. When our nRF52 device is charging, it advertises as being ready for DFU. We can then connect to the device with an Android phone and perform the application update with a zip package.

Since the device is still on the charger after the update is finished, it starts advertising again as if it's ready for DFU. Therefore I'd like to run a function at this point, so I can stop the advertising, and give a LED indication that the DFU is finished.

My question is, where to add a function that runs after the DFU is finished? Another approach with the same result is also fine of course.

Thanks in advance!

Parents
  • Hi koos, assuming that you're using the bootloader from our SDK, then the nRF52 will perform a soft-reset after a successful DFU, see on_dfu_complete() in dfu_req_handling.c.

    My suggestion would be to write a specific value to the GPREGRET register just before the NVIC_SystemReset() call. Upon entering the bootloader or later the application(depending on where you're advertising that the device is ready for DFU) you can check the value of this register. If the register matches the value that indicates that a successful DFU was completed and you're charging, then you stop advertising.

    Best regards

    Bjørn

Reply
  • Hi koos, assuming that you're using the bootloader from our SDK, then the nRF52 will perform a soft-reset after a successful DFU, see on_dfu_complete() in dfu_req_handling.c.

    My suggestion would be to write a specific value to the GPREGRET register just before the NVIC_SystemReset() call. Upon entering the bootloader or later the application(depending on where you're advertising that the device is ready for DFU) you can check the value of this register. If the register matches the value that indicates that a successful DFU was completed and you're charging, then you stop advertising.

    Best regards

    Bjørn

Children
Related