Index: include/urjtag/flash.h
===================================================================
--- include/urjtag/flash.h	(revision 1966)
+++ include/urjtag/flash.h	(working copy)
@@ -65,6 +65,8 @@
 
 extern const urj_flash_driver_t * const urj_flash_flash_drivers[];
 
+void urj_set_flash_cb(void (*cb)(int, int)); 
+
 /** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */
 int urj_flash_detectflash (urj_log_level_t ll, urj_bus_t *bus, uint32_t adr);
 void urj_flash_cleanup (void);
Index: src/flash/flash.c
===================================================================
--- src/flash/flash.c	(revision 1966)
+++ src/flash/flash.c	(working copy)
@@ -64,6 +64,12 @@
 
 static const urj_flash_driver_t *flash_driver = NULL;
 
+void (*flash_cb)(int, int) = NULL;
+
+void urj_set_flash_cb (void (*cb)(int, int)) {
+    flash_cb = cb;
+}
+
 static int
 set_flash_driver (void)
 {
@@ -308,7 +314,12 @@
     uint32_t write_buffer[BSIZE];
     int write_buffer_count;
     uint32_t write_buffer_adr;
+    uint32_t fsize, bytes;
 
+    fseek(f, 0L, SEEK_END);
+    fsize = ftell(f);
+    fseek(f, 0L, SEEK_SET);
+
     set_flash_driver ();
     if (!urj_flash_cfi_array || !flash_driver)
     {
@@ -337,6 +348,7 @@
 
     urj_log (URJ_LOG_LEVEL_NORMAL, _("program:\n"));
     adr = addr;
+    bytes = 0;
     while (!feof (f))
     {
         uint32_t data;
@@ -391,6 +403,10 @@
             adr += flash_driver->bus_width;
         }
 
+        bytes += bc;
+        if (flash_cb != NULL)
+            flash_cb(bytes, fsize);
+
         if (write_buffer_count > 0)
             if (flash_driver->program (urj_flash_cfi_array, write_buffer_adr,
                                        write_buffer, write_buffer_count))
