2015-11-25 11:32:55 +01:00
|
|
|
#!/bin/bash
|
2016-02-18 12:02:44 +01:00
|
|
|
haveSerial=false
|
|
|
|
serial=""
|
|
|
|
function usage {
|
|
|
|
echo -e "Usage: $(basename $0) [-s serialNumber] [IMGLIST]"
|
|
|
|
echo -e " IMGLIST is a list of file in .img separated by space"
|
|
|
|
echo -e " If no IMGLIST provied all the .img in the current directory will be flashed"
|
|
|
|
echo -e " e.g. $(basename $0) -s 132456789 out/target/device/boot.img out/target/device/system.img"
|
|
|
|
}
|
|
|
|
|
|
|
|
while getopts ":s:" opt; do
|
|
|
|
case $opt in
|
|
|
|
s) echo "Using Serial $OPTARG"
|
|
|
|
serial=$OPTARG
|
|
|
|
haveSerial=true
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( OPTIND - 1 ))
|
|
|
|
|
2015-11-25 11:32:55 +01:00
|
|
|
if [ $# -eq 0 ];
|
|
|
|
then
|
|
|
|
imgList=$(ls *.img)
|
2016-02-18 12:02:44 +01:00
|
|
|
echo "Flashing all images in current path $imgList"
|
2015-11-25 11:32:55 +01:00
|
|
|
else
|
|
|
|
imgList=$@
|
|
|
|
echo "Flashing $imgList"
|
|
|
|
fi
|
|
|
|
if [ -z "$imgList" ];
|
|
|
|
then
|
|
|
|
echo "No img to Flash"
|
|
|
|
exit 1
|
|
|
|
else
|
2016-02-18 12:02:44 +01:00
|
|
|
echo "Reboot device in fastboot"
|
|
|
|
if $haveSerial ; then
|
|
|
|
adb -s $serial reboot bootloader;
|
|
|
|
else
|
|
|
|
adb reboot bootloader;
|
|
|
|
fi
|
|
|
|
echo "Flashing images"
|
|
|
|
for img in $imgList; do
|
|
|
|
imageName=$(basename $img)
|
|
|
|
imageName=${imageName%.img}
|
|
|
|
if $haveSerial ; then
|
|
|
|
fastboot -s $serial -S 256M flash ${imageName} $img;
|
|
|
|
else
|
|
|
|
fastboot -S 256M flash ${imageName} $img;
|
|
|
|
fi
|
|
|
|
done && fastboot reboot
|
2015-11-25 11:32:55 +01:00
|
|
|
fi
|