作者:孫曉明,華清遠見嵌入式學院講師。
uboot源碼默認是不支持yaffs文件系統(tǒng)的,所以我們需要自己修改源碼進行支持。
首先我們進入U-Boot源碼目錄添加對yaffs鏡像燒寫的支持.
在common/cmd_nand.c里仿照jffs2來寫一些yaffs的內(nèi)容:
在:
U_BOOT_CMD(nand, 5, 1, do_nand,
"nand - NAND sub-systemn",
"info - show available NAND devicesn"
"nand device [dev] - show or set current devicen"
"nand read[.jffs2] - addr off|partition sizen"
"nand write[.jffs2] - addr off|partition size - read/write `size' bytes startingn"
" at offset `off' to/from memory address `addr'n"
之后添加nand read.yaffs 的使用說明:
"nand read.yaffs - addr off|partition sizen"
"nand write.yaffs - addr off|partition size - read/write `size' bytes startingn"
然后在nand命令的處理函數(shù)里do_nand中增加對write.yaffs的支持,do_nand在common/cmd_nand.c中實現(xiàn):
在:
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函數(shù),將它去掉,修改如下:
case NAND_ECC_NONE:
//printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not ecommendedn");
this->write_buf(mtd, this->data_poi, mtd->oobblock);
break;
修改完這些,U-BOOT就可以支持yaffs文件鏡像的燒寫了。
“本文由華清遠見http://www.embedu.org/index.htm提供”
來源:華清遠見0次