mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-06-02 09:46:34 +03:00
Merge pull request #2070 from stefanrueger/parsing
Update command line option parsing
This commit is contained in:
@@ -22,36 +22,38 @@
|
||||
.Dt AVRDUDE 1
|
||||
.Sh NAME
|
||||
.Nm avrdude
|
||||
.Nd driver program for ``simple'' Atmel AVR MCU programmer
|
||||
.Nd driver program for AVR MCU programmers
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl p, \-part Ar partname
|
||||
.Op Fl b, \-baud Ar baudrate
|
||||
.Op Fl B, \-bitclock Ar bitclock
|
||||
.Op Fl c, \-programmer Ar programmer-id
|
||||
.Op Fl C, \-config Ar config-file
|
||||
.Op Fl N, \-noconfig
|
||||
.Op Fl A
|
||||
.Op Fl D, \-noerase
|
||||
.Op Fl e, \-erase
|
||||
.Oo Fl E Ar exitspec Ns
|
||||
.Op Fl p \-part Ar part
|
||||
.Op Fl b \-baud Ar baudrate
|
||||
.Op Fl B \-bitclock Ar clock
|
||||
.Op Fl c \-programmer Ar pgm
|
||||
.Op Fl C \-config Ar file
|
||||
.Op Fl C \-config Ar +file
|
||||
.Op Fl N \-noconfig
|
||||
.Op Fl A \-keep-trailing-0xff
|
||||
.Op Fl D \-noerase
|
||||
.Op Fl e \-erase
|
||||
.Oo Fl E \-exitspecs Ar exitspec Ns
|
||||
.Op \&, Ns Ar exitspec
|
||||
.Oc
|
||||
.Op Fl F
|
||||
.Op Fl i Ar delay
|
||||
.Op Fl l, \-logfile Ar logfile
|
||||
.Op Fl n, \-test-memory
|
||||
.Op Fl O, \-osccal
|
||||
.Op Fl P, \-port Ar port
|
||||
.Op Fl r, \-reconnect
|
||||
.Op Fl q, \-quell
|
||||
.Op Fl T Ar cmd
|
||||
.Op Fl t, \-terminal
|
||||
.Op Fl U, \-memory Ar memory:op:filename:filefmt
|
||||
.Op Fl v, \-verbose
|
||||
.Op Fl x Ar extended_param
|
||||
.Op Fl V, \-noverify-memory
|
||||
.Op Fl F \-force
|
||||
.Op Fl i \-isp-clock-delay Ar delay
|
||||
.Op Fl l \-logfile Ar file
|
||||
.Op Fl n \-test-memory
|
||||
.Op Fl O \-osccal
|
||||
.Op Fl P \-port Ar port
|
||||
.Op Fl r \-reconnect
|
||||
.Op Fl q \-quell
|
||||
.Op Fl T \-command Ar cmd
|
||||
.Op Fl t \-terminal
|
||||
.Op Fl U \-memory Ar mem:op:file:fmt
|
||||
.Op Fl v \-verbose
|
||||
.Op Fl x \-extended Ar extended_param
|
||||
.Op Fl V \-noverify-memory
|
||||
.Op Fl \-version
|
||||
.Op Fl h \-help
|
||||
.Sh DESCRIPTION
|
||||
.Nm Avrdude
|
||||
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
|
||||
their main use is for developers some flags can be of utility for users, e.g.,
|
||||
avrdude -c usbtiny/S shows AVRDUDE's understanding of usbtiny's properties;
|
||||
for more information run avrdude -c x/h.
|
||||
.It Fl C \-config Ar config-file
|
||||
.It Fl C \-config Ar file
|
||||
Use the specified config file to load configuration data. This file
|
||||
contains all programmer and part definitions that
|
||||
.Nm avrdude
|
||||
@@ -440,9 +442,9 @@ See the config file, located at
|
||||
which contains a description of the format.
|
||||
.Pp
|
||||
If
|
||||
.Ar config-file
|
||||
.Ar file
|
||||
is written as
|
||||
.Pa +filename
|
||||
.Pa +file
|
||||
then this file is read after the system wide and user configuration
|
||||
files. This can be used to add entries to the configuration
|
||||
without patching your system wide configuration file. It can be used
|
||||
@@ -452,7 +454,7 @@ line.
|
||||
Do not load the personal configuration file that is usually located at
|
||||
~/.config/avrdude/avrdude.rc, ~/.avrduderc or in the same directory as the
|
||||
avrdude executable
|
||||
.It Fl A
|
||||
.It Fl A \-keep-trailing-0xff
|
||||
Disable the automatic removal of trailing-0xFF sequences in file
|
||||
input that is to be programmed to flash and in AVR reads from
|
||||
flash memory. Normally, trailing 0xFFs can be discarded, as flash
|
||||
@@ -527,7 +529,7 @@ flash.
|
||||
Note that for reprogramming EEPROM cells, no explicit prior chip
|
||||
erase is required since the MCU provides an auto-erase cycle in that
|
||||
case before programming the cell.
|
||||
.It Xo Fl E Ar exitspec Ns
|
||||
.It Xo Fl E \-exitspecs Ar exitspec Ns
|
||||
.Op \&, Ns Ar exitspec
|
||||
.Xc
|
||||
Pass
|
||||
@@ -537,7 +539,7 @@ depends on the programmer itself. See below for a list of programmers
|
||||
accepting exitspec parameter options or issue
|
||||
.Nm
|
||||
-E help ... to see the options of the chosen programmer.
|
||||
.It Fl F
|
||||
.It Fl F \-force
|
||||
Normally,
|
||||
.Nm
|
||||
tries to verify that the device signature read from the part is
|
||||
@@ -553,7 +555,7 @@ together with
|
||||
to continue in terminal mode.
|
||||
Moreover, the option allows to continue despite failed initialization
|
||||
of connection between a programmer and a target.
|
||||
.It Fl i Ar delay
|
||||
.It Fl i \-isp-clock-delay Ar delay
|
||||
For bitbang-type programmers, delay for approximately
|
||||
.Ar delay
|
||||
microseconds between each bit state change.
|
||||
@@ -571,9 +573,9 @@ is running.
|
||||
On Win32 operating systems, a preconfigured number of cycles per
|
||||
microsecond is assumed that might be off a bit for very fast or very
|
||||
slow machines.
|
||||
.It Fl l \-logfile Ar logfile
|
||||
.It Fl l \-logfile Ar file
|
||||
Use
|
||||
.Ar logfile
|
||||
.Ar file
|
||||
rather than
|
||||
.Va stderr
|
||||
for diagnostics output.
|
||||
@@ -747,7 +749,7 @@ Posix systems (by now).
|
||||
.It Fl q \-quell
|
||||
Disable (or quell) output of the progress bar while reading or writing
|
||||
to the device. Specify it more often for even quieter operations.
|
||||
.It Fl T Ar cmd
|
||||
.It Fl T \-command Ar cmd
|
||||
Run terminal line
|
||||
.Ar cmd
|
||||
when it is its turn in relation to other -t interactive terminals
|
||||
@@ -969,7 +971,7 @@ options increase verbosity level.
|
||||
Disable automatic verify check when writing data to the AVR with -U.
|
||||
.It Fl \-version
|
||||
Print version and exit
|
||||
.It Fl x Ar extended_param
|
||||
.It Fl x \-extended Ar extended_param
|
||||
Pass
|
||||
.Ar extended_param
|
||||
to the chosen programmer implementation as an extended parameter.
|
||||
@@ -979,6 +981,8 @@ See below for a list of programmers accepting extended parameters
|
||||
or issue
|
||||
.Nm
|
||||
-x help ... to see the extended options of the chosen programmer.
|
||||
.It Fl h \-help
|
||||
Show a short help message and exit
|
||||
.El
|
||||
.Ss Terminal mode
|
||||
In this mode,
|
||||
|
||||
@@ -666,8 +666,11 @@ Do not load the personal configuration file that is usually located at
|
||||
directory as the avrdude executable.
|
||||
|
||||
@item -A
|
||||
@item --keep-trailing-0xff
|
||||
@cindex Option @code{-A}
|
||||
@cindex Option @code{--keep-trailing-0xff}
|
||||
@cindex @code{-A}
|
||||
@cindex @code{--keep-trailing-0xff}
|
||||
@cindex @code{flash}
|
||||
Disable the automatic removal of trailing-0xFF sequences in file input
|
||||
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
|
||||
programming the cell.
|
||||
|
||||
@item -E @var{exitspec}[,@dots{}]
|
||||
@item --exitspecs @var{exitspec}[,@dots{}]
|
||||
@cindex Option @code{-E} @var{exitspec}[,@dots{}]
|
||||
@cindex Option @code{--exitspecs} @var{exitspec}[,@dots{}]
|
||||
@cindex @code{-E} @var{exitspec}[,@dots{}]
|
||||
@cindex @code{--exitspecs} @var{exitspec}[,@dots{}]
|
||||
Pass @var{exitspec} to the programmer. The interpretation of the exitspec
|
||||
parameter depends on the programmer itself. See below for a list of
|
||||
programmers accepting exitspec parameter options or issue
|
||||
@@ -742,8 +748,11 @@ programmers accepting exitspec parameter options or issue
|
||||
Multiple @var{exitspec} options can be separated with commas.
|
||||
|
||||
@item -F
|
||||
@item --force
|
||||
@cindex Option @code{-F}
|
||||
@cindex Option @code{--force}
|
||||
@cindex @code{-F}
|
||||
@cindex @code{--force}
|
||||
@cindex @code{signature}
|
||||
Normally, AVRDUDE tries to verify that the device signature read from
|
||||
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
|
||||
of connection between a programmer and a target.
|
||||
|
||||
@item -i @var{delay}
|
||||
@item --isp-clock-delay @var{delay}
|
||||
@cindex Option @code{-i} @var{delay}
|
||||
@cindex Option @code{--isp-clock-delay} @var{delay}
|
||||
@cindex @code{-i} @var{delay}
|
||||
@cindex @code{--isp-clock-delay} @var{delay}
|
||||
For bitbang-type programmers, delay for approximately
|
||||
@var{delay}
|
||||
microseconds between each bit state change.
|
||||
@@ -941,8 +953,11 @@ Disable (or quell) output of the progress bar while reading or writing
|
||||
to the device. Specify it a second time for even quieter operation.
|
||||
|
||||
@item -T @var{cmd}
|
||||
@item --command @var{cmd}
|
||||
@cindex Option @code{-T} @var{cmd}
|
||||
@cindex Option @code{--command} @var{cmd}
|
||||
@cindex @code{-T} @var{cmd}
|
||||
@cindex @code{--command} @var{cmd}
|
||||
Run terminal line @var{cmd} when it is its turn in relation to other
|
||||
@code{-t} interactive terminals, @code{-T} terminal commands and
|
||||
@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
|
||||
relation to other @code{-t} interactive terminals, @code{-T}
|
||||
terminal commands and @code{-U} memory operations.
|
||||
|
||||
@item -U @var{memory}:@var{op}:@var{filename}[:@var{format}]
|
||||
@item --memory @var{memory}:@var{op}:@var{filename}[:@var{format}]
|
||||
@cindex Option @code{-U} @var{memory}:@var{op}:@var{filename}[:@var{format}]
|
||||
@cindex Option @code{--memory} @var{memory}:@var{op}:@var{filename}[:@var{format}]
|
||||
@cindex @code{-U} @var{memory}:@var{op}:@var{filename}[:@var{format}]
|
||||
@cindex @code{--memory} @var{memory}:@var{op}:@var{filename}[:@var{format}]
|
||||
@item -U @var{mem}:@var{op}:@var{file}[:@var{fmt}]
|
||||
@item --memory @var{mem}:@var{op}:@var{fil}[:@var{fmt}]
|
||||
@cindex Option @code{-U} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
|
||||
@cindex Option @code{--memory} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
|
||||
@cindex @code{-U} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
|
||||
@cindex @code{--memory} @var{mem}:@var{op}:@var{file}[:@var{fmt}]
|
||||
|
||||
Perform a memory operation when it is its turn in relation to other
|
||||
@code{-t} interactive terminals, @code{-T} terminal commands and @code{-U}
|
||||
memory operations. The @var{memory} field specifies the memory type to
|
||||
memory operations. The @var{mem} field specifies the memory type to
|
||||
operate on. From version 8.0 the memory field can also be a
|
||||
comma-separated list of memories, eg, @code{flash,eeprom}; also, Intel Hex
|
||||
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
|
||||
|
||||
@end table
|
||||
|
||||
The @var{filename} field indicates the name of the file to read or
|
||||
write. The @var{format} field is optional and contains the format of
|
||||
The @var{file} field indicates the name of the file to read or
|
||||
write. The @var{fmt} field is optional and contains the format of
|
||||
the file to read or write. Possible values are:
|
||||
|
||||
@table @code
|
||||
@@ -1066,7 +1081,7 @@ linker; currently only accepted as an input file
|
||||
@cindex Immediate file mode
|
||||
@item m
|
||||
immediate mode; actual byte values are specified on the command line,
|
||||
separated by commas or spaces in place of the @var{filename} field of the
|
||||
separated by commas or spaces in place of the @var{file} field of the
|
||||
@option{-U} option. This is useful for programming fuse bytes without
|
||||
having to create a single-byte file or enter terminal mode.
|
||||
|
||||
@@ -1120,9 +1135,9 @@ single output file from a memory list for all formats with the exception
|
||||
of elf (@code{:e}) it only recognises Intel hex (@code{:I} or @code{:i}),
|
||||
Motorola S-Record (@code{:s}) or elf files (@code{:e}, generated by the
|
||||
compiler) as valid multi-memory files when reading a file for verifying or
|
||||
writing memories. Note also that if a @var{filename} contains a colon as
|
||||
penultimate character the @var{format} field is no longer optional since
|
||||
the last character would otherwise be misinterpreted as @var{format}.
|
||||
writing memories. Note also that if a file name contains a colon as
|
||||
penultimate character the @var{fmt} field is no longer optional since
|
||||
the last character would otherwise be misinterpreted as @var{fmt}.
|
||||
|
||||
@cindex @code{flash}
|
||||
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
|
||||
contents at all. This behaviour can be overridden with the @code{-A} option.
|
||||
|
||||
@cindex @code{flash}
|
||||
As an abbreviation, the form @code{-U} @var{filename}
|
||||
As an abbreviation, the form @code{-U} @var{file}
|
||||
is equivalent to specifying
|
||||
@code{-U} @emph{flash:w:}@var{filename}@emph{:a} or
|
||||
@code{-U} @emph{application:w:}@var{filename}@emph{:a} for ATxmegas.
|
||||
This will only work if @var{filename} does not have a pair of colons in it
|
||||
@code{-U} @emph{flash:w:}@var{file}@emph{:a} or
|
||||
@code{-U} @emph{application:w:}@var{file}@emph{:a} for ATxmegas.
|
||||
This will only work if @var{file} does not have a pair of colons in it
|
||||
that sandwich a single character as otherwise the first part might be
|
||||
interpreted as memory, and the single character as memory operation.
|
||||
|
||||
@@ -1169,14 +1184,26 @@ Disable automatic verify check when writing data to the AVR with @code{-U}.
|
||||
@cindex Option @code{--version}
|
||||
Print avrdude version and exit
|
||||
|
||||
@item -x @var{extended_param}
|
||||
@cindex Option @code{-x} @var{extended_param}
|
||||
@cindex @code{-x} @var{extended_param}
|
||||
Pass @var{extended_param} to the chosen programmer implementation as
|
||||
@item -x @var{parameter}
|
||||
@item --extended @var{parameter}
|
||||
@cindex Option @code{-x} @var{parameter}
|
||||
@cindex Option @code{--extended} @var{parameter}
|
||||
@cindex @code{-x} @var{parameter}
|
||||
@cindex @code{--extended} @var{parameter}
|
||||
Pass @var{parameter} to the chosen programmer implementation as
|
||||
an extended parameter. The interpretation of the extended parameter
|
||||
depends on the programmer itself. See below for a list of programmers
|
||||
accepting extended parameters or issue @code{avrdude -x help ...} to
|
||||
see the extended options of the chosen programmer.
|
||||
see the extended options of the chosen programmer. This option can be used
|
||||
several times on the command line.
|
||||
|
||||
@item -h
|
||||
@item --help
|
||||
@cindex Option @code{-h}
|
||||
@cindex Option @code{--help}
|
||||
@cindex @code{-h}
|
||||
@cindex @code{--help}
|
||||
Show a short help text and exit
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
264
src/main.c
264
src/main.c
@@ -236,49 +236,48 @@ static void usage(void) {
|
||||
char *cfg = home && str_casestarts(usr_config, home)?
|
||||
mmt_sprintf("~/%s", usr_config + l + (usr_config[l] == '/')): mmt_sprintf("%s", usr_config);
|
||||
|
||||
msg_error("Usage: %s [options]\n"
|
||||
msg_error("Usage: %s {<option>}\n"
|
||||
"Options:\n"
|
||||
" -p, --part <partno> Specify AVR device; -p ? lists all known parts\n"
|
||||
" -p, --part <wildcard>/<flags>\n"
|
||||
" Run developer options for matched AVR devices,\n"
|
||||
" e.g., -p ATmega328P/s or /S for part definition\n"
|
||||
" -b, --baud <baudrate> Override RS-232 baud rate\n"
|
||||
" -B, --bitclock <bitclock> Specify bit clock period (us)\n"
|
||||
" -C, --config <config-file>\n"
|
||||
" Specify location of configuration file\n"
|
||||
" -C, --config +<config-file>\n"
|
||||
" Specify additional config file, can be repeated\n"
|
||||
" -N, --noconfig Do not load %s%s\n"
|
||||
" -c, --programmer <programmer>\n"
|
||||
" Specify programmer; -c ? and -c ?type list all\n"
|
||||
" -c, --programmer <wildcard>/<flags>\n"
|
||||
" Run developer options for matched programmers,\n"
|
||||
" e.g., -c 'ur*'/s for programmer info/definition\n"
|
||||
" -A Disable trailing-0xff removal for file/AVR read\n"
|
||||
" -D, --noerase Disable auto-erase for flash memory; implies -A\n"
|
||||
" -i <delay> Bit state change delay [in microseconds] for\n"
|
||||
" bit-banged ISP and TPI programmers\n"
|
||||
" -P, --port <port> Connection; -P ?s or -P ?sa lists serial ones\n"
|
||||
" -r, --reconnect Reconnect to -P port after \"touching\" it; wait\n"
|
||||
" 400 ms for each -r; needed for some USB boards\n"
|
||||
" -F Override invalid signature or initial checks\n"
|
||||
" -e, --erase Perform a chip erase at the beginning\n"
|
||||
" -O, --osccal Perform RC oscillator calibration (see AVR053)\n"
|
||||
" -t, --terminal Run an interactive terminal when it is its turn\n"
|
||||
" -T <terminal cmd line> Run terminal line when it is its turn\n"
|
||||
" -U, --memory <memstr>:r|w|v:<filename>[:format]\n"
|
||||
" Carry out memory operation when it is its turn\n"
|
||||
" Multiple -t, -T and -U options can be specified\n"
|
||||
" -n, --test-memory Do not write to the device whilst processing -U\n"
|
||||
" -V, --noverify-memory Do not automatically verify during -U\n"
|
||||
" -E <exitsp>[,<exitsp>] List programmer exit specifications\n"
|
||||
" -x <extended_param> Pass <extended_param> to programmer, see -x help\n"
|
||||
" -v, --verbose Verbose output; -v -v for more\n"
|
||||
" -q, --quell Quell progress output; -q -q for less\n"
|
||||
" -l, --logfile logfile Use logfile rather than stderr for diagnostics\n"
|
||||
" --version Print version and exit\n"
|
||||
" -?, --help Display this usage\n"
|
||||
"\navrdude version %s, https://github.com/avrdudes/avrdude\n",
|
||||
" -p --part <part> Specify AVR device; -p ? lists all known parts\n"
|
||||
" -p --part <wildcard>/<flags>\n"
|
||||
" Run developer options for matched AVR devices,\n"
|
||||
" e.g., -p ATmega328P/s or /S for part definition\n"
|
||||
" -b --baud <baudrate> Override RS-232 baud rate\n"
|
||||
" -B --bitclock <period> Bit clock period (us)\n"
|
||||
" -C --config <file> Specify location of configuration file\n"
|
||||
" -C --config +<file> Additional config file (*)\n"
|
||||
" -N --noconfig Do not load %s%s\n"
|
||||
" -c --programmer <pgm> Specify programmer; -c ? and -c ?type list all\n"
|
||||
" -c --programmer <wildcard>/<flags>\n"
|
||||
" Run developer options for matched programmers,\n"
|
||||
" e.g., -c 'ur*'/s for programmer definition\n"
|
||||
" -A --keep-trailing-0xff Disable trailing-0xff removal for file/AVR read\n"
|
||||
" -D --noerase Disable auto-erase for flash memory; implies -A\n"
|
||||
" -i --isp-clock-delay <delay>\n"
|
||||
" Bit state change delay [in microseconds] for\n"
|
||||
" bit-banged ISP and TPI programmers\n"
|
||||
" -P --port <port> Connection; -P ?s or -P ?sa lists serial ones\n"
|
||||
" -r --reconnect Reconnect to -P port after \"touching\" it; wait\n"
|
||||
" 400 ms for each -r; needed for some USB boards\n"
|
||||
" -F --force Override invalid signature or initial checks\n"
|
||||
" -e --erase Perform a chip erase at the beginning\n"
|
||||
" -O --osccal Perform RC oscillator calibration (see AVR053)\n"
|
||||
" -t --terminal Run interactive terminal on its turn (*)\n"
|
||||
" -T --command <line> Run terminal command <line> on its turn (*)\n"
|
||||
" -U --memory <mem>:r|w|v:<file>[:fmt]\n"
|
||||
" Carry out memory operation on its turn (*)\n"
|
||||
" -n --test-memory Do not write to the device whilst processing -U\n"
|
||||
" -V --noverify-memory Do not automatically verify during -U\n"
|
||||
" -E --exitspecs <exitsp>{,<exitsp>}\n"
|
||||
" Programmer exit specifications list\n"
|
||||
" -x --extended <param> Pass <param> to programmer, see -x help (*)\n"
|
||||
" -v --verbose Verbose output; -v -v for more\n"
|
||||
" -q --quell Quell progress output; -q -q for less\n"
|
||||
" -l --logfile logfile Use logfile rather than stderr for diagnostics\n"
|
||||
" --version Print version and exit\n"
|
||||
" -h --help Display this usage\n"
|
||||
"(*) These options can be repeatedly used on the command line\n"
|
||||
"\navrdude version %s https://github.com/avrdudes/avrdude\n",
|
||||
progname, strlen(cfg) < 24? "config file ": "", cfg, AVRDUDE_FULL_VERSION);
|
||||
|
||||
mmt_free(cfg);
|
||||
@@ -825,36 +824,41 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Process command line arguments
|
||||
struct option longopts[] = {
|
||||
{"help", no_argument, NULL, '?'},
|
||||
{"baud", required_argument, NULL, 'b'},
|
||||
{"bitclock", required_argument, NULL, 'B'},
|
||||
{"programmer", required_argument, NULL, 'c'},
|
||||
{"config", required_argument, NULL, 'C'},
|
||||
{"noerase", no_argument, NULL, 'D'},
|
||||
{"erase", no_argument, NULL, 'e'},
|
||||
{"logfile", required_argument, NULL, 'l'},
|
||||
{"test-memory",no_argument, NULL, 'n'},
|
||||
{"noconfig", no_argument, NULL, 'N'},
|
||||
{"osccal", no_argument, NULL, 'O'},
|
||||
{"part", required_argument, NULL, 'p'},
|
||||
{"port", required_argument, NULL, 'P'},
|
||||
{"quell", no_argument, NULL, 'q'},
|
||||
{"reconnect", no_argument, NULL, 'r'},
|
||||
{"terminal", no_argument, NULL, 't'},
|
||||
{"memory", required_argument, NULL, 'U'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"noverify-memory",no_argument, NULL, 'V'},
|
||||
{"version", no_argument, &showversion, 0},
|
||||
{NULL, 0, NULL, 0}
|
||||
{"keep-trailing-0xff", no_argument, NULL, 'A'},
|
||||
{"baud", required_argument, NULL, 'b'},
|
||||
{"bitclock", required_argument, NULL, 'B'},
|
||||
{"programmer", required_argument, NULL, 'c'},
|
||||
{"config", required_argument, NULL, 'C'},
|
||||
{"noerase", no_argument, NULL, 'D'},
|
||||
{"erase", no_argument, NULL, 'e'},
|
||||
{"exitspecs", required_argument, NULL, 'E'},
|
||||
{"force", no_argument, NULL, 'F'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"isp-clock-delay", required_argument, NULL, 'i'},
|
||||
{"logfile", required_argument, NULL, 'l'},
|
||||
{"test-memory", no_argument, NULL, 'n'},
|
||||
{"noconfig", no_argument, NULL, 'N'},
|
||||
{"osccal", no_argument, NULL, 'O'},
|
||||
{"part", required_argument, NULL, 'p'},
|
||||
{"port", required_argument, NULL, 'P'},
|
||||
{"quell", no_argument, NULL, 'q'},
|
||||
{"reconnect", no_argument, NULL, 'r'},
|
||||
{"terminal", no_argument, NULL, 't'},
|
||||
{"command", required_argument, NULL, 'T'},
|
||||
{"memory", required_argument, NULL, 'U'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"noverify-memory", no_argument, NULL, 'V'},
|
||||
{"version", no_argument, &showversion, 1},
|
||||
{"extended", required_argument, NULL, 'x'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
const char shortopts[] =
|
||||
"aAb:B:c:C:dDeE:fFgGhHi:IjJkKl:LmMnNoOp:P:qQrRsStT:uU:vVwWx:XyYzZ0123456789";
|
||||
int option_idx = 0;
|
||||
|
||||
while((ch = getopt_long(argc, argv,
|
||||
"?Ab:B:c:C:DeE:Fi:l:nNp:OP:qrtT:U:vVx:",
|
||||
longopts, &option_idx)) != -1) {
|
||||
while((ch = getopt_long(argc, argv, shortopts, longopts, &option_idx)) != -1) {
|
||||
switch(ch) {
|
||||
case 'b': // Override default programmer baud rate
|
||||
case 'b': // Override default programmer baud rate
|
||||
baudrate = str_int(optarg, STR_INT32, &errstr);
|
||||
if(errstr) {
|
||||
pmsg_error("invalid baud rate %s specified: %s\n", optarg, errstr);
|
||||
@@ -862,7 +866,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'B': // Specify bit clock period
|
||||
case 'B': // Specify bit clock period
|
||||
bitclock = strtod(optarg, &e);
|
||||
if((e == optarg) || bitclock <= 0.0) {
|
||||
pmsg_error("invalid bit clock period %s\n", optarg);
|
||||
@@ -884,7 +888,47 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'i': // Specify isp clock delay
|
||||
case 'c': // Programmer
|
||||
pgmid = optarg;
|
||||
explicit_c = 1;
|
||||
break;
|
||||
|
||||
case 'C': // System wide configuration file (can be repeated)
|
||||
if(optarg[0] == '+') {
|
||||
ladd(additional_config_files, optarg + 1);
|
||||
} else {
|
||||
strncpy(sys_config, optarg, PATH_MAX);
|
||||
sys_config[PATH_MAX - 1] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D': // Disable auto-erase
|
||||
uflags &= ~UF_AUTO_ERASE;
|
||||
// Fall through
|
||||
|
||||
case 'A': // Keep trailing flash 0xff
|
||||
cx->avr_disableffopt = 1;
|
||||
break;
|
||||
|
||||
case 'e': // Perform a chip erase
|
||||
erase = 1;
|
||||
explicit_e = 1;
|
||||
uflags &= ~UF_AUTO_ERASE;
|
||||
break;
|
||||
|
||||
case 'E': // Voltage levels on exit
|
||||
exitspecs = optarg;
|
||||
break;
|
||||
|
||||
case 'F': // Override invalid signature check
|
||||
ovsigck = 1;
|
||||
break;
|
||||
|
||||
case 'h': // Help message
|
||||
usage();
|
||||
exit(0);
|
||||
|
||||
case 'i': // ISP clock delay
|
||||
ispdelay = str_int(optarg, STR_INT32, &errstr);
|
||||
if(errstr || ispdelay == 0) {
|
||||
pmsg_error("invalid isp clock delay %s specified", optarg);
|
||||
@@ -896,83 +940,47 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c': // Programmer id
|
||||
pgmid = optarg;
|
||||
explicit_c = 1;
|
||||
break;
|
||||
|
||||
case 'C': // System wide configuration file
|
||||
if(optarg[0] == '+') {
|
||||
ladd(additional_config_files, optarg + 1);
|
||||
} else {
|
||||
strncpy(sys_config, optarg, PATH_MAX);
|
||||
sys_config[PATH_MAX - 1] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D': // Disable auto-erase
|
||||
uflags &= ~UF_AUTO_ERASE;
|
||||
// Fall through
|
||||
|
||||
case 'A': // Explicit disabling of trailing-0xff removal
|
||||
cx->avr_disableffopt = 1;
|
||||
break;
|
||||
|
||||
case 'e': // Perform a chip erase
|
||||
erase = 1;
|
||||
explicit_e = 1;
|
||||
uflags &= ~UF_AUTO_ERASE;
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
exitspecs = optarg;
|
||||
break;
|
||||
|
||||
case 'F': // Override invalid signature check
|
||||
ovsigck = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'l': // Log file
|
||||
logfile = optarg;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
case 'n': // -U does not write to chip
|
||||
uflags |= UF_NOWRITE;
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
case 'N': // Do not load user config file
|
||||
no_avrduderc = 1;
|
||||
break;
|
||||
|
||||
case 'O': // Perform RC oscillator calibration
|
||||
case 'O': // Perform RC oscillator calibration
|
||||
calibrate = 1;
|
||||
break;
|
||||
|
||||
case 'p': // Specify AVR part
|
||||
case 'p': // Specify AVR part
|
||||
partdesc = optarg;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
case 'P': // Port
|
||||
port = mmt_strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'q': // Quell progress output
|
||||
case 'q': // Quell progress output
|
||||
quell_progress++;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'r': // Reconnect
|
||||
touch_1200bps++;
|
||||
break;
|
||||
|
||||
case 't': // Enter terminal mode
|
||||
case 't': // Enter terminal mode (can be repeated)
|
||||
ladd(updates, cmd_update("interactive terminal"));
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
case 'T': // Execute terminal command (can be repeated)
|
||||
ladd(updates, cmd_update(optarg));
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
case 'U': // Memory operation (can be repeated)
|
||||
upd = parse_op(optarg);
|
||||
if(upd == NULL) {
|
||||
pmsg_error("unable to parse update operation %s\n", optarg);
|
||||
@@ -981,33 +989,31 @@ int main(int argc, char *argv[]) {
|
||||
ladd(updates, upd);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
case 'v': // Increase verbosity
|
||||
verbose++;
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
case 'V': // No verification on -U
|
||||
uflags &= ~UF_VERIFY;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
case 'x': // Extended parameter (can be repeated)
|
||||
ladd(extended_params, optarg);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
if(longopts[option_idx].flag)
|
||||
*longopts[option_idx].flag = 1;
|
||||
break;
|
||||
case '?': // Some error with options
|
||||
if(optopt == '?')
|
||||
usage();
|
||||
exit(optopt != '?');
|
||||
|
||||
case '?': // Help
|
||||
usage();
|
||||
exit(0);
|
||||
case 0: // Nothing to do for long options
|
||||
break;
|
||||
|
||||
default:
|
||||
pmsg_error("invalid option -%c\n\n", ch);
|
||||
usage();
|
||||
msg_error("\n");
|
||||
pmsg_error("invalid option -%c\n", ch);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user