Asus Zenfone 8 ZS590KS

@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”

)

set FASTBOOT=fastboot

set MARCO_PACKAGE_VARIANT_USERDEBUG=userdebug

@set MARCO_PACKAGE_VARIANT_USER=user

@set MARCO_PACKAGE_VARIANT_ENG=eng

@set EVB_NAME=EV

@set SR_NAME=SR

::=========Additional Override Define For Input Para Use========

@set MARCO_PACKAGE_VARIANT_FACTORY=fac

@set MARCO_PACKAGE_VARIANT_SHIPPING=shipping

@set SKIP_REBOOT=0

::==============GLOBLE DEFINE=========================================

@set PACKAGE_VARIANT=

@set PROJECT=

@set ERASE_DATA_CACHE=

@set DEVICE_SSN=

@set PACKAGE_TARGET_SKU=

@set UPDATE_SCRIPT_NAME=

@set STAGE_ID=

@set PROJECT_VERSION=

@set SKIP_CRC=

:loop_args

@echo off

if “%1” NEQ “” (

if “%1″==”–shipping” (

set PACKAGE_VARIANT=%MARCO_PACKAGE_VARIANT_SHIPPING%

)

if “%1″==”–fac” (

set PACKAGE_VARIANT=%MARCO_PACKAGE_VARIANT_FACTORY%

)

if “%1″==”1” (

set ERASE_DATA_CACHE=1

)

if “%1″==”–skip” (

set SKIP_REBOOT=1

)

if “%1″==”-s” (

if “%2” EQU “” (

call :color_text 0c “-s requires an argument.” & echo,

pause

exit 1

)

set DEVICE_SSN=%2

SHIFT

)

if “%1″==”skipcrc” (

set SKIP_CRC=1

)

SHIFT

goto loop_args

) else (

goto setfb

)

:setfb

if “%DEVICE_SSN%” neq “” (

set FASTBOOT=%FASTBOOT% -s %DEVICE_SSN%

)

echo fastboot cmd : %FASTBOOT%

@if “%PACKAGE_VARIANT%”==”%MARCO_PACKAGE_VARIANT_SHIPPING%” (

@echo Cautious, This is shipping flash route

)

@if “%PACKAGE_VARIANT%”==”%MARCO_PACKAGE_VARIANT_FACTORY%” (

@echo Cautious, This is factory flash route

)

%FASTBOOT% getvar project > getprjtemp%DEVICE_SSN%.txt 2>&1

for /f “tokens=2 delims=:” %%i in (‘type getprjtemp%DEVICE_SSN%.txt ^| findstr “project”‘) do (

set “project=%%i”

)

del getprjtemp%DEVICE_SSN%.txt

%FASTBOOT% oem get-hwid > gethwtemp%DEVICE_SSN%.txt 2>&1

for /f “tokens=2 delims==” %%i in (‘type gethwtemp%DEVICE_SSN%.txt ^| findstr “HWID”‘) do (

set “hwid=%%i”

)

del gethwtemp%DEVICE_SSN%.txt

if “x%hwid%” equ “x 0 ” (

call :color_text 0a “Hwid=%hwid%,this is EVB!” & echo,

) else if “x%hwid%” equ “x 1 ” (

call :color_text 0a “Hwid=%hwid%,this is EVB2!” & echo,

) else if “x%project%” equ “x ZS590KS” (

call :color_text 0a “Project %project% matching success!” & echo,

) else (

call :color_text 0c “The script can’t be used in this devices,hwid=%hwid%,project=%project%!” & echo,

pause

exit 1

)

:: =================== erase: misc ======================

call :erase_partition misc

if “%ERASE_DATA_CACHE%” equ “1” (

%FASTBOOT% -w

%FASTBOOT% erase asuskey

)

:: ====================== 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 firmwaremulti_image.mbn

call :flash_image multiimgoem_b firmwaremulti_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

:: ================ flash: multiimgoem ==================

call :flash_image multiimgoem_a firmwaremulti_image.mbn

call :flash_image multiimgoem_b firmwaremulti_image.mbn

:: =============== flash: xbl & xbl_config===============

call :flash_image xbl_a firmwarexbl.elf

call :flash_image xbl_config_a firmwarexbl_config.elf

call :flash_image xbl_b firmwarexbl.elf

call :flash_image xbl_config_b firmwarexbl_config.elf

:: ==================== flash: shrm =====================

call :flash_image shrm_a firmwareshrm.elf

call :flash_image shrm_b firmwareshrm.elf

:: ====================== flash: abl ====================

call :flash_image abl_a abl.elf

call :flash_image abl_b abl.elf

:: ==================== flash: aop ======================

call :flash_image aop_a firmwareaop.mbn

call :flash_image aop_b firmwareaop.mbn

:: ==================== flash: TZ =======================

call :flash_image tz_a firmwaretz.mbn

call :flash_image tz_b firmwaretz.mbn

:: ==================== flash: hyp ======================

call :flash_image hyp_a firmwarehypvm.mbn

call :flash_image hyp_b firmwarehypvm.mbn

:: ================== flash: Modem ======================

call :flash_image modem_a firmwareNON-HLOS.bin

call :flash_image modem_b firmwareNON-HLOS.bin

:: ================ flash: bluetooth ====================

call :flash_image bluetooth_a firmwareBTFM.bin

call :flash_image bluetooth_b firmwareBTFM.bin

:: ===================== flash: dsp =====================

call :flash_image dsp_a firmwaredspso.bin

call :flash_image dsp_b firmwaredspso.bin

:: ================= flash: keymaster ===================

call :flash_image keymaster_a firmwarekm41.mbn

call :flash_image keymaster_b firmwarekm41.mbn

:: =================== flash: rtice =====================

call :flash_image rtice firmwarertice.mbn

:: ================== flash: storsec ====================

call :flash_image storsec firmwarestorsec.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 firmwarespunvm.bin

:: ================ flash: qweslicstore =================

call :flash_image qweslicstore_a firmwareqweslicstore.bin

call :flash_image qweslicstore_b firmwareqweslicstore.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: devcfg =====================

call :flash_image devcfg_a firmwaredevcfg.mbn

call :flash_image devcfg_b firmwaredevcfg.mbn

:: ============= flash: cmnlib & cmnlib64 ===============

::call :flash_image cmnlib_a firmwarecmnlib.mbn

::call :flash_image cmnlib_b firmwarecmnlib.mbn

::call :flash_image cmnlib64_a firmwarecmnlib64.mbn

::call :flash_image cmnlib64_b firmwarecmnlib64.mbn

:: ==================== flash: qupfw ====================

call :flash_image qupfw_a firmwarequpv3fw.elf

call :flash_image qupfw_b firmwarequpv3fw.elf

:: ==================== flash: qupfw ====================

call :flash_image cpucp_a firmwarecpucp.elf

call :flash_image cpucp_b firmwarecpucp.elf

:: ==================== flash: logfs ====================

call :flash_image logfs firmwarelogfs_ufs_8mb.bin

:: ================= flash: uefisecapp ==================

call :flash_image uefisecapp_a firmwareuefi_sec.mbn

call :flash_image uefisecapp_b firmwareuefi_sec.mbn

:: ================ flash: featenabler ==================

call :flash_image featenabler_a firmwarefeatenabler.mbn

call :flash_image featenabler_b firmwarefeatenabler.mbn

:: =================== flash: imagefv ===================

call :flash_image imagefv_a firmwareimagefv.elf

call :flash_image imagefv_b firmwareimagefv.elf

:: ==================== flash: vbmeta ===================

::call :flash_image persist persist.img

:: ===================== flash: ADF =====================

call :flash_image ADF ADF.img

:: ==================== flash: vbmeta ===================

call :flash_image vbmeta_a vbmeta.img

call :flash_image vbmeta_b vbmeta.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: vendor_boot =================

call :flash_image vendor_boot_a vendor_boot.img

call :flash_image vendor_boot_b vendor_boot.img

:: ====================== flash: dtbo ===================

call :flash_image dtbo_a dtbo.img

call :flash_image dtbo_b dtbo.img

:: ===================== flash: asdf=====================

call :erase_partition asdf

call :flash_image asdf asdf_384M.img

:: ==================== flash: XROM =====================

if exist ASUS-xrom.img (

call :flash_image xrom_a ASUS-xrom.img

call :flash_image xrom_b ASUS-xrom.img

)

:: ===================== flash: super ===================

call :erase_partition super

call :flash_image super super.img

call :Crc32CheckGeneralPartition

:: ================= erase: userdata ====================

if “%ERASE_DATA_CACHE%” equ “1” (

%FASTBOOT% -w

%FASTBOOT% erase asuskey

) else (

echo “don’t erase userdate”

)

:: ==================== reset active ====================

:: ====================== finished ======================

echo =======================

echo “Download_PASS”

echo =======================

goto :eof

:Crc32CheckGeneralPartition

echo Crc32 General Check Partitions…

call :Crc32Checksum multiimgoem_a

call :Crc32Checksum multiimgoem_b

call :Crc32Checksum xbl_a

call :Crc32Checksum xbl_config_a

call :Crc32Checksum xbl_b

call :Crc32Checksum xbl_config_b

call :Crc32Checksum abl_a

call :Crc32Checksum abl_b

call :Crc32Checksum aop_a

call :Crc32Checksum aop_b

call :Crc32Checksum tz_a

call :Crc32Checksum tz_b

call :Crc32Checksum hyp_a

call :Crc32Checksum hyp_b

call :Crc32Checksum modem_a

call :Crc32Checksum modem_b

call :Crc32Checksum bluetooth_a

call :Crc32Checksum bluetooth_b

call :Crc32Checksum dsp_a

call :Crc32Checksum dsp_b

call :Crc32Checksum keymaster_a

call :Crc32Checksum keymaster_b

call :Crc32Checksum rtice

call :Crc32Checksum storsec

call :Crc32Checksum shrm_a

call :Crc32Checksum shrm_b

call :Crc32Checksum asdf

call :Crc32Checksum devcfg_a

call :Crc32Checksum devcfg_b

call :Crc32Checksum qupfw_a

call :Crc32Checksum qupfw_b

call :Crc32Checksum cpucp_a

call :Crc32Checksum cpucp_b

call :Crc32Checksum logfs

call :Crc32Checksum uefisecapp_a

call :Crc32Checksum uefisecapp_b

call :Crc32Checksum featenabler_a

call :Crc32Checksum featenabler_b

call :Crc32Checksum spunvm

call :Crc32Checksum qweslicstore_a

call :Crc32Checksum qweslicstore_b

call :Crc32Checksum imagefv_a

call :Crc32Checksum imagefv_b

call :Crc32Checksum ADF

call :Crc32Checksum vbmeta_a

call :Crc32Checksum vbmeta_b

call :Crc32Checksum vbmeta_system_a

call :Crc32Checksum vbmeta_system_b

call :Crc32Checksum boot_a

call :Crc32Checksum boot_b

call :Crc32Checksum vendor_boot_a

call :Crc32Checksum vendor_boot_b

call :Crc32Checksum dtbo_a

call :Crc32Checksum dtbo_b

if “x%SKIP_CRC%” equ “x1” (

call :color_text 0a “Crc32Check General Partitions Pass” & echo,

goto :eof

) else (

call :Crc32Checksum super

call :color_text 0a “Crc32Check General Partitions Pass” & echo,

goto :eof

)

:Crc32Checksum

set patition_name=%~1

set patition_name_in_crc32file=%patition_name%

for /f %%a in (‘grep.exe -w %patition_name_in_crc32file% crc32_img_size.txt’) do (

set file_size=%%a

)

for /f “tokens=1” %%i in (‘grep.exe -w %patition_name_in_crc32file% crc32_checksum.txt’) do (

set img_crc32_val=%%i

)

%FASTBOOT% oem hashsize_%file_size% > nul 2>&1

for /f “tokens=2” %%a in (‘%FASTBOOT% oem crc32check_%patition_name% 2^>^&1 ^| findstr bootloader’) do (

set pt_crc32_val=%%a

)

if /i “%pt_crc32_val%” neq “%img_crc32_val%” (

call :color_text 0c “pt_crc32_val = %pt_crc32_val% img_crc32_val = %img_crc32_val%” & echo,

call :color_text 0c “Crc32Check partition %1 fail = different” & echo,

pause

) else (

call :color_text 0a “%patition_name% crc32 check succeed!” & 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% flash -S 300M %1 %2

call :failure_prompt !errorlevel! %1

goto :eof

:erase_partition

echo “Start erase %1”

%FASTBOOT% erase %1

call :failure_prompt !errorlevel! %1

goto :eof

:color_text

::echo off

<nul set /p “.=%DEL%” > “%~2%DEVICE_SSN%”

findstr /v /a:%1 /R “^$” “%~2%DEVICE_SSN%” nul

del “%~2%DEVICE_SSN%” > nul 2>&1

goto :eof

pause

More from my site