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

DFU SDK13. Problems with update. Starnge behavior.

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?

  • For berret understand problem, I type real code:

     volatile PASSKEY_CONTEXT pass __attribute__((section(".ARM.__at_0x72500"))) =
    {
    	.passkey_length 			= 6, 	.passkey 				= "123456", 
    };

    But in the .hex I get:

    :102500000631323334353600000000000000000090
    :10251000011022011A4002B11BFFFF1401619461F6
    :102520008A028B893D0C012E0C10181818122901F3
    :10253000014E1220027540C490D00314E1360223EC
    :0425400003FF000095
    :040000050001F20103
    :00000001FF

    What the final lines? Suppose, this is part of firmware.

Related