File tree 10 files changed +96
-94
lines changed
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 4
4
#
5
5
6
6
# Get the directory where the script is running.
7
- DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
7
+ DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
8
8
9
9
# Choose dfu program by arch
10
- if [ " $( uname -m) " == " x86_64" ]; then
10
+ if [ " $( uname -m) " == " x86_64" ]; then
11
11
DFU_UTIL=${DIR} /dfu-util_x86_64/dfu-util
12
12
else
13
13
DFU_UTIL=${DIR} /dfu-util/dfu-util
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
3
if 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
12
12
else
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."
14
14
fi
15
-
Original file line number Diff line number Diff line change 3
3
# set -e
4
4
5
5
if [ $# -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
8
8
fi
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 "
10
13
if [ $# -eq 5 ]; then
11
- dfuse_addr=" --dfuse-address $5 "
14
+ dfuse_addr=" --dfuse-address $5 "
12
15
else
13
- dfuse_addr=" "
16
+ dfuse_addr=" "
14
17
fi
15
18
16
-
17
19
# Get the directory where the script is running.
18
- DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
20
+ DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
19
21
20
22
# ----------------- IMPORTANT -----------------
21
23
# The 2nd parameter to upload-reset is the delay after resetting before it exits
22
24
# This value is in milliseonds
23
25
# You may need to tune this to your system
24
26
# 750ms to 1500ms seems to work on my Mac
25
27
26
-
27
28
" ${DIR} /upload-reset" " ${dummy_port_fullpath} " 750
28
29
29
30
" ${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...
32
33
33
34
COUNTER=0
34
35
while [ ! -r " ${dummy_port_fullpath} " ] && (( COUNTER++ < 40 )) ; do
35
- sleep 0.1
36
+ sleep 0.1
36
37
done
37
38
38
39
echo Done
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
- set -o nounset # Treat unset variables as an error
2
+ set -o nounset # Treat unset variables as an error
3
3
4
4
# List
5
5
bin_filepath=
@@ -8,8 +8,7 @@ mountpoint_path=
8
8
9
9
# ##############################################################################
10
10
# # Help function
11
- usage ()
12
- {
11
+ usage () {
13
12
echo " ############################################################"
14
13
echo " ##"
15
14
echo " ## $( basename " $0 " ) [-I <filepath>] [-O <mountpoint(s)> ]"
@@ -30,13 +29,13 @@ if [ $# -lt 2 ]; then
30
29
fi
31
30
32
31
# Parsing options
33
- if [ " $1 " == " -I" ]; then
32
+ if [ " $1 " == " -I" ]; then
34
33
shift 1
35
34
fi
36
35
37
36
bin_filepath=$1
38
37
39
- if [ " $2 " == " -O" ]; then
38
+ if [ " $2 " == " -O" ]; then
40
39
shift 1
41
40
fi
42
41
# Strip first and last ""
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
- set -o nounset # Treat unset variables as an error
2
+ set -o nounset # Treat unset variables as an error
3
3
STM32CP_CLI=STM32_Programmer.sh
4
4
ADDRESS=0x8000000
5
5
ERASE=" "
9
9
10
10
# ##############################################################################
11
11
# # Help function
12
- usage ()
13
- {
12
+ usage () {
14
13
echo " ############################################################"
15
14
echo " ##"
16
15
echo " ## $( basename " $0 " ) <protocol> <file_path> [OPTIONS]"
@@ -37,12 +36,10 @@ usage()
37
36
}
38
37
39
38
check_tool () {
40
- if ! command -v $STM32CP_CLI > /dev/null 2>&1
41
- then
39
+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
42
40
export PATH=" $HOME /STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin" :$PATH
43
41
fi
44
- if ! command -v $STM32CP_CLI > /dev/null 2>&1
45
- then
42
+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
46
43
echo " $STM32CP_CLI not found."
47
44
echo " Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
48
45
echo " https://www.st.com/en/development-tools/stm32cubeprog.html"
@@ -54,8 +51,8 @@ check_tool() {
54
51
check_tool
55
52
56
53
if [ $# -lt 2 ]; then
57
- echo " Not enough arguments!"
58
- usage 2
54
+ echo " Not enough arguments!"
55
+ usage 2
59
56
fi
60
57
61
58
# Parse options
@@ -75,20 +72,24 @@ case $PROTOCOL in
75
72
0)
76
73
PORT=" SWD"
77
74
MODE=" mode=UR"
78
- shift 2;;
75
+ shift 2
76
+ ;;
79
77
1)
80
78
if [ $# -lt 3 ]; then
81
79
usage 3
82
80
else
83
81
PORT=$3
84
82
shift 3
85
- fi ;;
83
+ fi
84
+ ;;
86
85
2)
87
86
PORT=" USB1"
88
- shift 2;;
87
+ shift 2
88
+ ;;
89
89
* )
90
90
echo " Protocol unknown!"
91
- usage 4;;
91
+ usage 4
92
+ ;;
92
93
esac
93
94
94
95
if [ $# -gt 0 ]; then
98
99
${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE: +" -e all" } -q -d " ${FILEPATH} " ${ADDRESS} " ${OPTS} "
99
100
100
101
exit $?
101
-
Original file line number Diff line number Diff line change 3
3
set -e
4
4
5
5
if [ $# -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
8
8
fi
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 "
11
13
12
14
# 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)
15
16
16
17
# ----------------- Old code to reset the USB - which doesn't seem to work --------
17
18
#
@@ -34,20 +35,20 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
34
35
" ${DIR} " /upload-reset " ${dummy_port_fullpath} " 750
35
36
36
37
if [ $# -eq 5 ]; then
37
- dfuse_addr=" --dfuse-address $5 "
38
+ dfuse_addr=" --dfuse-address $5 "
38
39
else
39
- dfuse_addr=" "
40
+ dfuse_addr=" "
40
41
fi
41
42
42
43
# DFU_UTIL=/usr/local/bin/dfu-util
43
44
DFU_UTIL=${DIR} /dfu-util/dfu-util
44
45
if [ ! -x " ${DFU_UTIL} " ]; then
45
- DFU_UTIL=/opt/local/bin/dfu-util
46
+ DFU_UTIL=/opt/local/bin/dfu-util
46
47
fi
47
48
48
49
if [ ! -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
51
52
fi
52
53
53
54
${DFU_UTIL} -d " ${usbID} " -a " ${altID} " -D " ${binfile} " -R ${dfuse_addr} -R
@@ -56,7 +57,7 @@ echo -n Waiting for "${dummy_port_fullpath}" serial...
56
57
57
58
COUNTER=0
58
59
while [ ! -c " ${dummy_port_fullpath} " ] && (( COUNTER++ < 40 )) ; do
59
- sleep 0.1
60
+ sleep 0.1
60
61
done
61
62
62
63
echo Done
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
- set -o nounset # Treat unset variables as an error
2
+ set -o nounset # Treat unset variables as an error
3
3
4
4
# List
5
5
bin_filepath=
@@ -8,8 +8,7 @@ mountpoint_path=
8
8
9
9
# ##############################################################################
10
10
# # Help function
11
- usage ()
12
- {
11
+ usage () {
13
12
echo " ############################################################"
14
13
echo " ##"
15
14
echo " ## $( basename " $0 " ) [-I <filepath>] [-O <mountpoint(s)> ]"
@@ -30,13 +29,13 @@ if [ $# -lt 2 ]; then
30
29
fi
31
30
32
31
# Parsing options
33
- if [ " $1 " == " -I" ]; then
32
+ if [ " $1 " == " -I" ]; then
34
33
shift 1
35
34
fi
36
35
37
36
bin_filepath=$1
38
37
39
- if [ " $2 " == " -O" ]; then
38
+ if [ " $2 " == " -O" ]; then
40
39
shift 1
41
40
fi
42
41
# Strip first and last ""
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
- set -o nounset # Treat unset variables as an error
2
+ set -o nounset # Treat unset variables as an error
3
3
STM32CP_CLI=STM32_Programmer_CLI
4
4
ADDRESS=0x8000000
5
5
ERASE=" "
9
9
10
10
# ##############################################################################
11
11
# # Help function
12
- usage ()
13
- {
12
+ usage () {
14
13
echo " ############################################################"
15
14
echo " ##"
16
15
echo " ## $( basename " $0 " ) <protocol> <file_path> [OPTIONS]"
@@ -37,12 +36,10 @@ usage()
37
36
}
38
37
39
38
check_tool () {
40
- if ! ommand -v $STM32CP_CLI > /dev/null 2>&1
41
- then
39
+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
42
40
export PATH=" /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin" :$PATH
43
41
fi
44
- if ! command -v $STM32CP_CLI > /dev/null 2>&1
45
- then
42
+ if ! command -v $STM32CP_CLI > /dev/null 2>&1 ; then
46
43
echo " $STM32CP_CLI not found."
47
44
echo " Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
48
45
echo " https://www.st.com/en/development-tools/stm32cubeprog.html"
@@ -54,8 +51,8 @@ check_tool() {
54
51
check_tool
55
52
56
53
if [ $# -lt 2 ]; then
57
- echo " Not enough arguments!"
58
- usage 2
54
+ echo " Not enough arguments!"
55
+ usage 2
59
56
fi
60
57
61
58
# Parse options
@@ -75,20 +72,24 @@ case $PROTOCOL in
75
72
0)
76
73
PORT=" SWD"
77
74
MODE=" mode=UR"
78
- shift 2;;
75
+ shift 2
76
+ ;;
79
77
1)
80
78
if [ $# -lt 3 ]; then
81
79
usage 3
82
80
else
83
81
PORT=$3
84
82
shift 3
85
- fi ;;
83
+ fi
84
+ ;;
86
85
2)
87
86
PORT=" USB1"
88
- shift 2;;
87
+ shift 2
88
+ ;;
89
89
* )
90
90
echo " Protocol unknown!"
91
- usage 4;;
91
+ usage 4
92
+ ;;
92
93
esac
93
94
94
95
if [ $# -gt 0 ]; then
98
99
${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE: +" -e all" } -q -d " ${FILEPATH} " ${ADDRESS} " ${OPTS} "
99
100
100
101
exit $?
101
-
You can’t perform that action at this time.
0 commit comments