Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritizing DFU speed in settings #467

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Conversation

philips77
Copy link
Member

This PR modifies the default DFU parameters:

  • Sets "Prepare Data Object Delay" to 0 ms (from 400 ms)
  • Enables MTU request (was disabled by default)

The goal is to make the DFU faster (reach ~ 9kB/s) on most moden devices.


What are those settings?

  1. In Secure DFU the firmware is sent in chunks (4096 bytes each). Each chunk is validated (Calculate CRC) and executed after sending. Executing it saves teh received data in permanent storage on the device. Some implementations of DFU bootloader notify readiness after executing too soon, before the data is actually saved. Prepare Data Object delay is a special delay added after receiving Execute response to give the device some time to finish flash operation. I don't think it's needed with nRF5 SDK 17.1.
    Read more here:

    /**
    * This method sets the duration of a delay, that the service will wait before sending each
    * data object in Secure DFU. The delay will be done after a data object is created, and before
    * any data byte is sent. The default value is 0, which disables this feature.
    * <p>
    * It has been found, that a delay of at least 300ms reduces the risk of packet lose (the
    * bootloader needs some time to prepare flash memory) on DFU bootloader from SDK 15 and 16.
    * The delay does not have to be longer than 400 ms, as according to performed tests, such delay
    * is sufficient.
    * <p>
    * The longer the delay, the more time DFU will take to complete (delay will be repeated for
    * each data object (4096 bytes)). However, with too small delay a packet lose may occur,
    * causing the service to enable PRN and set them to 1 making DFU process very, very slow
    * (but reliable).
    *
    * @param delay the initial delay that the service will wait before sending each data object.
    * @since 1.10
    * @return the builder
    */
    public DfuServiceInitiator setPrepareDataObjectDelay(final long delay) {
    this.dataObjectDelay = delay;
    return this;
    }

  2. Secure DFU from nRF5 SDK 15+ supports MTU (Maximum Transfer Unit) higher than default (23 bytes). With higher MTU more data can be sent in a unit of time. However, some devices, like Samsung Tab A8 and perhaps other with the same hardware claim support for it, but in fact they have a bug preventing use of it. The library will automatically disable MTU for devices with Build.HARDWARE set to ums512_25c10 (see Disabling MTU request on Samsung Tab A8 #408), but perhaps there are other devices with similar problem. If you get error 133 just after sending the upload, try disabling MTU request in app's Settings.

@philips77 philips77 merged commit 8be2dab into main Oct 22, 2024
1 check passed
@philips77 philips77 deleted the settings/prioritize-speed branch October 22, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant