mcu-tools / mcuboot

Secure boot for 32-bit Microcontrollers!
Apache License 2.0
1.3k stars 662 forks source link

Serial USB DFU taking too much time #1547

Closed AmruthaRMenon closed 1 year ago

AmruthaRMenon commented 1 year ago

Hi, I am working on nRF Connect SDK V2.0.0 for my project. I am using Mcuboot as my bootloader & I have implemented a usb DFU in Serial Recovery Mode based on DFU Timeout (CONFIG_BOOT_SERIAL_WAIT_FOR_DFU). Currently my app_update.bin file size is around 370kb and its taking around 7 minutes to complete this DFU via USB. Is there any solution to reduce this DFU timing?

Regards, Amrutha

nordicjm commented 1 year ago

Yes - see https://github.com/mcu-tools/mcuboot/pull/1536

You can increase the buffer sizes and then use the mtu option of mcumgr to transfer in larger chunks

AmruthaRMenon commented 1 year ago

Thanks,

I tried increasing the BOOT_SERIAL_MAX_RECEIVE_SIZE. The dfu time was reduced from 7minutes to 2minutes when I increased the BOOT_SERIAL_MAX_RECEIVE_SIZE from 512 to 1024 & mtu to 1024. But when I further increased the buffer size, there don't seem to be any further improvement. My attempt is is to bring the dfu time under 1minute.

nordicjm commented 1 year ago

My attempt is is to bring the dfu time under 1minute.

Probably not going to get that unless you change the UART baud rate

AmruthaRMenon commented 1 year ago

Is UART baud rate relevant if I am attempting USB DFU?

nordicjm commented 1 year ago

Is UART baud rate relevant if I am attempting USB DFU?

No, it should not be. You might need to see if changing mcuboot config (stack/buffer/workqueue sizes, flash write size) helps. A 4KB MTU is optimal for nRF52/nRF53 modules, though this would be 4KB of actual data to write, not 4KB of cbor data

nordicjm commented 1 year ago

I've submitted some fixes to mcuboot and performed some tests with a custom uploading program, with mcuboot in serial recovery mode (USB CDC) I was about to achieve upload speeds of 17.7KiBps, which would require about 21 seconds to upload a 370KiB application.

github-actions[bot] commented 1 year ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.