forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 5
/
autoflash
executable file
·44 lines (39 loc) · 859 Bytes
/
autoflash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
#
# 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
DEVICE=0483:df11
while true; do
echo "waiting for DFU device..."
while true; do
if lsusb | grep -q DFU; then
break
fi
sleep 1s
done
echo "found DFU device, flashing"
dfu-util -a 0 -d $DEVICE -D build/flash.dfu
echo "waiting for DFU to exit..."
while true; do
if lsusb | grep -q DFU; then
sleep 1s
continue
fi
break
done
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
done