@@ -14,6 +14,7 @@ ADDRESS=0x8000000
1414START=0x8000000
1515ERASE=
1616# Optional for SWD
17+ FREQ=
1718MODE=UR
1819# Optional for Serial
1920RTS=
@@ -39,6 +40,7 @@ usage() {
3940
4041 Specific options for SWD protocol:
4142 Optional:
43+ -f, --freq <value> SWD frequency in KHz.
4244 -m, --mode connection mode: UR (default), HOTPLUG, POWERDOWN or hwRstPulse
4345
4446 Specific options for Serial protocol:
@@ -124,12 +126,12 @@ esac
124126# parse command line arguments
125127# options may be followed by one colon to indicate they have a required arg
126128if [ -n " ${GNU_GETOPT} " ]; then
127- if ! options=$( getopt hi:b:a:es:o:m:c:d:p:r:v: " $@ " ) ; then
129+ if ! options=$( getopt hi:b:a:es:o:f: m:c:d:p:r:v: " $@ " ) ; then
128130 echo " Terminating..." >&2
129131 exit 1
130132 fi
131133else
132- if ! options=$( getopt -a -o hi:b:a:es:o:m:c:d:p:r:v: --long help,interface:,bin:,address:,erase,start:,offset:,mode:,com:,dtr:,parity:,rts:,pid:,vid: -- " $@ " ) ; then
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
133135 echo " Terminating..." >&2
134136 exit 1
135137 fi
@@ -167,6 +169,10 @@ while true; do
167169 OFFSET=$2
168170 shift 2
169171 ;;
172+ -f | --freq)
173+ FREQ=$2
174+ shift 2
175+ ;;
170176 -m | --mode)
171177 MODE=$2
172178 shift 2
221227
222228case " ${INTERFACE} " in
223229 swd)
224- ${STM32CP_CLI} --connect port=SWD mode=" ${MODE} " " ${ERASE} " --quietMode --download " ${FILEPATH} " " ${ADDRESS} " --start " ${START} "
230+ PORT_PARAM=" port=SWD"
231+ if [ -n " ${FREQ} " ]; then
232+ case " ${FREQ} " in
233+ 0) ;;
234+ * [!0-9]* )
235+ echo " Invalid SWD frequency (expected integer KHz): ${FREQ} " >&2
236+ exit 1
237+ ;;
238+ * )
239+ PORT_PARAM=" ${PORT_PARAM} freq=${FREQ} "
240+ ;;
241+ esac
242+ fi
243+ ${STM32CP_CLI} --connect " ${PORT_PARAM} " mode=" ${MODE} " " ${ERASE} " --quietMode --download " ${FILEPATH} " " ${ADDRESS} " --start " ${START} "
225244 ;;
226245 dfu)
227246 if [ -z " ${VID} " ] || [ -z " ${PID} " ]; then
0 commit comments