From 1cc25f3284a3fb7a1d58ad5e62f0bf64d6f6d329 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 15:03:08 +0100 Subject: [PATCH] Unify memory description for memory list --- src/update.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/update.c b/src/update.c index 60aba7c7..5a561927 100644 --- a/src/update.c +++ b/src/update.c @@ -464,8 +464,9 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat return LIBAVRDUDE_SOFTFAIL; } + const char *mem_desc = !umemlist? avr_mem_name(p, mem): + ns==1? avr_mem_name(p, umemlist[0]): "multiple memories"; int rc = 0; - const char *mem_desc = avr_mem_name(p, mem); switch (upd->op) { case DEVICE_READ: // Read out the specified device memory and write it to a file @@ -489,8 +490,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat */ int dffo = cx->avr_disableffopt; cx->avr_disableffopt = 1; - pmsg_info("reading %s memor%s ...\n", - ns==1? avr_mem_name(p, umemlist[0]): "multiple", ns==1? "y": "ies"); + pmsg_info("reading %s ...\n", mem_desc); int nn = 0; for(int ii = 0; ii < ns; ii++) { m = umemlist[ii]; @@ -547,17 +547,15 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat break; case DEVICE_WRITE: - // Write the selected device memory using data from a file + // Write the selected device memory/ies using data from a file - rc = fileio(FIO_READ, upd->filename, upd->format, p, umstr, -1); + pmsg_info("reading input file %s for %s\n", str_inname(upd->filename), mem_desc); + rc = fileio_mem(FIO_READ, upd->filename, upd->format, p, mem, -1); if (rc < 0) { pmsg_error("read from file %s failed\n", str_inname(upd->filename)); goto error; } - - pmsg_info("reading input file %s for %s\n", str_inname(upd->filename), mem_desc); - - if(memstats(p, umstr, rc, &fs) < 0) + if(memstats_mem(p, mem, rc, &fs) < 0) goto error; imsg_info("with %d byte%s in %d section%s within %s\n", @@ -574,6 +572,8 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat msg_info("\n"); } + + // Patch flash input, eg, for vector bootloaders if(pgm->flash_readhook) { AVRMEM *mem = avr_locate_mem(p, umstr); @@ -607,7 +607,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat size = rc; // Write the buffer contents to the selected memory - pmsg_info("writing %d byte%s %s ...\n", fs.nbytes, + pmsg_info("writing %d byte%s to %s ...\n", fs.nbytes, str_plural(fs.nbytes), mem_desc); if (!(flags & UF_NOWRITE)) {