Skip to content

Commit

Permalink
Merge pull request #181 from mcci-catena/issue180
Browse files Browse the repository at this point in the history
Fix uploads on Linux
  • Loading branch information
terrillmoore authored Oct 19, 2021
2 parents 97252ca + 03a05ab commit a6eb527
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/linux/stm32l0-upload
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function _usage {

TOOLDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)

# VIDPID is either empty or has a trailing comma.
VIDPID=
if [[ "$1" != "-" ]]; then
if [[ "$2" != "-" ]]; then
Expand All @@ -35,7 +36,7 @@ if [[ "$1" != "-" ]]; then
_usage "First two args are vid/pid; both must be '-' if either is"
fi
elif [[ "$2" != "-" ]]; then
_usage "First two args are vid/pid; bost must be '-' if either is"
_usage "First two args are vid/pid; both must be '-' if either is"
fi

FILE="$3"
Expand Down Expand Up @@ -78,6 +79,7 @@ fi

if [[ $VERBOSE -ne 0 ]]; then
echo "Program file: $FILE"
# VIDPID is either empty or has a trailing comma. Strip the trailing comma for display
echo "Board VID:PID: ${VIDPID%,}"
echo "Base address: $BASEADDR"
if [[ "$BOOTLOADER" != "-" ]]; then
Expand Down Expand Up @@ -113,13 +115,15 @@ fi
# upload
if [[ "$BOOTLOADER" != "-" ]]; then
# upload the bootloader, and leave in upload mode.
if ! "$TOOLDIR"/dfu-util -d "VIDPID"0x0483:0xdf11 -a 0 -s 0x08000000 -D "$BOOTLOADER"; then
# VIDPID is either empty or has a trailing comma.
if ! "$TOOLDIR"/dfu-util -d "$VIDPID"0x0483:0xdf11 -a 0 -s 0x08000000 -D "$BOOTLOADER"; then
echo "bootloader upload failed"
exit 1
fi
fi

if ! "$TOOLDIR"/dfu-util -d "VIDPID"0x0483:0xdf11 -a 0 -s "$BASEADDR:leave" -D "$FILE" ; then
# do the main upload. Again, VIDPID is eitehr empty or has a trailing comma.
if ! "$TOOLDIR"/dfu-util -d "$VIDPID"0x0483:0xdf11 -a 0 -s "$BASEADDR:leave" -D "$FILE" ; then
echo "main upload failed"
exit 1
fi
Expand Down

0 comments on commit a6eb527

Please sign in to comment.