Skip to content

Instantly share code, notes, and snippets.

@delphym
Last active January 22, 2019 19:37
Show Gist options
  • Save delphym/2079545c6ba8b30e1284393812116242 to your computer and use it in GitHub Desktop.
Save delphym/2079545c6ba8b30e1284393812116242 to your computer and use it in GitHub Desktop.
Random handy stuff
#!/bin/sh
## Script location: https://gist.github.com/delphym/2079545c6ba8b30e1284393812116242#file-flashall-sh
## For flashing full Android and our images to the device
AMSSROOT=AMSS
ANDROIDROOT=Android
ls -1 -I "*.txt" -I "*.md5" | awk -F'.' '{print "fastboot flash "$1" "$1"."$2}' [17:16:26]
fastboot flash dsp $AMSSROOT/adspso.bin
fastboot flash bluetooth $AMSSROOT/BTFM.bin
fastboot flash cmnlib $AMSSROOT/cmnlib.mbn
fastboot flash cmnlib64 $AMSSROOT/cmnlib64.mbn
fastboot flash hyp $AMSSROOT/hyp.mbn
fastboot flash keymaster $AMSSROOT/keymaster64.mbn
fastboot flash mdtp $AMSSROOT/mdtp.img
fastboot flash modem $AMSSROOT/NON-HLOS.bin
fastboot flash pmic $AMSSROOT/pmic.elf
fastboot flash rpm $AMSSROOT/rpm.mbn
#fastboot flash sec $AMSSROOT/sec.dat
fastboot flash tz $AMSSROOT/tz.mbn
#fastboot flash xbl $AMSSROOT/xbl.elf
#fastboot flash aboot $AMSSROOT/emmc_appsboot.mbn
#fastboot flash reserve $AMSSROOT/sig.bin
#fastboot flash splash $AMSSROOT/trimble_logo.img
fastboot reboot bootloader
ls -1 -I "*.txt" -I "*.md5" | awk -F'.' '{print "fastboot flash "$1" "$1"."$2}'
fastboot flash boot $ANDROIDROOT/boot.img
fastboot flash bootloder $ANDROIDROOT/bootloder.img
fastboot flash cache $ANDROIDROOT/cache.img
fastboot flash persist $ANDROIDROOT/persist.img
fastboot flash recovery $ANDROIDROOT/recovery.img
fastboot flash system $ANDROIDROOT/system.img
fastboot flash userdata $ANDROIDROOT/userdata.img
fastboot flash vendor $ANDROIDROOT/vendor.img
#!/bin/bash
## Script location: https://gist.github.com/delphym/2079545c6ba8b30e1284393812116242#file-otira-fastboot-sh
TMP_SH=`tempfile -p otira- -s .sh`
FSB_DIR="./FSB1"
OLD_PWD=`pwd`
#!/bin/bash
## Script location: https://gist.github.com/delphym/2079545c6ba8b30e1284393812116242#file-otira-fastboot-sh
TMP_SH=`tempfile -p otira- -s .sh`
FSB_DIR="./FSB1"
OLD_PWD=`pwd`
echo "LIST of DEVICES in ADB mode:"; adb devices -l
echo "LIST of DEVICES in FASTBOOT mode:"; fastboot devices -l
adbRebootBootloader () {
for adev in $(adb devices -l | grep -v devices | cut -d' ' -f 1); do
adb -s $adev reboot bootloader
done
}
echo "Would you like to boot into 'Fastboot Mode'?"
select answer in "Yes" "No" "Cancel"; do
case $answer in
Yes ) echo -e "BOOTING INTO FASTBOOT MODE\n";
adbRebootBootloader; break;;
No ) echo -e "CARRYING WITH FASTBOOT FLASHING\n"; break;;
* ) echo -e "EXITING FLASHING PROCEDURE\n"; exit;;
esac
done
if [[ -e $1 && "${1##*.}" = "tgz" ]]; then
mkdir -p $FSB_DIR
echo "UNTARing FSB IMAGES...."
tar xzvf $1 -C $FSB_DIR
cd $FSB_DIR
fi
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
echo "LIST of DEVICES in ADB mode:"; adb devices -l
echo "LIST of DEVICES in FASTBOOT mode:"; fastboot devices -l
sleep 5
## Perform operation on each device
for adev in $(fastboot devices -l | grep -v devices | cut -d' ' -f 1); do
echo -e "UNLOCKING THE DEVICE $adev..."
fastboot -s $adev oem unlock
fastboot -s $adev flashing unlock
sleep 5
fastboot devices -l
fastboot -s $adev -w
echo -ne '\n\007' ## Make beep sound
read -t 20 -p "Would you like wipe userdata (Yes/No) (default Yes)? " answer
if [[ $answer = "Yes" || -z $answer ]]; then
echo -e "FASTBOOT Wiping userdata NOW...\n"
fastboot -s $adev -w
fi
echo -e "\nFLASHING FOLLOWING OS IMAGES on $adev device:"
echo "#!/bin/bash" > $TMP_SH
ls -1 -I "*.txt" -I "*.md5" | awk -F'.' '{print "fastboot -s '$adev' flash "$1" "$1"."$2}' | tee -a $TMP_SH
. $TMP_SH; echo $TMP_SH
rm -v $TMP_SH
echo "DONE with flash on $adev device."
echo -ne '\n\007' ## Make beep sound
read -t 20 -p "Would you like FASTBOOT REBOOT (Yes/No) (default Yes)? " answer
if [[ $answer = "Yes" || -z $answer ]]; then
echo -e "FASTBOOT REBOOT NOW...\n"
fastboot -s $adev reboot
fi
echo "RUN FOLLOWING COMMANDS from ADB shell:"
echo "adb -s $adev wait-for-device root && adb -s $adev wait-for-device shell"
echo "getprop | grep finger"
echo "logcat"
done
if [ $OLD_PWD != `pwd` ]; then
cd $OLD_PWD
echo -ne '\n\007' ## Make beep sound
read -t 20 -p "Would you like DELETE UNPACK FSB IMAGES (Yes/No) (default No)? " answer
if ! [[ $answer = "No" || -z $answer ]]; then
echo "DELETING FSB IMAGES..."
rm -rfv $(readlink -e $FSB_DIR)
fi
fi
echo "LIST of DEVICES in ADB mode:"; adb devices -l
echo "LIST of DEVICES in FASTBOOT mode:"; fastboot devices -l
adbRebootBootloader () {
for adev in $(adb devices -l | grep -v devices | cut -d' ' -f 1); do
adb -s $adev reboot bootloader
done
}
echo "Would you like to boot into 'Fastboot Mode'?"
select answer in "Yes" "No" "Cancel"; do
case $answer in
Yes ) echo -e "BOOTING INTO FASTBOOT MODE\n";
adbRebootBootloader; break;;
No ) echo -e "CARRYING WITH FASTBOOT FLASHING\n"; break;;
* ) echo -e "EXITING FLASHING PROCEDURE\n"; exit;;
esac
done
if [[ -e $1 && "${1##*.}" = "tgz" ]]; then
mkdir -p $FSB_DIR
echo "UNTARing FSB IMAGES...."
tar xzvf $1 -C $FSB_DIR
cd $FSB_DIR
fi
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
echo "LIST of DEVICES in ADB mode:"; adb devices -l
echo "LIST of DEVICES in FASTBOOT mode:"; fastboot devices -l
sleep 5
## Perform operation on each device
for adev in $(fastboot devices -l | grep -v devices | cut -d' ' -f 1); do
echo -e "UNLOCKING THE DEVICE $adev..."
fastboot -s $adev oem unlock
fastboot -s $adev flashing unlock
sleep 5
fastboot devices -l
fastboot -s $adev -w
echo -ne '\n\007' ## Make beep sound
read -t 20 -p "Would you like wipe userdata (Yes/No) (default Yes)? " answer
if [[ $answer = "Yes" || -z $answer ]]; then
echo -e "FASTBOOT Wiping userdata NOW...\n"
fastboot -s $adev -w
fi
echo -e "\nFLASHING FOLLOWING OS IMAGES on $adev device:"
echo "#!/bin/bash" > $TMP_SH
ls -1 -I "*.txt" -I "*.md5" | awk -F'.' '{print "fastboot -s '$adev' flash "$1" "$1"."$2}' | tee -a $TMP_SH
. $TMP_SH; echo $TMP_SH
rm -v $TMP_SH
echo "DONE with flash on $adev device."
echo -ne '\n\007' ## Make beep sound
read -t 20 -p "Would you like FASTBOOT REBOOT (Yes/No) (default Yes)? " answer
if [[ $answer = "Yes" || -z $answer ]]; then
echo -e "FASTBOOT REBOOT NOW...\n"
fastboot -s $adev reboot
fi
echo "RUN FOLLOWING COMMANDS from ADB shell:"
echo "adb -s $adev wait-for-device root && adb -s $adev wait-for-device shell"
echo "getprop | grep finger"
echo "logcat"
done
if [ $OLD_PWD != `pwd` ]; then
cd $OLD_PWD
echo -ne '\n\007' ## Make beep sound
read -t 20 -p "Would you like DELETE UNPACK FSB IMAGES (Yes/No) (default No)? " answer
if ! [[ $answer = "No" || -z $answer ]]; then
echo "DELETING FSB IMAGES..."
rm -rfv $(readlink -e $FSB_DIR)
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment