@@ -12,8 +12,9 @@ OFFSET=0x0
1212# Optional
1313ADDRESS=0x8000000
1414START=0x8000000
15- MODE=UR
1615ERASE=
16+ # Optional for SWD
17+ MODE=UR
1718# Optional for Serial
1819RTS=
1920DTR=
@@ -33,19 +34,22 @@ usage() {
3334 Optional options:
3435 -a, --address <hex value> flash base address. Default: $ADDRESS
3536 -e, --erase erase all sectors before flashing
36- -m, --mode connection mode: UR (default), HOTPLUG, POWERDOWN or hwRstPulse
3737 -s, --start <hex value> start address after flashing. Default: $START
3838 -o, --offset <hex value> offset from flash base ($ADDRESS ) where flashing should start
3939
40+ Specific options for SWD protocol:
41+ Optional:
42+ -m, --mode connection mode: UR (default), HOTPLUG, POWERDOWN or hwRstPulse
43+
4044 Specific options for Serial protocol:
4145 Mandatory:
42- -c, --com <name> serial identifier, ex: COM1 or /dev/ttyS0,...
46+ -c, --com <name> serial identifier, ex: COM1 or /dev/ttyS0,...
4347 Optional:
44- -r, --rts <low/high> polarity of RTS signal ('low' by default)
4548 -d, --dtr <low/high> polarity of DTR signal
4649 -p, --parity <none/even/odd> parity bit configuration ('even' by default)
50+ -r, --rts <low/high> polarity of RTS signal ('low' by default)
4751
48- Specific options for DFU protocol:
52+ Specific options for DFU protocol:
4953 Mandatory:
5054 -v, --vid <hex value> vendor id, ex: 0x0483
5155 -p, --pid <hex value> product id, ex: 0xdf11
@@ -120,12 +124,12 @@ esac
120124# parse command line arguments
121125# options may be followed by one colon to indicate they have a required arg
122126if [ -n " ${GNU_GETOPT} " ]; then
123- if ! options=$( getopt a :b:hi:m:e:o:c:r:s:d:v:p : " $@ " ) ; then
127+ if ! options=$( getopt hi :b:a:es:o:m:c:d:p:r:v : " $@ " ) ; then
124128 echo " Terminating..." >&2
125129 exit 1
126130 fi
127131else
128- if ! options=$( getopt -a -o a :b:hi:m:e:o:c:r:s:d :v:p: --long address:,bin:, help,interface:,mode:, erase,start:,offset:,com:,rts :,dtr:,vid:, pid:,parity : -- " $@ " ) ; then
132+ if ! options=$( getopt -a -o hi :b:a:es:o:m:c:d:p:r :v: --long help,interface:,bin:,address:, erase,start:,offset:,mode:,com :,dtr:,parity:,rts:, pid:,vid : -- " $@ " ) ; then
129133 echo " Terminating..." >&2
130134 exit 1
131135 fi
@@ -143,51 +147,51 @@ while true; do
143147 echo " Selected interface: $INTERFACE "
144148 shift 2
145149 ;;
146- -m | --mode )
147- MODE =$2
150+ -b | --bin )
151+ FILEPATH =$2
148152 shift 2
149153 ;;
150154 -a | --address)
151155 ADDRESS=$2
152156 shift 2
153157 ;;
154- -s | --start)
155- START=$2
156- shift 2
157- ;;
158158 -e | --erase)
159159 ERASE=" --erase all"
160160 shift 1
161161 ;;
162- -b | --bin )
163- FILEPATH =$2
162+ -s | --start )
163+ START =$2
164164 shift 2
165165 ;;
166166 -o | --offset)
167167 OFFSET=$2
168168 shift 2
169169 ;;
170- -c | --com )
171- PORT =$2
170+ -m | --mode )
171+ MODE =$2
172172 shift 2
173173 ;;
174- -r | --rts )
175- RTS= $( echo " rts= $2 " | tr ' [:upper:] ' ' [:lower:] ' )
174+ -c | --com )
175+ PORT= $2
176176 shift 2
177177 ;;
178178 -d | --dtr)
179179 DTR=$( echo " dtr=$2 " | tr ' [:upper:]' ' [:lower:]' )
180180 shift 2
181181 ;;
182- -v | --vid)
183- VID=$2
184- shift 2
185- ;;
186182 -p | --pid | --parity)
187183 PID=$2
188184 PARITY=$( echo " $2 " | tr ' [:lower:]' ' [:upper:]' )
189185 shift 2
190186 ;;
187+ -r | --rts)
188+ RTS=$( echo " rts=$2 " | tr ' [:upper:]' ' [:lower:]' )
189+ shift 2
190+ ;;
191+ -v | --vid)
192+ VID=$2
193+ shift 2
194+ ;;
191195 --)
192196 shift
193197 break
0 commit comments