Speeding up DFU OTA on Linux

Hello,

I am using Linux computer as an update hub for BT device, based on NRF52840. 

The device is set to use Coded PHY, so there is no possibility to use McuMgr - but with Bluez 5.64 and Bleak 0.21.1. The application is compiled using NRF Connect 2.4.2 SDK. 

Negotiated MTU is 495, but some of the capacity is "wasted" by BT headers and SMP message parameters - so I cannot send more than 410 bytes in a first chunk and around 470 in a subsequent ones. I am writing the chunks one by one, without requiring the response - and waiting for a notification to read the next offset. 

Unfortunately, top speed I managed to achieve is 1.4 KB/s - when with Nordic Android app I am easily reaching upload speed of 11.3 kB/s - i.e. 8 times faster. 

What can be improved to speed up the upload?

Thanks,



Parents
  • Hi,

    The device is set to use Coded PHY, so there is no possibility to use McuMgr - but with Bluez 5.64 and Bleak 0.21.1. The application is compiled using NRF Connect 2.4.2 SDK. 

    Do I understand it correctly that you implement your own DFU program using Bluez and Bleak?

    Regards,
    Sigurd Hellesvik

  • Hi,

    Well - kind of. We had an IOT hub, collecting data from and managing sensors. It is written in Python. as all our software -and running on Linux computers located at the remote sites (where sensors are deployed).

    This IOT hub already contained BLE advertisements processing and GATT characteristics read/wrtite/notify functionality - so implementing SMP client on top of it was more or less a matter of adding CBOR library to the project and writing a functions for serialization/deserialization of the SMP payload. And I had NRF Connect Android app - logs of it helped me to see that I am doing the right thing (or not). So I managed to implement the sequential chunk-by-chunk upload, confirmation and reset - so from the fucntional perspective everyhting is ok. 

    Unfortunately - the whole block of image upload in the app doesn't have a detailed logs, neither performance aspect of SMP is documented well in general. I understood that the performance has to do with "SMP reassembly" and three numbers - MTU (which is reported to be 495), SMP buffer size (2475) and number of buffers (4). 

    I have tried to tweak the chunk size, so SMP write command will fit into one packet, MTU or SMP buffer size (latter requires multiple "write" commands in a sequence, as BlueZ cannot write more than MTU). At 2475 bytes - It takes to a device 400-500 ms to respond with the notiifcaton (confirm the new offset), so I can proceed with the next chunk. With any combination - the speed hardly goes above 2 kB/s, when with Android application it is quite stable on 11.3 kB/s.

    Could you advise regarding the algorithm - how to divide the image into a SMP commands/BLE packets so the reassembly will be at least as effective as with the mobile app as a client?

    Thanks!

  • The nRF Device Manager code is public for both android and iOS.
    This implements FOTA, so we can have a look at what that does to be so fast.

    From the android one, Maximum SMP packet length seems to enable longer packets than the MTU, which probably speeds this up. But if BlueZ does not support that, that is not possible I guess.

    here is also something mentioning file transfer speeds.
    Also here.
    Well, you get the jist, Im just reading the comments from that file.

    That is all I can find on this, but I will ask a colleague who is more experienced with BLE to see if they have any suggestions.

Reply Children
Related