From bd55feaba6b18732f769d0650485f2ccf0778a88 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Tue, 23 Sep 2003 18:04:03 +0000 Subject: [PATCH] 2003-09-23 Marcel Telka * src/flash.c (flash_drivers): Added amd_16_flash_driver (Bradley D. LaRonde). (find_block): New function (Bradley D. LaRonde). (flashmem): Added block calculations using exact CFI data (Bradley D. LaRonde). * src/tap/cable/triton.c (triton_init): Removed unused variable 'data'. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@570 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 8 ++++++++ jtag/NEWS | 1 + jtag/THANKS | 1 + jtag/src/flash.c | 32 +++++++++++++++++++++++++++++--- jtag/src/tap/cable/triton.c | 2 -- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index e6753c04..3c55d83b 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,11 @@ +2003-09-23 Marcel Telka + + * src/flash.c (flash_drivers): Added amd_16_flash_driver (Bradley D. LaRonde). + (find_block): New function (Bradley D. LaRonde). + (flashmem): Added block calculations using exact CFI data (Bradley D. LaRonde). + + * src/tap/cable/triton.c (triton_init): Removed unused variable 'data'. + 2003-09-15 Marcel Telka * configure.ac: Fixed spelling (patch 805108, Andreas Mohr). diff --git a/jtag/NEWS b/jtag/NEWS index 7e77cd75..a574bd10 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -12,6 +12,7 @@ jtag-0.5.1: * Used real data bus width for data reading in PXA2x0, SA1110, and SH7727 bus drivers (based on patch 792591, thanks to Guennadi Liakhovetski). * Added 'initbus' command to allow dynamic bus driver loading. + * Added support for flashes with multiple block erase regions for 'flashmem' (Bradley D. LaRonde). * Added BOOT_DEF register emulation for PXA2x0 bus driver. * Fixed inverted TRST signal for Macraigor Wiggler JTAG Cable see patch 799377 for more info, thanks to Mike Tesch for reporting). diff --git a/jtag/THANKS b/jtag/THANKS index f73feba9..db57f672 100644 --- a/jtag/THANKS +++ b/jtag/THANKS @@ -12,6 +12,7 @@ Jachym Holecek August Hörandl Rojhalat Ibrahim Stas Khirman +Bradley D. LaRonde Guennadi Liakhovetski Andreas Mohr Brad Parker diff --git a/jtag/src/flash.c b/jtag/src/flash.c index 15558fd2..85a71bf7 100644 --- a/jtag/src/flash.c +++ b/jtag/src/flash.c @@ -47,6 +47,7 @@ #include "jtag.h" extern flash_driver_t amd_32_flash_driver; +extern flash_driver_t amd_16_flash_driver; extern flash_driver_t amd_8_flash_driver; extern flash_driver_t intel_32_flash_driver; extern flash_driver_t intel_16_flash_driver; @@ -54,6 +55,7 @@ extern flash_driver_t intel_8_flash_driver; flash_driver_t *flash_drivers[] = { &amd_32_flash_driver, + &amd_16_flash_driver, &amd_8_flash_driver, &intel_32_flash_driver, &intel_16_flash_driver, @@ -232,6 +234,26 @@ flashmsbin( bus_t *bus, FILE *f ) cfi_array_free( cfi_array ); } +static int +find_block( cfi_query_structure_t *cfi, int adr ) +{ + int i; + int b = 0; + int bb = 0; + + for (i = 0; i < cfi->device_geometry.number_of_erase_regions; i++) { + const int region_blocks = cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks; + const int region_block_size = cfi->device_geometry.erase_block_regions[i].erase_block_size; + const int region_size = region_blocks * region_block_size; + + if (adr < (bb + region_size)) + return b + ((adr - bb) / region_block_size); + b += region_blocks; + bb += region_size; + } + return -1; +} + void flashmem( bus_t *bus, FILE *f, uint32_t addr ) { @@ -240,6 +262,7 @@ flashmem( bus_t *bus, FILE *f, uint32_t addr ) cfi_array_t *cfi_array; int *erased; int i; + int neb; flashcheck( bus, &cfi_array ); if (!cfi_array || !flash_driver) { @@ -248,12 +271,15 @@ flashmem( bus_t *bus, FILE *f, uint32_t addr ) } cfi = &cfi_array->cfi_chips[0]->cfi; - erased = malloc( cfi->device_geometry.erase_block_regions[0].number_of_erase_blocks * sizeof *erased ); + for (i = 0, neb = 0; i < cfi->device_geometry.number_of_erase_regions; i++) + neb += cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks; + + erased = malloc( neb * sizeof *erased ); if (!erased) { printf( _("Out of memory!\n") ); return; } - for (i = 0; i < cfi->device_geometry.erase_block_regions[0].number_of_erase_blocks; i++) + for (i = 0; i < neb; i++) erased[i] = 0; printf( _("program:\n") ); @@ -263,7 +289,7 @@ flashmem( bus_t *bus, FILE *f, uint32_t addr ) #define BSIZE 4096 uint8_t b[BSIZE]; int bc = 0, bn = 0; - int block_no = adr / (cfi->device_geometry.erase_block_regions[0].erase_block_size * flash_driver->bus_width / 2); + int block_no = find_block( cfi, adr ); if (!erased[block_no]) { flash_driver->unlock_block( cfi_array, adr ); diff --git a/jtag/src/tap/cable/triton.c b/jtag/src/tap/cable/triton.c index cc0fd59c..797d139c 100644 --- a/jtag/src/tap/cable/triton.c +++ b/jtag/src/tap/cable/triton.c @@ -68,8 +68,6 @@ static int triton_init( cable_t *cable ) { - int data; - if (parport_open( cable->port )) return -1;