Wordclock/tools/initialFlash.sh

73 lines
1.3 KiB
Bash
Raw Normal View History

2016-06-23 18:42:58 +02:00
#!/bin/bash
LUATOOL=./tools/luatool.py
DEVICE=$1
2020-03-06 23:55:14 +01:00
BAUD=115200
2016-06-23 18:42:58 +02:00
2021-01-15 17:45:37 +01:00
# check environment
if [ ! -f $LUATOOL ]; then
echo "$LUATOOL not found"
echo "is the command prompt at the same level as the tools folder ?"
exit 1
fi
2016-06-23 18:42:58 +02:00
# check the serial connection
if [ ! -c $DEVICE ]; then
echo "$DEVICE does not exist"
exit 1
fi
if [ $# -eq 0 ]; then
2016-06-23 18:42:58 +02:00
echo ""
echo "e.g. usage $0 <device> [<files to upoad>]"
2016-06-23 18:42:58 +02:00
exit 1
fi
if [ $# -eq 1 ]; then
2020-03-06 23:55:14 +01:00
FILES="displayword.lua main.lua timecore.lua webpage.html webserver.lua telnet.lua wordclock.lua init.lua"
else
FILES=$2
fi
2018-12-23 21:53:25 +01:00
# Format filesystem first
2020-03-06 23:55:14 +01:00
echo "Format the complete ESP"
$LUATOOL -p $DEVICE -w -b $BAUD
if [ $? -ne 0 ]; then
echo "STOOOOP"
exit 1
fi
2020-03-06 23:55:14 +01:00
#stty -F $DEVICE $BAUD
#echo "Reboot the ESP"
#echo "node.restart()" >> $DEVICE
#sleep 1
#for i in $(seq 0 5); do
# echo "Stop TMR $i"
# echo "tmr.stop($i)" >> $DEVICE
# sleep 1
#done
2020-03-06 23:55:14 +01:00
#echo
echo "Start Flasing ..."
2016-06-23 18:42:58 +02:00
for f in $FILES; do
if [ ! -f $f ]; then
echo "Cannot find $f"
echo "place the terminal into the folder where the lua files are present"
exit 1
fi
echo "------------- $f ------------"
2020-03-06 23:55:14 +01:00
$LUATOOL -p $DEVICE -f $f -b $BAUD -t $f
2016-06-23 18:42:58 +02:00
if [ $? -ne 0 ]; then
echo "STOOOOP"
exit 1
fi
done
echo "Reboot the ESP"
2020-03-04 22:24:13 +01:00
echo "node.restart()" >> $DEVICE
2016-06-23 18:42:58 +02:00
exit 0