Repository navigation
fastboot: overlap flash writes with downloads - #3997
Open
JianyuWang0623 wants to merge 3 commits into
Open
JianyuWang0623 wants to merge 3 commits into
JianyuWang0623 wants to merge 3 commits into
Conversation
Integer variables may change value at run time. Storing the value by copy freezes it at startup, so getvar keeps returning the old value after it changes. Store a pointer instead and read the current value in getvar; the existing variables keep their behavior. Assisted-by: OpenCode:mimo-v2.6-pro Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Run flash writes on a worker with the download buffer split in half,
so a write overlaps the next download and max-download-size halves.
A flash response reports the previous segment's result; "fastboot oem
flash" returns the result of the last write.
Flashing a 32 MiB image to eMMC over USB high speed, in 131 segments
of 256 KiB, with the same max-download-size before and after:
Sending Writing Total Throughput
before 1.04 s 1.36 s 2.80 s 11.4 MiB/s
after 1.05 s 0.27 s 1.40 s 22.8 MiB/s
Assisted-by: OpenCode:mimo-v2.6-pro
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The download buffer is split in half to overlap flash writes with downloads, so max-download-size is half of SYSTEM_FASTBOOTD_DOWNLOAD_MAX. With the default of 40960 that is 20480, and older host fastboot (libsparse 1:10.0.0+r36) fails to split an ordinary image for a max-download-size below roughly 28 KiB, reporting "Sparse file is too large or invalid". Raise the default to 65536 so max-download-size is 32768. Assisted-by: OpenCode:claude-sonnet-5 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
JianyuWang0623
marked this pull request as ready for review
November 9, 2026 15:20
xiaoxiang781216
approved these changes
Nov 9, 2026
cederom
approved these changes
Nov 9, 2026
acassis
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Publish getvar's integer variables by reference, raise the default
download buffer to 64 KiB, and overlap flash writes with the next
download on a worker thread.
Impact
the overlapped writes), and a flash write failure is now reported on
the response to the next command rather than the one that triggered
the write.
65536, adding 24 KiB of download buffer on every board that enables
CONFIG_SYSTEM_FASTBOOTD, so the halved size (32768) stays above what
older host fastboot (libsparse 1:10.0.0+r36) needs to split an
ordinary image.
Testing
Internal measurement on the board this was developed on, flashing a
32 MiB image to eMMC over USB high speed in 131 segments of 256 KiB,
same max-download-size before and after:
Build Host: Ubuntu 22.04.5 LTS x86_64; xtensa-esp32s3-elf-gcc
(crosstool-NG esp-12.2.0_20230208) 12.2.0; Arm GNU Toolchain 13.2.rel1
aarch64-none-elf-gcc 13.2.1; QEMU 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.31)
Target: lckfb-szpi-esp32s3:fastboot_usb, with CONFIG_ESP32S3_SPIFLASH=y
to expose /dev/mtdblock0; SYSTEM_FASTBOOTD_DOWNLOAD_MAX left at the
Kconfig default
A
download:request larger than max-download-size is rejected withFAILData too large, and the device keeps responding afterwards.Target: qemu-armv8a:fastboot (TCP transport, default defconfig)
The whole 204800-byte ramdisk, read back over fastboot after the flash,
matches the source image (same sha256).