diff options
author | Boris Baykov <dev@borisbaykov.com> | 2016-06-08 12:23:55 +0200 |
---|---|---|
committer | Cédric Le Goater <clg@kaod.org> | 2016-06-08 12:23:55 +0200 |
commit | de6a59ef0a1122b805de3cd7ffb3e06ae07b9e38 (patch) | |
tree | 5fe3a803d9a91e27e213904737b9b0cd64eacec8 /spi25.c | |
parent | 146062255451c196701c8a36e4196023a7be36be (diff) | |
download | flashrom-de6a59ef0a1122b805de3cd7ffb3e06ae07b9e38.zip flashrom-de6a59ef0a1122b805de3cd7ffb3e06ae07b9e38.tar.gz |
4BA: Progress visualization for long read, writes and erases
I've added progress visualization for read, erase and write operations.
It's turned out that seeing progress is essential for reading and
especially writing 32 MB of data via SPI. The operation can take more
then 10 minutes on 15 MHz frequency of SPI. So, it's good to see its
progress. I've added percents and slightly modified cli_output.c to
send percents to screen only but not to logfile.
Patched files
-------------
cli_output.c
+ print() patched to skip strings which are starting from '\b'
to prevent writing progress percents to logfile
flash.h
+ added some definitions for progress visialization
flashrom.c
+ added progress visualization for erase/write (essensial for 32MB+ chips)
spi25.c
+ added progress visualization for read operation (essensial for 32MB+ chips)
Signed-off-by: Boris Baykov <dev@borisbaykov.com>, Russia, Jan 2014
[clg: ported from
https://www.flashrom.org/pipermail/flashrom/2015-January/013203.html ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Diffstat (limited to 'spi25.c')
-rw-r--r-- | spi25.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -949,6 +949,16 @@ int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, int rc = 0; unsigned int i, j, starthere, lenhere, toread; unsigned int page_size = flash->chip->page_size; + int show_progress = 0; + unsigned int percent_last, percent_current; + + /* progress visualizaion init */ + if(len >= MIN_LENGTH_TO_SHOW_READ_PROGRESS) { + msg_cinfo(" "); /* only this space will go to logfile but all strings with \b wont. */ + msg_cinfo("\b 0%%"); + percent_last = percent_current = 0; + show_progress = 1; /* enable progress visualizaion */ + } /* Warning: This loop has a very unusual condition and body. * The loop needs to go through each page with at least one affected @@ -976,8 +986,20 @@ int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, } if (rc) break; + + if(show_progress) { + percent_current = (unsigned int) ((unsigned long long)(starthere + + lenhere - start) * 100 / len); + if(percent_current != percent_last) { + msg_cinfo("\b\b\b%2d%%", percent_current); + percent_last = percent_current; + } + } } + if(show_progress && !rc) + msg_cinfo("\b\b\b\b"); /* remove progress percents from the screen */ + return rc; } |