Skip to content

Commit 3200d92

Browse files
authored
Merge pull request #2070 from stefanrueger/parsing
Update command line option parsing
2 parents fc7ac1c + b48fd5f commit 3200d92

File tree

3 files changed

+206
-169
lines changed

3 files changed

+206
-169
lines changed

src/avrdude.1

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,38 @@
2222
.Dt AVRDUDE 1
2323
.Sh NAME
2424
.Nm avrdude
25-
.Nd driver program for ``simple'' Atmel AVR MCU programmer
25+
.Nd driver program for AVR MCU programmers
2626
.Sh SYNOPSIS
2727
.Nm
28-
.Op Fl p, \-part Ar partname
29-
.Op Fl b, \-baud Ar baudrate
30-
.Op Fl B, \-bitclock Ar bitclock
31-
.Op Fl c, \-programmer Ar programmer-id
32-
.Op Fl C, \-config Ar config-file
33-
.Op Fl N, \-noconfig
34-
.Op Fl A
35-
.Op Fl D, \-noerase
36-
.Op Fl e, \-erase
37-
.Oo Fl E Ar exitspec Ns
28+
.Op Fl p \-part Ar part
29+
.Op Fl b \-baud Ar baudrate
30+
.Op Fl B \-bitclock Ar clock
31+
.Op Fl c \-programmer Ar pgm
32+
.Op Fl C \-config Ar file
33+
.Op Fl C \-config Ar +file
34+
.Op Fl N \-noconfig
35+
.Op Fl A \-keep-trailing-0xff
36+
.Op Fl D \-noerase
37+
.Op Fl e \-erase
38+
.Oo Fl E \-exitspecs Ar exitspec Ns
3839
.Op \&, Ns Ar exitspec
3940
.Oc
40-
.Op Fl F
41-
.Op Fl i Ar delay
42-
.Op Fl l, \-logfile Ar logfile
43-
.Op Fl n, \-test-memory
44-
.Op Fl O, \-osccal
45-
.Op Fl P, \-port Ar port
46-
.Op Fl r, \-reconnect
47-
.Op Fl q, \-quell
48-
.Op Fl T Ar cmd
49-
.Op Fl t, \-terminal
50-
.Op Fl U, \-memory Ar memory:op:filename:filefmt
51-
.Op Fl v, \-verbose
52-
.Op Fl x Ar extended_param
53-
.Op Fl V, \-noverify-memory
41+
.Op Fl F \-force
42+
.Op Fl i \-isp-clock-delay Ar delay
43+
.Op Fl l \-logfile Ar file
44+
.Op Fl n \-test-memory
45+
.Op Fl O \-osccal
46+
.Op Fl P \-port Ar port
47+
.Op Fl r \-reconnect
48+
.Op Fl q \-quell
49+
.Op Fl T \-command Ar cmd
50+
.Op Fl t \-terminal
51+
.Op Fl U \-memory Ar mem:op:file:fmt
52+
.Op Fl v \-verbose
53+
.Op Fl x \-extended Ar extended_param
54+
.Op Fl V \-noverify-memory
5455
.Op Fl \-version
56+
.Op Fl h \-help
5557
.Sh DESCRIPTION
5658
.Nm Avrdude
5759
is a program for downloading and uploading on-chip memories of Atmel AVR
@@ -430,7 +432,7 @@ Run developer options for programmers that are matched by wildcard. Whilst
430432
their main use is for developers some flags can be of utility for users, e.g.,
431433
avrdude -c usbtiny/S shows AVRDUDE's understanding of usbtiny's properties;
432434
for more information run avrdude -c x/h.
433-
.It Fl C \-config Ar config-file
435+
.It Fl C \-config Ar file
434436
Use the specified config file to load configuration data. This file
435437
contains all programmer and part definitions that
436438
.Nm avrdude
@@ -440,9 +442,9 @@ See the config file, located at
440442
which contains a description of the format.
441443
.Pp
442444
If
443-
.Ar config-file
445+
.Ar file
444446
is written as
445-
.Pa +filename
447+
.Pa +file
446448
then this file is read after the system wide and user configuration
447449
files. This can be used to add entries to the configuration
448450
without patching your system wide configuration file. It can be used
@@ -452,7 +454,7 @@ line.
452454
Do not load the personal configuration file that is usually located at
453455
~/.config/avrdude/avrdude.rc, ~/.avrduderc or in the same directory as the
454456
avrdude executable
455-
.It Fl A
457+
.It Fl A \-keep-trailing-0xff
456458
Disable the automatic removal of trailing-0xFF sequences in file
457459
input that is to be programmed to flash and in AVR reads from
458460
flash memory. Normally, trailing 0xFFs can be discarded, as flash
@@ -527,7 +529,7 @@ flash.
527529
Note that for reprogramming EEPROM cells, no explicit prior chip
528530
erase is required since the MCU provides an auto-erase cycle in that
529531
case before programming the cell.
530-
.It Xo Fl E Ar exitspec Ns
532+
.It Xo Fl E \-exitspecs Ar exitspec Ns
531533
.Op \&, Ns Ar exitspec
532534
.Xc
533535
Pass
@@ -537,7 +539,7 @@ depends on the programmer itself. See below for a list of programmers
537539
accepting exitspec parameter options or issue
538540
.Nm
539541
-E help ... to see the options of the chosen programmer.
540-
.It Fl F
542+
.It Fl F \-force
541543
Normally,
542544
.Nm
543545
tries to verify that the device signature read from the part is
@@ -553,7 +555,7 @@ together with
553555
to continue in terminal mode.
554556
Moreover, the option allows to continue despite failed initialization
555557
of connection between a programmer and a target.
556-
.It Fl i Ar delay
558+
.It Fl i \-isp-clock-delay Ar delay
557559
For bitbang-type programmers, delay for approximately
558560
.Ar delay
559561
microseconds between each bit state change.
@@ -571,9 +573,9 @@ is running.
571573
On Win32 operating systems, a preconfigured number of cycles per
572574
microsecond is assumed that might be off a bit for very fast or very
573575
slow machines.
574-
.It Fl l \-logfile Ar logfile
576+
.It Fl l \-logfile Ar file
575577
Use
576-
.Ar logfile
578+
.Ar file
577579
rather than
578580
.Va stderr
579581
for diagnostics output.
@@ -747,7 +749,7 @@ Posix systems (by now).
747749
.It Fl q \-quell
748750
Disable (or quell) output of the progress bar while reading or writing
749751
to the device. Specify it more often for even quieter operations.
750-
.It Fl T Ar cmd
752+
.It Fl T \-command Ar cmd
751753
Run terminal line
752754
.Ar cmd
753755
when it is its turn in relation to other -t interactive terminals
@@ -969,7 +971,7 @@ options increase verbosity level.
969971
Disable automatic verify check when writing data to the AVR with -U.
970972
.It Fl \-version
971973
Print version and exit
972-
.It Fl x Ar extended_param
974+
.It Fl x \-extended Ar extended_param
973975
Pass
974976
.Ar extended_param
975977
to the chosen programmer implementation as an extended parameter.
@@ -979,6 +981,8 @@ See below for a list of programmers accepting extended parameters
979981
or issue
980982
.Nm
981983
-x help ... to see the extended options of the chosen programmer.
984+
.It Fl h \-help
985+
Show a short help message and exit
982986
.El
983987
.Ss Terminal mode
984988
In this mode,

src/doc/avrdude.texi

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,11 @@ Do not load the personal configuration file that is usually located at
666666
directory as the avrdude executable.
667667

668668
@item -A
669+
@item --keep-trailing-0xff
669670
@cindex Option @code{-A}
671+
@cindex Option @code{--keep-trailing-0xff}
670672
@cindex @code{-A}
673+
@cindex @code{--keep-trailing-0xff}
671674
@cindex @code{flash}
672675
Disable the automatic removal of trailing-0xFF sequences in file input
673676
that is to be programmed to flash and in AVR reads from flash memory.
@@ -732,8 +735,11 @@ required since the MCU provides an auto-erase cycle in that case before
732735
programming the cell.
733736

734737
@item -E @var{exitspec}[,@dots{}]
738+
@item --exitspecs @var{exitspec}[,@dots{}]
735739
@cindex Option @code{-E} @var{exitspec}[,@dots{}]
740+
@cindex Option @code{--exitspecs} @var{exitspec}[,@dots{}]
736741
@cindex @code{-E} @var{exitspec}[,@dots{}]
742+
@cindex @code{--exitspecs} @var{exitspec}[,@dots{}]
737743
Pass @var{exitspec} to the programmer. The interpretation of the exitspec
738744
parameter depends on the programmer itself. See below for a list of
739745
programmers accepting exitspec parameter options or issue
@@ -742,8 +748,11 @@ programmers accepting exitspec parameter options or issue
742748
Multiple @var{exitspec} options can be separated with commas.
743749

744750
@item -F
751+
@item --force
745752
@cindex Option @code{-F}
753+
@cindex Option @code{--force}
746754
@cindex @code{-F}
755+
@cindex @code{--force}
747756
@cindex @code{signature}
748757
Normally, AVRDUDE tries to verify that the device signature read from
749758
the part is reasonable before continuing. Since it can happen from time
@@ -758,8 +767,11 @@ Moreover, the option allows to continue despite failed initialization
758767
of connection between a programmer and a target.
759768

760769
@item -i @var{delay}
770+
@item --isp-clock-delay @var{delay}
761771
@cindex Option @code{-i} @var{delay}
772+
@cindex Option @code{--isp-clock-delay} @var{delay}
762773
@cindex @code{-i} @var{delay}
774+
@cindex @code{--isp-clock-delay} @var{delay}
763775
For bitbang-type programmers, delay for approximately
764776
@var{delay}
765777
microseconds between each bit state change.
@@ -941,8 +953,11 @@ Disable (or quell) output of the progress bar while reading or writing
941953
to the device. Specify it a second time for even quieter operation.
942954

943955
@item -T @var{cmd}
956+
@item --command @var{cmd}
944957
@cindex Option @code{-T} @var{cmd}
958+
@cindex Option @code{--command} @var{cmd}
945959
@cindex @code{-T} @var{cmd}
960+
@cindex @code{--command} @var{cmd}
946961
Run terminal line @var{cmd} when it is its turn in relation to other
947962
@code{-t} interactive terminals, @code{-T} terminal commands and
948963
@code{-U} memory operations. Except for the simplest of terminal commands
@@ -960,16 +975,16 @@ Tells AVRDUDE to run an interactive terminal when it is its turn in
960975
relation to other @code{-t} interactive terminals, @code{-T}
961976
terminal commands and @code{-U} memory operations.
962977

963-
@item -U @var{memory}:@var{op}:@var{filename}[:@var{format}]
964-
@item --memory @var{memory}:@var{op}:@var{filename}[:@var{format}]
965-
@cindex Option @code{-U} @var{memory}:@var{op}:@var{filename}[:@var{format}]
966-
@cindex Option @code{--memory} @var{memory}:@var{op}:@var{filename}[:@var{format}]
967-
@cindex @code{-U} @var{memory}:@var{op}:@var{filename}[:@var{format}]
968-
@cindex @code{--memory} @var{memory}:@var{op}:@var{filename}[:@var{format}]
978+
@item -U @var{mem}:@var{op}:@var{file}[:@var{fmt}]
979+
@item --memory @var{mem}:@var{op}:@var{fil}[:@var{fmt}]
980+
@cindex Option @code{-U} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
981+
@cindex Option @code{--memory} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
982+
@cindex @code{-U} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
983+
@cindex @code{--memory} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
969984

970985
Perform a memory operation when it is its turn in relation to other
971986
@code{-t} interactive terminals, @code{-T} terminal commands and @code{-U}
972-
memory operations. The @var{memory} field specifies the memory type to
987+
memory operations. The @var{mem} field specifies the memory type to
973988
operate on. From version 8.0 the memory field can also be a
974989
comma-separated list of memories, eg, @code{flash,eeprom}; also, Intel Hex
975990
or Motorola S-Record files generated by AVRDUDE can store multiple
@@ -1037,8 +1052,8 @@ read data from both the device and the specified file and perform a verify
10371052

10381053
@end table
10391054

1040-
The @var{filename} field indicates the name of the file to read or
1041-
write. The @var{format} field is optional and contains the format of
1055+
The @var{file} field indicates the name of the file to read or
1056+
write. The @var{fmt} field is optional and contains the format of
10421057
the file to read or write. Possible values are:
10431058

10441059
@table @code
@@ -1066,7 +1081,7 @@ linker; currently only accepted as an input file
10661081
@cindex Immediate file mode
10671082
@item m
10681083
immediate mode; actual byte values are specified on the command line,
1069-
separated by commas or spaces in place of the @var{filename} field of the
1084+
separated by commas or spaces in place of the @var{file} field of the
10701085
@option{-U} option. This is useful for programming fuse bytes without
10711086
having to create a single-byte file or enter terminal mode.
10721087

@@ -1120,9 +1135,9 @@ single output file from a memory list for all formats with the exception
11201135
of elf (@code{:e}) it only recognises Intel hex (@code{:I} or @code{:i}),
11211136
Motorola S-Record (@code{:s}) or elf files (@code{:e}, generated by the
11221137
compiler) as valid multi-memory files when reading a file for verifying or
1123-
writing memories. Note also that if a @var{filename} contains a colon as
1124-
penultimate character the @var{format} field is no longer optional since
1125-
the last character would otherwise be misinterpreted as @var{format}.
1138+
writing memories. Note also that if a file name contains a colon as
1139+
penultimate character the @var{fmt} field is no longer optional since
1140+
the last character would otherwise be misinterpreted as @var{fmt}.
11261141

11271142
@cindex @code{flash}
11281143
When reading any kind of flash memory area (including the various sub-areas
@@ -1132,11 +1147,11 @@ entire memory is unprogrammed, this will result in an output file that has no
11321147
contents at all. This behaviour can be overridden with the @code{-A} option.
11331148

11341149
@cindex @code{flash}
1135-
As an abbreviation, the form @code{-U} @var{filename}
1150+
As an abbreviation, the form @code{-U} @var{file}
11361151
is equivalent to specifying
1137-
@code{-U} @emph{flash:w:}@var{filename}@emph{:a} or
1138-
@code{-U} @emph{application:w:}@var{filename}@emph{:a} for ATxmegas.
1139-
This will only work if @var{filename} does not have a pair of colons in it
1152+
@code{-U} @emph{flash:w:}@var{file}@emph{:a} or
1153+
@code{-U} @emph{application:w:}@var{file}@emph{:a} for ATxmegas.
1154+
This will only work if @var{file} does not have a pair of colons in it
11401155
that sandwich a single character as otherwise the first part might be
11411156
interpreted as memory, and the single character as memory operation.
11421157

@@ -1169,14 +1184,26 @@ Disable automatic verify check when writing data to the AVR with @code{-U}.
11691184
@cindex Option @code{--version}
11701185
Print avrdude version and exit
11711186

1172-
@item -x @var{extended_param}
1173-
@cindex Option @code{-x} @var{extended_param}
1174-
@cindex @code{-x} @var{extended_param}
1175-
Pass @var{extended_param} to the chosen programmer implementation as
1187+
@item -x @var{parameter}
1188+
@item --extended @var{parameter}
1189+
@cindex Option @code{-x} @var{parameter}
1190+
@cindex Option @code{--extended} @var{parameter}
1191+
@cindex @code{-x} @var{parameter}
1192+
@cindex @code{--extended} @var{parameter}
1193+
Pass @var{parameter} to the chosen programmer implementation as
11761194
an extended parameter. The interpretation of the extended parameter
11771195
depends on the programmer itself. See below for a list of programmers
11781196
accepting extended parameters or issue @code{avrdude -x help ...} to
1179-
see the extended options of the chosen programmer.
1197+
see the extended options of the chosen programmer. This option can be used
1198+
several times on the command line.
1199+
1200+
@item -h
1201+
@item --help
1202+
@cindex Option @code{-h}
1203+
@cindex Option @code{--help}
1204+
@cindex @code{-h}
1205+
@cindex @code{--help}
1206+
Show a short help text and exit
11801207

11811208
@end table
11821209

0 commit comments

Comments
 (0)