Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dd command instead of test command to wait the Serial device #297

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions tools/macosx/maple_upload
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

MAXWAITCOUNT=40 # about 4000ms

set -e

if [ $# -lt 4 ]; then
Expand All @@ -25,13 +27,7 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
#fi
# ------------------ End of old code -----------------

# ----------------- IMPORTANT -----------------
# The 2nd parameter to upload-reset is the delay after resetting before it exits
# This value is in milliseonds
# You may need to tune this to your system
# 750ms to 1500ms seems to work on my Mac

${DIR}/upload-reset ${dummy_port_fullpath} 750
${DIR}/upload-reset ${dummy_port_fullpath}

if [ $# -eq 5 ]; then
dfuse_addr="--dfuse-address $5"
Expand All @@ -50,12 +46,22 @@ if [ ! -x ${DFU_UTIL} ]; then
exit 2
fi

# wait for the DFU device after upload-reset command reboot target
COUNTER=0
while ! ${DFU_UTIL} -d ${usbID} -l | grep -e '^Found DFU: ' && ((COUNTER++ < ${MAXWAITCOUNT})); do
sleep 0.1
done
if ((${MAXWAITCOUNT} <= $COUNTER)); then
echo "$0: error: cannot find ${usbID}" >&2
exit 2
fi

${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} -R ${dfuse_addr} -R

echo -n Waiting for ${dummy_port_fullpath} serial...

COUNTER=0
while [ ! -c ${dummy_port_fullpath} ] && ((COUNTER++ < 40)); do
while ! dd if=${dummy_port_fullpath} of=/dev/null count=0 > /dev/null 2>&1 && ((COUNTER++ < ${MAXWAITCOUNT})); do
sleep 0.1
done

Expand Down