Skip to content

Instantly share code, notes, and snippets.

@CFM880
Created October 11, 2025 11:27
Show Gist options
  • Save CFM880/69f23494b3e539853cf9e26e01100515 to your computer and use it in GitHub Desktop.
Save CFM880/69f23494b3e539853cf9e26e01100515 to your computer and use it in GitHub Desktop.
fix xiaomi pad5 stuck in fastboot and Failed to load/authenticate boot image: Device Error
fastboot %* getvar product 2>&1 | findstr /r /c:"^product: *nabu" || echo Missmatching image and device
fastboot %* getvar product 2>&1 | findstr /r /c:"^product: *nabu" || exit /B 1
fastboot %* flash partition:0 %~dp0images\gpt_both0.bin || @echo "flash partition:0 error" && exit /B 1
fastboot %* flash partition:1 %~dp0images\gpt_both1.bin || @echo "flash partition:1 error" && exit /B 1
fastboot %* flash partition:2 %~dp0images\gpt_both2.bin || @echo "flash partition:2 error" && exit /B 1
fastboot %* flash partition:3 %~dp0images\gpt_both3.bin || @echo "flash partition:3 error" && exit /B 1
fastboot %* flash partition:4 %~dp0images\gpt_both4.bin || @echo "flash partition:4 error" && exit /B 1
fastboot %* flash partition:5 %~dp0images\gpt_both5.bin || @echo "flash partition:5 error" && exit /B 1
::check anti_version
if exist %~dp0images\anti_version.txt (for /f "delims==" %%a in (%~dp0images\anti_version.txt) do (set CURRENT_ANTI_VER=%%a))
if [%CURRENT_ANTI_VER%] EQU [] set CURRENT_ANTI_VER=1
for /f "tokens=2 delims=: " %%i in ('fastboot %* getvar anti 2^>^&1 ^| findstr /r /c:"anti:"') do (set version=%%i)
if [%version%] EQU [] set version=0
set anticheck="antirollback check pass"
if %version% GTR %CURRENT_ANTI_VER% set anticheck="Current device antirollback version is greater than this pakcage"
echo %anticheck% | findstr /r /c:"pass" || @echo "Antirollback check error" && exit /B 1
fastboot %* erase boot_ab || @echo "Erase boot error" && exit /B 1
fastboot %* flash crclist %~dp0images\crclist.txt || @echo "Flash crclist error" && exit /B 1
fastboot %* flash sparsecrclist %~dp0images\sparsecrclist.txt || @echo "Flash sparsecrclist error" && exit /B 1
fastboot %* flash xbl_ab %~dp0images\xbl.elf || @echo "Flash xbl error" && exit /B 1
fastboot %* flash xbl_config_ab %~dp0images\xbl_config.elf || @echo "Flash xbl_config error" && exit /B 1
fastboot %* flash abl_ab %~dp0images\abl.elf || @echo "Flash abl error" && exit /B 1
fastboot %* flash tz_ab %~dp0images\tz.mbn || @echo "Flash tz error" && exit /B 1
fastboot %* flash hyp_ab %~dp0images\hyp.mbn || @echo "Flash hyp error" && exit /B 1
fastboot %* flash devcfg_ab %~dp0images\devcfg.mbn || @echo "Flash devcfg error" && exit /B 1
fastboot %* flash storsec %~dp0images\storsec.mbn || @echo "Flash storsec error" && exit /B 1
fastboot %* flash bluetooth_ab %~dp0images\BTFM.bin || @echo "Flash bluetooth error" && exit /B 1
fastboot %* flash cmnlib_ab %~dp0images\cmnlib.mbn || @echo "Flash cmnlib error" && exit /B 1
fastboot %* flash cmnlib64_ab %~dp0images\cmnlib64.mbn || @echo "Flash cmnlib64 error" && exit /B 1
fastboot %* flash modem_ab %~dp0images\NON-HLOS.bin || @echo "Flash modem error" && exit /B 1
fastboot %* flash dsp_ab %~dp0images\dspso.bin || @echo "Flash dsp error" && exit /B 1
fastboot %* flash keymaster_ab %~dp0images\km41.mbn || @echo "Flash keymaster error" && exit /B 1
fastboot %* flash aop_ab %~dp0images\aop.mbn || @echo "Flash aop error" && exit /B 1
fastboot %* flash qupfw_ab %~dp0images\qupv3fw.elf || @echo "Flash qupfw error" && exit /B 1
fastboot %* erase imagefv_ab || @echo "Erase metadata error" && exit 1
fastboot %* flash imagefv_ab %~dp0images\imagefv.elf || @echo "Flash imagefv error" && exit /B 1
fastboot %* flash uefisecapp_ab %~dp0images\uefi_sec.mbn || @echo "Flash uefisecapp error" && exit /B 1
fastboot %* flash multiimgoem_ab %~dp0images\multi_image.mbn || @echo "Flash multiimgoem error" && exit /B 1
fastboot %* flash super %~dp0images\super.img || @echo "Flash super error" && exit /B 1
fastboot %* erase metadata || @echo "Erase metadata error" && exit 1
fastboot %* flash metadata %~dp0images\metadata.img || @echo "Flash metadata error" && exit /B 1
fastboot %* flash vbmeta_system_ab %~dp0images\vbmeta_system.img || @echo "Flash vbmeta_system error" && exit /B 1
fastboot %* flash vbmeta_ab %~dp0images\vbmeta.img || @echo "Flash vbmeta error" && exit /B 1
fastboot %* flash dtbo_ab %~dp0images\dtbo.img || @echo "Flash dtbo error" && exit /B 1
fastboot %* flash userdata %~dp0images\userdata.img || @echo "Flash userdata error" && exit /B 1
fastboot %* flash rescue %~dp0images\rescue.img || @echo "Flash rescue.img error" && exit /B 1
fastboot %* flash vendor_boot_ab %~dp0images\vendor_boot.img || @echo "Flash vendor_boot" && exit /B 1
fastboot %* flash cust %~dp0images\cust.img || @echo "Flash cust error" && exit /B 1
fastboot %* flash boot_ab %~dp0images\boot.img || @echo "Flash boot error" && exit /B 1
fastboot %* flash misc %~dp0images\misc.img || @echo "Flash misc error" && exit /B 1
fastboot %* set_active a || @echo "Set active a error" && exit 1
fastboot %* reboot || @echo "Reboot error" && exit /B 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment