0% found this document useful (0 votes)
106 views4 pages

Untitled

This document contains a batch script that flashes images to the partitions of a device using fastboot. It gets device information like the platform and current slot. It then flashes images for partitions like the bootloader, Linux kernel, and file system. If specified, it will also erase and lock partitions and perform a factory reset.

Uploaded by

Ferdinan N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views4 pages

Untitled

This document contains a batch script that flashes images to the partitions of a device using fastboot. It gets device information like the platform and current slot. It then flashes images for partitions like the bootloader, Linux kernel, and file system. If specified, it will also erase and lock partitions and perform a factory reset.

Uploaded by

Ferdinan N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

::

:: file create by liunianliang for windows fastboot flash image


::
:: 20180117
::
@echo off
@echo ------------------------
@echo Begin fastboot flashall
@echo ------------------------

@setlocal enabledelayedexpansion

:: get platform
@set platform=sdm636
@set buildtype=eng
@set current-slot=a
@set frp-partition=QHYBSBJk
@set input=%1%
@set deviceId=%2%
@set flashtype=%3%

if !input! == 0 (
@echo Earse Data: No
) else (
@echo Earse Data: Yes
)

if "!deviceId!" == "" (
@echo Support All device !
) else (
@echo Support one device: !deviceId!
)

if "!deviceId!" == "" (
@fastboot getvar platform 2>&1 | findstr platform > %~dp0\platform.txt
@fastboot getvar current-slot 2>&1 | findstr current-slot > %~dp0\current-slot.txt
@fastboot getvar build-type 2>&1 | findstr build-type > %~dp0\build-type.txt
@fastboot getvar secret-key-opt 2>&1 | findstr secret-key-opt > %~dp0\secret-key-
opt.txt
@fastboot oem get_random_partition 2>&1 | findstr bootloader > %~dp0\frp-
partition.txt
) else (
@fastboot -s !deviceId! getvar platform 2>&1 | findstr platform > %~dp0\
platform.txt
@fastboot -s !deviceId! getvar current-slot 2>&1 | findstr current-slot > %~dp0\
current-slot.txt
@fastboot -s !deviceId! getvar build-type 2>&1 | findstr build-type > %~dp0\build-
type.txt
@fastboot -s !deviceId! getvar secret-key-opt 2>&1 | findstr secret-key-opt >
%~dp0\secret-key-opt.txt
@fastboot -s !deviceId! oem get_random_partition 2>&1 | findstr bootloader > %~dp0\
frp-partition.txt
)

@for /f "tokens=2 delims=: " %%i in (%~dp0\current-slot.txt) do @(


set "current-slot=%%i"
@echo current-slot is !current-slot!

@for /f "tokens=2 delims=: " %%a in (%~dp0\build-type.txt) do (


set "buildtype=%%a"
)

@for /f "tokens=2 delims=: " %%n in (%~dp0\platform.txt) do (


set "platform=%%n"
)

@for /f "tokens=2 delims=: " %%k in (%~dp0\secret-key-opt.txt) do (


set "secret_key=%%k"
set /p =!secret_key!<nul> %~dp0\default_key.bin
)

@for /f "tokens=2 delims=: " %%m in (%~dp0\frp-partition.txt) do (


set "frp-partition=%%m"
)

@echo buildtype is !buildtype!


if !buildtype! == user (
if "!deviceId!" == "" (
fastboot flash !frp-partition! %~dp0\default_key.bin
fastboot flashing unlock
fastboot flashing unlock_critical
) else (
fastboot -s !deviceId! flash !frp-partition! %~dp0\default_key.bin
fastboot -s !deviceId! flashing unlock
fastboot -s !deviceId! flashing unlock_critical
)
)

:: partition and file name


call:flash_one_image xbl xbl.elf
call:flash_one_image xblbak xbl.elf
call:flash_one_image tz tz.mbn
call:flash_one_image tzbak tz.mbn
call:flash_one_image rpm rpm.mbn
call:flash_one_image rpmbak rpm.mbn
call:flash_one_image hyp hyp.mbn
call:flash_one_image hypbak hyp.mbn
call:flash_one_image pmic pmic.elf
call:flash_one_image pmicbak pmic.elf
call:flash_one_image boot boot.img
call:flash_one_image system system.img
call:flash_one_image vendor vendor.img
call:flash_one_image keymaster keymaster64.mbn
call:flash_one_image keymasterbak keymaster64.mbn
call:flash_one_image cmnlib cmnlib.mbn
call:flash_one_image cmnlibbak cmnlib.mbn
call:flash_one_image cmnlib64 cmnlib64.mbn
call:flash_one_image cmnlib64bak cmnlib64.mbn
call:flash_one_image mdtpsecapp mdtpsecapp.mbn
call:flash_one_image mdtpsecappbak mdtpsecapp.mbn
call:flash_one_image mdtp mdtp.img
call:flash_one_image mdtpbak mdtp.img
call:flash_one_image modem NON-HLOS.bin
call:flash_one_image dsp dspso.bin
call:flash_one_image abl abl.elf
call:flash_one_image ablbak abl.elf
call:flash_one_image sec sec.dat
call:flash_one_image bluetooth BTFM.bin
call:flash_one_image bluetoothbak BTFM.bin
call:flash_one_image devcfg devcfg.mbn
call:flash_one_image devcfgbak devcfg.mbn
call:flash_one_image storsec storsec.mbn
call:flash_one_image APD APD.img
call:flash_one_image cache cache.img
call:flash_one_image asusfw asusfw.img
call:flash_one_image recovery recovery.img

if !input! == 0 (
@echo not earse data partition...
) else (
call:flash_one_image userdata userdata.img
)

if !buildtype! == user (
if "!deviceId!" == "" (
fastboot flashing lock
fastboot flashing lock_critical
if !flashtype! == tool (
fastboot flash !frp-partition! %~dp0\default_key.bin
)
) else (
fastboot -s !deviceId! flashing lock
fastboot -s !deviceId! flashing lock_critical
if !flashtype! == tool (
fastboot -s !deviceId! flash !frp-partition! %~dp0\default_key.bin
)
)
)

if "!deviceId!" == "" (
if !input! == 0 (
@echo not do factory reset...
) else (
fastboot oem recovery_and_reboot
)
) else (
if !input! == 0 (
@echo not do factory reset...
) else (
fastboot -s !deviceId! oem recovery_and_reboot
)
)
)

@echo All is download


goto:eof

:: function for download


:flash_one_image
@echo --------------------------------
@echo begin to flash partition %1
@if exist %~dp0!platform!_%2 (
if "!deviceId!" == "" (
fastboot flash %1 %~dp0!platform!_%2
) else (
fastboot -s !deviceId! flash %1 %~dp0!platform!_%2
)
) else (
if exist %~dp0%2 (
if "!deviceId!" == "" (
fastboot flash %1 %~dp0%2
) else (
fastboot -s !deviceId! flash %1 %~dp0%2
)
) else (
@echo can't flash partion %1
)
)
@echo done!
@echo --------------------------------

You might also like