Hello all,
The flash programming speed can be improved by skipping the write of the
blocks which contains only 0xFF.
I have added time measuring feature to the flashing rutine.
Regards,
Miklós
Index: src/flash/flash.c
===================================================================
--- src/flash/flash.c (revision 1971)
+++ src/flash/flash.c (working copy)
@@ -39,6 +39,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
#include <urjtag/error.h>
#include <urjtag/log.h>
@@ -308,7 +309,11 @@
uint32_t write_buffer[BSIZE];
int write_buffer_count;
uint32_t write_buffer_adr;
+ time_t write_start, write_end;
+ size_t bytes_written = 0;
+ time (&write_start);
+
set_flash_driver ();
if (!urj_flash_cfi_array || !flash_driver)
{
@@ -341,6 +346,8 @@
{
uint32_t data;
uint8_t b[BSIZE];
+ uint8_t write_need = 0;
+
int bc = 0, bn = 0, btr = BSIZE;
int block_no = find_block (cfi, adr - urj_flash_cfi_array->address,
bus_width, chip_width, &btr);
@@ -352,6 +359,7 @@
btr = BSIZE;
// @@@@ RFHH check error state?
bn = fread (b, 1, btr, f);
+ bytes_written += bn;
if (bn > 0 && !erased[block_no])
{
@@ -380,11 +388,16 @@
data = 0;
for (j = 0; j < flash_driver->bus_width; j++)
+ {
if (urj_get_file_endian () == URJ_ENDIAN_BIG)
data = (data << 8) | b[bc + j];
else
data |= b[bc + j] << (j * 8);
+ if (b[bc + j] != 0xFF)
+ write_need = 1;
+ }
+
/* store data in write buffer, will be programmed to flash later */
write_buffer[write_buffer_count++] = data;
@@ -392,18 +405,30 @@
}
if (write_buffer_count > 0)
- if (flash_driver->program (urj_flash_cfi_array, write_buffer_adr,
- write_buffer, write_buffer_count))
+ {
+ if (write_need)
{
- // retain error state
- return URJ_STATUS_FAIL;
+ if (flash_driver->program (urj_flash_cfi_array, write_buffer_adr,
+ write_buffer, write_buffer_count))
+ {
+ // retain error state
+ return URJ_STATUS_FAIL;
+ }
}
+ else
+ {
+ urj_log (URJ_LOG_LEVEL_NORMAL, _("empty block skip programming\n"));
+ }
+ }
}
free (erased);
- urj_log (URJ_LOG_LEVEL_NORMAL, _("addr: 0x%08lX\n"),
- (long unsigned) adr - flash_driver->bus_width);
+ time(&write_end);
+ urj_log (URJ_LOG_LEVEL_NORMAL, _("addr: 0x%08lX\nDone: %lu bytes written in %.2lf seconds.\n"),
+ (long unsigned) adr - flash_driver->bus_width,
+ (long unsigned) bytes_written,
+ difftime (write_end, write_start));
flash_driver->readarray (urj_flash_cfi_array);
@@ -467,9 +492,13 @@
finish condition twice within the loop */
(void) URJ_BUS_READ_END (bus);
}
- urj_log (URJ_LOG_LEVEL_NORMAL, _("addr: 0x%08lX\nDone.\n"),
- (long unsigned) adr - flash_driver->bus_width);
+ time(&write_end);
+
+ urj_log (URJ_LOG_LEVEL_NORMAL, _("addr: 0x%08lX\nDone: %lu bytes written and verified in %.2lf seconds.\n"),
+ (long unsigned) adr - flash_driver->bus_width,
+ (long unsigned) bytes_written,
+ difftime (write_end, write_start));
return URJ_STATUS_OK;
}
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development