mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-21 16:46:30 +03:00
Allow multiple -t interactive terminals on the command line
Think breakpoints for a series of memory operations. In this example $ avrdude -t -U eeprom:r:dopp.eep:i -t -U eeprom:w:dopp.eep the first -U makes a backup of the EEPROM that the second terminal can then arbitrarily change because the second -U restores the EEPROM content.
This commit is contained in:
@@ -696,31 +696,31 @@ to the device. Specify it more often for even quieter operations.
|
||||
These options used to control the obsolete "safemode" feature which
|
||||
is no longer present. They are silently ignored for backwards compatibility.
|
||||
.It Fl T Ar cmd
|
||||
Slots a terminal command line
|
||||
Run terminal line
|
||||
.Ar cmd
|
||||
into the intermixed list of -T terminal commands and -U memory operations.
|
||||
The terminal command line is executed when it is its turn in the mixed list.
|
||||
Except for the simplest of terminal commands the argument
|
||||
when it is its turn in relation to other -t interactive terminal shells,
|
||||
-T terminal commands and -U memory operations. Except for the simplest
|
||||
of terminal commands the argument
|
||||
.Ar cmd
|
||||
will most likely need to be set in quotes, see your OS shell manual for
|
||||
details.
|
||||
details. See below for a detailed description of all terminal commands.
|
||||
.It Fl t
|
||||
Tells
|
||||
.Nm
|
||||
to enter the interactive terminal shell before up- or downloading files
|
||||
via the -U option or processing other -T terminal commands, if any. See
|
||||
below for a detailed description of the terminal mode.
|
||||
to run an interactive terminal shell when it is its turn in relation to
|
||||
other -t interactive terminal shells, -T terminal commands and -U memory
|
||||
operations.
|
||||
.It Xo Fl U Ar memory Ns
|
||||
.Ar \&: Ns Ar op Ns
|
||||
.Ar \&: Ns Ar filename Ns
|
||||
.Op \&: Ns Ar format
|
||||
.Xc
|
||||
Perform a memory operation as indicated. Multiple -U operations are
|
||||
allowed. The
|
||||
Perform a memory operation as indicated when it is its turn in relation to
|
||||
other -t interactive terminal shells, -T terminal commands and -U memory
|
||||
operations. The
|
||||
.Ar memory
|
||||
field specifies the memory to operate on.
|
||||
The available memory types are device-dependent, the actual
|
||||
configuration can be viewed with the
|
||||
field specifies the memory to operate on. The available memory types are
|
||||
device-dependent, the actual configuration can be viewed with the
|
||||
.Cm part
|
||||
command in terminal mode.
|
||||
Typically, a device's memory configuration at least contains
|
||||
|
||||
@@ -758,26 +758,25 @@ These options used to control the obsolete "safemode" feature which
|
||||
is no longer present. They are silently ignored for backwards compatibility.
|
||||
|
||||
@item -T @var{cmd}
|
||||
Slots a terminal command line @var{cmd} into the intermixed list of
|
||||
@code{-T} terminal commands and @code{-U} memory operations. The terminal
|
||||
command line is executed when it is its turn in the mixed list. Except for
|
||||
the simplest of terminal commands the argument @var{cmd} will most likely
|
||||
need to be set in quotes, see your OS shell manual for details.
|
||||
Run terminal line @var{cmd} when it is its turn in relation to other
|
||||
@code{-t} interactive terminal shells, @code{-T} terminal commands and
|
||||
@code{-U} memory operations. Except for the simplest of terminal commands
|
||||
the argument @var{cmd} will most likely need to be set in quotes, see your
|
||||
OS shell manual for details. See below for a detailed description of all
|
||||
terminal commands.
|
||||
|
||||
@item -t
|
||||
Tells AVRDUDE to enter the interactive terminal shell before uploading or
|
||||
downloading files via the @code{-U} option or processing other @code{-T}
|
||||
terminal commands, if any. See below for a detailed description of the
|
||||
terminal mode.
|
||||
Tells AVRDUDE to run an interactive terminal shell when it is its turn in
|
||||
relation to other @code{-t} interactive terminal shells, @code{-T}
|
||||
terminal commands and @code{-U} memory operations.
|
||||
|
||||
@item -U @var{memory}:@var{op}:@var{filename}[:@var{format}]
|
||||
Perform a memory operation.
|
||||
Multiple @option{-U} options can be specified in order to operate on
|
||||
multiple memories on the same command-line invocation. The
|
||||
@var{memory} field specifies the memory type to operate on. Use
|
||||
the @option{-v} option on the command line or the @code{part} command from
|
||||
terminal mode to display all the memory types supported by a particular
|
||||
device.
|
||||
Perform a memory operation when it is its turn in relation to other
|
||||
@code{-t} interactive terminal shells, @code{-T} terminal commands and
|
||||
@code{-U} memory operations. The @var{memory} field specifies the memory
|
||||
type to operate on. Use the @option{-T part} option on the command line or
|
||||
the @code{part} command in the interactive terminal to display all the
|
||||
memory types supported by a particular device.
|
||||
|
||||
Typically, a device's memory configuration at least contains the memory
|
||||
types @code{flash}, @code{eeprom}, @code{signature} and @code{lock}, which
|
||||
|
||||
31
src/main.c
31
src/main.c
@@ -240,12 +240,11 @@ static void usage(void)
|
||||
" -F Override invalid signature or initial checks\n"
|
||||
" -e Perform a chip erase\n"
|
||||
" -O Perform RC oscillator calibration (see AVR053)\n"
|
||||
" -t Enter terminal shell before processing -U/T\n"
|
||||
" -T <terminal cmd line> Slot terminal line into a list and run in turn\n"
|
||||
" -t Run an interactive terminal when it is its turn\n"
|
||||
" -T <terminal cmd line> Run terminal line when it is its turn\n"
|
||||
" -U <memtype>:r|w|v:<filename>[:format]\n"
|
||||
" Memory operation specification\n"
|
||||
" Multiple -U/T options are allowed; each request\n"
|
||||
" is performed in the specified intermixed order\n"
|
||||
" Carry out memory operation when it is its turn\n"
|
||||
" Multiple -t, -T and -U options can be specified\n"
|
||||
" -n Do not write to the device whilst processing -U\n"
|
||||
" -V Do not automatically verify during -U\n"
|
||||
" -E <exitsp>[,<exitsp>] List programmer exit specifications\n"
|
||||
@@ -511,11 +510,10 @@ int main(int argc, char * argv [])
|
||||
int erase; /* 1=erase chip, 0=don't */
|
||||
int calibrate; /* 1=calibrate RC oscillator, 0=don't */
|
||||
char * port; /* device port (/dev/xxx) */
|
||||
int terminal; /* 1=enter terminal mode, 0=don't */
|
||||
const char *exitspecs; /* exit specs string from command line */
|
||||
const char *programmer; /* programmer id */
|
||||
int explicit_c; /* 1=explicit -c on command line, 0=not spcified there */
|
||||
int explicit_e; /* 1=explicit -e on command line, 0=not spcified there */
|
||||
int explicit_c; /* 1=explicit -c on command line, 0=not specified there */
|
||||
int explicit_e; /* 1=explicit -e on command line, 0=not specified there */
|
||||
char sys_config[PATH_MAX]; /* system wide config file */
|
||||
char usr_config[PATH_MAX]; /* per-user config file */
|
||||
char executable_abspath[PATH_MAX]; /* absolute path to avrdude executable */
|
||||
@@ -603,7 +601,6 @@ int main(int argc, char * argv [])
|
||||
calibrate = 0;
|
||||
p = NULL;
|
||||
ovsigck = 0;
|
||||
terminal = 0;
|
||||
quell_progress = 0;
|
||||
exitspecs = NULL;
|
||||
pgm = NULL;
|
||||
@@ -767,7 +764,7 @@ int main(int argc, char * argv [])
|
||||
break;
|
||||
|
||||
case 't': /* enter terminal mode */
|
||||
terminal = 1;
|
||||
ladd(updates, cmd_update("interactive terminal"));
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@@ -1249,7 +1246,6 @@ int main(int argc, char * argv [])
|
||||
upd->filename, mtype);
|
||||
upd->memtype = cfg_strdup("main()", mtype);
|
||||
}
|
||||
|
||||
rc = update_dryrun(p, upd);
|
||||
if (rc && rc != LIBAVRDUDE_SOFTFAIL)
|
||||
doexit = 1;
|
||||
@@ -1486,15 +1482,6 @@ int main(int argc, char * argv [])
|
||||
}
|
||||
}
|
||||
|
||||
if (terminal) {
|
||||
/*
|
||||
* terminal mode
|
||||
*/
|
||||
if (uflags & UF_NOWRITE)
|
||||
pmsg_warning("the terminal ignores option -n, that is, it writes to the device\n");
|
||||
exitrc = terminal_mode(pgm, p);
|
||||
}
|
||||
|
||||
if (!init_ok) {
|
||||
/*
|
||||
* If we came here by the -tF options, bail out now.
|
||||
@@ -1504,7 +1491,7 @@ int main(int argc, char * argv [])
|
||||
}
|
||||
|
||||
|
||||
int wrmem = 0;
|
||||
int wrmem = 0, terminal = 0;
|
||||
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
||||
upd = ldata(ln);
|
||||
if(upd->cmdline && wrmem) { // Invalidate cache if device was written to
|
||||
@@ -1514,6 +1501,8 @@ int main(int argc, char * argv [])
|
||||
pgm->flush_cache(pgm, p);
|
||||
wrmem |= upd->op == DEVICE_WRITE;
|
||||
}
|
||||
if((uflags & UF_NOWRITE) && !terminal++ && upd->cmdline)
|
||||
pmsg_warning("the terminal ignores option -n, that is, it writes to the device\n");
|
||||
rc = do_op(pgm, p, upd, uflags);
|
||||
if (rc && rc != LIBAVRDUDE_SOFTFAIL) {
|
||||
exitrc = 1;
|
||||
|
||||
12
src/update.c
12
src/update.c
@@ -147,7 +147,8 @@ void free_update(UPDATE * u)
|
||||
|
||||
char *update_str(const UPDATE *upd) {
|
||||
if(upd->cmdline)
|
||||
return str_sprintf("-T %s", upd->cmdline);
|
||||
return str_sprintf("-%c %s",
|
||||
str_eq("interactive terminal", upd->cmdline)? 't': 'T', upd->cmdline);
|
||||
return str_sprintf("-U %s:%c:%s:%c",
|
||||
upd->memtype,
|
||||
upd->op == DEVICE_READ? 'r': upd->op == DEVICE_WRITE? 'w': 'v',
|
||||
@@ -375,8 +376,13 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat
|
||||
pmsg_info("processing %s\n", tofree = update_str(upd));
|
||||
free(tofree);
|
||||
|
||||
if(upd->cmdline)
|
||||
return terminal_line(pgm, p, upd->cmdline);
|
||||
if(upd->cmdline) {
|
||||
if(!str_eq(upd->cmdline, "interactive terminal"))
|
||||
return terminal_line(pgm, p, upd->cmdline);
|
||||
// Interactive terminal shell
|
||||
clearerr(stdin);
|
||||
return terminal_mode(pgm, p);
|
||||
}
|
||||
|
||||
mem = avr_locate_mem(p, upd->memtype);
|
||||
if (mem == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user