ubifs文件系统的移植

来源:互联网 发布:python中字符串的 编辑:程序博客网 时间:2024/05/22 03:45

转载地址:http://blog.chinaunix.net/uid-26498888-id-3405220.html

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

把生成的arm版mtd工具复制到nfs文件夹

通过ubiattch把mtd5作为ubi0 



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

通过ubimkvol创建ubi卷ubi0_0,名称为rootfs

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

通过卷名mount:

mount –t ubifsubi0:rootfs /tmp

 

或者通过卷序号mount:

mount –t ubifsubi0_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.partubifs

ubi part ubifs2048           

ubi create rootfs

tftp 0xc1180000ubifs.img

ubi write0xc1180000 rootfs 0x1000000

setenv bootargsconsole=ttyS0,115200n8 ubi.mtd=5 root=ubi0:rootfs rootfstype=ubifsinit=/linuxrc rw

 

启动系统成功界面



备注:

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




参考资料:

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

mcuzone的MAN3010A_CH