From b90309b66046e5d48467fc0433e477baa87eec67 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Fri, 13 Jan 2012 19:16:15 +0100 Subject: [PATCH] Less noisy output for STM32L erase/program, but still showing progess --- src/stlink-common.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/stlink-common.c b/src/stlink-common.c index 5a51314..28be2d2 100644 --- a/src/stlink-common.c +++ b/src/stlink-common.c @@ -893,7 +893,6 @@ uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr){ */ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) { - ILOG("Erasing flash page at addr: %#x\n", flashaddr); if (sl->chip_id == STM32F4_CHIP_ID) { /* wait for ongoing op to finish */ @@ -1234,8 +1233,11 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, unsigned WLOG("Failed to erase_flash_page(%#zx) == -1\n", addr + off); return -1; } + fprintf(stdout,"\rFlash page at addr: 0x%08lx erased", addr + off); + fflush(stdout); page_count++; } + fprintf(stdout,"\n"); ILOG("Finished erasing %d pages of %d (%#x) bytes\n", page_count, sl->flash_pgsz, sl->flash_pgsz); @@ -1321,19 +1323,20 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, unsigned /* write a word in program memory */ for (off = 0; off < len; off += sizeof(uint32_t)) { uint32_t data; + write_uint32((unsigned char*) &data, *(uint32_t*) (base + off)); + stlink_write_debug32(sl, addr + off, data); + if (sl->verbose >= 1) { if ((off & (sl->flash_pgsz - 1)) == 0) { /* show progress. writing procedure is slow and previous errors are misleading */ const uint32_t pgnum = off / sl->flash_pgsz; const uint32_t pgcount = len / sl->flash_pgsz; - fprintf(stdout, "%u pages written out of %u\n", pgnum, pgcount); + fprintf(stdout, "\r%3u/%u pages written", pgnum, pgcount); + fflush(stdout); } } - write_uint32((unsigned char*) &data, *(uint32_t*) (base + off)); - stlink_write_debug32(sl, addr + off, data); - /* wait for sr.busy to be cleared */ while ((stlink_read_debug32(sl, STM32L_FLASH_SR) & (1 << 0)) != 0) { } @@ -1377,6 +1380,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, unsigned #endif /* todo: check redo write operation */ } + fprintf(stdout, "\n"); /* reset lock bits */ val = stlink_read_debug32(sl, STM32L_FLASH_PECR) | (1 << 0) | (1 << 1) | (1 << 2);