[U-Boot] [PATCH] cfi_flash: Micron Nor flash don't support read operation after send
Qi Wang 王起 (qiwang)
qiwang at micron.com
Fri Mar 14 09:13:06 CET 2014
Hi Wolfgang,
> > Micron Nor flash don't support read operation after send write command.
> As below,
>
> I understand you attempt to copy data between two different areas on
> the same NOR device? This is not supported.
>
> > If the src address locate in NOR flash, flash_read operation will be failed.
> > So, read out the data to DRAM before send write command operation.
> > ---
> > drivers/mtd/cfi_flash.c | 70 +++++++++++++++++++++++++++++++----------
> >------
> > 1 file changed, 46 insertions(+), 24 deletions(-)
>
> Thanks, but NAK.
>
> If the source address range and the target address range are both in
> the same NOR flash device, please use a two step approach instead:
> first copy the data to RAM, then copy from RAM to NOR.
>
> No code changes are needed for this.
Yes, I totally agree with you, copy from NOR flash to NOR flash is not support.
But in the flash_write_cfibuffer() function, flash_read16(src) is used to read data
from src address, I think this "flash_read" function give users much mislead, src address
can be located in flash address range, not only can be in RAM.
And currently, one of micron customers uses "cp.b" command to copy data from NOR flash
to Nor flash, such as "cp.b src_addr dest_addr len", both src_addr and dest_addr are
located in NOR flash address range. Some manufactory's Nor flash can work fine under
this command, but micron nor flash cannot.
As you said, copy from NOR flash to NOR flash is forbidden.
In the cp command function,
do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]),
you can see below code, it just judge if the dest address is located in NOR flash, but
don't do any detect on src address.
#ifndef CONFIG_SYS_NO_FLASH
/* check if we are copying to Flash */
if ( (addr2info(dest) != NULL)
#ifdef CONFIG_HAS_DATAFLASH
&& (!addr_dataflash(dest))
#endif
) {
int rc;
puts ("Copy to Flash... ");
rc = flash_write ((char *)addr, dest, count*size);
if (rc != 0) {
flash_perror (rc);
return (1);
}
puts ("done\n");
return 0;
}
#endif
So my suggestion is,
1. don't use flash_read function in flash_write_cfibuffer() function, use
readb(),readw(), readl() function instead.
2. add detection in do_mem_cp() function, check if src address is locate in NOR flash address range.
So what's your opinions?
Thanks for your help.
More information about the U-Boot
mailing list