* 1831321 amdstatus() broken in libbrux/flash/amd.c
  revert to previous implementation of amdstatus()
  RTL8181 specific implementation deactivated but kept for reference
* 1830707 Flashing for Jedec devices broken
  removed flashcheck() and activated previous set_flash_chip() in
  src/flash.c
* libbrux/flash/jedec.c fills in cfi_chip_t.width
  this is required for new functionality in find_block() of src/flash.c


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@759 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Arnim Läuger 17 years ago
parent 70ff64e8bf
commit 04c88f80bc

@ -116,6 +116,44 @@ amdstatus29( parts *ps, uint32_t adr, uint32_t data )
}
#endif /* 0 */
#if 1
/*
* second implementation: see [1], page 30
*/
static int
amdstatus( bus_t *bus, uint32_t adr, int data )
{
int timeout;
uint32_t togglemask = ((1 << 6) << 16) + (1 << 6); /* DQ 6 */
/* int dq5mask = ((1 << 5) << 16) + (1 << 5); DQ5 */
for (timeout = 0; timeout < 100; timeout++) {
uint32_t data1 = bus_read( bus, adr );
uint32_t data2 = bus_read( bus, adr );
/*printf("amdstatus %d: %04X/%04X %04X/%04X \n", */
/* timeout, data1, data2, (data1 & togglemask), (data2 & togglemask)); */
if ( (data1 & togglemask) == (data2 & togglemask))
return 1;
/* if ( (data1 & dq5mask) != 0 ) TODO */
/* return 0; */
if (dbg)
printf( "amdstatus %d: %04X/%04X\n", timeout, data1, data2 );
else
printf( "." );
usleep( 100 );
}
return 0;
}
#else /* 1 */
/* Note: This implementation of amdstatus() has been added by patch
[ 1429825 ] EJTAG driver (some remaining patch lines for flash/amd.c)
It's a quirk workaround and seems to break status polling for other chips.
Therefore it's deactivated at the moment but kept for reference. */
/*
* second implementation: see [1], page 30
*/
@ -131,6 +169,7 @@ amdstatus( bus_t *bus, uint32_t adr, int data )
for (timeout = 0; timeout < 100; timeout++) {
data2 = bus_read( bus, adr );
/*printf("amdstatus %d: %04X/%04X %04X/%04X \n", */
/* timeout, data1, data2, (data1 & togglemask), (data2 & togglemask)); */
/* Work around an issue with RTL8181: toggle bits don't
@ -157,6 +196,8 @@ amdstatus( bus_t *bus, uint32_t adr, int data )
return 0;
}
#endif /* 0 */
#if 0
static int
amdisprotected( parts *ps, cfi_array_t *cfi_array, uint32_t adr )

@ -377,6 +377,9 @@ jedec_detect( bus_t *bus, uint32_t adr, cfi_array_t **cfi_array )
if (!(*cfi_array)->cfi_chips[0])
return -2; /* out of memory */
/* annotate chip width */
(*cfi_array)->cfi_chips[0]->width = (*cfi_array)->bus_width;
/* probe device with Autoselect method 1 */
bus_write(bus, adr, 0xf0);
bus_write(bus, adr+0xaaa, 0xaa);

@ -66,57 +66,34 @@ flash_driver_t *flash_drivers[] = {
NULL
};
flash_driver_t *flash_driver = NULL;
extern cfi_array_t *cfi_array;
static flash_driver_t *flash_driver = NULL;
extern int amd_detect(bus_t *bus, cfi_array_t **cfi_array ); //Ajit
static void
set_flash_driver( cfi_array_t *cfi_array )
set_flash_driver( void )
{
int i;
cfi_query_structure_t *cfi = &cfi_array->cfi_chips[0]->cfi;
cfi_query_structure_t *cfi;
flash_driver = NULL;
if (cfi_array == NULL)
return;
cfi = &cfi_array->cfi_chips[0]->cfi;
for (i = 0; flash_drivers[i] != NULL; i++)
if (flash_drivers[i]->autodetect( cfi_array )) {
flash_driver = flash_drivers[i];
flash_driver->print_info( cfi_array );
return;
}
printf( _("unknown flash - vendor id: %d (0x%04x)\n"),
cfi->identification_string.pri_id_code,
cfi->identification_string.pri_id_code );
}
/* check for flashmem - set driver */
static void
flashcheck( bus_t *bus, cfi_array_t **cfi_array )
{
flash_driver = NULL;
bus_prepare( bus );
printf( _("Note: Supported configuration is 2 x 16 bit or 1 x 8/16 bit only\n") );
*cfi_array = NULL;
if (cfi_detect( bus, 0, cfi_array )) {
cfi_array_free( *cfi_array );
if(amd_detect(bus, cfi_array ) != 0)
{
cfi_array_free( *cfi_array );
printf( _("Flash not found!\n") );
return;
}
}
set_flash_driver( *cfi_array );
if (!flash_driver) {
printf( _("Flash not supported!\n") );
return;
}
flash_driver->print_info( *cfi_array );
printf( _("Flash not supported!\n") );
}
void
@ -124,9 +101,8 @@ flashmsbin( bus_t *bus, FILE *f )
{
uint32_t adr;
cfi_query_structure_t *cfi;
cfi_array_t *cfi_array;
flashcheck( bus, &cfi_array );
set_flash_driver();
if (!cfi_array || !flash_driver) {
printf( _("no flash driver found\n") );
return;
@ -240,8 +216,6 @@ flashmsbin( bus_t *bus, FILE *f )
}
printf( _("\nDone.\n") );
cfi_array_free( cfi_array );
}
static int
@ -270,14 +244,13 @@ flashmem( bus_t *bus, FILE *f, uint32_t addr )
{
uint32_t adr;
cfi_query_structure_t *cfi;
cfi_array_t *cfi_array;
int *erased;
int i;
int neb;
int bus_width;
int chip_width;
flashcheck( bus, &cfi_array );
set_flash_driver();
if (!cfi_array || !flash_driver) {
printf( _("no flash driver found\n") );
return;
@ -378,19 +351,16 @@ flashmem( bus_t *bus, FILE *f, uint32_t addr )
printf( _("\nDone.\n") );
free( erased );
cfi_array_free( cfi_array );
}
void
flasherase( bus_t *bus, uint32_t addr, int number )
{
cfi_query_structure_t *cfi;
cfi_array_t *cfi_array;
int i;
int status = 0;
flashcheck( bus, &cfi_array );
set_flash_driver();
if (!cfi_array || !flash_driver) {
printf( _("no flash driver found\n") );
return;
@ -425,7 +395,6 @@ flasherase( bus_t *bus, uint32_t addr, int number )
else
printf( _("\nErasing Failed.\n") );
cfi_array_free( cfi_array );
/* BYPASS */
// parts_set_instruction( ps, "BYPASS" );
// chain_shift_instructions( chain );

Loading…
Cancel
Save