Fix: Declare smaller timeouts in F1 DFU to speed up probe upgrades #1718
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Detailed description
This commit from July 2023 resulted from a deeper look into
dfu-util
operation (and partiallybmputil
) and BMPBootloader DFU internals (usbdfu, dfucore, dfu_f1). Armed with some DFU operation specs and MCU datasheets for STM32F103CB and GD32F103xx, I added a bit of instrumentation (blinky on dfu_event) toswlink
and tried to reduce the timings.The logic is similar to
dfu_f4.c
in that there should be two different timeouts for page erase (1 KiB on F1) and buffer program (1024 because ofwTransferSize
over EP0) calculated from typical or minimum characteristic times (but not maximum). Making the host wait less then come knocking with 1ms polls is safe; and faster than making it wait "for sure long enough". Why that is so -- may need additional argumentation.Tested on WeAct Studio BluePillPlus boards containing STM32F103CB and GD32F103CB with no regressions (the payload is then manually verified over SWD to match by qCRC) and with a measurable speedup, helpful for both developers often upgrading to daily builds, and for end-users waiting up on the yearly release upgrade.
Example time for a full 120 KiB upload (128 capacity - 8 for bootloader) on current
main
: 100ms * 120 page erases + 100ms * 120 buffers = 24 seconds, not accounting for synchronous transfer of payload data over USB FS Control EP0.Example time for a full 120 KiB upload with this patch: 20ms * 120 page erases + 27ms * 120 buffers = 5.64 seconds plus USB exchange. This is, too, a preliminary 4x-5x improvement.
bmputil
should benefit from this, too, and it measures upgrade times with a different algorithm than I do with/usr/bin/time -v dfu-util -d 1d50:6017 -s 0x08002000:leave -D src/blackmagic.elf
.Detailed speed tests may be conducted on request. Doing these measurements on a MaskROM USB DFU-capable
blackpill-f411ce
to replace the bootloader is easier, but F1 parts need either a USB-UART + stm32flash (and BOOT0 button/jumper manipulation) or a proper SWD adapter.Commit message optionally subject to editing.
Your checklist for this pull request
make PROBE_HOST=native
)make PROBE_HOST=hosted
) -- and is not applicableClosing issues