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

nRF5 DFU over serial

We are implementing a DFU controller to perform DFU over serial for the nRF52832.

Our reference is the nRF5 SDK v15.3.0 DFU Serial documentation (Nordic/SDK/nRF_SDK_15.3.0_docs/nrf5/lib_dfu_transport_serial.html).

The documentation has a message sequence chart that describes Transfer of an Init Packet, and Transfer of a firmware Image.

I'm find the description regarding transfer of a firmware image a bit ambiguous. It says the firmware image is split up into several data objects that are transferred consecutively.  For example if the image is 10k and the maximum object size is 4k, then 3 data objects must be transferred.   Presumably two 4k objects followed by a 2k object.

1) Is the Select command required at the start of each data object, or just once when the firmware image transfer is started?

2) Is the execute command sent at the end of each data object, or just once at the end of the entire firmware image transfer?

2) Once all the data has been transferred (3 data objects in the example) is it necessary to do one more Select command immediately followed by an execute command?

3) At what point does the boot-loader know the entire image has been downloaded and start the application.  Does it attempt to do this on every execute command?

In our case we have found the Select response returns a maximum object size of 4096 bytes.  Our firmware image is not a multiple of 4096 bytes, so I my difficulty is understanding what happens when the last data object, which is less than the maximum object size,  is transferred.

Parents
  • Furthermore after some trial and error, I found I couldn't send a CREATE data object command with a size less than the max_size returned by the SELECT data object command.

    For example SELECT data object returns max_size 0x1000 (4096)

    If the firmware image size is 0x3200, this requires 3 data objects of 0x1000 and 1 data object of 0x200

    When command CREATE data object of size 0x1000,  [01 02 00 10 00 00] is sent the response is [01] success. After that the data object is sent Ok and the EXECUTE command also returns success.

    When sending the last 512 bytes the command CREATE data object of size 0x0200, [01 02 00 02 00 00] , returns status code [03] NRF_DFU_RES_CODE_INVALID_PARAMETER..  Then it doesn't accept any write commands.

    It seems the only size that is valid for the Create Data Object command is the max_size returned by the Select data object request.

    How do we send the last data block of 512 bytes in this example?

Reply
  • Furthermore after some trial and error, I found I couldn't send a CREATE data object command with a size less than the max_size returned by the SELECT data object command.

    For example SELECT data object returns max_size 0x1000 (4096)

    If the firmware image size is 0x3200, this requires 3 data objects of 0x1000 and 1 data object of 0x200

    When command CREATE data object of size 0x1000,  [01 02 00 10 00 00] is sent the response is [01] success. After that the data object is sent Ok and the EXECUTE command also returns success.

    When sending the last 512 bytes the command CREATE data object of size 0x0200, [01 02 00 02 00 00] , returns status code [03] NRF_DFU_RES_CODE_INVALID_PARAMETER..  Then it doesn't accept any write commands.

    It seems the only size that is valid for the Create Data Object command is the max_size returned by the Select data object request.

    How do we send the last data block of 512 bytes in this example?

Children
No Data
Related