第一、cp.b命令说明
cp [.b, .w, .l] source target count
- copy memory
cp命令可以在内存中复制数据块,包括对Flash的读写操作。
第1个参数source是要复制的数据块起始地址。
第2个参数target是数据块要复制到的地址。这个地 址如果在Flash中, 那么会直接调用写Flash的函数操作。所以U-Boot写Flash就使用这个命令,当然需要先把对应Flash区域擦干净。
第3个参数count是要复制的数目,根据cp.b cp.w cp.l分别以字节、字、长字为单位。
第二、一般我们在用这个命令时第一个参数一般为sdram的地址空间,这时我们调用这个命令是可以正常操作的,但是如果第一个参数如果是片外norflash的地址,钱对不同的norflash就有问题了,会发现如果count大于1时,写入norflash的数据是不对的。这是为什么呢?根本的原因要看一下这个flash的底层写函数如下:static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp, int len)
{
flash_sect_t sector;
int cnt;
int retcode;
void *src = cp;
void *dst = (void *)dest;
void *dst2 = dst;
int flag = 1;
uint offset = 0;
unsigned int shift;
uchar write_cmd;
switch (info->portwidth) {
case FLASH_CFI_8BIT:
shift = 0;
break;
case FLASH_CFI_16BIT:
shift = 1;