@echo off
@echo ————————
@echo Begin fastboot flashall
@echo ————————
@setlocal enabledelayedexpansion
:: get platform
@set platform=sdm636
@set buildtype=eng
@set current-slot=a
@set frp-partition=QHYBSBJk
@set input=%1%
@set deviceId=%2%
@set flashtype=%3%
if !input! == 0 (
@echo Earse Data: No
) else (
@echo Earse Data: Yes
)
if "!deviceId!" == "" (
@echo Support All device !
) else (
@echo Support one device: !deviceId!
)
:: partition and file name
call:flash_one_image sig signature
call:flash_one_image modem NON-HLOS.bin
call:flash_one_image sbl1 sbl1.mbn
call:flash_one_image sbl1bak sbl1.mbn
call:flash_one_image rpm rpm.mbn
call:flash_one_image rpmbak rpm.mbn
call:flash_one_image tz tz.mbn
call:flash_one_image tzbak tz.mbn
call:flash_one_image devcfg devcfg.mbn
call:flash_one_image devcfgbak devcfg.mbn
call:flash_one_image dsp adspso.bin
call:flash_one_image splash splash.img
call:flash_one_image aboot emmc_appsboot.mbn
call:flash_one_image abootbak emmc_appsboot.mbn
call:flash_one_image boot boot.img
call:flash_one_image recovery recovery.img
call:flash_one_image system system.img
call:flash_one_image vendor vendor.img
call:flash_one_image cache cache.img
call:flash_one_image mdtp mdtp.img
call:flash_one_image lksecapp lksecapp.mbn
call:flash_one_image lksecappbak lksecapp.mbn
call:flash_one_image cmnlibbak cmnlib_30.mbn
call:flash_one_image cmnlib cmnlib_30.mbn
call:flash_one_image cmnlib64 cmnlib64_30.mbn
call:flash_one_image cmnlib64bak cmnlib64_30.mbn
call:flash_one_image keymaster keymaster64.mbn
call:flash_one_image keymasterbak keymaster64.mbn
::call:flash_one_image factory2 factory.img
::call:flash_one_image APD apd.img
::call:flash_one_image ADF adf.img
::call:flash_one_image asusfw asusfw.img
::Clear user data
if "!deviceId!" == "" (
::fastboot erase sig
if !input! == 0 (
echo not do factory reset…
::Lock image partition
%~dp0fastboot erase sig
if NOT %ERRORLEVEL% == 0 (
@echo lock signature failed
goto DL_FAIL
)
%~dp0fastboot reboot
if NOT %ERRORLEVEL% == 0 (
echo reboot failed
goto DL_FAIL
)
) else (
echo Begin to Recovery Phone
%~dp0fastboot flash userdata %~dp0userdata.img
if NOT %ERRORLEVEL% == 0 (
echo recovery failed
goto DL_FAIL
)
%~dp0fastboot flash frp-unlock %~dp0signature
if NOT %ERRORLEVEL% == 0 (
echo frp unlock failed
goto DL_FAIL
)
::Lock image partition
%~dp0fastboot erase sig
if NOT %ERRORLEVEL% == 0 (
@echo lock signature failed
goto DL_FAIL
)
%~dp0fastboot reboot
if NOT %ERRORLEVEL% == 0 (
echo reboot failed
goto DL_FAIL
)
)
) else (
if !input! == 0 (
echo not do factory reset…
::Lock image partition
%~dp0fastboot erase sig
if NOT %ERRORLEVEL% == 0 (
@echo lock signature failed
goto DL_FAIL
)
%~dp0fastboot reboot
if NOT %ERRORLEVEL% == 0 (
echo reboot failed
goto DL_FAIL
)
) else (
::fastboot -s !deviceId! oem recovery_and_reboot
echo ——————————–
echo Begin to Recovery Phone
%~dp0fastboot -s !deviceId! flash userdata %~dp0userdata.img
if NOT %ERRORLEVEL% == 0 (
echo recovery failed
goto DL_FAIL
)
%~dp0fastboot -s !deviceId! flash frp-unlock %~dp0signature
if NOT %ERRORLEVEL% == 0 (
echo frp unlock failed
goto DL_FAIL
)
::Lock image partition
%~dp0fastboot -s !deviceId! erase sig
if NOT %ERRORLEVEL% == 0 (
@echo lock signature failed
goto DL_FAIL
)
%~dp0fastboot -s !deviceId! reboot
if NOT %ERRORLEVEL% == 0 (
@echo reboot failed
goto DL_FAIL
)
)
)
L_END
@echo DL_END
pause
exit
L_FAIL
@echo DL_FAIL
exit
:: function for download
:flash_one_image
@echo begin to flash partition %1
if exist %~dp0%2 (
if "!deviceId!" == "" (
%~dp0fastboot flash %1 %~dp0%2
if NOT %ERRORLEVEL% == 0 (
@echo DL %2 Failed
goto DL_FAIL
) else (
goto DL_PASS
)
) else (
%~dp0fastboot -s !deviceId! flash %1 %~dp0%2
if NOT %ERRORLEVEL% == 0 (
@echo DL _%2 Failed
goto DL_FAIL
)
)
) else (
@echo can't flash partion %1
)
@echo done!
@echo ——————————–
L_PASS
@echo DL_PASS