在uboot里添加yaffs镜像的支持
2009-07-09 10:01
246 查看
作者:孙晓明,华清远见嵌入式学院讲师。
uboot源码默认是不支持yaffs文件系统的,所以我们需要自己修改源码进行支持。
首先我们进入U-Boot源码目录添加对yaffs镜像烧写的支持.
在common/cmd_nand.c里仿照jffs2来写一些yaffs的内容:
在:
U_BOOT_CMD(nand, 5, 1, do_nand,
"nand - NAND sub-system/n",
"info - show available NAND devices/n"
"nand device [dev] - show or set current device/n"
"nand read[.jffs2] - addr off|partition size/n"
"nand write[.jffs2] - addr off|partition size - read/write `size' bytes starting/n"
" at offset `off' to/from memory address `addr'/n"
之后添加nand read.yaffs 的使用说明:
"nand read.yaffs - addr off|partition size/n"
"nand write.yaffs - addr off|partition size - read/write `size' bytes starting/n"
然后在nand命令的处理函数里do_nand中增加对write.yaffs的支持,do_nand在common/cmd_nand.c中实现:
在:
if (s != NULL &&
(!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
…….
的判断后面加:
else if (s != NULL &&
(!strcmp(s, ".yaffs") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
if (read) {
/* read */
nand_read_options_t opts;
memset(&opts, 0, sizeof(opts));
opts.buffer = (u_char*) addr;
opts.length = size;
opts.offset = off;
opts.readoob = 1;
opts.quiet = quiet;
ret = nand_read_opts(nand, &opts);
} else {
/* write */
nand_write_options_t opts;
memset(&opts, 0, sizeof(opts));
opts.buffer = (u_char*) addr;
opts.length = size;
opts.offset = off;
/* opts.forcejffs2 = 1; */
//opts.pad = 1;
opts.noecc = 1;
opts.writeoob = 1;
opts.blockalign = 1;
opts.quiet = quiet;
ret = nand_write_opts(nand, &opts);
}
}
由于前面设置了opts.noecc = 1,不使用ecc校验码,烧写过程中会提示这个信息:
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
可以修改driver/mtd/nand/nand_base.c文件的nand_write_page函数,将它去掉,修改如下:
case NAND_ECC_NONE:
//printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not ecommended/n");
this->write_buf(mtd, this->data_poi, mtd->oobblock);
break;
修改完这些,U-BOOT就可以支持yaffs文件镜像的烧写了。
uboot源码默认是不支持yaffs文件系统的,所以我们需要自己修改源码进行支持。
首先我们进入U-Boot源码目录添加对yaffs镜像烧写的支持.
在common/cmd_nand.c里仿照jffs2来写一些yaffs的内容:
在:
U_BOOT_CMD(nand, 5, 1, do_nand,
"nand - NAND sub-system/n",
"info - show available NAND devices/n"
"nand device [dev] - show or set current device/n"
"nand read[.jffs2] - addr off|partition size/n"
"nand write[.jffs2] - addr off|partition size - read/write `size' bytes starting/n"
" at offset `off' to/from memory address `addr'/n"
之后添加nand read.yaffs 的使用说明:
"nand read.yaffs - addr off|partition size/n"
"nand write.yaffs - addr off|partition size - read/write `size' bytes starting/n"
然后在nand命令的处理函数里do_nand中增加对write.yaffs的支持,do_nand在common/cmd_nand.c中实现:
在:
if (s != NULL &&
(!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
…….
的判断后面加:
else if (s != NULL &&
(!strcmp(s, ".yaffs") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
if (read) {
/* read */
nand_read_options_t opts;
memset(&opts, 0, sizeof(opts));
opts.buffer = (u_char*) addr;
opts.length = size;
opts.offset = off;
opts.readoob = 1;
opts.quiet = quiet;
ret = nand_read_opts(nand, &opts);
} else {
/* write */
nand_write_options_t opts;
memset(&opts, 0, sizeof(opts));
opts.buffer = (u_char*) addr;
opts.length = size;
opts.offset = off;
/* opts.forcejffs2 = 1; */
//opts.pad = 1;
opts.noecc = 1;
opts.writeoob = 1;
opts.blockalign = 1;
opts.quiet = quiet;
ret = nand_write_opts(nand, &opts);
}
}
由于前面设置了opts.noecc = 1,不使用ecc校验码,烧写过程中会提示这个信息:
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
可以修改driver/mtd/nand/nand_base.c文件的nand_write_page函数,将它去掉,修改如下:
case NAND_ECC_NONE:
//printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not ecommended/n");
this->write_buf(mtd, this->data_poi, mtd->oobblock);
break;
修改完这些,U-BOOT就可以支持yaffs文件镜像的烧写了。
相关文章推荐
- 在uboot里添加yaffs镜像的支持
- uboot-2010.06移植到mini2440经验(3)添加nor flash支持
- uboot-2010.06移植到mini2440经验(4)添加对DM9000网卡支持
- uboot 2015 添加新的板级支持
- WIM镜像添加多语言支持
- linux添加yaffs支持需要注意的事情
- 修改 UBOOT (支持 NFS 、 yaffs 和 USB)
- uboot 添加 DM9000支持,作为uboot移植网卡驱动参考
- 基于乌班图的标准镜像添加中文支持
- linux 3.4 添加yaffs文件系统支持
- 使SAMBA支持YAFFS镜像烧写
- uboot移植添加nfs支持
- FL2440移植LINUX-3.4.2(四)-- 添加支持YAFFS文件系统
- uboot添加write.yaffs功能
- u-boot-2009.11移植(适用于TQ2440和MINI2440)第六篇:添加Yaffs(2)镜像烧写功能
- 在U-Boot中实现对Yaffs镜像的支持
- 完美用Nlite添加ACHI SATA驱动至XP镜像
- Spring实现动态数据源,支持动态添加、删除和设置权重及读写分离
- 在Android C/C++层添加LOG调试(LOGI\LOGD\LOGE...)输出支持 开花结果