Hi,
I'm working with an NRF52 Dev Kit and we want to implement OTA DFU using BLE as we have in a previous project. All our projects are worked on in Segger Embedded Studio. Recently we migrated from Nordic SDK 14.2.0 to SDK 15.3.0 and soft device 132 5.0.0 to sd 132 6.1.1 and so far everything is working well. I've searched around the Infocenter and Devzone and right now am able to make DFU .zip files from my own projects (made from modified ble_blinky) with my own private key using the nrfutil command line tool. The most helpful resources in getting this for me have been this blog post and this github readme.
Ultimately my goal will be to create projects to upload to any future devices using OTA DFU that implement a WDT in case of a hardfault, infinite loop, etc. occurring in an application. Having had a few devices stop working after completely closing them up in an enclosure with no access from the outside has made this a priority.
I've modified the "sdk_config.h" of a copy of the "secure_bootloader" example project as well as the source file "nrf_bootloader.c" thus far to try and include functionality for detecting a reset caused by a WDT. My assumption would be that if the device is reset from the WDT that the uploaded application likely has an error in it and I enter DFU mode from there instead of just jumping back into the same application.
In "sdk_config.h" the file originally includes:
I have now also included:
In "nrf_bootloader.c" there is already a function for checking if the device should enter DFU mode:
I have also added these lines to the above function:
I tried this method because I had already previously tested reading the register "NRF_POWER->RESETREAS" and checking the appropriate bit masks to detect why the device was reset before. The result of this is that the device does enter DFU mode after resetting from a timed out WDT and from there I am able to upload a new application successfully to it. Where I'm running into problems is I believe I need to also include somewhere in the source code for DFU a reset of the WDT bit in the "NRF_POWER->RESETREAS" register. When the device in DFU mode times out or when the application such as the buttonless DFU example project perform a software reset this register is not overwritten and the device will simply detect the same bit has been raised and reenter DFU mode over and over. Currently, if the device is reset by the WDT and a new application is uploaded to it the device will continuously reset and reenter DFU mode. I need to be able to have a device enter DFU mode if the application creates a WDT reset, upload a new application to the device, and have the device immediately run that new application like normal without needing to power cycle it (which does skip past DFU mode and cause the new application to run just fine).
A few other questions I had that hopefully can be answered more quickly.
1.) I'm still new to some of the changes from jumping between SDK 14.2.0 and SDK 15.3.0, some files I'm familiar with have been dubbed legacy and new ones with the "nrfx" prefix seem to be in their place. Will modifying the files as I've done potentially ruin any other example projects and/ or functionality for using OTA DFU bootloaders in the future? I've only recently delved into the "NRF_POWER->RESETREAS" register use and I'm still not completely sure what every part of it is used for and what registers are or aren't stored during what types of resets.
2.) What registers are or aren't stored during what types of resets? I've read the "GPREGRET" register has been used in the past for entering DFU mode from an application but there seems to be a newer way that doesn't include any reset I'm unfamiliar with. Is there a downside to using the reset reason register how I am?
3.) Originally I tried implementing a WDT directly in my copy of the secure bootloader project and I could not manage to get it working. No matter what preprocessor user included directories I created and what files I linked the error always said it could not find either "nrfx_clock.h" or "nrfx_wdt.h". Is there a different manner of including these files new to SDK 15.3.0 and/ or does the bootloader have extra requirements to include files? I managed to modify a copy of the ble blinky example project to run a WDT successfully before; I started a 10 second WDT and didn't feed it to ensure the device was actually entering DFU mode after a WDT reset.
Thanks,
Andy