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

Document regarding DFUMaster_UART to do a serial firmware upgrade.

To do a serial DFU I have followed the steps provided in the DFUMaster_UART link.

1) Generated the key using the NrfUtil.

2) Added the private.key and generated a DFU package using the NrfUtil tool.

3) Added the public.key to the secure_bootloader_uart example and build it.

4) Flashed the Softdevice and the above-builded bootloader to one nrf52840 DK.

5) Extracted the DFU package generated in step 2, got three files:

    - app_xyz .bat

    - app_xyz .bin

    - manifest.json

6) Tried building in the DFUMaster_UART with the SDK v15.2 as it was giving some errors, tried building it with the SDKv14.2 it was successful.

7) Flashed DFUMaster_UART in one nrf52832 DK as the example available was for the PCA10040.

8) Flashed the extracted app_xyz.bat to 0x9000 location as in the DFUMaster code it was reading this location for the init packet.

9) Flashed the extracted app_xyz.bin to 0x30000 location as in the DFUMaster code it was reading this location for the image to be sent to DFU_Target(nrf52840).

10) Now Bootloader code was successfully able to parse the init package and validated it. But, as the DFUMaster Starts sending the FW Image the bootloader code resets after receiving the two packets and writing in to flash.

Debugged that by putting the breakpoint, got to know that as the bootloader tries to write the third packet in the flash it stuck in the wait_for_flash_ready().

Please correct me if any of the above steps are incorrect, so that I can successfully complete the DFU.

  • Ya bootloader is from SDK15.2.0 and I have compiled the DFUMaster using SDK14.2.0.

    And I will try with the HWFC enabled.

    Thanks

  • Hi Edvin,

    Thanks!

    It worked with HWFC enabled.

    But I need the DFUMaster which works with the HWFC disabled.

    Also, I have verified that the NrfUtil is working with the HWFC disabled.

    I tried decreasing the baud-rate(9600) and put the delay(1sec) in between the sending of packets, but it didn't worked.

    So can you guide me on the changes needed to be done in the current DFUMaster so that it works with the HWFC disabled or if you have a DFUMaster which works without the HWFC that will be great?

    Also, I can see "Todo: instead of using delay response code checking should be done here." in the uart_event_handler. So is this the point where we have to handle the response from the DFUTarget to make it work with the HWFC disabled?

  • Attaching the logs of Bootloader when it fails after 4096bytes of the chunk.

     WRITE_ADDR = 159512 s_dfu_settings.write_offset = 3864
    
    Flash write success
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 20003810
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x26F18, src=0x20003790, len=92 bytes), queue usage: 1
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    Handle NRF_DFU_OP_OBJECT_WRITE (data)
    
     WRITE_ADDR = 159604 s_dfu_settings.write_offset = 3956
    
    Flash write success
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 2000378C
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x26F74, src=0x20003814, len=92 bytes), queue usage: 1
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    Handle NRF_DFU_OP_OBJECT_WRITE (data)
    
     WRITE_ADDR = 159696 s_dfu_settings.write_offset = 4048
    
    Flash write success
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 20003810
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x26FD0, src=0x20003790, len=48 bytes), queue usage: 1
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 20003810
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (data)
    <debug> nrf_dfu_req_handler: Offset:4096, CRC:0x5E4A6474
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_serial: Sending Response: [0x3, 0x1]
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 20003810
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (data)
    <debug> nrf_dfu_serial: Sending Response: [0x4, 0x1]
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> app: timer_stop (0x20000024)
    <debug> app: timer_activate (0x20000024)
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 20003810
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data)
    <error> app: Received an error: 0x00000001!

    So increased the delay to 5secs after every 4096chunk. so now it is working.

    Can you guide me what are the changes need to make it work properly?

  • Ok. So Please see the section on "Set receipt notification". If you set this it will calculate the CRC after every PWN is reached. Have you tried to wait until you receive this CRC calculation before you send the next chunk?

Related