@echo off
adb reboot bootloader
set expected=Daredevil
for /f "tokens=2 delims= " %%a in ('fastboot oem getprojectcode 2^>^&1 ^| findstr bootloader') do set project=%%a
if "%project%"=="%expected%" (goto :Flash) else (goto :Error)
rem :Check_Device
rem set expected=ZANGYAPRO
rem for /f "tokens=2 delims=: " %%a in ('fastboot.exe getvar device 2^>^&1 ^| findstr device') do set device=%%a
rem if "%device%"=="%expected%" (goto :Flash) else (goto :Error)
rem :Old_Way
rem set expected=SDM660
rem for /f "tokens=2 delims=: " %%a in ('fastboot.exe getvar product 2^>^&1 ^| findstr product') do set product=%%a
rem if "%product%"=="%expected%" (goto :Flash) else (goto :Error)
:Flash
echo for not erase modemst1 and modemst2
rem fastboot flash partition gpt_both0.bin
rem fastboot flash abl_a abl.elf
rem fastboot flash abl_b abl.elf
rem fastboot reboot-bootloader
rem timeout /t 6
rem fastboot flash partition gpt_both0.bin
rem fastboot reboot-bootloader
rem timeout /t 6
rem fastboot flash elableinfo elableinfo.img
fastboot flash dtbo_a dtbo.img
fastboot flash dtbo_b dtbo.img
fastboot flash vbmeta_a vbmeta.img
fastboot flash vbmeta_b vbmeta.img
fastboot flash bluetooth_a BTFM.bin
fastboot flash bluetooth_b BTFM.bin
fastboot flash devcfg_a devcfg.mbn
fastboot flash devcfg_b devcfg.mbn
fastboot flash dsp_a dspso.bin
fastboot flash dsp_b dspso.bin
fastboot flash modem_a NON-HLOS.bin
fastboot flash modem_b NON-HLOS.bin
fastboot flash xbl_a xbl.elf
fastboot flash xbl_b xbl.elf
fastboot flash pmic_a pmic.elf
fastboot flash pmic_b pmic.elf
fastboot flash rpm_a rpm.mbn
fastboot flash rpm_b rpm.mbn
fastboot flash tz_a tz.mbn
fastboot flash tz_b tz.mbn
fastboot flash hyp_a hyp.mbn
fastboot flash hyp_b hyp.mbn
fastboot flash keymaster_a km4.mbn
fastboot flash keymaster_b km4.mbn
fastboot flash cmnlib_a cmnlib.mbn
fastboot flash cmnlib_b cmnlib.mbn
fastboot flash cmnlib64_a cmnlib64.mbn
fastboot flash cmnlib64_b cmnlib64.mbn
fastboot flash mdtpsecapp_a mdtpsecapp.mbn
fastboot flash mdtpsecapp_b mdtpsecapp.mbn
rem fastboot flash devinfo devinfo.bin
rem fastboot flash fsg fs_image.tar.gz.mbn.img
rem fastboot flash modemst1 dummy.bin
rem fastboot flash modemst2 dummy.bin
rem fastboot flash persist persist.img
rem fastboot flash sec sec.dat
rem fastboot erase misc
fastboot flash abl_a abl.elf
fastboot flash abl_b abl.elf
fastboot flash boot_a boot.img
fastboot flash boot_b boot.img
fastboot flash system_a system.img
fastboot flash system_b system.img
fastboot flash vendor_a vendor.img
fastboot flash vendor_b vendor.img
fastboot flash userdata userdata.img
fastboot flash mdtp_a mdtp.img
fastboot flash mdtp_b mdtp.img
fastboot flash splash splash.img
fastboot reboot
pause
exit
:Error
echo Device does not match Daredevil and cannot be flashed. Check the FW.
pause
exit