6.1 include/conskfigs/micro2440.h
添加
#define CONFIG_CMD_NAND_YAFFS
【说明】
本人在阅读cmd_nand.c时发现u-boot-2011.03已经支持yaffs写入,只需添加如上定义即可,但实际写入错误,再阅读源代码,发现只要按下一步修改即可,虽然这是最简单的方法,但似乎并不是最优的方法。
6.2 drivers/mtd/nand/nand_util.c
int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
u_char *buffer, int withoob)
{
……
if (need_skip < 0) {
printf ("Attempt to write outside the flash area/n");
*length = 0;
return -EINVAL;
}
if (!need_skip && !withoob) {
……
}
while (left_to_write > 0) {
……
#ifdef CONFIG_CMD_NAND_YAFFS
if (withoob) {
……
ops.len = pagesize;
ops.ooblen = nand->oobsize;
ops.mode = MTD_OOB_RAW;
ops.ooboffs = 0;
pages = write_size / pagesize_oob;
for (page = 0; page < pages; page++) {
ops.datbuf = p_buffer;
ops.oobbuf = ops.datbuf + pagesize;
rval = nand->write_oob(nand, offset, &ops);
if (rval)
break;
offset += pagesize;
p_buffer += pagesize_oob;
}
}
……
}
6.3 下载yaffs镜像
下载yaffs镜像的时候要注意分区的第一块不能写,比如友善之臂的默认分区如下:
Number of partitions: 4
name : offset size flag
------------------------------------------------------------
vivi : 0x00000000 0x00040000 0
param : 0x00040000 0x00020000 0
kernel : 0x00060000 0x00500000 0
root : 0x00560000 0x3fa80000 0
也就是说yaffs镜像所在分区的起始地址在0x560000,因此使用nand write.yaffs命令下载yaffs时要写的地址为0x560000 + 0x20000 (Nand Flash每块的大小)= 0x580000,即下载命令类似如下
tftp 0x30008000 uImage
nand write.yaffs 0x30008000 0x580000 0x300000