Chinaunix首页 | 论坛 | 博客
  • 博客访问: 287045
  • 博文数量: 23
  • 博客积分: 491
  • 博客等级: 下士
  • 技术积分: 612
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-29 19:57
文章分类

全部博文(23)

文章存档

2013年(1)

2012年(22)

我的朋友

分类: 嵌入式

2012-11-12 11:51:46

1、  在内核中添加对ubifs文件系统的支持

MTD选项中进入UBI配置选项

file system中配置ubifs,如下

配置完成后重新编译内核生成uImage,上电加载启动内核,可以看到/proc/filesystem已经有了ubifs的选项

2、  修改arch/arm/mach-davinci/board-da850-evm.c文件中nandflash分区


点击(此处)折叠或打开

  1. struct mtd_partition da850_evm_nandflash_partition[] = {
  2.     {
  3.         .name        = "u-boot env",
  4.         .offset        = 0,
  5.         .size        = SZ_128K,
  6.         .mask_flags    = MTD_WRITEABLE,
  7.      },
  8.     {
  9.         .name        = "UBL",
  10.         .offset        = MTDPART_OFS_APPEND,
  11.         .size        = SZ_128K,
  12.         .mask_flags    = MTD_WRITEABLE,
  13.     },
  14.     {
  15.         .name        = "u-boot",
  16.         .offset        = MTDPART_OFS_APPEND,
  17.         .size        = 4 * SZ_128K,
  18.         .mask_flags    = MTD_WRITEABLE,
  19.     },
  20.     {
  21.         .name        = "kernel",
  22.         .offset        = 0x300000, //txl
  23.         .size        = SZ_2M,
  24.         .mask_flags    = 0,
  25.     },
  26.     {
  27.         .name        = "filesystem",
  28.         .offset        = 0x500000,
  29.         .size        = SZ_32M,
  30.         .mask_flags    = 0,
  31.     },
  32.     {
  33.         .name        = "ubifs",
  34.         .offset        = MTDPART_OFS_APPEND,
  35.         .size        = 1.5 * SZ_32M,
  36.         .mask_flags    = 0,
  37.     },
  38.     {
  39.         .name        = "user",
  40.         .offset        = MTDPART_OFS_APPEND,
  41.         .size        = MTDPART_SIZ_FULL,
  42.         .mask_flags    = 0,
  43.     },

3、  u-boot中添加ubifs支持,编辑include/configs/da850evm.h文件


点击(此处)折叠或打开

  1. #define CONFIG_CMD_MTDPARTS
  2. #define CONFIG_MTD_DEVICE
  3. #define CONFIG_MTD_PARTITIONS
  4. #define CONFIG_LZO
  5. #define CONFIG_RBTREE
  6. #define CONFIG_CMD_UBI
  7. #define CONFIG_CMD_UBIFS
  8. 添加为
  9. #define CONFIG_CMD_MTDPARTS
  10. #define CONFIG_MTD_DEVICE
  11. #define CONFIG_MTD_PARTITIONS
  12. #define CONFIG_LZO
  13. #define CONFIG_RBTREE
  14. #define CONFIG_CMD_UBI
  15. #define CONFIG_CMD_UBIFS
  16. #define MTDIDS_DEFAULT        "nand0=nandflash0"
  17. #define MTDPARTS_DEFAULT    "mtdparts=nandflash0:128k@0(ubi0),"\
  18.                     "128k(ubl),"\
  19.                     "2816k(uboots),"\
  20.                     "2m(kernel),"\
  21.                     "32m(root),"\
  22.                     "32m(ubifs)"

这里u-boot分区尽量与内核划分的分区一致。


4、  使用工具测试ubi

把生成的armmtd工具复制到nfs文件夹

通过ubiattchmtd5作为ubi0 



注意这些信息,接下来创建ubifs镜像时要一一对应

通过ubimkvol创建ubiubi0_0,名称为rootfs

./ubimkvol /dev/ubi0 -N rootfs -s 48MiB

通过卷名mount

mount –t ubifs ubi0:rootfs /tmp

 

或者通过卷序号mount

mount –t ubifs ubi0_0 /tmp

 

mount 成功后系统的信息:



6、生成ubifs镜像

mk.ubifs -r /root/targetfs -m 2048 -e 126976 -c 230 -o /tftpboot/ubifs.img

 

-r 参数指定输入的源文件夹名称

-m 参数指定页大小(min-io-size)

这个可以通过./ ubiattch输出信息看出

-e  参数指定逻辑擦除块大小(leb-size)

     ./ ubiattch输出信息          UBI:logical eraseblock size:   126976bytes

-c  参数指定逻辑擦除块数量(max-leb-cnt)

   UBI:total number of reserved 257.一共有257块,选取230个,这个参数比较随意,不要太小,也不要超过总块数

 

u-boot启动



擦除建立ubifs分区并下载镜像

nand erase.part ubifs

ubi part ubifs 2048           

ubi create rootfs

tftp 0xc1180000 ubifs.img

ubi write 0xc1180000 rootfs 0x1000000

setenv bootargs console=ttyS0,115200n8 ubi.mtd=5 root=ubi0:rootfs rootfstype=ubifs init=/linuxrc rw

 

启动系统成功界面



备注:

ubi分区一定不能有坏块,因为ubi write命令不坏检测坏块并跳过,有坏块的话经常会导致ubi无法启动。内核的ubifs48Mu-boot的为32M,这样是能成功的,尝试过内核对应u-boot32M,出错ubi分区过小,呃。。。。。再看




参考资料:

http://blog.csdn.net/yx_l128125/article/details/7478042

mcuzoneMAN3010A_CH

阅读(11035) | 评论(0) | 转发(3) |
0

上一篇:mtd工具的建立

下一篇:DSPBIOS的HWI线程应用

给主人留下些什么吧!~~