OFF CHIP OTA UPDATE using external flash

I am working on this project off chip ota update on nRF5_SDK  using ecample/thread/dfu

by now, i have done changes in these functions on_data_obj_create_request() and on_data_obj_write_request(). initially these functions were erasing and writing data in internal flash which I changed to qspi functions like nrf_drv_qspi_erase() and nrf_drv_qspi_write(). and it works perfectly.

Later i changed functions for hash verification which is also working but i am not sure about what should be the next step so that bootloader changes the earlier application with the new firmware image.

  • You can use regex or a text processing tool like 'awk' to filter out the address column from the output.

    Example of using regex in Vs code:

  • hey I tried all possible commands to read external qspi flash, but as I am using custom board none of them worked. 

    so i tried another way. even though crc calculation fails, i jumped to start the app directly buy changing the code in nrf_bootloader_init() function and my dfu is complete after this.

    return NRF_ERROR_INTERNAL; // Should not reach this.

    case ACTIVATION_ERROR:
    default:
    return NRF_ERROR_INTERNAL;
    }

    if (dfu_enter)
    {
    nrf_bootloader_app_start();
    nrf_bootloader_wdt_init();
    scheduler_init();
    dfu_enter_flags_clear();

    // Call user-defined init function if implemented
    ret_val = nrf_dfu_init_user();
    if (ret_val != NRF_SUCCESS)
    {
    return NRF_ERROR_INTERNAL;
    }

    nrf_bootloader_dfu_inactivity_timer_restart(initial_timeout, inactivity_timeout);

    in above juggad code nrf_bootloader_app_start(); function is used to start the app code. and it works and my app version 2 is working perfectlly.

    my device sends Payloads on server and on the server i can see the update and ota version as well.

    in this payload you can see at the last 2 is wrrten which represents the app version.

    and in another payload ota done message is visible.

    and also in j link it is visible 

    even this ota is done but still why that crc calculation fails? and if let this run then without crc verification this ota process is just like the single bank dfu process. 

    so please help me in this crc calculation

  • I would still like you to verify that the updated binary stored in the bank 0 matches the binary you uploaded through DFU. Since you are not able to read data from your external flash, you can program the hex file of your new application to the device, then read out the memory. Then, repeat the same steps but when loading the image through DFU and not via the debug interface.

    If the images are identical, then that suggests that the CRC computed by the application and the one computed by the bootloader were not computed over the same area.

  • I simply flashed the same application twice using j link(not dfu) by following all the steps .

    and still there is difference in both hex files.


    dnk124 ~ nrfjprog --memrd 0x0 --n 1048576 > flash_on_board.hex
    dnk124 ~ nrfjprog --memrd 0x0 --n 1048576 > flash_on_board2.hex
    dnk124 ~ cmp flash_on_board.hex flash_on_board2.hex
    flash_on_board.hex flash_on_board2.hex differ: byte 1762439, line 25543
    dnk124 ~ 1 diff flash_on_board.hex flash_on_board2.hex
    25543,25544c25543,25544
    < 0x00063C60: 20206365 30322037 31203332 39313A38 |ec 7 2023 18:19|
    < 0x00063C70: 0038323A 6F727245 6E692072 61687320 |:28.Error in sha|
    ---
    > 0x00063C60: 20206365 30322037 31203332 33323A38 |ec 7 2023 18:23|
    > 0x00063C70: 0035353A 6F727245 6E692072 61687320 |:55.Error in sha|
    60938,60943c60938,60943
    < 0x000EE090: FFFF0026 C4320402 00000000 000003EA |&.....2.........|
    < 0x000EE0A0: 000003EB 0504C84E 147D016A 2D24DB7D |....N...j.}.}.$-|
    < 0x000EE0B0: 7A2DC0CC DC4F0076 0AB10002 FFF40007 |..-zv.O.........|
    < 0x000EE0C0: FFFF0020 3D33E0D3 C5638CC0 E76FBB73 | .....3=..c.s.o.|
    < 0x000EE0D0: 8D48228A 5967488E D7E90C97 8F3891A9 |."H..HgY......8.|
    < 0x000EE0E0: 3F784A25 FFFFFFFF FFFFFFFF FFFFFFFF |%Jx?............|
    ---
    > 0x000EE090: FFFF0026 C4330402 00000000 000003EA |&.....3.........|
    > 0x000EE0A0: 000003EB 0504C84E E9DEB6BA AEDF0E4C |....N.......L...|
    > 0x000EE0B0: 8B4A8FCE 8EEED222 0AB10002 FFF40007 |..J."...........|
    > 0x000EE0C0: FFFF0020 787E306D 482D2AD0 06EE9446 | ...m0~x.*-HF...|
    > 0x000EE0D0: 062B3A5A 0069BE23 1EA55933 1806B761 |Z:+.#.i.3Y..a...|
    > 0x000EE0E0: 56F8A127 FFFFFFFF FFFFFFFF FFFFFFFF |'..V............|
    65025,65026c65025,65026
    < 0x000FE000: 1341AA60 00000002 00000001 00000001 |`.A.............|
    < 0x000FE010: 00000000 00000000 00064F38 895C458F |........8O...E\.|
    ---
    > 0x000FE000: AD7C8D5D 00000002 00000001 00000001 |].|.............|
    > 0x000FE010: 00000000 00000000 00064F38 C9CBBF5C |........8O..\...|
    65062c65062
    < 0x000FE250: 00000000 00000000 00000000 37CD1E9A |...............7|
    ---
    > 0x000FE250: 00000000 00000000 00000000 151DE479 |............y...|
    65067c65067
    < 0x000FE2A0: 458F0100 0000895C 00000000 00000000 |...E\...........|
    ---
    > 0x000FE2A0: BF5C0100 0000C9CB 00000000 00000000 |..\.............|
    65281,65282c65281,65282
    < 0x000FF000: 1341AA60 00000002 00000001 00000001 |`.A.............|
    < 0x000FF010: 00000000 00000000 00064F38 895C458F |........8O...E\.|
    ---
    > 0x000FF000: AD7C8D5D 00000002 00000001 00000001 |].|.............|
    > 0x000FF010: 00000000 00000000 00064F38 C9CBBF5C |........8O..\...|
    65318c65318
    < 0x000FF250: 00000000 00000000 00000000 37CD1E9A |...............7|
    ---
    > 0x000FF250: 00000000 00000000 00000000 151DE479 |............y...|
    65323c65323
    < 0x000FF2A0: 458F0100 0000895C 00000000 00000000 |...E\...........|
    ---
    > 0x000FF2A0: BF5C0100 0000C9CB 00000000 00000000 |..\.............|
    dnk124 ~ 1

  • Priyesh Shahi said:
    < 0x00063C60: 20206365 30322037 31203332 39313A38 |ec 7 2023 18:19|
    < 0x00063C70: 0038323A 6F727245 6E692072 61687320 |:28.Error in sha|
    ---
    > 0x00063C60: 20206365 30322037 31203332 33323A38 |ec 7 2023 18:23|
    > 0x00063C70: 0035353A 6F727245 6E692072 61687320 |:55.Error in sha|

    I see there's a timestamp here. I guess it might be showing when the firmware was built? Regardless, you need to ensure you are programming the same hex file ever time. The DFU image must also be from the same build.

Related