Source
userdatasize=`./fastboot getvar userdata_size 2>&1 | grep "userdata_size" | awk '{print$2}'`
usage ()
{
echo "Usage: sudo fastboot.sh <options>";
echo "options:";
echo " --help Show this message and exit"
echo " --revg Flashes the dtb required for Rev-G J6 EVm which has 10inch panel";
exit 1;
}
#no args case
if [ "$1" = "--help" ] ; then
usage
fi
# Pre-packaged DB
export FASTBOOT=${FASTBOOT-"./fastboot"}
export PRODUCT_OUT=${PRODUCT_OUT-"./"}
echo "Fastboot: $FASTBOOT"
echo "Image location: $PRODUCT_OUT"
# =============================================================================
# pre-run
# =============================================================================
# Verify fastboot program is available
# Verify user permission to run fastboot
# Verify fastboot detects a device, otherwise exit
if [ -f ${FASTBOOT} ]; then
fastboot_status=`${FASTBOOT} devices 2>&1`
if [ `echo $fastboot_status | grep -wc "no permissions"` -gt 0 ]; then
cat <<-EOF >&2
-------------------------------------------
Fastboot requires administrator permissions
Please run the script as root or create a
fastboot udev rule, e.g:
% cat /etc/udev/rules.d/99_android.rules
SUBSYSTEM=="usb",
SYSFS{idVendor}=="0451"
OWNER="<username>"
GROUP="adm"
-------------------------------------------
EOF
exit 1
elif [ "X$fastboot_status" = "X" ]; then
echo "No device detected. Please ensure that" \
"fastboot is running on the target device"
exit -1;
else
device=`echo $fastboot_status | awk '{print$1}'`
echo -e "\nFastboot - device detected: $device\n"
fi
else
echo "Error: fastboot is not available at ${FASTBOOT}"
exit -1;
fi
## poll the board to find out its configuration
#product=`${FASTBOOT} getvar product 2>&1 | grep product | awk '{print$2}'`