Skip to content

Commit

Permalink
Process rewrited
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariCalyx authored Apr 7, 2019
1 parent b351092 commit dfe607d
Showing 1 changed file with 174 additions and 75 deletions.
249 changes: 174 additions & 75 deletions FlashingScript/generic_flash_script_gsi_sdm660_64.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ echo.
echo Initializing...
rem Navigating these partitions
dir /b > list.txt
if exist modem.img goto otaflashinginit
if exist prcsd.hikaricalyx goto otaflashinginitd
if exist modem.img goto otaflashinginitd
if exist payload.bin goto otaflashingbefore
:returnx
findstr "gpt_both0.bin" list.txt > tmp.txt
Expand All @@ -29,7 +30,7 @@ findstr "hyp.mbn" list.txt > tmp.txt
set /p hyp_sdm660=<tmp.txt
findstr "pmic.elf" list.txt > tmp.txt
set /p pmic_sdm660=<tmp.txt
findstr "keymaster64.mbn" list.txt > tmp.txt
findstr "keymaster.mbn keymaster64.mbn" list.txt > tmp.txt
set /p keymaster_sdm660=<tmp.txt
findstr "cmnlib.mbn" list.txt > tmp.txt
set /p cmnlib_sdm660=<tmp.txt
Expand Down Expand Up @@ -82,6 +83,9 @@ set /p logfs_sdm660=<tmp.txt
del list.txt
del tmp.txt
:normal
if "%xconfirm%"=="a" cls
echo.
echo Current flashing mode: stock firmware
echo.
echo Hi there! This script is designed for flashing FIH gsi_sdm660_64 devices
echo back to factory stock without using OST LA.
Expand Down Expand Up @@ -119,7 +123,7 @@ set /p actprojectcode=<tmp.txt
del tmp.txt
echo.
echo Your Phone's serial number is %devsn:~0,16% and the Project Code is %actprojectcode:~0,3%.
if %otapackagemode% equ 1 goto pass
rem goto pass
echo The firmware itself is used for %fwprojectcode:~0,3%.
echo.
if "%actprojectcode%"=="%fwprojectcode%" goto pass
Expand All @@ -132,7 +136,9 @@ pause>nul
cls
echo.
echo Your Phone's serial number is %devsn:~0,16% and the Project Code is %actprojectcode:~0,3%.
if %errorlevel% neq 0 echo The firmware itself is used for %fwprojectcode:~0,3%.
rem goto otapm2
echo The firmware itself is used for %fwprojectcode:~0,3%.
:otapm2
echo.
fastboot oem getversions
echo.
Expand All @@ -147,7 +153,7 @@ pause>nul
echo.
echo Flashing critical partitions...
echo.
if %otapackagemode% equ 1 goto otaflashing
rem goto otaflashing
fastboot flash partition %partition_sdm660%
if %errorlevel% equ 1 goto errorcritical
fastboot flash xbl_a %xbls_sdm660%
Expand All @@ -171,7 +177,8 @@ fastboot reboot-bootloader
echo.
echo Please wait while phone is rebooting...
echo.
fastboot oem alive>nul
ping 127.0.0.1 -n 2 >nul
fastboot oem alive
:normal2
echo.
echo Flashing non-critical partitions...
Expand All @@ -185,12 +192,13 @@ echo.
echo Flashing system partition, please wait...
echo.
fastboot flash system_a %systema_sdm660%
if %otapackagemode% equ 1 goto otaflashing2
rem goto otaflashing2
fastboot flash system_b %systemb_sdm660%
fastboot flash bluetooth_a %bluetooth_sdm660%
fastboot flash persist %persist_sdm660%
if "%econfirm%"=="yes" fastboot format userdata
fastboot flash sutinfo %sutinfo_sdm660%
fastboot flash hwcfg %hwcfg_sdm660%
fastboot flash nvdef_a %nvdef_sdm660%
fastboot flash hidden_a %hidden_sdm660%
fastboot flash cda_a %cda_sdm660%
Expand All @@ -199,17 +207,31 @@ if "%econfirm%"=="yes" fastboot erase misc
if "%econfirm%"=="yes" fastboot erase sti
fastboot flash splash_a %splash_sdm660%
fastboot flash splash2 %splash2_sdm660%
if "%vendor_sdm660%"=="" goto nougat1
fastboot flash vendor_a %vendor_sdm660%
:nougat1
if "%econfirm%"=="yes" fastboot erase ddr
fastboot flash xbl_a %xbl_sdm660%
fastboot flash xbl_b %xbl_sdm660%
fastboot flash abl_a %abl_sdm660%
fastboot flash abl_b %abl_sdm660%
fastboot oem set_active _a
fastboot oem enable-charger-screen
if "%logfs_sdm660%"=="" goto nougat2
fastboot flash logfs %logfs_sdm660%
echo Verifying flashing result, please wait...
:nougat2
if "%fwprojectcode:~0,3%"=="SS2" goto sharp
if "%fwprojectcode:~0,3%"=="SAT" goto sharp
if "%fwprojectcode:~0,3%"=="HH1" goto sharp
if "%fwprojectcode:~0,3%"=="SD1" goto sharp
if "%fwprojectcode:~0,3%"=="SG1" goto sharp
:aftersharp
if exist md4.dat (
echo.
if exist md4.dat echo Verifying flashing result, please wait...
echo.
fastboot flash md4 md4.dat
)
:normal3
fastboot reboot
echo All done! Press any key to exit.
Expand Down Expand Up @@ -263,6 +285,7 @@ echo Otherwise press Enter Key with nothing typed will ignore the payload.bin.
echo.
set /p econfirm=
if "%econfirm%"=="yes" goto startdump
set xconfirm=a
goto returnx
:startdump
set econfirm=
Expand All @@ -280,12 +303,14 @@ echo.
echo ERROR: Your PC doesn't have Python 3 installed. Therefore the payload dumping will be skipped.
echo.
pause
cls
goto returnx

:pdumperexe
echo.
payload_dumper payload.bin
if %errorlevel% neq 0 goto errorscript2
set xconfirm=1
goto otaflashinginitd

:errornoscript
Expand All @@ -294,6 +319,7 @@ echo ERROR: You didn't put both scripts to the same directory of this script.
echo Therefore the payload dumping will be skipped.
echo.
pause
cls
goto returnx

:errorscript2
Expand All @@ -302,84 +328,157 @@ echo ERROR: The script didn't process the payload.bin well.
echo Therefore the payload dumping will be skipped.
echo.
pause
cls
goto returnx

:otaflashinginitd
if exist flashit.cmd del /q flashit.cmd
echo.
echo Processed payload.bin image files found.
echo.
:otaflashinginit
echo Current flashing mode: payload as fastboot images
echo.
echo Hi there! This script is designed for flashing FIH gsi_sdm660_64 devices
echo back to factory stock without using OST LA.
echo.
echo Unpacked OTA package detected.
echo Made by Hikari Calyx and written for following models:
echo Nokia 6.1 PL2, Nokia 6.1 Plus X6 DRG, Nokia 7 C1N, Nokia 7.1 CTL, Nokia 7 Plus B2N,
echo Sharp Aquos C10 S2 SS2-SAT, Sharp Aquos S3mini SG1, Sharp Aquos S3 HH1-SD1.
echo.
echo Please type lowercase "yes" to confirm, then press Enter Key to proceed.
echo Please choose a slot you wish to flash. ( a / b )
echo.
:reselectslot
set /p cslot=
if %cslot%==A set wslot=a&goto chosenx
if %cslot%==B set wslot=b&goto chosenx
if %cslot%==a set wslot=a&goto chosenx
if %cslot%==b set wslot=b&goto chosenx
echo.
echo Incorrect slot, please type again. ( a / b )
echo.
goto reselectslot
:chosenx
echo.
echo Generating flashing script...
echo.
dir /b *.img > list.txt
for /f "delims=." %%i in (list.txt) do set "%%i=%%i.img"&echo fastboot flash %%i_%wslot% %%i.img>>flashit.cmd
del list.txt
if not exist vendor.img.ext4 ren system.img system.img.ext4
if not exist vendor.img.ext4 ren vendor.img vendor.img.ext4
if not exist system.img echo Converting system image to sparse, please wait...
if not exist system.img img2simg system.img.ext4 system.img
if not exist vendor.img echo Converting vendor image to sparse, please wait...
if not exist vendor.img img2simg vendor.img.ext4 vendor.img
echo DO NOT DELETE ME > prcsd.hikaricalyx
goto reflash

:reflash
cls
echo.
echo Otherwise press Enter Key with nothing typed will ignore the unpacked OTA.
echo The payload.bin is already processed.
echo.
echo Please connect your powered off phone or phone that entered Fastboot mode
fastboot oem alive
cls
fastboot devices > tmp.txt
set /p devsn=<tmp.txt
echo %devsn:~0,16% > tmp.txt
set /p devsn=<tmp.txt
echo %devsn:~0,3% > tmp.txt
set /p actprojectcode=<tmp.txt
del tmp.txt
echo.
echo Your Phone's serial number is %devsn:~0,16% and the Project Code is %actprojectcode:~0,3%.
echo.
echo Do you wish to erase userdata while flashing?
echo.
echo.Userdata erasing will not erase FRP lock.
echo.
echo.Please type lowercase "yes" to confirm erasing, then press Enter Key to proceed.
echo.
echo.Otherwise, press Enter Key will skip userdata erasing.
echo.
set /p econfirm=
cls
echo.
if "%econfirm%"=="yes" goto n3
goto returnx
:n3
echo Your Phone's serial number is %devsn:~0,16% and the Project Code is %actprojectcode:~0,3%.
echo.
fastboot oem getversions
echo.
fastboot oem device-info
echo.
echo Please check information above.
echo If your phone is unlocked, press any key to proceed.
pause>nul
echo.
echo Flashing, please wait...
echo.
call flashit.cmd
if %errorlevel% equ 1 goto errorunlock
if "%econfirm%"=="yes" goto erasing
:flashdone
set econfirm=
:otaflashinginitd
if not exist new_system.img echo Converting system image to sparse, please wait...
if not exist new_system.img img2simg system.img new_system.img
if not exist new_vendor.img echo Converting vendor image to sparse, please wait...
if not exist new_vendor.img img2simg vendor.img new_vendor.img
set abl_sdm660=abl.img
set bluetooth_sdm660=bluetooth.img
set boot_sdm660=boot.img
set cmnlib_sdm660=cmnlib.img
set cmnlib64_sdm660=cmnlib64.img
set devcfg_sdm660=devcfg.img
set dsp_sdm660=dsp.img
set hidden_sdm660=hidden.img
set hyp_sdm660=hyp.img
set keymaster_sdm660=keymaster.img
set mdtp_sdm660=mdtp.img
set mdtpsecapp_sdm660=mdtpsecapp.img
set modem_sdm660=modem.img
set nvdef_sdm660=nvdef.img
set pmic_sdm660=pmic.img
set rpm_sdm660=rpm.img
set splash_sdm660=splash.img
set systema_sdm660=new_system.img
set systeminfo_sdm660=systeminfo.img
set tz_sdm660=tz.img
set vendor_sdm660=new_vendor.img
set xbl_sdm660=xbl.img
set otapackagemode=1
goto normal
echo.
echo.Flashing done.
echo.
echo Do you want to switch to slot %cslot% right now?
echo.
echo.Please type lowercase "yes" to confirm erasing, then press Enter Key to proceed.
echo.
echo.Otherwise, press Enter Key will only reboot your phone.
echo.
set /p econfirm=
if "%econfirm%"=="yes" fastboot --set-active=%wslot%
if "%econfirm%"=="yes" fastboot --set-active=_%wslot%
fastboot reboot
echo.
echo All done. Press any key to exit.
echo.
pause>nul
goto EOF

:otaflashing
fastboot flash xbl_a %xbl_sdm660%
if %errorlevel% equ 1 goto errorcritical
fastboot flash xbl_b %xbl_sdm660%
fastboot flash abl_a %abl_sdm660%
fastboot flash abl_b %abl_sdm660%
fastboot flash tz_a %tz_sdm660%
fastboot flash rpm_a %rpm_sdm660%
fastboot flash hyp_a %hyp_sdm660%
fastboot flash pmic_a %pmic_sdm660%
fastboot flash keymaster_a %keymaster_sdm660%
fastboot flash cmnlib_a %cmnlib_sdm660%
fastboot flash cmnlib64_a %cmnlib64_sdm660%
fastboot flash dsp_a %dsp_sdm660%
fastboot flash devcfg_a %devcfg_sdm660%
fastboot flash mdtpsecapp_a %mdtpsecapp_sdm660%
fastboot flash systeminfo_a %systeminfo_sdm660%
goto normal2
:erasing
echo.
echo Erasing userdata...
echo.
fastboot format userdata
fastboot erase ssd
fastboot erase misc
fastboot erase sti
fastboot erase ddr
goto flashdone

:otaflashing2
fastboot flash bluetooth_a %bluetooth_sdm660%
if "%econfirm%"=="yes" fastboot format userdata
fastboot flash nvdef_a %nvdef_sdm660%
fastboot flash hidden_a %hidden_sdm660%
if "%econfirm%"=="yes" fastboot erase ssd
if "%econfirm%"=="yes" fastboot erase misc
if "%econfirm%"=="yes" fastboot erase sti
fastboot flash splash_a %splash_sdm660%
fastboot flash vendor_a %vendor_sdm660%
if "%econfirm%"=="yes" fastboot erase ddr
fastboot oem set_active _a
fastboot oem enable-charger-screen
goto normal3
:sharp
echo.
echo Sharp Aquos Phone flashing detected.
echo.
echo.To ensure the flashing result will pass, the script will also flash every partitions in slot B.
echo.
ping 127.0.0.1 -n 2 >nul
fastboot flash tz_b %tz_sdm660%
fastboot flash rpm_b %rpm_sdm660%
fastboot flash hyp_b %hyp_sdm660%
fastboot flash pmic_b %pmic_sdm660%
fastboot flash keymaster_b %keymaster_sdm660%
fastboot flash cmnlib_b %cmnlib_sdm660%
fastboot flash cmnlib64_b %cmnlib64_sdm660%
fastboot flash dsp_b %dsp_sdm660%
fastboot flash devcfg_b %devcfg_sdm660%
fastboot flash mdtpsecapp_b %mdtpsecapp_sdm660%
fastboot flash systeminfo_b %systeminfo_sdm660%
fastboot flash modem_b %modem_sdm660%
fastboot flash mdtp_b %mdtp_sdm660%
fastboot flash boot_b %boot_sdm660%
fastboot flash bluetooth_b %bluetooth_sdm660%
fastboot flash nvdef_b %nvdef_sdm660%
fastboot flash hidden_b %hidden_sdm660%
fastboot flash cda_b %cda_sdm660%
fastboot flash splash_b %splash_sdm660%
if "%vendor_sdm660%"=="" goto aftersharp
fastboot flash vendor_b %vendor_sdm660%
echo.
goto aftersharp

:EOF

0 comments on commit dfe607d

Please sign in to comment.