File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 11#! /bin/sh -
22set -o nounset # Treat unset variables as an error
3+ # set -o xtrace # Print command traces before executing command.
34
45STM32CP_CLI=
56ADDRESS=0x8000000
@@ -13,7 +14,7 @@ OPTS=""
1314usage () {
1415 echo " ############################################################"
1516 echo " ##"
16- echo " ## $( basename " $0 " ) <protocol> <file_path> [OPTIONS]"
17+ echo " ## $( basename " $0 " ) <protocol> <file_path> <offset> [OPTIONS]"
1718 echo " ##"
1819 echo " ## protocol:"
1920 echo " ## 0: SWD"
@@ -22,6 +23,7 @@ usage() {
2223 echo " ## Note: prefix it by 1 to erase all sectors."
2324 echo " ## Ex: 10 erase all sectors using SWD interface."
2425 echo " ## file_path: file path name to be downloaded: (bin, hex)"
26+ echo " ## offset: offset to add to $ADDRESS "
2527 echo " ## Options:"
2628 echo " ## For SWD and DFU: no mandatory options"
2729 echo " ## For Serial: <com_port>"
@@ -92,14 +94,17 @@ case "${UNAME_OS}" in
9294 ;;
9395esac
9496
95- if [ $# -lt 2 ]; then
97+ if [ $# -lt 3 ]; then
9698 echo " Not enough arguments!"
9799 usage 2
98100fi
99101
100102# Parse options
101103PROTOCOL=$1
102104FILEPATH=$2
105+ OFFSET=$3
106+ ADDRESS=$( printf " 0x%x" $(( ADDRESS + OFFSET)) )
107+
103108# Protocol $1
104109# 1x: Erase all sectors
105110if [ " $1 " -ge 10 ]; then
@@ -114,19 +119,19 @@ case $PROTOCOL in
114119 0)
115120 PORT=" SWD"
116121 MODE=" mode=UR"
117- shift 2
122+ shift 3
118123 ;;
119124 1)
120- if [ $# -lt 3 ]; then
125+ if [ $# -lt 4 ]; then
121126 usage 3
122127 else
123- PORT=$3
124- shift 3
128+ PORT=$4
129+ shift 4
125130 fi
126131 ;;
127132 2)
128133 PORT=" USB1"
129- shift 2
134+ shift 3
130135 ;;
131136 * )
132137 echo " Protocol unknown!"
You can’t perform that action at this time.
0 commit comments