File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ MAXWAITCOUNT=40 # about 4000ms
4+
35set -e
46
57if [ $# -lt 4 ]; then
@@ -25,13 +27,7 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
2527# fi
2628# ------------------ End of old code -----------------
2729
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}
3531
3632if [ $# -eq 5 ]; then
3733 dfuse_addr=" --dfuse-address $5 "
@@ -50,12 +46,22 @@ if [ ! -x ${DFU_UTIL} ]; then
5046 exit 2
5147fi
5248
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+
5359${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} -R ${dfuse_addr} -R
5460
5561echo -n Waiting for ${dummy_port_fullpath} serial...
5662
5763COUNTER=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
5965 sleep 0.1
6066done
6167
You can’t perform that action at this time.
0 commit comments