@ECHO OFF
REM Version: V04
REM Date: 150625
REM ============== USAGE ==============
REM flashall_AFT.cmd [Format option] [SN number]
REM [Format option]: 1=enable, 0=disable. default=0
REM Format userdata/cache
REM [SN number]: device SN number
REM Support multiple download image
REM ============== setting ==============
SETLOCAL
IF "%selfWrapped%"=="" (
REM this is necessary so that we can use "exit" to terminate the batch file,
REM and all subroutines, but not the original cmd.exe
SET selfWrapped=true
%ComSpec% /s /c ""%~0" %*"
GOTO :EOF
)
REM ============== main() ==============
CLS
SET "dataerase=0"
SET "SSN="
SET "para="
SET "tempSysName=.system_tmp.img"
IF %1 EQU 1 ( SET dataerase=1 )
IF NOT [%2] EQU [] ( SET para=-s )
IF NOT [%2] EQU [] (
SET SSN=%2
SET tempSysName=.system_tmp_%2.img
)
call:flash
EXIT 0
REM ============== flash() ==============
:flash
SET "RAW="
FOR /F "delims=" %%i IN ('dir "%~dp0" /B ^| findstr /I "raw"') DO ( SET RAW=%%i )
IF NOT EXIST "%RAW%" ECHO "FAILED, RAW NOT EXIST!" && EXIT 1
ECHO.
ECHO ##################################################################
ECHO ####################### FLASH RAW FILE ########################
ECHO ##################################################################
ECHO.
ECHO ## RAW: %RAW%
ECHO ## ERASE DATA: %dataerase%
ECHO ## SSN: %SSN%
ECHO.
ECHO ===================================================================
call:fastboot_tool flash all "%RAW%"
call:fastboot_tool reboot-bootloader
REM timeout /T 10
ping 127.0.0.1 -n 10 > null
IF %dataerase% EQU 1 (
call:fastboot_tool -w
call:fastboot_tool erase apdp
call:fastboot_tool erase msadp
call:fastboot_tool format asdf
call:fastboot_tool format ADF
)
call:fastboot_tool oem adb_enable
IF EXIST %tempSysName% DEL %tempSysName%
ECHO.
ECHO ##################################################################
ECHO ################## FLASH COMPLETE. RESTART! ###################
ECHO ##################################################################
ECHO.
GOTO:EOF
REM ============== fastboot_tool() ==============
:fastboot_tool
ECHO [command] : fastboot.exe %~1 %~2 %~3 %~4 %para% %SSN%
fastboot.exe %~1 %~2 %~3 %~4 %para% %SSN%
IF NOT %ERRORLEVEL% == 0 (
ECHO "FAILED, fastboot.exe %~1 %~2 %~3 %~4 %para% %SSN% failure, EXIT!"
IF EXIST %tempSysName% DEL %tempSysName%
EXIT 1
)
ECHO ===================================================================
GOTO:EOF
:END