From 2589b176405ad5024f1f4d041efea5b179f152f6 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Thu, 17 Feb 2022 11:24:59 +0100 Subject: [PATCH] Add support for memory "fill" mode Syntax: write ... --- src/term.c | 48 +++++++++++++++++++++++++++++++++++++----------- src/term.h | 4 ++++ 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/term.c b/src/term.c index 5c91931c..295ae612 100644 --- a/src/term.c +++ b/src/term.c @@ -336,11 +336,13 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p, unsigned char b; int rc; int werror; + int write_mode; AVRMEM * mem; if (argc < 4) { - avrdude_message(MSG_INFO, "Usage: write " - " ... \n"); + avrdude_message(MSG_INFO, + "Usage: write \n" + " write <...>\n"); return -1; } @@ -368,8 +370,19 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p, return -1; } - /* number of bytes to write at the specified address */ - len = argc - 3; + // Figure out how many bytes to write to memory + if(strcmp(argv[5], "...") == 0) { + write_mode = WRITE_MODE_FILL; + len = strtoul(argv[3], &e, 0); + if (*e || (e == argv[3])) { + avrdude_message(MSG_INFO, "%s (write ...): can't parse address \"%s\"\n", + progname, argv[3]); + return -1; + } + } else { + write_mode = WRITE_MODE_STANDARD; + len = argc - 3; + } if ((addr + len) > maxsize) { avrdude_message(MSG_INFO, "%s (write): selected address and # bytes exceed " @@ -384,13 +397,26 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p, return -1; } - for (i=3; i