@echo off & setlocal enabledelayedexpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
if "%2" NEQ "" (
set FASTBOOT=fastboot -s %2
) else (
set FASTBOOT=fastboot
)
%FASTBOOT% oem get_prj > getprjtemp.txt 2>&1
for /f "tokens=2 delims=\)" %%i in (getprjtemp.txt) do (
set "project=%%i"
)
del getprjtemp.txt
if "x%project%" equ "x ZS670KS" (
call :color_text 0a "Project%project% matching success!" & echo,
) else (
call :color_text 0c "The script can't be used in the project%project%!" & echo,
pause
exit 1
)
:: ====================== flash: abl ====================
call :flash_image abl_a abl.elf
call :flash_image abl_b abl.elf
%FASTBOOT% reboot-bootloader
ping 0.0.0.0 -n 10 > nul
:: ============== add for fac flash fail ================
call :flash_image multiimgoem_a firmware\multi_image.mbn
call :flash_image multiimgoem_b firmware\multi_image.mbn
:: ==================== partition_0 =====================
%FASTBOOT% flash partition:0 gpt_both0.bin
call :failure_prompt !errorlevel! partition0
:: ==================== partition_1 =====================
%FASTBOOT% flash partition:1 gpt_both1.bin
call :failure_prompt !errorlevel! partition1
:: ==================== partition_2 =====================
%FASTBOOT% flash partition:2 gpt_both2.bin
call :failure_prompt !errorlevel! partition2
:: ==================== partition_3 =====================
%FASTBOOT% flash partition:3 gpt_both3.bin
call :failure_prompt !errorlevel! partition3
:: ==================== partition_4 =====================
%FASTBOOT% flash partition:4 gpt_both4.bin
call :failure_prompt !errorlevel! partition4
:: ==================== partition_5 =====================
%FASTBOOT% flash partition:5 gpt_both5.bin
call :failure_prompt !errorlevel! partition5
:: ==================== partition_6 =====================
%FASTBOOT% flash partition:6 gpt_both6.bin
call :failure_prompt !errorlevel! partition6
%FASTBOOT% oem getddr > getddrtemp.txt 2>&1
for /f "tokens=2 delims=\=" %%i in (getddrtemp.txt) do (
set "ddrtype=%%i"
)
del getddrtemp.txt
if "x%ddrtype%" equ "x LP4" (
set ddr=4
) else if "x%ddrtype%" equ "x LP5" (
set ddr=5
) else (call :color_text 0c "Not the expected ddr,press any key to exit the script! " & echo,)
call :color_text 0a "This phone is lp%ddr%!" & echo,
:: ================ flash: multiimgoem ==================
call :flash_image multiimgoem_a firmware\multi_image.mbn
call :flash_image multiimgoem_b firmware\multi_image.mbn
:: =============== flash: xbl & xbl_config===============
call :flash_image xbl_a firmware\xbl_lp%ddr%.elf
call :flash_image xbl_config_a firmware\xbl_config_lp%ddr%.elf
call :flash_image xbl_b firmware\xbl_lp%ddr%.elf
call :flash_image xbl_config_b firmware\xbl_config_lp%ddr%.elf
:: ====================== flash: abl ====================
call :flash_image abl_a abl.elf
call :flash_image abl_b abl.elf
:: ==================== flash: aop ======================
call :flash_image aop_a firmware\aop.mbn
call :flash_image aop_b firmware\aop.mbn
:: ==================== flash: TZ =======================
call :flash_image tz_a firmware\tz.mbn
call :flash_image tz_b firmware\tz.mbn
:: ==================== flash: hyp ======================
call :flash_image hyp_a firmware\hyp.mbn
call :flash_image hyp_b firmware\hyp.mbn
:: ================== flash: Modem ======================
call :flash_image modem_a firmware\NON-HLOS.bin
call :flash_image modem_b firmware\NON-HLOS.bin
:: ================ flash: bluetooth ====================
call :flash_image bluetooth_a firmware\BTFM.bin
call :flash_image bluetooth_b firmware\BTFM.bin
:: ===================== flash: dsp =====================
call :flash_image dsp_a firmware\dspso.bin
call :flash_image dsp_b firmware\dspso.bin
:: ================= flash: keymaster ===================
call :flash_image keymaster_a firmware\km4.mbn
call :flash_image keymaster_b firmware\km4.mbn
:: =================== erase: misc ======================
call :erase_partition misc
:: =================== erase: ssd =======================
call :erase_partition ssd
:: ================= erase: keystore ====================
call :erase_partition keystore
:: ================ flash: apdp & spunvm ================
::call :flash_image apdp apdp.mbn
call :flash_image spunvm firmware\spunvm.bin
:: ================ flash: batinfo================
::call :flash_image batinfo batinfo.img
:: ================ flash: ADF ================
::call :flash_image ADF ADF.img
:: ================ flash: ADF ================
::call :flash_image APD APD.img
:: ================ flash: asdf================
call :flash_image asdf asdf_128M.img
:: =============== flash: XROM ================
call :flash_image xrom_a ASUS-xrom.img
call :flash_image xrom_b ASUS-xrom.img
:: ================== flash: devcfg =====================
call :flash_image devcfg_a firmware\devcfg.mbn
call :flash_image devcfg_b firmware\devcfg.mbn
:: ============= flash: cmnlib & cmnlib64 ===============
call :flash_image cmnlib_a firmware\cmnlib.mbn
call :flash_image cmnlib_b firmware\cmnlib.mbn
call :flash_image cmnlib64_a firmware\cmnlib64.mbn
call :flash_image cmnlib64_b firmware\cmnlib64.mbn
:: ==================== flash: qupfw ====================
call :flash_image qupfw_a firmware\qupv3fw.elf
call :flash_image qupfw_b firmware\qupv3fw.elf
:: ==================== flash: logfs ====================
call :flash_image logfs firmware/logfs_ufs_8mb.bin
:: ================= flash: uefisecapp ==================
call :flash_image uefisecapp_a firmware\uefi_sec.mbn
call :flash_image uefisecapp_b firmware\uefi_sec.mbn
:: ================ flash: featenabler ==================
call :flash_image featenabler_a firmware\featenabler.mbn
call :flash_image featenabler_b firmware\featenabler.mbn
:: =================== flash: imagefv ===================
call :flash_image imagefv_a firmware\imagefv_lp%ddr%.elf
call :flash_image imagefv_b firmware\imagefv_lp%ddr%.elf
:: ==================== flash: vbmeta ===================
call :flash_image vbmeta_a vbmeta.img
call :flash_image vbmeta_b vbmeta.img
:: =================== flash: recovery ==================
call :flash_image recovery_a recovery.img
call :flash_image recovery_b recovery.img
:: =============== flash: vbmeta_system =================
call :flash_image vbmeta_system_a vbmeta_system.img
call :flash_image vbmeta_system_b vbmeta_system.img
:: ==================== flash: Kernel ===================
call :flash_image boot_a boot.img
call :flash_image boot_b boot.img
:: ====================== flash: dtbo ===================
call :flash_image dtbo_a dtbo.img
call :flash_image dtbo_b dtbo.img
:: ===================== flash: super ===================
call :flash_image super super.img
:: ================= erase: userdata ====================
if "%1" equ "1" (
%FASTBOOT% -w
%FASTBOOT% erase asuskey
) else (
echo "don't erase userdate"
)
:: ==================== reset active ====================
:: ====================== finished ======================
echo =======================
echo "Download_PASS"
echo =======================
goto :eof
:failure_prompt
if "x%1" neq "x0" (
call :color_text 0c "%2 flash failed,press any key to exit the script! " & echo,
pause
exit 1
) else (
call :color_text 0a "%2 flash succeed!" & echo,
)
goto :eof
:flash_image
echo "Start Flash %1"
%FASTBOOT% erase %1 > nul 2>&1
%FASTBOOT% flash %1 %2
call :failure_prompt !errorlevel! %1
goto :eof
:erase_partition
echo "Start erase %1"
%FASTBOOT% erase %1 > nul 2>&1
call :failure_prompt !errorlevel! %1
goto :eof
:color_text
::echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof
Tank you