From 64b645b989ee65cdfc6e0d0aec0173d7008852b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Fri, 22 May 2009 19:57:09 +0000 Subject: [PATCH] verify speed-up: use URJ_BUS_READ_START, _NEXT, and _END instead of monolithic URJ_BUS_READ git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1618 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 3 +++ urjtag/src/flash/flash.c | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index b3d25f54..f5c0bd1d 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,5 +1,8 @@ 2009-05-22 Arnim Laeuger + * src/flash/flash.c: verify speed-up: use URJ_BUS_READ_START, _NEXT, + and _END instead of monolithic URJ_BUS_READ + * src/flash/jedec.c: rework autoselect probing, better support of x8/x16 capable flash chips diff --git a/urjtag/src/flash/flash.c b/urjtag/src/flash/flash.c index 966fd332..2eb47ce6 100644 --- a/urjtag/src/flash/flash.c +++ b/urjtag/src/flash/flash.c @@ -421,9 +421,14 @@ urj_flashmem (urj_bus_t *bus, FILE *f, uint32_t addr, int noverify) // @@@@ RFHH check error state? bn = fread (b, 1, btr, f); + /* start consecutive read */ + URJ_BUS_READ_START (bus, adr); + for (bc = 0; bc < bn; bc += flash_driver->bus_width) { int j; + uint32_t next_adr = adr + flash_driver->bus_width; + if ((adr & 0xFF) == 0) { urj_log (URJ_LOG_LEVEL_NORMAL, _("addr: 0x%08lX"), @@ -438,17 +443,25 @@ urj_flashmem (urj_bus_t *bus, FILE *f, uint32_t addr, int noverify) else data |= b[bc + j] << (j * 8); - readed = URJ_BUS_READ (bus, adr); + readed = URJ_BUS_READ_NEXT (bus, next_adr); if (data != readed) { + /* end consecutive read */ + (void) URJ_BUS_READ_END (bus); + urj_error_set (URJ_ERROR_FLASH_PROGRAM, _("addr: 0x%08lX\n verify error:\nread: 0x%08lX\nexpected: 0x%08lX\n"), (long unsigned) adr, (long unsigned) readed, (long unsigned) data); return URJ_STATUS_FAIL; } - adr += flash_driver->bus_width; + adr = next_adr; } + + /* end consecutive read + this wastes one read access but saves us from determining the for-loop + 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);