Community Packages

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#63370 - [android-tools] Flashing image leads to assertion error

Attached to Project: Community Packages
Opened by Philipp Klein (kleinph) - Monday, 05 August 2019, 08:16 GMT
Last edited by Anatol Pomozov (anatolik) - Thursday, 19 September 2019, 18:13 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Anatol Pomozov (anatolik)
Filipe Laíns (FFY00)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 13
Private No


Trying to flash a boot image leads to an assertion.

Additional info:
* android-tools-29.0.2-1
* target device: Xiaomi Mi A2 Lite

Steps to reproduce:
fastboot flash boot magisk_patched_boot_10.0.10.0.img
> fastboot: core/libsparse/sparse.cpp:131: int write_all_blocks(struct sparse_file *, struct output_file *): Assertion `pad >= 0' failed.

Doing the same with android-tools-9.0.0_r45-1 works fine.
This task depends upon

Closed by  Anatol Pomozov (anatolik)
Thursday, 19 September 2019, 18:13 GMT
Reason for closing:  Fixed
Additional comments about closing:  29.0.3-2
Comment by David (Marzal) - Tuesday, 06 August 2019, 10:03 GMT
Same error with nexus 6P, some images works others no.

android-tools-9.0.0_r45-1 works fine.
Comment by Aqmal Hakim (XxSingleOriginxX) - Tuesday, 06 August 2019, 22:21 GMT
Same error with Redmi 5 Plus.
rolled back to android-tools-9.0.0_r45-1 and it works.
Comment by Alexander Koskovich (ZVNexus) - Thursday, 08 August 2019, 14:11 GMT
Cannot flash Google Pixel 3a factory image for Android Q Beta 6 because of this.
Comment by Brad (braderhart) - Friday, 16 August 2019, 09:56 GMT
Ran into the same issue today while trying to flash via fastboot. Was able to get to work.
Comment by Thibaut Sautereau (thithib) - Wednesday, 21 August 2019, 10:10 GMT
Just ran into the same issue when trying to flash GrapheneOS to a Pixel 3a.
fastboot version 29.0.2-5738569 from current indeed works fine (thanks @braderhart for the tip!).
Comment by Pellegrino Prevete (tallero) - Wednesday, 28 August 2019, 13:00 GMT
Happening here, too.
Comment by Albert (albmathis) - Thursday, 29 August 2019, 14:10 GMT

Try something like:

sudo fastboot boot /path/of/file.img

Remember you must unlock the OEM before.
Comment by Pellegrino Prevete (tallero) - Thursday, 29 August 2019, 17:04 GMT
@Albert it is the bug's reproduce step. Also for me fails on `flash` command, luckily not on boot, too.
Comment by Aqmal Hakim (XxSingleOriginxX) - Friday, 30 August 2019, 20:10 GMT
still giving error with android-tools 29.0.2-2

fastboot: core/libsparse/sparse.cpp:131: int write_all_blocks(struct sparse_file *, struct output_file *): Assertion `pad >= 0' failed. line 7: 7682 Aborted (core dumped) fastboot $* flash sbl1 `dirname $0`/images/sbl1.mbn
Flash sbl1 error

sorry i could not be more verbose. already doing the best i can
Comment by Anatol Pomozov (anatolik) - Wednesday, 04 September 2019, 14:56 GMT
Could you please provide more data? Do you see the crash with any image or just a specific one. If it is a specific one - could you please share it with us?
Comment by Henry Tung (compgamer89) - Thursday, 05 September 2019, 07:21 GMT
Note: After looking into this some:

This looks like a suspicious change, particularly since sparse_file_import_auto seems to treat even non-sparse files as "sparse" in some way (as opposed to sparse_file_import, which checks for sparse magic header value before proceeding).

I'm trying to flash a Pixel 3 image, which requires platform tools 28.0.2+, which was released August 2018 - conveniently right before this change.

EDIT: Cross-reference:
Comment by Anatol Pomozov (anatolik) - Friday, 06 September 2019, 17:23 GMT
Henry, thank you for filing the upstream issue. Let's see what is going to be the official answer.
Comment by Chih-Hsuan Yen (yan12125) - Saturday, 07 September 2019, 13:55 GMT
Based on Henry's discovery, I managed to create a workaround script - pad the input image to make its size a multiple of 4096.


filesize=$(stat --format=%s "$filename")
block_count=$(( ($filesize + $block_size - 1) / $block_size ))
aligned_size=$(( $block_count * $block_size ))
padding_len=$(( $aligned_size - $filesize ))
dd if=/dev/zero of="$filename-padding" bs=1 count=$padding_len
cat $filename "$filename-padding" > "$filename-padded"

Tested with stock recovery image of HTC U11 (ocndugl).
Comment by Anatol Pomozov (anatolik) - Wednesday, 11 September 2019, 14:48 GMT Comment by Chih-Hsuan Yen (yan12125) - Thursday, 12 September 2019, 15:46 GMT
Still no luck with either community/android-tools or android-tools with rebased 45853 patch. Details in
Comment by Aqmal Hakim (XxSingleOriginxX) - Thursday, 12 September 2019, 16:53 GMT
also no luck here. same error as per last time. attached terminal commands that i used. will revert back to android-tools-9.0.0_r45-1.
if its any help, i flash phone's stock rom firmware using the flash command, resulting in an error. weirdly the fastboot command works.
also the link for the firmware file is:
   shlogs (0.6 KiB)
Comment by levi lovelock (bookpage) - Sunday, 15 September 2019, 04:46 GMT
Thanks Chih-Hsuan* - your script let me flash my coral dev board
Comment by Chih-Hsuan Yen (yan12125) - Wednesday, 18 September 2019, 03:51 GMT
There is a pull request ( waiting to be merged. It fixes the issue for me.

The attached file is a patch for PKGBUILD. It pulls the commit from the aforementioned pull request.
Comment by Anatol Pomozov (anatolik) - Wednesday, 18 September 2019, 17:40 GMT
The upstream fix been merged. Thank you for the follow-up Chih-Hsuan!

android-tools-29.0.3-2 with the upstream fix been pushed to [testing]. Please update the system and let me know if this bug is fixed for you now.
Comment by Chih-Hsuan Yen (yan12125) - Thursday, 19 September 2019, 01:06 GMT
29.0.3-2 works with the previously-broken image. Thanks for update!
Comment by Anatol Pomozov (anatolik) - Thursday, 19 September 2019, 04:23 GMT
Thank you very much Chih-Hsuan! Thank you for debugging this problem, working with the upstream and getting back to us with a fix. You are a great example of an pro-active Arch user who tries to make this distro better.