2003-02-14 Marcel Telka <marcel@telka.sk>

* src/readmem.c (readmem): Added support for 1 x 16 bit memory configuration and
		buffered file writes (Christian Pellegrin).
	* src/flash.c (flashmem): Added support for 1 x 16 bit flash configuration and
		buffered file reads (Christian Pellegrin).
	(flash_erase_block): Added debug messages (Christian Pellegrin).
	(flash_unlock_block): Added debug message (Christian Pellegrin).
	(flash_program): Ditto.


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@352 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 22 years ago
parent 4e2c69c38b
commit 98b4881223

@ -1,3 +1,13 @@
2003-02-14 Marcel Telka <marcel@telka.sk>
* src/readmem.c (readmem): Added support for 1 x 16 bit memory configuration and
buffered file writes (Christian Pellegrin).
* src/flash.c (flashmem): Added support for 1 x 16 bit flash configuration and
buffered file reads (Christian Pellegrin).
(flash_erase_block): Added debug messages (Christian Pellegrin).
(flash_unlock_block): Added debug message (Christian Pellegrin).
(flash_program): Ditto.
2003-02-14 Marcel Telka <marcel@telka.sk>
* src/cfi.c (detect_cfi): Added support for 1 x 16 bit flash configuration (Christian

@ -9,7 +9,8 @@ $Id$
* Added JTAG declarations for Intel IXP425 (Christian Pellegrin).
* Added bus driver for Intel IXP425 (Christian Pellegrin).
* Added JTAG declarations for Xilinx XC2C256-TQ144 (Alessandro Zummo).
* Added support for 1 x 16 bit flash memory detection (Christian Pellegrin).
* Added support for 1 x 16 bit memory configuration (Christian Pellegrin).
* Added buffered file reads/writes (Christian Pellegrin).
jtag-0.2.2 (2003-02-04):

@ -38,6 +38,9 @@
#include <flash/cfi.h>
#include <flash/intel.h>
#include <arpa/inet.h>
/* for ntohs */
#include "part.h"
#include "bus.h"
@ -202,7 +205,7 @@ flashmem( parts *ps, FILE *f, uint32_t addr )
int *erased;
int i;
printf( "Note: Supported configuration is 2 x 16 bit only\n" );
printf( "Note: Supported configuration is 2 x 16 bit or 1 x 16 bit only\n" );
switch (bus_width( ps )) {
case 16:
@ -238,28 +241,44 @@ flashmem( parts *ps, FILE *f, uint32_t addr )
adr = addr;
while (!feof( f )) {
uint32_t data;
#define BSIZE 4096
char b[BSIZE];
int bc = 0, bn = 0;
/* FIXME: block_no is probably invalid for 1 x 16 bit memory configuration */
int block_no = adr / (cfi->device_geometry.erase_block_regions[0].erase_block_size * 2);
printf( "addr: 0x%08X\r", adr );
if (!erased[block_no]) {
flash_unlock_block32( ps, adr );
if (o == 1)
flash_unlock_block( ps, adr );
else
flash_unlock_block32( ps, adr );
printf( "block %d unlocked\n", block_no );
printf( "erasing block %d: %d\n", block_no, flash_erase_block32( ps, adr ) );
printf( "erasing block %d: %d\n", block_no,
(o == 1) ? flash_erase_block( ps, adr ) : flash_erase_block32( ps, adr ) );
erased[block_no] = 1;
}
fread( &data, sizeof data, 1, f );
if (flash_program32( ps, adr, data )) {
printf( "\nflash error\n" );
return;
bn = fread( b, 1, BSIZE, f );
printf("addr 0x%08X (n is %d)\n", adr, bn);
for (bc = 0; bc < bn; bc += (o == 1) ? 2 : 4) {
if (o == 1)
data = htons( *((uint16_t *) &b[bc]) );
else
data = * ((uint32_t *) &b[bc]);
if ((o == 1) ? flash_program( ps, adr, data ) : flash_program32( ps, adr, data )) {
printf( "\nflash error\n" );
return;
}
adr += (o == 1) ? 2 : 4;
}
adr += 4;
}
printf( "\n" );
/* Read Array */
bus_write( ps, 0 << o, 0x00FF00FF );
if (o != 1) { /* TODO: not available in 1 x 16 bit mode */
fseek( f, 0, SEEK_SET );
printf( "verify:\n" );
adr = addr;
@ -276,6 +295,8 @@ flashmem( parts *ps, FILE *f, uint32_t addr )
adr += 4;
}
printf( "\nDone.\n" );
} else
printf( "TODO: Verify is not available in 1 x 16 bit mode.\n" );
/* BYPASS */
parts_set_instruction( ps, "BYPASS" );
@ -305,10 +326,13 @@ flash_erase_block( parts *ps, uint32_t adr )
case 0:
return 0;
case CFI_INTEL_SR_ERASE_ERROR | CFI_INTEL_SR_PROGRAM_ERROR:
printf("flash: invalid command seq\n");
return CFI_INTEL_ERROR_INVALID_COMMAND_SEQUENCE;
case CFI_INTEL_SR_ERASE_ERROR | CFI_INTEL_SR_VPEN_ERROR:
printf("flash: low vpen\n");
return CFI_INTEL_ERROR_LOW_VPEN;
case CFI_INTEL_SR_ERASE_ERROR | CFI_INTEL_SR_BLOCK_LOCKED:
printf("flash: block locked\n");
return CFI_INTEL_ERROR_BLOCK_LOCKED;
default:
break;
@ -328,9 +352,10 @@ flash_unlock_block( parts *ps, uint32_t adr )
while (!((sr = bus_read( ps, 0 ) & 0xFE) & CFI_INTEL_SR_READY)) ; /* TODO: add timeout */
if (sr != CFI_INTEL_SR_READY)
if (sr != CFI_INTEL_SR_READY) {
printf("flash: unknown error while unblocking\n");
return CFI_INTEL_ERROR_UNKNOWN;
else
} else
return 0;
}
@ -345,9 +370,10 @@ flash_program( parts *ps, uint32_t adr, uint32_t data )
while (!((sr = bus_read( ps, 0 ) & 0xFE) & CFI_INTEL_SR_READY)) ; /* TODO: add timeout */
if (sr != CFI_INTEL_SR_READY)
if (sr != CFI_INTEL_SR_READY) {
printf("flash: unknown error while programming\n");
return CFI_INTEL_ERROR_UNKNOWN;
else
} else
return 0;
}
int

@ -38,6 +38,10 @@
#include <flash/intel.h>
#include <std/mic.h>
#include <arpa/inet.h>
/* for ntohs */
#include "part.h"
#include "bus.h"
@ -55,7 +59,7 @@ detectflash( parts *ps )
return;
}
printf( "Note: Supported configuration is 2 x 16 bit only\n" );
printf( "Note: Supported configuration is 2 x 16 bit or 1 x 16 bit only\n" );
switch (bus_width( ps )) {
case 16:
@ -262,6 +266,7 @@ readmem( parts *ps, FILE *f, uint32_t addr, uint32_t len )
part *p = ps->parts[0];
int step = 0;
uint32_t a;
int bc = 0;
if (!bus_driver) {
printf( "Error: Missing bus_driver!\n" );
@ -293,15 +298,33 @@ readmem( parts *ps, FILE *f, uint32_t addr, uint32_t len )
printf( "reading:\n" );
bus_read_start( ps, addr );
for (a = addr + step; a <= addr + len; a += step) {
uint32_t d;
printf( "addr: 0x%08X\r", a );
uint32_t d = 0;
uint16_t d16 = 0;
#define BSIZE 4096
char b[BSIZE];
if (a < addr + len)
d = bus_read_next( ps, a );
else
d = bus_read_end( ps );
fwrite( &d, step, 1, f );
if (a < addr + len) {
if (step == 2)
d16 = bus_read_next( ps, a );
else
d = bus_read_next( ps, a );
}
else {
if (step == 2)
d16 = bus_read_end( ps );
else
d = bus_read_end( ps );
}
if (step == 2)
*((uint16_t *) &b[bc]) = ntohs(d16);
else
*((uint32_t *) &b[bc]) = d;
bc += step;
if ((bc >= BSIZE) || (a >= (addr + len)) ) {
printf( "addr: 0x%08X\r", a );
fwrite( b, bc, 1, f );
bc = 0;
}
}
printf( "\nDone.\n" );

Loading…
Cancel
Save