File tree 3 files changed +48
-17
lines changed
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
3
3
# set -x
4
4
STM32CP_CLI=STM32_Programmer.sh
5
5
ADDRESS=0x8000000
6
- FILEPATH =
6
+ ERASE =
7
7
MODE=
8
8
PORT=
9
9
OPTS=
@@ -16,10 +16,12 @@ usage()
16
16
echo " ##"
17
17
echo " ## ` basename $0 ` <protocol> <file_path> [OPTIONS]"
18
18
echo " ##"
19
- echo " ## protocol: "
19
+ echo " ## protocol:"
20
20
echo " ## 0: SWD"
21
- echo " ## 1: Serial "
21
+ echo " ## 1: Serial"
22
22
echo " ## 2: DFU"
23
+ echo " ## Note: prefix it by 1 to erase all sectors."
24
+ echo " ## Ex: 10 erase all sectors using SWD interface."
23
25
echo " ## file_path: file path name to be downloaded: (bin, hex)"
24
26
echo " ## Options:"
25
27
echo " ## For SWD and DFU: no mandatory options"
@@ -58,14 +60,20 @@ if [ $# -lt 2 ]; then
58
60
usage 2
59
61
fi
60
62
61
- FILEPATH=$2
62
-
63
63
# 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
64
72
# Protocol $1
65
73
# 0: SWD
66
74
# 1: Serial
67
75
# 2: DFU
68
- case $1 in
76
+ case $PROTOCOL in
69
77
0)
70
78
PORT=' SWD'
71
79
MODE=' mode=UR'
@@ -89,7 +97,7 @@ if [ $# -gt 0 ]; then
89
97
OPTS=" $@ "
90
98
fi
91
99
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}
93
101
94
102
exit 0
95
103
Original file line number Diff line number Diff line change 2
2
set -o nounset # Treat unset variables as an error
3
3
STM32CP_CLI=STM32_Programmer_CLI
4
4
ADDRESS=0x8000000
5
- FILEPATH =
5
+ ERASE =
6
6
MODE=
7
7
PORT=
8
8
OPTS=
@@ -17,8 +17,10 @@ usage()
17
17
echo " ##"
18
18
echo " ## protocol: "
19
19
echo " ## 0: SWD"
20
- echo " ## 1: Serial "
20
+ echo " ## 1: Serial"
21
21
echo " ## 2: DFU"
22
+ echo " ## Note: prefix it by 1 to erase all sectors."
23
+ echo " ## Ex: 10 erase all sectors using SWD interface."
22
24
echo " ## file_path: file path name to be downloaded: (bin, hex)"
23
25
echo " ## Options:"
24
26
echo " ## For SWD and DFU: no mandatory options"
@@ -57,14 +59,21 @@ if [ $# -lt 2 ]; then
57
59
usage 2
58
60
fi
59
61
60
- FILEPATH=$2
61
-
62
62
# 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
63
71
# Protocol $1
64
72
# 0: SWD
65
73
# 1: Serial
66
74
# 2: DFU
67
- case $1 in
75
+ case $PROTOCOL in
76
+
68
77
0)
69
78
PORT=' SWD'
70
79
MODE=' mode=UR'
@@ -88,7 +97,7 @@ if [ $# -gt 0 ]; then
88
97
OPTS=" $@ "
89
98
fi
90
99
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}
92
101
93
102
exit 0
94
103
Original file line number Diff line number Diff line change 3
3
set ERROR = 0
4
4
set STM32CP_CLI = STM32_Programmer_CLI.exe
5
5
set ADDRESS = 0x8000000
6
+ set ERASE =
7
+ set MODE =
8
+ set PORT =
9
+ set OPTS =
6
10
7
11
:: Check tool
8
12
where /Q %STM32CP_CLI%
@@ -23,15 +27,23 @@ exit 1
23
27
:: Parse options
24
28
if " %~1 " == " " echo Not enough arguments! & set ERROR = 2 & goto :usage
25
29
if " %~2 " == " " echo Not enough arguments! & set ERROR = 2 & goto :usage
30
+
31
+ set PROTOCOL = %~1
26
32
set FILEPATH = %~2
27
33
28
34
:: Protocol
35
+ :: 1x: Erase all sectors
36
+ if %~1 lss 10 goto :proto
37
+ set ERASE = -e all
38
+ set /a PROTOCOL -= 10
39
+
29
40
:: 0: SWD
30
41
:: 1: Serial
31
42
:: 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
35
47
echo Protocol unknown!
36
48
set ERROR = 4
37
49
goto :usage
@@ -59,7 +71,7 @@ set OPTS=%1 %2 %3 %4 %5 %6 %7 %8 %9
59
71
goto :prog
60
72
61
73
: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%
63
75
exit 0
64
76
65
77
:usage
69
81
echo 0: SWD
70
82
echo 1: Serial
71
83
echo 2: DFU
84
+ echo Note: prefix it by 1 to erase all sectors
85
+ echo Ex: 10 erase all sectors using SWD interface
72
86
echo file_path: file path name to be downloaded: (bin, hex)
73
87
echo Options:
74
88
echo For SWD and DFU: no mandatory options
You can’t perform that action at this time.
0 commit comments