File tree Expand file tree Collapse file tree 3 files changed +48
-17
lines changed Expand file tree Collapse file tree 3 files changed +48
-17
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ set -o nounset # Treat unset variables as an error
33# set -x
44STM32CP_CLI=STM32_Programmer.sh
55ADDRESS=0x8000000
6- FILEPATH =
6+ ERASE =
77MODE=
88PORT=
99OPTS=
@@ -16,10 +16,12 @@ usage()
1616 echo " ##"
1717 echo " ## ` basename $0 ` <protocol> <file_path> [OPTIONS]"
1818 echo " ##"
19- echo " ## protocol: "
19+ echo " ## protocol:"
2020 echo " ## 0: SWD"
21- echo " ## 1: Serial "
21+ echo " ## 1: Serial"
2222 echo " ## 2: DFU"
23+ echo " ## Note: prefix it by 1 to erase all sectors."
24+ echo " ## Ex: 10 erase all sectors using SWD interface."
2325 echo " ## file_path: file path name to be downloaded: (bin, hex)"
2426 echo " ## Options:"
2527 echo " ## For SWD and DFU: no mandatory options"
@@ -58,14 +60,20 @@ if [ $# -lt 2 ]; then
5860 usage 2
5961fi
6062
61- FILEPATH=$2
62-
6363# Parse options
64+ PROTOCOL=$1
65+ FILEPATH=$2
66+ # Protocol $1
67+ # 1x: Erase all sectors
68+ if [ $1 -ge 10 ]; then
69+ ERASE=' -e all'
70+ PROTOCOL=$(( $1 - 10 ))
71+ fi
6472# Protocol $1
6573# 0: SWD
6674# 1: Serial
6775# 2: DFU
68- case $1 in
76+ case $PROTOCOL in
6977 0)
7078 PORT=' SWD'
7179 MODE=' mode=UR'
@@ -89,7 +97,7 @@ if [ $# -gt 0 ]; then
8997 OPTS=" $@ "
9098fi
9199
92- ${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
100+ ${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
93101
94102exit 0
95103
Original file line number Diff line number Diff line change 22set -o nounset # Treat unset variables as an error
33STM32CP_CLI=STM32_Programmer_CLI
44ADDRESS=0x8000000
5- FILEPATH =
5+ ERASE =
66MODE=
77PORT=
88OPTS=
@@ -17,8 +17,10 @@ usage()
1717 echo " ##"
1818 echo " ## protocol: "
1919 echo " ## 0: SWD"
20- echo " ## 1: Serial "
20+ echo " ## 1: Serial"
2121 echo " ## 2: DFU"
22+ echo " ## Note: prefix it by 1 to erase all sectors."
23+ echo " ## Ex: 10 erase all sectors using SWD interface."
2224 echo " ## file_path: file path name to be downloaded: (bin, hex)"
2325 echo " ## Options:"
2426 echo " ## For SWD and DFU: no mandatory options"
@@ -57,14 +59,21 @@ if [ $# -lt 2 ]; then
5759 usage 2
5860fi
5961
60- FILEPATH=$2
61-
6262# Parse options
63+ PROTOCOL=$1
64+ FILEPATH=$2
65+ # Protocol $1
66+ # 1x: Erase all sectors
67+ if [ $1 -ge 10 ]; then
68+ ERASE=' -e all'
69+ PROTOCOL=$(( $1 - 10 ))
70+ fi
6371# Protocol $1
6472# 0: SWD
6573# 1: Serial
6674# 2: DFU
67- case $1 in
75+ case $PROTOCOL in
76+
6877 0)
6978 PORT=' SWD'
7079 MODE=' mode=UR'
@@ -88,7 +97,7 @@ if [ $# -gt 0 ]; then
8897 OPTS=" $@ "
8998fi
9099
91- ${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
100+ ${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
92101
93102exit 0
94103
Original file line number Diff line number Diff line change 33set ERROR = 0
44set STM32CP_CLI = STM32_Programmer_CLI.exe
55set ADDRESS = 0x8000000
6+ set ERASE =
7+ set MODE =
8+ set PORT =
9+ set OPTS =
610
711:: Check tool
812where /Q %STM32CP_CLI%
@@ -23,15 +27,23 @@ exit 1
2327:: Parse options
2428if " %~1 " == " " echo Not enough arguments! & set ERROR = 2 & goto :usage
2529if " %~2 " == " " echo Not enough arguments! & set ERROR = 2 & goto :usage
30+
31+ set PROTOCOL = %~1
2632set FILEPATH = %~2
2733
2834:: Protocol
35+ :: 1x: Erase all sectors
36+ if %~1 lss 10 goto :proto
37+ set ERASE = -e all
38+ set /a PROTOCOL -= 10
39+
2940:: 0: SWD
3041:: 1: Serial
3142:: 2: DFU
32- if %~1 == 0 goto :SWD
33- if %~1 == 1 goto :SERIAL
34- if %~1 == 2 goto :DFU
43+ :proto
44+ if %PROTOCOL% == 0 goto :SWD
45+ if %PROTOCOL% == 1 goto :SERIAL
46+ if %PROTOCOL% == 2 goto :DFU
3547echo Protocol unknown!
3648set ERROR = 4
3749goto :usage
@@ -59,7 +71,7 @@ set OPTS=%1 %2 %3 %4 %5 %6 %7 %8 %9
5971goto :prog
6072
6173:prog
62- %STM32CP_CLI% -c port=%PORT% %MODE% -q -d %FILEPATH% %ADDRESS% %OPTS%
74+ %STM32CP_CLI% -c port=%PORT% %MODE% %ERASE% -q -d %FILEPATH% %ADDRESS% %OPTS%
6375exit 0
6476
6577:usage
6981 echo 0: SWD
7082 echo 1: Serial
7183 echo 2: DFU
84+ echo Note: prefix it by 1 to erase all sectors
85+ echo Ex: 10 erase all sectors using SWD interface
7286 echo file_path: file path name to be downloaded: (bin, hex)
7387 echo Options:
7488 echo For SWD and DFU: no mandatory options
You can’t perform that action at this time.
0 commit comments