u8 predata;
int retry = 0;
d->read(address, 1, &predata);
+ predata &= 0x40;
do{
u8 data;
d->read(address, 1, &data);
//DQ6 toggle check
- if((predata & 0x40) == (data & 0x40)){
+ if(predata == (data & 0x40)){
return OK;
}
//DQ5 == 0 ¤Ê¤é¤ä¤ê¤Ê¤ª¤·
- dprintf("toggle out %06x \n", (int) address);
if(data & 0x20){
//recheck toggle bit, read twice
u8 t[2];
//Program/Erase operation not complete, write reset command.
return NG;
}
+ if((retry & 0x0f) == 0){
+ dprintf("toggle out %06x \n", (int) address);
+ }
retry++;
}while(retry < CHECK_RETRY_MAX);
return NG;
---- polling check ----
databit7
*/
-static int polling_check(const struct flash_order *d, long address, u8 truedata)
+static int polling_check_d7(const struct flash_order *d, long address, u8 truedata)
{
int retry = 0;
return NG;
}
+static int polling_check_d5d7(const struct flash_order *d, long address, u8 truedata)
+{
+ int retry = 0;
+
+ truedata &= 0x80;
+ do{
+ u8 data;
+ d->read(address, 1, &data);
+ if(truedata == (data & 0x80)){
+ return OK;
+ }
+ if(data & 0x20){
+ d->read(address, 1, &data);
+ if(truedata == (data & 0x80)){
+ return OK;
+ }
+ dprintf("%s error", __FUNCTION__);
+ return NG;
+ }
+ retry++;
+ }while(retry < CHECK_RETRY_MAX);
+ return NG;
+}
/*
---- erase ----
*/
static void flash_erase_chip_02aa(const struct flash_order *d)
{
+ u8 data;
+ d->read(d->command_2aaa, 1, &data);
command_set(d, ERASE_CHIP);
- toggle_check_d2d5d6(d, d->command_2aaa);
- Sleep(5200); //AM29F020 1.0 sec ¤Ê¤ó¤À¤±¤É¤³¤ì¤Ã¤Æ sector ñ°Ì?
+ if(0){
+ toggle_check_d2d5d6(d, d->command_2aaa);
+ Sleep(5200); //AM29F020 1.0 sec ¤Ê¤ó¤À¤±¤É¤³¤ì¤Ã¤Æ sector ñ°Ì?
+ }
+ polling_check_d5d7(d, d->command_2aaa, data);
+ Sleep(4200);
}
#if DEBUG==1
int ret = toggle_check_d6(d, toggle_address);
if(0){
data--;
- polling_check(d, address - 1, *data);
+ polling_check_d7(d, address - 1, *data);
}
return ret;
u8 *program_compare;
program_compare = NULL;
if(c->mode == MODE_ROM_PROGRAM){
+ printf("flashmemory/SRAM program mode. To abort programming, press Ctrl+C\n");
+ printf("device initialize ... ");
+ fflush(stdout);
//device ¤è¤Ã¤Æ¤Ï erase
c->cpu_flash_driver->init(&(r->cpu_flash));
if(r->ppu_rom.size != 0){
c->ppu_flash_driver->init(&(r->ppu_flash));
}
- printf("flashmemory/SRAM program mode. you can abort programming Ctrl+C\n");
int size = r->cpu_rom.size;
if(size < r->ppu_rom.size){
size = r->ppu_rom.size;
}
+ printf("done\n");
+ fflush(stdout);
program_compare = malloc(size);
}
struct memory cpu_rom, ppu_rom, cpu_ram;