Skip to content

Commit 3d52d4c

Browse files
committed
Update stm32CubeProg scripts
All trailing arguments will be passed to the STM32CubeProgrammer Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 0a5abb3 commit 3d52d4c

File tree

3 files changed

+52
-46
lines changed

3 files changed

+52
-46
lines changed

linux/stm32CubeProg.sh

+17-16
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ usage()
2222
echo "## 2: DFU"
2323
echo "## file_path: file path name to be downloaded: (bin, hex)"
2424
echo "## Options:"
25-
echo "## For SWD: -rst"
26-
echo "## -rst: Reset system (default)"
27-
echo "## For Serial: <com_port> -s"
28-
echo "## com_port: serial identifier. Ex: /dev/ttyS0"
29-
echo "## -s: start automatically"
30-
echo "## For DFU: none"
25+
echo "## For SWD and DFU: no mandatory options"
26+
echo "## For Serial: <com_port>"
27+
echo "## com_port: serial identifier (mandatory). Ex: /dev/ttyS0"
28+
echo "##"
29+
echo "## Note: all trailing arguments will be passed to the $STM32CP_CLI"
30+
echo "## They have to be valid commands for STM32 MCU"
31+
echo "## Ex: -g: Run the code at the specified address"
32+
echo "## -rst: Reset system"
33+
echo "## -s: start automatically (optional)"
3134
echo "############################################################"
3235
exit $1
3336
}
@@ -66,28 +69,26 @@ case $1 in
6669
0)
6770
PORT='SWD'
6871
MODE='mode=UR'
69-
if [ $# -lt 3 ]; then
70-
OPTS=-rst
71-
else
72-
OPTS=$3
73-
fi;;
72+
shift 2;;
7473
1)
7574
if [ $# -lt 3 ]; then
7675
usage 3
7776
else
7877
PORT=$3
79-
if [ $# -gt 3 ]; then
80-
shift 3
81-
OPTS="$@"
82-
fi
78+
shift 3
8379
fi;;
8480
2)
85-
PORT='USB1';;
81+
PORT='USB1'
82+
shift 2;;
8683
*)
8784
echo "Protocol unknown!"
8885
usage 4;;
8986
esac
9087

88+
if [ $# -gt 0 ]; then
89+
OPTS="$@"
90+
fi
91+
9192
${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
9293

9394
exit 0

macosx/stm32CubeProg

+17-16
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ usage()
2121
echo "## 2: DFU"
2222
echo "## file_path: file path name to be downloaded: (bin, hex)"
2323
echo "## Options:"
24-
echo "## For SWD: -rst"
25-
echo "## -rst: Reset system (default)"
26-
echo "## For Serial: <com_port> -s"
27-
echo "## com_port: serial identifier. Ex: /dev/ttyS0"
28-
echo "## -s: start automatically"
29-
echo "## For DFU: none"
24+
echo "## For SWD and DFU: no mandatory options"
25+
echo "## For Serial: <com_port>"
26+
echo "## com_port: serial identifier (mandatory). Ex: /dev/ttyS0"
27+
echo "##"
28+
echo "## Note: all trailing arguments will be passed to the $STM32CP_CLI"
29+
echo "## They have to be valid commands for STM32 MCU"
30+
echo "## Ex: -g: Run the code at the specified address"
31+
echo "## -rst: Reset system"
32+
echo "## -s: start automatically (optional)"
3033
echo "############################################################"
3134
exit $1
3235
}
@@ -65,28 +68,26 @@ case $1 in
6568
0)
6669
PORT='SWD'
6770
MODE='mode=UR'
68-
if [ $# -lt 3 ]; then
69-
OPTS=-rst
70-
else
71-
OPTS=$3
72-
fi;;
71+
shift 2;;
7372
1)
7473
if [ $# -lt 3 ]; then
7574
usage 3
7675
else
7776
PORT=$3
78-
if [ $# -gt 3 ]; then
79-
shift 3
80-
OPTS="$@"
81-
fi
77+
shift 3
8278
fi;;
8379
2)
84-
PORT='USB1';;
80+
PORT='USB1'
81+
shift 2;;
8582
*)
8683
echo "Protocol unknown!"
8784
usage 4;;
8885
esac
8986

87+
if [ $# -gt 0 ]; then
88+
OPTS="$@"
89+
fi
90+
9091
${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
9192

9293
exit 0

win/stm32CubeProg.bat

+18-14
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,23 @@ goto :usage
3939
:SWD
4040
set PORT=SWD
4141
set MODE=mode=UR
42-
if "%~3"=="" (set OPTS=-rst) else (set OPTS=%3)
43-
goto :prog
42+
goto :opt
4443

4544
:SERIAL
4645
if "%~3"=="" set ERROR=3 & goto :usage
4746
set PORT=%~3
48-
49-
if "%~4"=="" goto :prog
50-
shift
5147
shift
52-
shift
53-
set OPTS=%*
54-
goto :prog
48+
goto :opt
5549

5650
:DFU
5751
set PORT=USB1
52+
goto :opt
53+
54+
:opt
55+
shift
56+
shift
57+
if "%~1"=="" goto :prog
58+
set OPTS=%*
5859
goto :prog
5960

6061
:prog
@@ -70,10 +71,13 @@ exit 0
7071
echo 2: DFU
7172
echo file_path: file path name to be downloaded: (bin, hex)
7273
echo Options:
73-
echo For SWD: -rst
74-
echo -rst: Reset system (default)
75-
echo For Serial: ^<com_port^> -s
76-
echo com_port: serial identifier. Ex: /dev/ttyS0
77-
echo -s: start automatically
78-
echo For DFU: none
74+
echo For SWD and DFU: no mandatory options
75+
echo For Serial: ^<com_port^>
76+
echo com_port: serial identifier (mandatory). Ex: COM15
77+
echo.
78+
echo Note: all trailing arguments will be passed to the %STM32CP_CLI%
79+
echo They have to be valid commands for STM32 MCU
80+
echo Ex: -g: Run the code at the specified address
81+
echo -rst: Reset system
82+
echo -s: start automatically (optional)
7983
exit %ERROR%

0 commit comments

Comments
 (0)