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

TFTP DFU Block Size

I try to integrate the CoAP Server and TFTP DFU example code, and it works well.

[ENV]

  • IoT SDK v0.9.0
  • nRF52832 DK

According to the specification, the MTU of L2CAP is 1280 bytes.

The default APP_TFTP_BLOCK_SIZE in the TFTP DFU example code is 512 bytes.

When I try to increase it to 1024 bytes, it didn't work.

I try to look the LOG and find it works well before starting to receive the image file.

it will trigger STATE_RECV_COMPLETE state just after sending block 0 of 55 ACK instead of calling iot_tftp_resume() and receive next block of data.

the LOG shows below:

[TFTP]: Set value: /dfu/app/iot_app_dfu_prox.bin.
[TFTP]: Set value: octet.
[TFTP]: Set option: tsize with value: 0.
[TFTP]: Set option: timeout with value: 3.
[TFTP]: << iot_tftp_get
[TFTP]: << client_process
[TFTP]: >> client_process
[TFTP]: Received OACK.
[TFTP]: Negotiate options:
[FILE][PSTORAGE][C]VERIFY MODULE INITIALIZED()
[FILE][PSTORAGE][C]check module param
[FILE][PSTORAGE][C]check block id
[FILE][PSTORAGE][C]check module_param_cb
[TFTP]:    TSIZE:   57012
[TFTP]:    TIMEOUT: 3
[TFTP]:    BLKSIZE: 1024
[TFTP]: Create ACK packet.
[TFTP]: Send packet.
[TFTP]: Send packet to UDP module.
[TFTP]:     Recv code: 00000000.
[TFTP]: << client_process
[TFTP]: >> client_process
[TFTP]: Received DATA.
[TFTP]: Received next DATA (n+1).
[TFTP]: Create ACK packet.
[TFTP]: Send block    0 of 55 ACK.
[TFTP]: << client_process
[TFTP]: >> iot_tftp_resume
[TFTP]: Send packet.
[TFTP]: Send packet to UDP module.
[TFTP]:     Recv code: 00000000.
[TFTP]: Complete due to STATE_RECV_COMPLETE state.
[TFTP]: Raise TRANSFER COMPLETE event.
[TFTP]: Reset instance 0.
[APPL]: In TFTP Application Handler.
[APPL]: TFTP transfer complete - size 57012.
[APPL]: New firmware file successfully downloaded.
[IOT_DFU]: >> iot_dfu_firmware_validate
[IOT_DFU]: Application CRC mismatch.
[IOT_DFU]: CRC in device is 64028.
[IOT_DFU]: << iot_dfu_firmware_validate
[** ASSERT **]: Error 0x0000000B, Line 0, File

but decrease the APP_TFTP_BLOCK_SIZE works well.

I have no idea how to solve it, did I miss anything? what is the limitation of APP_TFTP_BLOCK_SIZE?

Sincerely, Thank you.

  • yes, it still works with APP_TFTP_BLOCK_SIZE = 512.

    I have added those 2 definition, and my tftp configuration is :

    TFTP_USERNAME="pi"
    TFTP_DIRECTORY="/srv/tftp"
    TFTP_ADDRESS="[::]:69"
    TFTP_OPTIONS="-s -l -6 -c --blocksize 1024"
    

    I also tried to use the example tftp_dfu from SDK, but it did not work too. The LOG looks the same with my application.

  • Can you please post some wireshark sniffer logs? Start wireshark on the bt0 interface. Then we can see if the nRF side or the PC side rejects the blocksize.

    If the purpose of increasing the block size is to increase the speed, you should consider lowering the connection interval to 7.5ms. You can do this by writing:

    echo 7.5 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
    echo 7.5 > /sys/kernel/debug/bluetooth/hci0/conn_max_interval
    
Related