@echo off
chcp 65001 >nul
echo =======================================================================
echo Warning: This ROM dumped from prototype device.
echo The firmware may not start or may encounter problems
echo =======================================================================
echo Press ENTER to continue…
pause >nul
echo.
echo Waiting fastboot device…
fastboot wait-for-device
echo.
echo Detected device! Flashing…
echo =======================================================================
echo Flashing tz partition…
fastboot flash tz "%~dp0images\tz.mbn" || goto :error
echo Flashing sbl1 partition…
fastboot flash sbl1 "%~dp0images\sbl1.mbn" || goto :error
echo Flashing sbl2 partition…
fastboot flash sbl2 "%~dp0images\sbl2.mbn" || goto :error
echo Flashing sbl3 partition…
fastboot flash sbl3 "%~dp0images\sbl3.mbn" || goto :error
echo Flashing rpm partition…
fastboot flash rpm "%~dp0images\rpm.mbn" || goto :error
echo Flashing aboot partition…
fastboot flash aboot "%~dp0images\emmc_appsboot.mbn" || goto :error
echo Erasing boot partition…
fastboot erase boot || goto :error1
echo Flashing misc partition…
fastboot flash misc "%~dp0images\misc.img" || goto :error
echo Flashing modem partition…
fastboot flash modem+modem1 "%~dp0images\NON-HLOS.bin" || goto :error
echo Flashing system partition…
fastboot flash system+system1 "%~dp0images\system.img" || goto :error
echo Flashing cache partition…
fastboot flash cache "%~dp0images\cache.img" || goto :error
echo Flashing userdata partition…
fastboot flash userdata "%~dp0images\userdata.img" || goto :error
echo Flashing storage partition…
fastboot flash storage "%~dp0images\storage.img" || goto :error
echo Flashing recovery partition…
fastboot flash recovery "%~dp0images\recovery.img" || goto :error
echo Flashing boot partition…
fastboot flash boot+boot1 boot.img || goto :error
echo.
echo =======================================================================
echo Flashed succesfully! Rebooting device…
echo =======================================================================
fastboot reboot || goto :errorreboot
echo Press ENTER to exit…
pause >nul
exit
:error
color 0C
echo.
echo =======================================================================
echo ERROR: Error during partition flashing!
echo =======================================================================
echo Press ENTER to exit…
pause >nul
exit
:error1
color 0C
echo.
echo =======================================================================
echo ERROR: Error during partition erasing!
echo =======================================================================
echo Press ENTER to exit…
pause >nul
exit
:errorreboot
color 0C
echo.
echo =======================================================================
echo ERROR: Error during rebooting device!
echo =======================================================================
echo Press ENTER to exit…
pause >nul
exit