Skip to content

Instantly share code, notes, and snippets.

@Senorsen
Last active August 11, 2016 09:28
Show Gist options
  • Save Senorsen/7024c35fbe05b32f940bfcb0792fa815 to your computer and use it in GitHub Desktop.
Save Senorsen/7024c35fbe05b32f940bfcb0792fa815 to your computer and use it in GitHub Desktop.
Flash Nexus Device (especially approriate for unlocked & rooted devices)
#!/bin/sh
# Author: Senorsen <senorsen.zhang@gmail.com>
# Prerequisites: adb, fastboot, unzip
# Flash Nexus Device (especially approriate for unlocked & rooted devices), which cannot be upgraded with OTA
# First download nexus factory image from:
# https://developers.google.com/android/nexus/images
set -e
FILE="$1"
echo "Upgrade my Nexus device..."
if [ "x" = "x$FILE" ]; then
echo "Filename cannot be null"
echo "Usage: $0 <filename>"
exit 1
fi
echo
echo "Filename: $FILE"
echo
tar xzvf $FILE
ENTRY=$(echo $FILE | sed 's/-factory.*$//')
echo
echo "Entry: $ENTRY"
echo
cd $ENTRY
fastboot flash bootloader bootloader*.img
fastboot reboot-bootloader
sleep 5
fastboot flash radio radio-*.img
fastboot reboot-bootloader
sleep 5
unzip -o image-$ENTRY.zip
fastboot flash boot boot.img
fastboot flash cache cache.img
fastboot flash system system.img
fastboot flash vendor vendor.img
# If you need flash recovery image, uncomment the line below
#fastboot flash recovery recovery.img
echo
echo "It seems that everything is done!"
echo "(If you need root) Download SuperSU BETA version from: http://forum.xda-developers.com/apps/supersu"
echo "And install it use your TWRP recovery, ADB Sideload blah blah blah..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment