diff --git a/src/avrdude.1 b/src/avrdude.1 index eb8ab98d..158a5085 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -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 bytes padded by repeating the last .Ar data diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 022448c4..f6655c67 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -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 diff --git a/src/term.c b/src/term.c index 0828e17e..5100a28e 100644 --- a/src/term.c +++ b/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 [,] {[,]}\n" " write [,] {[,]} ...\n" + " write \n" "\n" "Ellipsis ... writes bytes padded by repeating the last 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; }