Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8473a61 authored by Sahil Sonar's avatar Sahil Sonar 💬 Committed by Sahil Sonar
Browse files

flash-scripts: Move teracube devices to S

parent a1a7bb17
Loading
Loading
Loading
Loading
+100 −46
Original line number Diff line number Diff line
@@ -23,22 +23,32 @@


# Exit status
# - 0 : device flashed
# - 1 : generic error
# - 10: can't unpack system.img
# - 11: can't wipe data
# - 12: can't flash boot
# - 13: can't flash recovery
# - 14: can't flash vbmeta
# - 15: can't flash vbmeta_system
# - 16: can't flash vbmeta_vendor
# - 17: can't reboot on fastboot
# - 18: can't flash system
# - 19: can't flash product
# - 20: can't flash vendor
# - 0 : Device flashed successfully
# - 1 : Generic error
# - 10: Error unpacking system.img
# - 11: Error wiping data
# - 12: Error flashing preloader
# - 13: Error flashing lk
# - 14: Error flashing md1img
# - 15: Error flashing logo
# - 16: Error flashing scp1
# - 17: Error flashing scp2
# - 18: Error flashing spmfw
# - 19: Error flashing sspm_1
# - 20: Error flashing sspm_2
# - 21: Error flashing tee1
# - 22: Error flashing tee2
# - 23: Error flashing boot
# - 24: Error flashing dtbo
# - 25: Error flashing recovery
# - 26: Error flashing vbmeta
# - 27: Error flashing vbmeta_system
# - 28: Error flashing vbmeta_vendor
# - 29: Error flashing super
# - 101 : DEVICE_ID missing
# - 102 : ARCHIVE_PATH missing
# - 103 : fastboot folder path missing
# - 103 : Fastboot folder path missing
# - 104 : Java folder path missing

DEVICE_ID=$1
ARCHIVE_PATH=$2
@@ -92,7 +102,7 @@ echo "unpacked archive"
sleep 1

# Wipe user data
if ! "$FASTBOOT_PATH" -w ;
if ! "$FASTBOOT_PATH" erase userdata ;
then
  exit 11
fi
@@ -101,66 +111,110 @@ echo "user data wiped"
sleep 5

# Flash the device
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash boot boot.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash preloader preloader_zirconia.bin ; then
  exit 12
fi
sleep 1
echo "Flashed boot"
echo "Flashed preloader"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash recovery recovery.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash lk lk.img ; then
  exit 13
fi
sleep 1
echo "Flashed recovery"
echo "Flashed lk"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash vbmeta vbmeta.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash md1img md1img.img ; then
  exit 14
fi
sleep 1
echo "Flashed vbmeta"
echo "Flashed md1img"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash vbmeta_system vbmeta_system.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash logo logo.bin ; then
  exit 15
fi
sleep 1
echo "Flashed vbmeta_system"
echo "Flashed logo"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash vbmeta_vendor vbmeta_vendor.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash scp1 scp.img ; then
  exit 16
fi
sleep 1
echo "Flashed vbmeta_vendor"

echo "Flashed scp1"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" reboot fastboot
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash scp2 scp.img ; then
  exit 17
fi
sleep 6
echo "Rebooted on fastboot"
sleep 1
echo "Flashed scp2"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash system system.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash spmfw spmfw.img ; then
  exit 18
fi
sleep 1
echo "Flashed system"
echo "Flashed spmfw"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash product product.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash sspm_1 sspm.img ; then
  exit 19
fi
sleep 1
echo "Flashed product"
echo "Flashed sspm_1"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash vendor vendor.img
then
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash sspm_2 sspm.img ; then
  exit 20
fi
sleep 1
echo "Flashed vendor"
 No newline at end of file
echo "Flashed sspm_2"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash tee1 tee.img ; then
  exit 21
fi
sleep 1
echo "Flashed tee1"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash tee2 tee.img ; then
  exit 22
fi
sleep 1
echo "Flashed tee2"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash boot boot.img ; then
  exit 23
fi
sleep 1
echo "Flashed boot"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash dtbo dtbo.img ; then
  exit 24
fi
sleep 1
echo "Flashed dtbo"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash recovery recovery.img ; then
  exit 25
fi
sleep 1
echo "Flashed recovery"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash vbmeta vbmeta.img ; then
  exit 26
fi
sleep 1
echo "Flashed vbmeta"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash vbmeta_system vbmeta_system.img ; then
  exit 27
fi
sleep 1
echo "Flashed vbmeta_system"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash vbmeta_vendor vbmeta_vendor.img ; then
  exit 28
fi
sleep 1
echo "Flashed vbmeta_vendor"

if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash super super.img ; then
  exit 29
fi
sleep 1
echo "Flashed super"
+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ fi
FASTBOOT_PATH=${FASTBOOT_FOLDER_PATH}"fastboot"

# Lock bootloader
if ! ${FASTBOOT_PATH} flashing lock ;
if ! ${FASTBOOT_PATH} -s $DEVICE_ID flashing lock ;
then
  exit 2
fi
+8 −17
Original line number Diff line number Diff line
@@ -29,14 +29,14 @@
# - 11: can't wipe userdata
# - 12: can't wipe metadata
# - 13: can't active partition
# - 20-30 : see partition_name index below
# - 20-34 : see partition_name index below
# - 101 : DEVICE_ID missing
# - 102 : ARCHIVE_PATH missing
# - 103 : fastboot folder path missing

partition_name=(boot_a dtbo_a vbmeta_a vbmeta_system_a vbmeta_vendor_a super lk_a logo preloader_a)	
partition_image=(boot.img dtbo.img vbmeta.img vbmeta_system.img vbmeta_vendor.img super.img lk.img logo-verified.bin preloader_yk673v6_lwg62_64.bin)
partition_error=(20 21 22 23 24 25 26 27 28)
partition_name=(boot_a dtbo_a vbmeta_a vbmeta_system_a vbmeta_vendor_a super lk_a logo preloader_a tee_a gz_a sspm_a scp_a spmfw_a md1img_a)
partition_image=(boot.img dtbo.img vbmeta.img vbmeta_system.img vbmeta_vendor.img super.img lk.img logo.bin preloader_emerald.bin tee.img gz.img sspm.img scp.img spmfw.img md1img.img)
partition_error=(20 21 22 23 24 25 26 27 28 29 30 31 32 33 34)

DEVICE_ID=$1
ARCHIVE_PATH=$2
@@ -97,14 +97,6 @@ fi
echo "user data wiped"
sleep 5

if ! "$FASTBOOT_PATH" format md_udc ;
then 
  exit 12
fi

echo "format md_udc"
sleep 5

#Flash partition
for i in ${!partition_name[@]}; do
  if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" flash ${partition_name[$i]} ${partition_image[$i]}
@@ -116,8 +108,7 @@ for i in ${!partition_name[@]}; do
done


if ! "$FASTBOOT_PATH" --set-active=a ;
if ! "$FASTBOOT_PATH" -s "$DEVICE_ID" --set-active=a ;
then
  exit 13
fi
+101 −36
Original line number Diff line number Diff line
@@ -19,24 +19,34 @@
:: $3: fastboot folder path
:: $4: Java folder path


:: Exit status
:: - 0 : device flashed
:: - 1 : generic error
:: - 10: can't unpack system.img
:: - 11: can't wipe data
:: - 12: can't flash boot
:: - 13: can't flash recovery
:: - 14: can't flash vbmeta
:: - 15: can't flash vbmeta_systel
:: - 16: can't flash vbmeta_vendor
:: - 17: can't reboot to fastboot
:: - 18: can't flash system
:: - 19: can't flash product
:: - 20: can't flash vendor
:: - 0 : Device flashed successfully
:: - 1 : Generic error
:: - 10: Error unpacking system.img
:: - 11: Error wiping user data
:: - 12: Error flashing preloader
:: - 13: Error flashing lk
:: - 14: Error flashing md1img
:: - 15: Error flashing logo
:: - 16: Error flashing scp1
:: - 17: Error flashing scp2
:: - 18: Error flashing spmfw
:: - 19: Error flashing sspm_1
:: - 20: Error flashing sspm_2
:: - 21: Error flashing tee1
:: - 22: Error flashing tee2
:: - 23: Error flashing boot
:: - 24: Error flashing dtbo
:: - 25: Error flashing recovery
:: - 26: Error flashing vbmeta
:: - 27: Error flashing vbmeta_system
:: - 28: Error flashing vbmeta_vendor
:: - 29: Error flashing super
:: - 30: Error rebooting to system
:: - 101 : DEVICE_ID missing
:: - 102 : ARCHIVE_PATH missing
:: - 103 : fastboot folder path missing
:: - 103 : FASTBOOT_FOLDER_PATH missing
:: - 104 : JAVA_FOLDER_PATH missing

set DEVICE_ID="%1"
set ARCHIVE_PATH=%~2
@@ -80,62 +90,117 @@ echo "unpacked archive"

ping 127.0.0.1 -n 1 -w 10000 >NUL

%FASTBOOT_PATH% -w
%FASTBOOT_PATH% erase userdata
if errorLevel 1 ( exit /b 11 )

echo "user data wiped"

ping 127.0.0.1 -n 5 -w 10000 >NUL

%FASTBOOT_PATH% -s %DEVICE_ID% flash boot boot.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash preloader preloader_zirconia.bin
if errorLevel 1 ( exit /b 12 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed boot"
echo "Flashed preloader"

%FASTBOOT_PATH% -s %DEVICE_ID% flash recovery recovery.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash lk lk.img
if errorLevel 1 ( exit /b 13 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed recovery"
echo "Flashed lk"

%FASTBOOT_PATH% -s %DEVICE_ID% flash vbmeta vbmeta.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash md1img md1img.img
if errorLevel 1 ( exit /b 14 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vbmeta"
echo "Flashed md1img"

%FASTBOOT_PATH% -s %DEVICE_ID% flash vbmeta_system vbmeta_system.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash logo logo.bin
if errorLevel 1 ( exit /b 15 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vbmeta_system"
echo "Flashed logo"

%FASTBOOT_PATH% -s %DEVICE_ID% flash vbmeta_vendor vbmeta_vendor.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash scp1 scp.img
if errorLevel 1 ( exit /b 16 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vbmeta_vendor"
echo "Flashed scp1"

%FASTBOOT_PATH% -s %DEVICE_ID% flash scp2 scp.img
if errorLevel 1 ( exit /b 17 )

%FASTBOOT_PATH% -s %DEVICE_ID% reboot fastboot
ping 127.0.0.1 -n 6 -w 10000 >NUL
echo "Rebooted on fastboot"
ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed scp2"

%FASTBOOT_PATH% -s %DEVICE_ID% flash system system.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash spmfw spmfw.img
if errorLevel 1 ( exit /b 18 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vbmeta_vendor"
echo "Flashed spmfw"

%FASTBOOT_PATH% -s %DEVICE_ID% flash product product.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash sspm_1 sspm.img
if errorLevel 1 ( exit /b 19 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed product"
echo "Flashed sspm_1"

%FASTBOOT_PATH% -s %DEVICE_ID% flash vendor vendor.img
%FASTBOOT_PATH% -s %DEVICE_ID% flash sspm_2 sspm.img
if errorLevel 1 ( exit /b 20 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vendor"
exit /b 0
 No newline at end of file
echo "Flashed sspm_2"

%FASTBOOT_PATH% -s %DEVICE_ID% flash tee1 tee.img
if errorLevel 1 ( exit /b 21 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed tee1"

%FASTBOOT_PATH% -s %DEVICE_ID% flash tee2 tee.img
if errorLevel 1 ( exit /b 22 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed tee2"

%FASTBOOT_PATH% -s %DEVICE_ID% flash boot boot.img
if errorLevel 1 ( exit /b 23 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed boot"

%FASTBOOT_PATH% -s %DEVICE_ID% flash dtbo dtbo.img
if errorLevel 1 ( exit /b 24 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed dtbo"

%FASTBOOT_PATH% -s %DEVICE_ID% flash recovery recovery.img
if errorLevel 1 ( exit /b 25 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed recovery"

%FASTBOOT_PATH% -s %DEVICE_ID% flash vbmeta vbmeta.img
if errorLevel 1 ( exit /b 26 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vbmeta"

%FASTBOOT_PATH% -s %DEVICE_ID% flash vbmeta_system vbmeta_system.img
if errorLevel 1 ( exit /b 27 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vbmeta_system"

%FASTBOOT_PATH% -s %DEVICE_ID% flash vbmeta_vendor vbmeta_vendor.img
if errorLevel 1 ( exit /b 28 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed vbmeta_vendor"

%FASTBOOT_PATH% -s %DEVICE_ID% flash super super.img
if errorLevel 1 ( exit /b 29 )

ping 127.0.0.1 -n 1 -w 10000 >NUL
echo "Flashed super"
+42 −24
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
:: - 11: can't wipe userdata
:: - 12: can't wipe metadata
:: - 13: can't active partition
:: - 20-30 : see partition_name index below
:: - 20-34 : see partition_name index below
:: - 101 : DEVICE_ID missing
:: - 102 : ARCHIVE_PATH missing
:: - 103 : fastboot folder path missing
@@ -43,6 +43,12 @@ SET partition_name[5]=super
SET partition_name[6]=lk_a
SET partition_name[7]=logo
SET partition_name[8]=preloader_a
SET partition_name[9]=tee_a
SET partition_name[10]=gz_a
SET partition_name[11]=sspm_a
SET partition_name[12]=scp_a
SET partition_name[13]=spmfw_a
SET partition_name[14]=md1img_a

SET partition_image[0]=boot.img
SET partition_image[1]=dtbo.img
@@ -51,8 +57,14 @@ SET partition_image[3]=vbmeta_system.img
SET partition_image[4]=vbmeta_vendor.img
SET partition_image[5]=super.img
SET partition_image[6]=lk.img
SET partition_image[7]=logo-verified.img 
SET partition_image[8]=preloader_yk673v6_lwg62_64.img
SET partition_image[7]=logo.bin
SET partition_image[8]=preloader_emerald.img
SET partition_image[9]=tee.img
SET partition_image[10]=gz.img
SET partition_image[11]=sspm.img
SET partition_image[12]=scp.img
SET partition_image[13]=spmfw.img
SET partition_image[14]=md1img.img

SET partition_error[0]=20
SET partition_error[1]=21
@@ -63,6 +75,12 @@ SET partition_error[5]=25
SET partition_error[6]=26
SET partition_error[7]=27
SET partition_error[8]=28
SET partition_error[9]=29
SET partition_error[10]=30
SET partition_error[11]=31
SET partition_error[12]=32
SET partition_error[13]=33
SET partition_error[14]=34

SET DEVICE_ID=%~1
SET ARCHIVE_PATH=%~2
@@ -123,7 +141,7 @@ timeout 5 >nul 2>&1
))

:: Activate
%FASTBOOT_PATH% --set-active=a
%FASTBOOT_PATH% -s %DEVICE_ID% --set-active=a
if errorLevel 1 ( exit /b 13 )
echo "set acivated"
timeout 5 >nul 2>&1
Loading