Hello,
I have made some modifications to the OTA DFU bootloader provided by nordic and would like to some advice. I went down this design path before nordic released the buttonless DFU that added a service to the application in order to transfer from application to bootloader w/ out reconnect and discovery. I would like an experts opinion on the impact of not updating to that design flow.
In short this is what I did.
-
When the application wants to go into bootloader mode it sets NRF_POWER->GPREGRET to BOOTLOADER_DFU_START then does a soft reset. Hence, bond information is not passed.
-
At this point i needed to make a slight modification to the bootloader. I made the bootloader always reinitialize the stack upon reset.
if (bootloader_dfu_sd_in_progress()) { //nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);
err_code = bootloader_dfu_sd_update_continue(); APP_ERROR_CHECK(err_code); ble_stack_init(!app_reset); scheduler_init(); err_code = bootloader_dfu_sd_update_finalize(); APP_ERROR_CHECK(err_code); //nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
} else { // If stack is present then continue initialization of bootloader. ble_stack_init(0x01); // *changed here to make it always reint scheduler_init(); }
-
I added a watchdog into the bootloader because my application has the watchdog running and a soft reset doesn't stop the watchdog. I feed the watchdog in the bootloader.c line 80. I initialize it in the main of the bootloader.
In this way once the app goes into bootloader mode the device must be rediscovered by the central. Of course bond information is not shared.
What is the benefit to sharing and using the bond information? The bootloader appears to have a different device_id then the normal application so I think it is fine to the central to rediscover it and communicate without an active bond.
At the time when I implemented this it seemed a simple solution, but sense then it seems nordic has devised a different plan where the application to seemlessly jump to the bootloader passing all bond information and making a reint of the softdevice unnecessary.
Issues I have noticed: I am not able to do a full OTA DFU update in many cases. It seems to work intermittently. What I usually do is update the bootloader&sd (in zip format) in one DFU connection. Then rediscover and update the application (in zip format). Putting all 3 in one zip doesn't seem to work well.
Questions I have:
-
Is the issue I am noticing expected?
-
Is it necessary to transfer over to the new way? Should I change?
-
How would I go about passing information from the bootloader to the application? The bootloader holds its software version number and I would like to pass that information to the application. In the past I was using the UICR to hold the bootloader version number which the application could freely access (programmed at flash). However, when updating the bootloader OTA the UICR is not updated and hence the version number is not changed. What I would like to do is make a static const in the bootloader projects which holds the version number. Once the application boots it is able to access the version number using a shared memory address. Any ideas? Anything easier than PSTORAGE. I'd hate to add an entire block for one version number