.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Fri Sep 22 14:15:29 2017 +0100
Parent:
23:e9c173193a6b
Child:
25:5d8ad2655781
Commit message:
Merge pull request #33 from janjongboom/patch-1

Add some feedback on stdout when flashing new binary
.
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	Fri Sep 15 05:00:36 2017 +0100
+++ b/main.cpp	Fri Sep 22 14:15:29 2017 +0100
@@ -40,6 +40,11 @@
 
 void apply_update(FILE *file, uint32_t address)
 {
+    fseek(file, 0, SEEK_END);
+    long len = ftell(file);
+    printf("Firmware size is %ld bytes\r\n", len);
+    fseek(file, 0, SEEK_SET);
+  
     flash.init();
 
     const uint32_t page_size = flash.get_page_size();
@@ -47,6 +52,7 @@
     uint32_t addr = address;
     uint32_t next_sector = addr + flash.get_sector_size(addr);
     bool sector_erased = false;
+    size_t pages_flashed = 0;
     while (true) {
 
         // Read data for this page
@@ -69,7 +75,10 @@
         if (addr >= next_sector) {
             next_sector = addr + flash.get_sector_size(addr);
             sector_erased = false;
+        }
 
+        if (++pages_flashed % 3 == 0) {
+            printf("Flashed %ld / %ld bytes\r\n", ftell(file), len);
         }
     }
     delete[] page_buffer;