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