原创文章版权所有!如需转载,请注明出处: http://hi.baidu.com/liushuiyue1/myhome 谢谢合作!!!!!
七. Uboot 支持 yaffs2 文件的读写
由于 Uboot 本身支持 yaffs2 文件的读写直接修改 ./include/configs/smdk6410.h 的配置文件,使得 uboot 支持 yaffs2 的读写,重新编译 Uboot 并下载到 Nand Flash 中,串口打印信息如下, uboot 已经支持 yaffs2 烧写到 nand flash (由于本人对于此 uboot 中指令不熟悉,所以至今还未写 yaffs2 文件成功,如有知道的可告知,谢谢)。
于是又重新手动 yaffs2 文件的烧写指令。首先修改 ./include/configs/smdk6410.h
#cd include/configs/smdk6410.h // #define CONFIG_YAFFS2 |
于是又重新手动 yaffs2 文件的烧写指令。
1) 修改 ./include/configs/smdk6410.h
注意一定要屏蔽掉 CONFIG_YAFFS2 ,否则 yaffs 文件读写有冲突。
#cd include/configs/smdk6410.h // //#define CONFIG_YAFFS2 #define CONFIG_SYS_NAND_YAFFS_WRITE 1 /* support yaffs write EN */ #define CONFIG_MTD_NAND_ECC_YAFFS 1 |
2) 修改 common/cmd_nand.c
在 373 行,红色字体为添加部分
if (!s || !strcmp(s, ".jffs2") ||
!strcmp(s, ".e") || !strcmp(s, ".i")) {
if (read)
ret = nand_read_skip_bad(nand, off, &size,
(u_char *)addr);
else
ret = nand_write_skip_bad(nand, off, &size,
(u_char *)addr);
}
#if defined(ENABLE_CMD_NAND_YAFFS)
}else if ( s != NULL &&
(!strcmp(s, ".yaffs") || !strcmp(s, ".yaffs1"))){
if(read) {
printf("nand read.yaffs[1] is not provide temporarily!");
} else {
nand->rw_oob = 1;
#if defined(ENABLE_CMD_NAND_YAFFS_SKIPFB)
nand->skipfirstblk = 1;
#else
nand->skipfirstblk = 0;
#endif
ret = nand_write_skip_bad(nand,off,&size,(u_char *)addr);
#if defined(ENABLE_CMD_NAND_YAFFS_SKIPFB)
nand->skipfirstblk = 0;
#endif
nand->rw_oob = 0;
}
#endif
}
else if (!strcmp(s, ".oob")) {
/* out-of-band data */
mtd_oob_ops_t ops = {
.oobbuf = (u8 *)addr,
.ooblen = size,
.mode = MTD_OOB_RAW
};
在 505 行添加,红色字体为添加部分
"nand erase [clean] [off size] - erase 'size' bytes from/n"
" offset 'off' (entire device if not specified)/n"
#if defined(CONFIG_SYS_NAND_YAFFS_WRITE)
"nand read[.yaffs[1]] is not provide temporarily/n"
"nand write[.yaffs[1]] addr off size -write the 'size' byte yaffs image starting/n"
"at offset 'off' from memory address 'addr' (.yaffs for 512+16 Nand)"
#endif
"nand bad - show bad blocks/n"