Reduce FOTA download speed

Hello!

I have implemented AES128 FW decryption in the FOTA app. Unfortunately the device sometimes is not able to decrypt incoming data fast enough and the FOTA app errors out here:

            if (size + msg_p->rx_len -
                image_download.prog_len > sizeof(msg_p->body_a))
            {
                ImageDownloadResp(IMAGE_DNL_INTERNAL_FAILURE);
                return false;
            }

I have have tried to adjust the following BLE parameters:

GAPM_DEFAULT_MTU_MAX
GAPM_DEFAULT_MPS_MAX
GAPM_DEFAULT_CON_INTV_MIN
GAPM_DEFAULT_CON_INTV_MAX
GAPM_DEFAULT_CON_LATENCY

Some phones (mainly android) do not respect the values and still send the FOTA image at max possible speed (11-14 KB/s).

How can I (reliably) reduce the maximum data transfer speed? I see that HDLC is used for transport layer (why?) in the fota app, is it possible to add some kind of backpressure mechanism there? I have tried returning false to HDLC calls (sets own_receiver_busy), but then phone app immediately aborts.

I do not want to modify the sample Android and iOS apps if possible.

@gotlaufs

Please start with check what system clock frequency is being set, as this can provide much more time for the AES processing to be completed for each packet. Are you using RLS10 or RLS15?
For example on the RSL15 the blinky_FOTA sample sets the system clock to 8MHz. That could be increased if the addition of encryption needs more compute cycles.

If the system clock can not be increased any further, then there are likely not other options that do not involve changing the Central side of the FOTA code. During a FOTA update, the Central device is the master of the link and will timeout if the update packet is not responded to in time. There is no way to circumvent this without 1. Responding to the Central packet on time or 2. Changing the Central device firmware to wait longer or until a response is received.

Thank you for using our community forum!

1 Like

Hello,

Increasing the CPU frequency from the default 8 MHz to 24 Mhz solved my problem, thanks!

I still don’t understand, why there is the HDLC layer between BLE and custom command protocol (where exatly one command is defined … )?

2 Likes

@gotlaufs

I still don’t understand, why there is the HDLC layer between BLE and custom command protocol (where exatly one command is defined … )?

It is included to provide some sort of flow control between the Central and Peripheral during the exchange of the FOTA update. That is, HDLC provides a relatively simple means of executing a Send/Acknowledge message framework to ensure the update is received properly as each chunk of data is communicated.

Thank you for using our community forum!