File tree 1 file changed +14
-8
lines changed
1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ MAXWAITCOUNT=40 # about 4000ms
4
+
3
5
set -e
4
6
5
7
if [ $# -lt 4 ]; then
@@ -25,13 +27,7 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
25
27
# fi
26
28
# ------------------ End of old code -----------------
27
29
28
- # ----------------- IMPORTANT -----------------
29
- # The 2nd parameter to upload-reset is the delay after resetting before it exits
30
- # This value is in milliseonds
31
- # You may need to tune this to your system
32
- # 750ms to 1500ms seems to work on my Mac
33
-
34
- ${DIR} /upload-reset ${dummy_port_fullpath} 750
30
+ ${DIR} /upload-reset ${dummy_port_fullpath}
35
31
36
32
if [ $# -eq 5 ]; then
37
33
dfuse_addr=" --dfuse-address $5 "
@@ -50,12 +46,22 @@ if [ ! -x ${DFU_UTIL} ]; then
50
46
exit 2
51
47
fi
52
48
49
+ # wait for the DFU device after upload-reset command reboot target
50
+ COUNTER=0
51
+ while ! ${DFU_UTIL} -d ${usbID} -l | grep -e ' ^Found DFU: ' && (( COUNTER++ < ${MAXWAITCOUNT} )) ; do
52
+ sleep 0.1
53
+ done
54
+ if (( ${MAXWAITCOUNT} <= $COUNTER )) ; then
55
+ echo " $0 : error: cannot find ${usbID} " >&2
56
+ exit 2
57
+ fi
58
+
53
59
${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} -R ${dfuse_addr} -R
54
60
55
61
echo -n Waiting for ${dummy_port_fullpath} serial...
56
62
57
63
COUNTER=0
58
- while ! dd if=${dummy_port_fullpath} of=/dev/null count=0 > /dev/null 2>&1 && (( COUNTER++ < 40 )) ; do
64
+ while ! dd if=${dummy_port_fullpath} of=/dev/null count=0 > /dev/null 2>&1 && (( COUNTER++ < ${MAXWAITCOUNT} )) ; do
59
65
sleep 0.1
60
66
done
61
67
You can’t perform that action at this time.
0 commit comments