2014-03-17 09:04:51 -04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2014-04-05 12:16:00 -04:00
|
|
|
# This script loops doing the following:
|
|
|
|
# - wait for DFU device
|
|
|
|
# - flash DFU device
|
|
|
|
# - wait for DFU to exit
|
|
|
|
# - wait for serial port to appear
|
|
|
|
# - run a terminal
|
|
|
|
|
|
|
|
SERIAL=/dev/ttyACM0
|
2014-03-17 09:04:51 -04:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
echo "waiting for DFU device..."
|
|
|
|
while true; do
|
|
|
|
if lsusb | grep -q DFU; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1s
|
|
|
|
done
|
2014-04-05 12:16:00 -04:00
|
|
|
|
2014-03-17 09:04:51 -04:00
|
|
|
echo "found DFU device, flashing"
|
|
|
|
dfu-util -a 0 -D build/flash.dfu
|
2014-04-05 12:16:00 -04:00
|
|
|
|
2014-03-17 09:04:51 -04:00
|
|
|
echo "waiting for DFU to exit..."
|
|
|
|
while true; do
|
|
|
|
if lsusb | grep -q DFU; then
|
|
|
|
sleep 1s
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
done
|
2014-04-05 12:16:00 -04:00
|
|
|
|
|
|
|
echo "waiting for $SERIAL..."
|
|
|
|
while true; do
|
|
|
|
if ls /dev/tty* | grep -q $SERIAL; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1s
|
|
|
|
continue
|
|
|
|
done
|
|
|
|
sleep 1s
|
|
|
|
picocom $SERIAL
|
2014-03-17 09:04:51 -04:00
|
|
|
done
|