Renamed old `readmem' to `detectflash'. Added new `readmem' which really read the memory.

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@254 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 22 years ago
parent df8ac7fa89
commit 2a086cbeeb

@ -46,7 +46,8 @@ get_token( char *buf )
return strtok( buf, " \f\n\r\t\v" );
}
void readmem( parts *ps );
void detectflash( parts *ps );
void readmem( parts *ps, FILE *f, uint32_t addr, uint32_t len );
void flashmem( parts *ps, FILE *f, uint32_t addr );
void flashmsbin( parts *ps, FILE *f );
@ -157,7 +158,56 @@ main( void )
}
if (strcmp( t, "readmem" ) == 0) {
readmem( ps );
FILE *f;
uint32_t addr = 0;
uint32_t len = 0;
t = get_token( NULL );
if (!t) {
printf( "flashmem: Missing argument(s)\n" );
continue;
}
if ((sscanf( t, "0x%x", &addr ) != 1) && (sscanf( t, "%d", &addr ) != 1)) {
printf( "syntax error\n" );
continue;
}
t = get_token( NULL );
if (!t) {
printf( "flashmem: Missing argument(s)\n" );
continue;
}
if ((sscanf( t, "0x%x", &len ) != 1) && (sscanf( t, "%d", &len ) != 1)) {
printf( "syntax error\n" );
continue;
}
/* filename */
t = get_token( NULL );
if (!t) {
printf( "flashmem: missing filename\n" );
continue;
}
f = fopen( t, "w" );
if (!f) {
printf( "Unable to create file `%s'!\n", t );
continue;
}
t = get_token( NULL );
if (t) {
printf( "syntax error!\n" );
fclose( f );
continue;
}
readmem( ps, f, addr, len );
fclose( f );
continue;
}
if (strcmp( t, "detectflash" ) == 0) {
detectflash( ps );
continue;
}

@ -44,7 +44,7 @@
cfi_query_structure_t *detect_cfi( parts * );
void
readmem( parts *ps )
detectflash( parts *ps )
{
part *p = ps->parts[0];
int o = 0;
@ -251,3 +251,54 @@ readmem( parts *ps )
/* Read Array */
bus_write( ps, 0 << o, 0x00FF00FF );
}
void
readmem( parts *ps, FILE *f, uint32_t addr, uint32_t len )
{
part *p = ps->parts[0];
int step = 0;
uint32_t a;
if (!bus_driver) {
printf( "Error: Missing bus_driver!\n" );
return;
}
step = bus_width( ps ) / 8;
if (step == 0) {
printf( "Unknown bus width!\n" );
return;
}
/* EXTEST */
part_set_instruction( p, "EXTEST" );
parts_shift_instructions( ps );
addr = addr & (~(step - 1));
len = (len + step - 1) & (~(step - 1));
printf( "address: 0x%08X\n", addr );
printf( "length: 0x%08X\n", len );
if (len == 0) {
printf( "length is 0.\n" );
return;
}
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 );
if (a < addr + len)
d = bus_read_next( ps, a );
else
d = bus_read_end( ps );
fwrite( &d, step, 1, f );
}
printf( "\nDone.\n" );
}

Loading…
Cancel
Save