author | yanpingw <yanpingw@google.com> | 2018-10-25 20:02:54 (GMT) |
---|---|---|
committer | yanpingw <yanpingw@google.com> | 2018-10-26 21:39:26 (GMT) |
commit | f1c0fd6ec48c9284d5e1eccf57d0e1a3f8dfe6c7 (patch) | |
tree | 6f87d39292a5773f83fc5f0f78a3b5c959ee95bd | |
parent | 771877fed048b8bdeb59fd600580b9aed5552957 (diff) | |
download | common-f1c0fd6ec48c9284d5e1eccf57d0e1a3f8dfe6c7.zip common-f1c0fd6ec48c9284d5e1eccf57d0e1a3f8dfe6c7.tar.gz common-f1c0fd6ec48c9284d5e1eccf57d0e1a3f8dfe6c7.tar.bz2 |
Flashing any partition again when there is FAILED
When flashing device in lab, the "fastboot flash" might return FAILED
from any partition including system partition. Also see b/113497732
Add function to flash any partition twice if there is FAILED on the
first trial.
Bug: 117216244
Test: ./flash-all.sh
Change-Id: I1751d165a925d6f9bc591d44146008169a2b8704
-rwxr-xr-x | flash-all.sh | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/flash-all.sh b/flash-all.sh index ef66a35..822d309 100755 --- a/flash-all.sh +++ b/flash-all.sh @@ -33,6 +33,20 @@ if [ "$skipreboot" != "skip" ] then adb $sern reboot fastboot fi + +function flash_with_retry() { + local partition=${1}; + local img=${2}; + msg=$(fastboot ${sern} flash ${partition} ${img} 2>&1) + echo "${msg}" + if [[ ${msg} =~ 'FAILED' ]]; then + echo "\nFlashing ${img} is not done properly. Do it again." + fastboot ${sern} reboot-bootloader + fastboot ${sern} flash ${partition} ${img} + fi + return 1 +} + fastboot $sern flashing unlock_critical fastboot $sern flashing unlock fastboot $sern flash bootloader bootloader.img @@ -46,18 +60,16 @@ fastboot $sern flashing unlock fastboot $sern flash dts dt.img fastboot $sern erase param fastboot $sern -w -fastboot $sern flash vbmeta vbmeta.img -fastboot $sern flash odm odm.img -fastboot $sern flash logo logo.img -fastboot $sern flash boot boot.img -if fastboot $sern flash system system.img 2>&1 | grep -q 'FAILED'; then - echo "Flashing system.img is not done properly. Try it again." - sleep 3 - fastboot $sern flash system system.img -fi -fastboot $sern flash vendor vendor.img -fastboot $sern flash recovery recovery.img -fastboot $sern flash product product.img + +flash_with_retry vbmeta vbmeta.img +flash_with_retry odm odm.img +flash_with_retry logo logo.img +flash_with_retry boot boot.img +flash_with_retry system system.img +flash_with_retry vendor vendor.img +flash_with_retry recovery recovery.img +flash_with_retry product product.img + if [ "$lflag" = "lock" ] then fastboot $sern flashing lock |