I implemented DFU secure ble. And implemented encryption. But now I remarked strange behavior. If make same DFU packet (.zip) and flah nRF52 than update firmware for same packet DFU- all OK. If flash nrf52 one firmware and than make small changes in the project and make DFU and update it- all OK. But if I make in project to many changes (compile same project from one optimization (-0) to 3nd optimization, for example) and than flash via DFU- project doesn't works. Project starts with new firmware and always has reboot.
As recommended I made next changes:
in a file dfu_req_handles.c
insert to line 589
case DFU_FW_TYPE_APPLICATION: p_bank->image_crc = crc32_compute((uint8_t *)MAIN_APPLICATION_START_ADDR, m_firmware_size_req, NULL);
line 637 just comment:
#endif // Calculate CRC32 for image // p_bank->image_crc = s_dfu_settings.progress.firmware_image_crc; // az comment p_bank->image_size = m_firmware_size_req;
and between 1004 -1005 and 1044-1045 I insert block for decrypt image:
for (int i = 0; i < m_data_buf_pos; i+=16) { AES128_ECB_decrypt (&m_data_buf[m_current_data_buffer][i], key, &m_data_buf[m_current_data_buffer][i]); }
at this changes I received wrong CRC in a file components/libraries/bootloader/dfu/nrf_dfu_utils.c
I just made changes in line 165;
s_dfu_settings.bank_1.image_crc = crc;
therefore I just ignore if CRC was wrong, but didn't decide real problem.
How to correct make changes for normal work DFU with encryped image?