OSDN Git Service

am29f040b の erase check を toggle から polling に替えたがあまり意味がなさそう
authornaruko <naruko@24ea1065-a21e-4ca1-99c9-f5125deb0858>
Thu, 8 Jan 2009 05:50:01 +0000 (05:50 +0000)
committernaruko <naruko@24ea1065-a21e-4ca1-99c9-f5125deb0858>
Thu, 8 Jan 2009 05:50:01 +0000 (05:50 +0000)
git-svn-id: svn+ssh://svn.osdn.net/svnroot/unagi@235 24ea1065-a21e-4ca1-99c9-f5125deb0858

client/trunk/flashmemory.c
client/trunk/script.c
client/trunk/version.h

index 5332400..24b6300 100644 (file)
@@ -177,15 +177,15 @@ static int toggle_check_d2d5d6(const struct flash_order *d, long address)
        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];
@@ -197,6 +197,9 @@ static int toggle_check_d2d5d6(const struct flash_order *d, long address)
                        //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;
@@ -206,7 +209,7 @@ static int toggle_check_d2d5d6(const struct flash_order *d, long address)
 ---- 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;
        
@@ -223,6 +226,29 @@ static int polling_check(const struct flash_order *d, long address, u8 truedata)
        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 ----
 */
@@ -235,9 +261,15 @@ static void flash_erase_chip_2aaa(const struct flash_order *d)
 
 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
@@ -299,7 +331,7 @@ static int program_pagewrite(const struct flash_order *d, long address, const u8
        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;
index be28dc0..e7ef77a 100644 (file)
@@ -1059,16 +1059,20 @@ static int execute(const struct script *s, const struct st_config *c, struct rom
        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;
index 97ada15..b6a71ec 100644 (file)
@@ -1,5 +1,5 @@
 //include from unagi.c only
-static const char STR_VERSION[] = "0.5.2 "
+static const char STR_VERSION[] = "0.5.3 "
 #if DEBUG==1
 "debug "
 #else