File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh -
2
2
set -o nounset # Treat unset variables as an error
3
+ # set -o xtrace # Print command traces before executing command.
3
4
4
5
STM32CP_CLI=
5
6
ADDRESS=0x8000000
@@ -13,7 +14,7 @@ OPTS=""
13
14
usage () {
14
15
echo " ############################################################"
15
16
echo " ##"
16
- echo " ## $( basename " $0 " ) <protocol> <file_path> [OPTIONS]"
17
+ echo " ## $( basename " $0 " ) <protocol> <file_path> <offset> [OPTIONS]"
17
18
echo " ##"
18
19
echo " ## protocol:"
19
20
echo " ## 0: SWD"
@@ -22,6 +23,7 @@ usage() {
22
23
echo " ## Note: prefix it by 1 to erase all sectors."
23
24
echo " ## Ex: 10 erase all sectors using SWD interface."
24
25
echo " ## file_path: file path name to be downloaded: (bin, hex)"
26
+ echo " ## offset: offset to add to $ADDRESS "
25
27
echo " ## Options:"
26
28
echo " ## For SWD and DFU: no mandatory options"
27
29
echo " ## For Serial: <com_port>"
@@ -92,14 +94,17 @@ case "${UNAME_OS}" in
92
94
;;
93
95
esac
94
96
95
- if [ $# -lt 2 ]; then
97
+ if [ $# -lt 3 ]; then
96
98
echo " Not enough arguments!"
97
99
usage 2
98
100
fi
99
101
100
102
# Parse options
101
103
PROTOCOL=$1
102
104
FILEPATH=$2
105
+ OFFSET=$3
106
+ ADDRESS=$( printf " 0x%x" $(( ADDRESS + OFFSET)) )
107
+
103
108
# Protocol $1
104
109
# 1x: Erase all sectors
105
110
if [ " $1 " -ge 10 ]; then
@@ -114,19 +119,19 @@ case $PROTOCOL in
114
119
0)
115
120
PORT=" SWD"
116
121
MODE=" mode=UR"
117
- shift 2
122
+ shift 3
118
123
;;
119
124
1)
120
- if [ $# -lt 3 ]; then
125
+ if [ $# -lt 4 ]; then
121
126
usage 3
122
127
else
123
- PORT=$3
124
- shift 3
128
+ PORT=$4
129
+ shift 4
125
130
fi
126
131
;;
127
132
2)
128
133
PORT=" USB1"
129
- shift 2
134
+ shift 3
130
135
;;
131
136
* )
132
137
echo " Protocol unknown!"
You can’t perform that action at this time.
0 commit comments