一、移植环境
二、移植步骤
上接:u-boot-2009.08在2440上的移植详解(四)
|
|
|
②、在原来对Nand操作的命令集列表中添加Yaffs2对Nand的写命令,如下:
|
U_BOOT_CMD(nand, CONFIG_SYS_MAXARGS, 1, do_nand, //注意:这里只添加了yaffs2的写命令,因为我们只用u-boot下载(即写)功能,所以我们没有添加yaffs2读的命令
|
接着,在该文件中对nand操作的do_nand函数中添加yaffs2对nand的操作,如下:
if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) if (argc <4) addr = (ulong)simple_strtoul(argv[2], NULL, 16); read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */ s = strchr(cmd, '.'); //添加yaffs2相关操作,注意该处又关联到nand_write_skip_bad函数 #if defined(CONFIG_MTD_NAND_YAFFS2) else if (!strcmp(s, ".oob")) if (read) printf(" %zu bytes %s: %s/n", size, read ? "read" : "written", ret ? "ERROR" : "OK"); return ret == 0 ? 0 : 1; |
|
|
|
int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, u_char *buffer) #if defined(CONFIG_MTD_NAND_YAFFS2) //add yaffs2 file system support if (((*length)%(nand->oobsize+nand->writesize)) != 0) datapages = *length/(datasize+oobsize); /* Reject writes, which are not page aligned */ len_incl_bad = get_len_incl_bad (nand, offset, *length); if ((offset + len_incl_bad) >= nand->size) { #if !defined(CONFIG_MTD_NAND_YAFFS2) //add yaffs2 file system support return rval; while (left_to_write > 0) { WATCHDOG_RESET (); if (nand_block_isbad (nand, offset & ~(nand->erasesize - 1))) { #if defined(CONFIG_MTD_NAND_YAFFS2) //add yaffs2 file system support if (left_to_write <(nand->erasesize - block_offset)) printf("/rWriting at 0x%llx -- ",offset); //add yaffs2 file system support
left_to_write -= write_size; #if defined(CONFIG_MTD_NAND_YAFFS2) //add yaffs2 file system support } return 0; |
|
|
⑥、使用nand write[.yaffs2]命令把事前制作好的yaffs2文件系统下载到Nand Flash中(yaffs2文件系统的制作请参考:Linux-2.6.30.4在2440上的移植之文件系统),下载操作步骤和效果图如下:
|
⑦、结合u-boot和内核来测试启动下载的yaffs2文件系统
设置u-boot启动参数bootargs,注意:这一长串参数要与内核配置里面的Boot options-->Default kernel command string的设置要一致。特别是mtdblock3要根据内核具体的分区来设,在上一篇中讲到了内核中Nand的分区情况,u-boot属于mtdblock0,param属于mtdblock1,kernel属于mtdblock2,root就属于mtdblock3,所以这里要设置成root=/dev/mtdblock3,否则文件系统无法启动成功,会出现一些什么I/O之类的错误
好了,最后重启开发板,内核引导成功,yaffs2文件系统也挂载成功,效果图如下: