File tree Expand file tree Collapse file tree 10 files changed +96
-94
lines changed Expand file tree Collapse file tree 10 files changed +96
-94
lines changed Original file line number Diff line number Diff line change 1+ [* .sh ]
2+ # like -i=2
3+ indent_style = space
4+ indent_size = 2
5+
6+ # shell_variant = posix # like -ln=posix
7+ # binary_next_line = true # like -bn
8+ switch_case_indent = true # like -ci
9+ space_redirects = true # like -sr
10+ # keep_padding = true # like -kp
Original file line number Diff line number Diff line change 44#
55
66# Get the directory where the script is running.
7- DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
7+ DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
88
99# Choose dfu program by arch
10- if [ " $( uname -m) " == " x86_64" ]; then
10+ if [ " $( uname -m) " == " x86_64" ]; then
1111 DFU_UTIL=${DIR} /dfu-util_x86_64/dfu-util
1212else
1313 DFU_UTIL=${DIR} /dfu-util/dfu-util
Original file line number Diff line number Diff line change 11#! /bin/sh
22
33if sudo [ -w /etc/udev/rules.d ]; then
4- echo " Copying Maple-specific udev rules..."
5- sudo cp -v 45-maple.rules /etc/udev/rules.d/45-maple.rules
6- sudo chown root:root /etc/udev/rules.d/45-maple.rules
7- sudo chmod 644 /etc/udev/rules.d/45-maple.rules
8- echo " Reloading udev rules"
9- sudo udevadm control --reload-rules
10- echo " Adding current user to dialout group"
11- sudo adduser " $USER " dialout
4+ echo " Copying Maple-specific udev rules..."
5+ sudo cp -v 45-maple.rules /etc/udev/rules.d/45-maple.rules
6+ sudo chown root:root /etc/udev/rules.d/45-maple.rules
7+ sudo chmod 644 /etc/udev/rules.d/45-maple.rules
8+ echo " Reloading udev rules"
9+ sudo udevadm control --reload-rules
10+ echo " Adding current user to dialout group"
11+ sudo adduser " $USER " dialout
1212else
13- echo " Couldn't copy to /etc/udev/rules.d/; you probably have to run this script as root? Or your distribution of Linux doesn't include udev; try running the IDE itself as root."
13+ echo " Couldn't copy to /etc/udev/rules.d/; you probably have to run this script as root? Or your distribution of Linux doesn't include udev; try running the IDE itself as root."
1414fi
15-
Original file line number Diff line number Diff line change 33# set -e
44
55if [ $# -lt 4 ]; then
6- echo " Usage: $0 $# <dummy_port> <altID> <usbID> <binfile>" >&2
7- exit 1
6+ echo " Usage: $0 $# <dummy_port> <altID> <usbID> <binfile>" >&2
7+ exit 1
88fi
9- altID=" $2 " ; usbID=" $3 " ; binfile=" $4 " ; dummy_port_fullpath=" /dev/$1 "
9+ altID=" $2 "
10+ usbID=" $3 "
11+ binfile=" $4 "
12+ dummy_port_fullpath=" /dev/$1 "
1013if [ $# -eq 5 ]; then
11- dfuse_addr=" --dfuse-address $5 "
14+ dfuse_addr=" --dfuse-address $5 "
1215else
13- dfuse_addr=" "
16+ dfuse_addr=" "
1417fi
1518
16-
1719# Get the directory where the script is running.
18- DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
20+ DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
1921
2022# ----------------- IMPORTANT -----------------
2123# The 2nd parameter to upload-reset is the delay after resetting before it exits
2224# This value is in milliseonds
2325# You may need to tune this to your system
2426# 750ms to 1500ms seems to work on my Mac
2527
26-
2728" ${DIR} /upload-reset" " ${dummy_port_fullpath} " 750
2829
2930" ${DIR} /dfu-util.sh" -d " ${usbID} " -a " ${altID} " -D " ${binfile} " ${dfuse_addr} -R
@@ -32,7 +33,7 @@ echo -n Waiting for "${dummy_port_fullpath}" serial...
3233
3334COUNTER=0
3435while [ ! -r " ${dummy_port_fullpath} " ] && (( COUNTER++ < 40 )) ; do
35- sleep 0.1
36+ sleep 0.1
3637done
3738
3839echo Done
Original file line number Diff line number Diff line change 11#! /bin/bash
2- set -o nounset # Treat unset variables as an error
2+ set -o nounset # Treat unset variables as an error
33
44# List
55bin_filepath=
@@ -8,8 +8,7 @@ mountpoint_path=
88
99# ##############################################################################
1010# # Help function
11- usage ()
12- {
11+ usage () {
1312 echo " ############################################################"
1413 echo " ##"
1514 echo " ## $( basename " $0 " ) [-I <filepath>] [-O <mountpoint(s)> ]"
@@ -30,13 +29,13 @@ if [ $# -lt 2 ]; then
3029fi
3130
3231# Parsing options
33- if [ " $1 " == " -I" ]; then
32+ if [ " $1 " == " -I" ]; then
3433 shift 1
3534fi
3635
3736bin_filepath=$1
3837
39- if [ " $2 " == " -O" ]; then
38+ if [ " $2 " == " -O" ]; then
4039 shift 1
4140fi
4241# Strip first and last ""
Original file line number Diff line number Diff line change 11#! /bin/bash
2- set -o nounset # Treat unset variables as an error
2+ set -o nounset # Treat unset variables as an error
33STM32CP_CLI=STM32_Programmer.sh
44ADDRESS=0x8000000
55ERASE=" "
99
1010# ##############################################################################
1111# # Help function
12- usage ()
13- {
12+ usage () {
1413 echo " ############################################################"
1514 echo " ##"
1615 echo " ## $( basename " $0 " ) <protocol> <file_path> [OPTIONS]"
@@ -37,12 +36,10 @@ usage()
3736}
3837
3938check_tool () {
40- if ! command -v $STM32CP_CLI > /dev/null 2>&1
41- then
39+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
4240 export PATH=" $HOME /STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin" :$PATH
4341 fi
44- if ! command -v $STM32CP_CLI > /dev/null 2>&1
45- then
42+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
4643 echo " $STM32CP_CLI not found."
4744 echo " Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
4845 echo " https://www.st.com/en/development-tools/stm32cubeprog.html"
@@ -54,8 +51,8 @@ check_tool() {
5451check_tool
5552
5653if [ $# -lt 2 ]; then
57- echo " Not enough arguments!"
58- usage 2
54+ echo " Not enough arguments!"
55+ usage 2
5956fi
6057
6158# Parse options
@@ -75,20 +72,24 @@ case $PROTOCOL in
7572 0)
7673 PORT=" SWD"
7774 MODE=" mode=UR"
78- shift 2;;
75+ shift 2
76+ ;;
7977 1)
8078 if [ $# -lt 3 ]; then
8179 usage 3
8280 else
8381 PORT=$3
8482 shift 3
85- fi ;;
83+ fi
84+ ;;
8685 2)
8786 PORT=" USB1"
88- shift 2;;
87+ shift 2
88+ ;;
8989 * )
9090 echo " Protocol unknown!"
91- usage 4;;
91+ usage 4
92+ ;;
9293esac
9394
9495if [ $# -gt 0 ]; then
9899${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE: +" -e all" } -q -d " ${FILEPATH} " ${ADDRESS} " ${OPTS} "
99100
100101exit $?
101-
Original file line number Diff line number Diff line change 33set -e
44
55if [ $# -lt 4 ]; then
6- echo " Usage: $0 $# <dummy_port> <altID> <usbID> <binfile>" >&2
7- exit 1
6+ echo " Usage: $0 $# <dummy_port> <altID> <usbID> <binfile>" >&2
7+ exit 1
88fi
9- altID=$2 ; usbID=$3 ; binfile=$4 ; dummy_port_fullpath=" /dev/$1 "
10-
9+ altID=$2
10+ usbID=$3
11+ binfile=$4
12+ dummy_port_fullpath=" /dev/$1 "
1113
1214# Get the directory where the script is running.
13- DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
14-
15+ DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
1516
1617# ----------------- Old code to reset the USB - which doesn't seem to work --------
1718#
@@ -34,20 +35,20 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
3435" ${DIR} " /upload-reset " ${dummy_port_fullpath} " 750
3536
3637if [ $# -eq 5 ]; then
37- dfuse_addr=" --dfuse-address $5 "
38+ dfuse_addr=" --dfuse-address $5 "
3839else
39- dfuse_addr=" "
40+ dfuse_addr=" "
4041fi
4142
4243# DFU_UTIL=/usr/local/bin/dfu-util
4344DFU_UTIL=${DIR} /dfu-util/dfu-util
4445if [ ! -x " ${DFU_UTIL} " ]; then
45- DFU_UTIL=/opt/local/bin/dfu-util
46+ DFU_UTIL=/opt/local/bin/dfu-util
4647fi
4748
4849if [ ! -x ${DFU_UTIL} ]; then
49- echo " $0 : error: cannot find ${DFU_UTIL} " >&2
50- exit 2
50+ echo " $0 : error: cannot find ${DFU_UTIL} " >&2
51+ exit 2
5152fi
5253
5354${DFU_UTIL} -d " ${usbID} " -a " ${altID} " -D " ${binfile} " -R ${dfuse_addr} -R
@@ -56,7 +57,7 @@ echo -n Waiting for "${dummy_port_fullpath}" serial...
5657
5758COUNTER=0
5859while [ ! -c " ${dummy_port_fullpath} " ] && (( COUNTER++ < 40 )) ; do
59- sleep 0.1
60+ sleep 0.1
6061done
6162
6263echo Done
Original file line number Diff line number Diff line change 11#! /bin/bash
2- set -o nounset # Treat unset variables as an error
2+ set -o nounset # Treat unset variables as an error
33
44# List
55bin_filepath=
@@ -8,8 +8,7 @@ mountpoint_path=
88
99# ##############################################################################
1010# # Help function
11- usage ()
12- {
11+ usage () {
1312 echo " ############################################################"
1413 echo " ##"
1514 echo " ## $( basename " $0 " ) [-I <filepath>] [-O <mountpoint(s)> ]"
@@ -30,13 +29,13 @@ if [ $# -lt 2 ]; then
3029fi
3130
3231# Parsing options
33- if [ " $1 " == " -I" ]; then
32+ if [ " $1 " == " -I" ]; then
3433 shift 1
3534fi
3635
3736bin_filepath=$1
3837
39- if [ " $2 " == " -O" ]; then
38+ if [ " $2 " == " -O" ]; then
4039 shift 1
4140fi
4241# Strip first and last ""
Original file line number Diff line number Diff line change 11#! /bin/bash
2- set -o nounset # Treat unset variables as an error
2+ set -o nounset # Treat unset variables as an error
33STM32CP_CLI=STM32_Programmer_CLI
44ADDRESS=0x8000000
55ERASE=" "
99
1010# ##############################################################################
1111# # Help function
12- usage ()
13- {
12+ usage () {
1413 echo " ############################################################"
1514 echo " ##"
1615 echo " ## $( basename " $0 " ) <protocol> <file_path> [OPTIONS]"
@@ -37,12 +36,10 @@ usage()
3736}
3837
3938check_tool () {
40- if ! ommand -v $STM32CP_CLI > /dev/null 2>&1
41- then
39+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
4240 export PATH=" /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin" :$PATH
4341 fi
44- if ! command -v $STM32CP_CLI > /dev/null 2>&1
45- then
42+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
4643 echo " $STM32CP_CLI not found."
4744 echo " Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
4845 echo " https://www.st.com/en/development-tools/stm32cubeprog.html"
@@ -54,8 +51,8 @@ check_tool() {
5451check_tool
5552
5653if [ $# -lt 2 ]; then
57- echo " Not enough arguments!"
58- usage 2
54+ echo " Not enough arguments!"
55+ usage 2
5956fi
6057
6158# Parse options
@@ -75,20 +72,24 @@ case $PROTOCOL in
7572 0)
7673 PORT=" SWD"
7774 MODE=" mode=UR"
78- shift 2;;
75+ shift 2
76+ ;;
7977 1)
8078 if [ $# -lt 3 ]; then
8179 usage 3
8280 else
8381 PORT=$3
8482 shift 3
85- fi ;;
83+ fi
84+ ;;
8685 2)
8786 PORT=" USB1"
88- shift 2;;
87+ shift 2
88+ ;;
8989 * )
9090 echo " Protocol unknown!"
91- usage 4;;
91+ usage 4
92+ ;;
9293esac
9394
9495if [ $# -gt 0 ]; then
9899${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE: +" -e all" } -q -d " ${FILEPATH} " ${ADDRESS} " ${OPTS} "
99100
100101exit $?
101-
You can’t perform that action at this time.
0 commit comments