mbed-os-examples
/
mbed-os-example-mbed5-bootloader
.
Revision 27:d0b91bdc2f52, committed 2017-10-06
- Comitter:
- mbed_official
- Date:
- Fri Oct 06 03:00:39 2017 +0100
- Parent:
- 26:bc66fc02f3ef
- Child:
- 28:eb466f6f50a1
- Commit message:
- Print percent done to increase speed
Print percent done and only print it when the percent has changed.
This greatly increases flashing speed on devices with small page
size, such as the K64F with a reported page size of 24 bytes.
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-bootloader
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 02 17:15:30 2017 +0100 +++ b/main.cpp Fri Oct 06 03:00:39 2017 +0100 @@ -53,6 +53,7 @@ uint32_t next_sector = addr + flash.get_sector_size(addr); bool sector_erased = false; size_t pages_flashed = 0; + uint32_t percent_done = 0; while (true) { // Read data for this page @@ -78,9 +79,15 @@ } if (++pages_flashed % 3 == 0) { - printf("Flashed %ld / %ld bytes\r\n", ftell(file), len); + uint32_t percent_done_new = ftell(file) * 100 / len; + if (percent_done != percent_done_new) { + percent_done = percent_done_new; + printf("Flashed %3ld%%\r", percent_done); + } } } + printf("Flashed 100%%\r\n", ftell(file), len); + delete[] page_buffer; flash.deinit();