The following patch needs to be applied to am29f040b.c in the utils/flash_and_burn directory:
---------------------- --- am29f040b-nv.c Wed Nov 5 14:33:34 2003 +++ am29f040b.c Wed Nov 5 14:20:26 2003 @@ -76,8 +76,8 @@ *(bios + 0x2AA) = 0x55; *(bios + 0x555) = 0x90;
- id1 = *(unsigned char *) bios; - id2 = *(unsigned char *) (bios + 0x01); + id1 = *(volatile unsigned char *) bios; + id2 = *(volatile unsigned char *) (bios + 0x01);
*bios = 0xF0;
----------------------
My C compiler was reordering the writes and reads, so that the flash wasn't ready to give an id when the reads occurred.
I notice that all the other flash devices already seem to have this correct.
I applied the fix in a slightly different way, can you test this for me?
It looks like this now:
int probe_29f040b (struct flashchip * flash) { volatile unsigned char * bios = flash->virt_addr; unsigned char id1, id2;
*(bios + 0x555) = 0xAA; *(bios + 0x2AA) = 0x55; *(bios + 0x555) = 0x90;
id1 = * bios; id2 = * (bios + 0x01);
*bios = 0xF0;
myusec_delay(10);
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); if (id1 == flash->manufacture_id && id2 == flash->model_id) return 1;
return 0; }
ron
That also works, here's the assembly difference between my version with volatiles in the cast, and yours with the bios type changed:
--- am29f040b-v.s Wed Nov 5 14:20:34 2003 +++ am29f040b.s Thu Nov 6 08:54:13 2003 @@ -23,12 +23,12 @@ subl $24, %esp movl 8(%ebp), %edx movl 12(%edx), %eax - movb $-86, 1365(%eax) + movb $170, 1365(%eax) movb $85, 682(%eax) - movb $-112, 1365(%eax) + movb $144, 1365(%eax) movzbl (%eax), %esi movb 1(%eax), %bl - movb $-16, (%eax) + movb $240, (%eax) movzbl %bl, %edi pushl $10 call myusec_delay