mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-23 17:46:33 +03:00
Merge pull request #1315 from MCUdude/terminal-single-byte-write
Make the start write address optional in terminal mode
This commit is contained in:
@@ -910,6 +910,11 @@ needs eight bytes as it is the same as 0xFFFFffffFFFFffffU.
|
||||
One trailing comma at the end of
|
||||
.Ar data
|
||||
items is ignored to facilitate copy & paste of lists.
|
||||
.It Ar write memory data
|
||||
The start address
|
||||
.Ar addr
|
||||
may be omitted if the size of the memory being written to is
|
||||
1 byte in size.
|
||||
.It Ar write memory addr len data[,] {data[,]} ...
|
||||
The ellipsis ... form writes <len> bytes padded by repeating the last
|
||||
.Ar data
|
||||
|
||||
@@ -1616,6 +1616,10 @@ eight bytes as it is the same as @code{0xFFFFffffFFFFffffU}.
|
||||
One trailing comma at the end of data items is ignored to facilitate copy
|
||||
and paste of lists.
|
||||
|
||||
@item write @var{memtype} @var{addr} @var{data}
|
||||
The start address @code{addr} may be omitted if the size of the memory
|
||||
being written to is 1 byte in size.
|
||||
|
||||
@item write @var{memtype} @var{addr} @var{length} @var{data[,]} @{@var{data[,]}@} @dots{}
|
||||
The ellipsis form @dots{} of write is similar to above, but @var{length}
|
||||
byte of the memory are written. For that purpose, after writing the
|
||||
|
||||
28
src/term.c
28
src/term.c
@@ -406,10 +406,11 @@ static int is_mantissa_only(char *p) {
|
||||
|
||||
|
||||
static int cmd_write(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
||||
if (argc < 4) {
|
||||
if (argc < 3) {
|
||||
msg_error(
|
||||
"Usage: write <memory> <addr> <data>[,] {<data>[,]}\n"
|
||||
" write <memory> <addr> <len> <data>[,] {<data>[,]} ...\n"
|
||||
" write <memory> <data>\n"
|
||||
"\n"
|
||||
"Ellipsis ... writes <len> bytes padded by repeating the last <data> item.\n"
|
||||
"\n"
|
||||
@@ -456,13 +457,23 @@ static int cmd_write(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
||||
}
|
||||
int maxsize = mem->size;
|
||||
|
||||
char *end_ptr;
|
||||
int addr = strtoul(argv[2], &end_ptr, 0);
|
||||
if (*end_ptr || (end_ptr == argv[2])) {
|
||||
pmsg_error("(write) cannot parse address %s\n", argv[2]);
|
||||
if (argc == 3 && maxsize > 1) {
|
||||
pmsg_error("(write) no start address specified for memory %s\n"
|
||||
"Please specify a start address for memories greater than 1 byte in size\n",
|
||||
memtype);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *end_ptr;
|
||||
int addr = 0;
|
||||
if(argc >= 4) {
|
||||
addr = strtoul(argv[2], &end_ptr, 0);
|
||||
if (*end_ptr || (end_ptr == argv[2])) {
|
||||
pmsg_error("(write) cannot parse address %s\n", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr < 0 || addr >= maxsize) {
|
||||
pmsg_error("(write) %s address 0x%05x is out of range [0, 0x%05x]\n", mem->desc, addr, maxsize-1);
|
||||
return -1;
|
||||
@@ -487,7 +498,12 @@ static int cmd_write(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
||||
}
|
||||
} else {
|
||||
write_mode = WRITE_MODE_STANDARD;
|
||||
start_offset = 3;
|
||||
// With no user specified start address, data starts at argv[2]
|
||||
// With user specified start address, data starts at a argv[3]
|
||||
if(argc == 3)
|
||||
start_offset = 2;
|
||||
else
|
||||
start_offset = 3;
|
||||
len = argc - start_offset;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user