Hi, I've tried to implement in my project the OTA DFU based on the dfu buttonless example using the secure bootloader.
I used this guide to realize it: https://devzone.nordicsemi.com/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader
Everything works fine but if I modify the application and try to load and consequently to debug it (with keil) the bootloader does not reconize it somehow as a valid version and to test it i'm forced to upload if via the OTA DFU.
This obviously is a problem for the debugging of the code.
Analysing the bootloader I noticed that in the function nrf_dfu_app_is_valid() there is a function that check the CRC of the code. Being different the code I update with the OTA DFU and the one (even strictly different) i want to debut the bootloader goed in DfuTarg.
Modifying the function if the following way:
bool nrf_dfu_app_is_valid(bool do_crc) { NRF_LOG_DEBUG("Enter nrf_dfu_app_is_valid"); if (s_dfu_settings.bank_0.bank_code != NRF_DFU_BANK_VALID_APP) { // Bank 0 has no valid app. Nothing to boot NRF_LOG_DEBUG("Return false in valid app check"); return false; } // If CRC == 0, the CRC check is skipped. if (do_crc && (s_dfu_settings.bank_0.image_crc != 0)) { uint32_t crc = crc32_compute((uint8_t*) nrf_dfu_app_start_address(), s_dfu_settings.bank_0.image_size, NULL); if (crc != s_dfu_settings.bank_0.image_crc) { // CRC does not match with what is stored. NRF_LOG_DEBUG("Return false in CRC"); //return false; // I return true instead of false return true; } } NRF_LOG_DEBUG("Return true. App was valid"); return true; }
in this way I'm able to debug properly the app but I don't feel is a nice thing to do, I'd like to know if there is a better way to debug the app with the dfu or if i'm oding something wrong.
thanks
Fabiano