Skip to content

Commit

Permalink
Added option to wait for device to be connected (on by default)
Browse files Browse the repository at this point in the history
Script looks for device every two seconds until device is found or script is aborted.
If Ctrl-C is detected script performs cleanup and exits.
  • Loading branch information
Stane1983 committed May 30, 2018
1 parent 07b4d79 commit 15b68b5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions aml-flash
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ destroy=
update_return=
debug=0
simu=0
wait_device=1
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
Expand All @@ -34,6 +35,7 @@ show_help()
echo " --*-file => Force overload of partition files"
echo " --password => Unlock usb mode using password file provided"
echo " --destroy => Erase the bootloader and reset the board"
echo " --no-wait => Do not wait for device to be pluged in"
}

# Check if a given file exists and exit if not
Expand All @@ -59,6 +61,7 @@ cleanup()
}
cleanup_trap()
{
echo -e "\nOperation stopped. Cleaning up..."
cleanup
exit 1
}
Expand Down Expand Up @@ -182,6 +185,9 @@ for opt do
--debug)
debug=1
;;
--no-wait)
wait_device=0
;;
*)
if [[ ${opt%=*} == "--"*"-file" ]]; then
newvar=`echo ${opt%=*} | sed 's/--//' | sed 's/-file/_file/'`
Expand Down Expand Up @@ -215,18 +221,28 @@ if [[ "$soc" != "gxl" ]] && [[ "$soc" != "axg" ]] && [[ "$soc" != "txlx" ]] && [
echo "Soc type is invalid, should be either gxl,axg,txlx,m8"
exit 1
fi

# Set trap
# --------
trap cleanup_trap SIGHUP SIGINT SIGTERM

run_update_return identify 7
if [[ "$simu" != "1" ]]; then
if ! `echo $update_return | grep -iq firmware`; then
echo "Amlogic device not found"
exit 1
if [[ "$wait_device" != "1" ]]; then
echo "Amlogic device not found"
exit 1
else
echo "Waiting for Amlogic device to be connected..."
while [ ! `echo $update_return | grep -iq firmware` ]
do
sleep 2
run_update_return identify 7
done
fi
fi
fi

# Set trap
# --------
trap cleanup_trap SIGHUP SIGINT SIGTERM

# Check if the board is locked with a password
# --------------------------------------------
need_password=0
Expand Down

0 comments on commit 15b68b5

Please sign in to comment.