[U-Boot-Users] Flash Erase/Write error in uboot

Shiju Mathew
2007-05-08T18:36:40Z

On Sat, 2007-05-05 at 08:48 -0500, Andrew Dyer wrote:
> On 5/4/07, Shiju Mathew <mshiju@gmail.com> wrote:
> > I was debugging the problem further. We have two other bootloaders running
> > on this board - redboot and Eboot. Both does not have this problem. Only on
> > Uboot I am experiencing this problem. On debugging what I could find is that
> > when I erase a sector, the function flash_is_busy() returns immidiatly with
> > success(not busy). Usually it should loop for a while in this function
> > before returning that the flash is not busy. Before writing to the erased
> > sector, the "md" command displayed 0xffffffff for the erased sector. But
> > when I tried to write data to the erased location using cp.b, the function
> > flash_write_cfiword() returns with error "flash is not erased" since it
> > failed to find 0xffffffff in the erased locations(Check if Flash is
> > (sufficiently) erased). So why does "md" displays 0xffffffff for erased
> > locations and flash routine says it is not 0xffffffff ? Could someone
>
> I suspect the code is reading the status word instead of the array
> data. You have to be careful with handling the array, as there is no
> separate status port, so the status data will show up as read data if
> you aren't careful.
>
> One thing you might check is to make sure the flash 'timeout' variable
> isn't getting set to zero. I found a problem with this a long time
> ago - it had to do with how the CFI timeout data (reported in usec)
> was being converted to a value for timeout (in msec). If timeout was
> zero, the status read stuff would time out before reding the data the
> second time through. I think was fixed, but it's worth checking.
>
Thanks for all your comments. I could get a few sector erase/write
success if I reduce the system clock to 398 MHz and bus speed to 66 MHz
and also make the below changes for erase status check. Previouly it was
running at 532 MHz/133 MHz (CPU/bus).Now I could update uboot without
any problem. But if I try to erase/write large no: of sectors, says 100
sectors, it fails with the same error as before. So I think the problem
is realated to timming.

#define TIMEOUT 10000000
timeout = TIMEOUT;
while (1) {
if (flash_isset (info, sect, 0, 0x08)) {
debug("Operation complete\n");
break;
}
if (!timeout--) {
printf("Operation Timed Out!!n");
break;
}
}
timeout = TIMEOUT;
while (1) {
if (flash_isset (info, sect, 0,
FLASH_STATUS_DONE)) {
debug("Flash erase done\n");
break;
}
if (!timeout--) {
printf("Erase Timed Out!!\n");
break;
}
}

> Check how CS configuration etc. is correctly configured. If it is
> working with the extension board not installed but not obviously you
> have something wrong. It could be that your CS1 configuration is
> incorrect. Possibilities are endless. But I do not see this as a
> flash
> driver issue.

If I disconnected the extension board, I don't have any issues. I could
also run the system at 532/133 MHz without any flash write issues. The
problem happens when the load increases on the bus. I made sure that the
CS are configured right.I disabled CS1( where extension board is
connected) without any success.

> Wow, 3 bootloaders for one board! What luxury. :)
>
We got eboot and redboot along with the board. But we want to move to
uboot to support all the OS runnning on the board because of its feature
rich and has good support from the community.

Thanks,
Shiju