Hi to all,

I used flashrom to flash the BIOS on a AxiomTek SBC84500, which mounts a
Winbond W29C020C. All is recognized fine, but the flashing fails.

# flashrom -v -w axiom.bin 
No LinuxBIOS table found.
Enabling flash write on CS5530...OK
W29C020C found at physical address: 0xfffc0000
Flash part is S29C51002T (256 KB)
Flash image seems to be a legacy BIOS. Disabling checks.
Programming Page: 2047 at address: 0x0003ff80 
Verifying flash - FAILED.

Trying fo find out the cause of the failure I eventually found a grave
error in jedec.c, at write_page_write_jedec(). The code:

      if (*src == 0xFF)
             continue;
       *dst++ = *src++;

is, of course, wrong. It should be

       if (*src != 0xFF ) 
               *dst = *src;
       dst++;
       src++;

I include a patch which fixes this error. But this is not enough.
Sector writes sometimes fail, so included a check/rewrite code 
similar to write_byte_program_jedec(). Maybe this is not the best way
to do the task, but at least for me works :)

Furthermore, the patch adds support for the SyncMos S29C51002T 256K
flash. Tested successfully on a Boser HS-2603. It is high probable that
the same configuration would work with all the chips of the same family.

# flashrom -v -w boser.bin 
No LinuxBIOS table found.
Enabling flash write on CS5530...OK
S29C51002T found at physical address: 0xfffc0000
Flash part is S29C51002T (256 KB)
Flash image seems to be a legacy BIOS. Disabling checks.
Programming Page: 2047 at address: 0x0003ff80 
Verifying flash - VERIFIED         

That's all.
Ciao.
Index: jedec.c
===================================================================
--- jedec.c     (revision 2497)
+++ jedec.c     (working copy)
@@ -134,23 +134,48 @@
 int write_page_write_jedec(volatile uint8_t *bios, uint8_t *src,
                           volatile uint8_t *dst, int page_size)
 {
-       int i;
+       int i, tried = 0, start_index = 0, ok;
+       volatile uint8_t *d = dst;
+       uint8_t *s = src;
 
+retry:
        /* Issue JEDEC Data Unprotect comand */
        *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
        *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
        *(volatile uint8_t *) (bios + 0x5555) = 0xA0;
 
        /* transfer data from source to destination */
-       for (i = 0; i < page_size; i++) {
+       for (i = start_index; i < page_size; i++) {
                /* If the data is 0xFF, don't program it */
-               if (*src == 0xFF)
-                       continue;
-               *dst++ = *src++;
+               if (*src != 0xFF ) 
+                       *dst = *src;
+               dst++;
+               src++;
        }
 
        toggle_ready_jedec(dst - 1);
 
+       dst = d;
+       src = s;
+       ok = 1;
+       for (i = 0; i < page_size; i++) {
+               if (*src != 0xFF) 
+                       if ( *dst != *src ) 
+                       {
+                               ok = 0;
+                               break;
+                       }
+               dst++;
+               src++;
+       }
+               
+       if (!ok && tried++ < 0x10) {
+               start_index = i;
+               goto retry;
+       }
+       if (!ok) {
+               fprintf( stderr, " page %d failed!\n", (d-bios)/page_size );
+       }
        return 0;
 }
 
Index: flashchips.c
===================================================================
--- flashchips.c        (revision 2497)
+++ flashchips.c        (working copy)
@@ -114,6 +114,8 @@
 #endif
        {"LHF00L04",    SHARP_ID,               SHARP_LHF00L04,         NULL, 
1024, 64 * 1024,
         probe_lhf00l04, erase_lhf00l04,        write_lhf00l04, NULL},
+       {"S29C51002T",  SM_ID,  S29C51002T,     NULL, 256, 128,
+        probe_jedec,   erase_chip_jedec, write_49f002, NULL},
        {NULL,}
 };
 

Attachment: signature.asc
Description: Digital signature

-- 
linuxbios mailing list
[email protected]
http://www.openbios.org/mailman/listinfo/linuxbios

Reply via email to