Skip to content

Commit 744264d

Browse files
committed
feat(stm32cubeprog): add stlink serial number option
Signed-off-by: bipoe <bipoeman12@gmail.com> Co-Authored-By: Frederic Pillon <frederic.pillon@st.com>
1 parent b33b5d7 commit 744264d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎stm32CubeProg.sh‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ERASE=
1616
# Optional for SWD
1717
FREQ=
1818
MODE=UR
19+
SERIAL_NUMBER=
1920
# Optional for Serial
2021
RTS=
2122
DTR=
@@ -42,7 +43,7 @@ usage() {
4243
Optional:
4344
-f, --freq <value> SWD frequency in KHz.
4445
-m, --mode connection mode: UR (default), HOTPLUG, POWERDOWN or hwRstPulse
45-
46+
-n, --snum <serial number> serial number of the ST-Link device (if multiple ST-Link devices are connected)
4647
Specific options for Serial protocol:
4748
Mandatory:
4849
-c, --com <name> serial identifier, ex: COM1 or /dev/ttyS0,...
@@ -126,12 +127,12 @@ esac
126127
# parse command line arguments
127128
# options may be followed by one colon to indicate they have a required arg
128129
if [ -n "${GNU_GETOPT}" ]; then
129-
if ! options=$(getopt hi:b:a:es:o:f:m:c:d:p:r:v: "$@"); then
130+
if ! options=$(getopt hi:b:a:es:o:f:m:n:c:d:p:r:v: "$@"); then
130131
echo "Terminating..." >&2
131132
exit 1
132133
fi
133134
else
134-
if ! options=$(getopt -a -o hi:b:a:es:o:f:m:c:d:p:r:v: --long help,interface:,bin:,address:,erase,start:,offset:,freq:,mode:,com:,dtr:,parity:,rts:,pid:,vid: -- "$@"); then
135+
if ! options=$(getopt -a -o hi:b:a:es:o:f:m:n:c:d:p:r:v: --long help,interface:,bin:,address:,erase,start:,offset:,freq:,mode:,snum:,com:,dtr:,parity:,rts:,pid:,vid: -- "$@"); then
135136
echo "Terminating..." >&2
136137
exit 1
137138
fi
@@ -177,6 +178,10 @@ while true; do
177178
MODE=$2
178179
shift 2
179180
;;
181+
-n | --snum)
182+
SERIAL_NUMBER="$2"
183+
shift 2
184+
;;
180185
-c | --com)
181186
PORT=$2
182187
shift 2
@@ -240,6 +245,9 @@ case "${INTERFACE}" in
240245
;;
241246
esac
242247
fi
248+
if [ -n "${SERIAL_NUMBER}" ] && [ "${SERIAL_NUMBER}" != "0" ]; then
249+
PORT_PARAM="${PORT_PARAM} sn=${SERIAL_NUMBER}"
250+
fi
243251
${STM32CP_CLI} --connect "${PORT_PARAM}" mode="${MODE}" "${ERASE}" --quietMode --download "${FILEPATH}" "${ADDRESS}" --start "${START}"
244252
;;
245253
dfu)

0 commit comments

Comments
 (0)