Skip to content

system/fastboot: fix the sparse chunk walk - #3903

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
JianyuWang0623:fix-sparse-chunk-walk
Oct 24, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
JianyuWang0623:fix-sparse-chunk-walk

Conversation

@JianyuWang0623

Copy link
Copy Markdown
Contributor

Summary

Fix three bugs in the sparse chunk walk of fastboot_flash_program():

  • DONT_CARE now advances the output offset.
  • CRC32 now skips its 4-byte payload.
  • FILL now reads its pattern with le32toh(); the sparse format is little-endian.

Impact

Sparse images flashed via fastbootd are no longer corrupted. No API or build change.

Testing

sim:nsh + CONFIG_SYSTEM_FASTBOOTD=y builds clean. Flashed on
lckfb-szpi-esp32s3:fastboot with fastboot flash ram1 sparse_test.img, then
read back with hexdump.

Test image (blk_sz 4096): RAW, DONT_CARE, FILL 0x11223344, CRC32, RAW.
Expected: RAW1 at 0, hole at 4096, FILL at 8192, RAW2 at 12288.

Before:

nsh> hexdump /dev/ram1 count=16
0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
nsh> hexdump /dev/ram1 skip=4096 count=16
0000: 11 22 33 44 11 22 33 44 11 22 33 44 11 22 33 44
nsh> hexdump /dev/ram1 skip=8192 count=16
0000: de ed df df f8 12 18 50 df f1 17 a7 4d f3 7f fd
nsh> hexdump /dev/ram1 skip=12288 count=16
0000: 48 28 06 d4 a9 67 df e7 05 8d 90 02 9c 51 17 42

After:

nsh> hexdump /dev/ram1 count=16
0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
nsh> hexdump /dev/ram1 skip=4096 count=16
0000: fe fe 67 21 51 1c b9 6a 81 31 76 93 7c 8b f7 ff
nsh> hexdump /dev/ram1 skip=8192 count=16
0000: 44 33 22 11 44 33 22 11 44 33 22 11 44 33 22 11
nsh> hexdump /dev/ram1 skip=12288 count=16
0000: 0d 14 1b 22 29 30 37 3e 45 4c 53 5a 61 68 6f 76

DONT_CARE must advance the output offset or later chunks land on earlier
ones; CRC32 chunks carry 4 bytes to skip; FILL data is little-endian.

Assisted-by: OpenCode:mimo-v2.6-pro
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623
JianyuWang0623 marked this pull request as ready for review October 23, 2026 11:14
@xiaoxiang781216
xiaoxiang781216 merged commit 731a8a3 into apache:master Oct 24, 2026
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants