• jffs2文件系统(二)


    本篇文章讲解一下如何制作jffs2文件系统,以及如何在linux下把jffs2作为根文件系统使用。

    文件系统制作

    制作工具:mtd_utils,可以自己安装

    mkfs.jffs2 -o root-uclibc-jffs2 -r root-uclibc -e 0x10000 -s 0x1000 -n -l -X zlib
    --pad=0x10000
    参数简介:
    -o, --output=FILE 指定生成文件的文件名.(default: stdout)
    -r, -d, --root=DIR 指定需要制作的文件夹目录名.(默认: 当前文件夹)
    -e, --eraseblock=SIZE 设定擦除块的大小为(默认: 64KB)
    -s, --pagesize=SIZE 节点页大小(默认: 4KB)
    -n, --no-cleanmarkers 指明不添加清楚标记(nand flash 有自己的校检块, 存
    放相关的信息。 ) 如果挂载后会出现类似: CLEANMARKER node found at
    0x0042c000 has totlen 0xc != normal 0x0 的警告, 则加上-n 就会消失。
    -l, --little-endian 指定使用小端格式
    -X, --enable-compressor=COMPRESSOR_NAME 指压缩格式
    -p, --pad[=SIZE] 通常用 16 进制表示输出文件系统大小, 不足部分用 0xff
    注意:

    1. 上面的-e选项和-s一定要根据自己的实际大小设置,否则可能出现启动失败的情况

    2. -X指定的压缩方式可以自己选择,不清楚使用mkfs.jffs2的帮助信息查看

    uboot启动参数设置

    我们这里使用的uboot版本是2013,新版本的设置类似。

    1. zhixia# setenv bootargs console=ttyS1,115200n8 mem=68M@0x0 rmem=40M@0x4400000 nmem=20M@0x6C00000 init=/linuxrc rootfstype=jffs2 root=/dev/mtdblock3 rw mtdparts=jz_sfc:256k(boot),64k(bootenv),2560k(kernel),25M(app),-(config) lpj=11968512
    2. zhixia# saveenv
    3. Erasing at 0x50000 -- 100% complete.
    4. Write at 0x50000 -- 100% complete.
    5. done

    上面我们主要设置了rootfstype=jffs2 ,即告诉linux启动的时候以jffs2的方式挂载根文件系统。

    启动日志

    1. ........
    2. [ 2.019842] jffs2: notice: (1) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
    3. [ 2.037152] VFS: Mounted root (jffs2 filesystem) on device 31:3.
    4. [ 2.043702] devtmpfs: mounted
    5. [ 2.047024] Freeing unused kernel memory: 224K
    6. [ 2.296708] FAT-fs (mmcblk0): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
    7. mdev is ok......
    8. [RCS]: /etc/init/S11
    9. [ 2.376306] random: nonblocking pool is initialized
    10. [ 2.383939] jffs2: notice: (570) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
    11. net.core.wmem_max = 26214400
    12. net.core.wmem_default = 26214400
    13. application start up
    14. [ 2.440720] @@@@@ inner codec power up@@@@@@
    15. zhixia login:

    问题记录

    在使用jffs2的时候你可能会遇到一些问题,下面列出常见的问题:

    1.启动出现wrong erase size

    1. [ 1.080526] jffs2: Node at 0x00007944 with length 0x00000a7c would run over the end of the erase block
    2. [ 1.090478] jffs2: Perhaps the file system was created with the wrong erase size?
    3. [ 1.090489] mmcblk0: mmc0:0001 SD32G 29.1 GiB
    4. [ 1.103183] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00007948: 0x0a7c instead

    出现这种问题一般是flash的擦除大小和制作jffs2的erase大小不一样导致,查看flash的手册看erase大小,或者看cat /proc/mtd ==》我们查到可以按sector、block、整片擦除

    所以有两种解决办法:一种是改flash适配的erase_size或者改制作jffs2时的erase_size大小,为了简单可以直接修改制作jffs2文件系统时的参数。

    2.启动出现jffs2: Empty flash

    1. [ 197.324942] jffs2: Empty flash at 0x013fff28 ends at 0x013fffd8
    2. [ 197.331095] jffs2: Empty flash at 0x013fffdc ends at 0x013ffff4
    3. [ 197.337488] jffs2: notice: (1) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.

    问题原因:

    This message is generated if a block of data is partially written. It is generally not a sign of any problem.  

    就是分区大而制作出来的文件系统小,导致分区后面没有jffs2文件系统的节点

    解决办法:制作相同分区大小的文件系统就可以了

    3. Magic bitmask not found

    1. [ 1.831034] jffs2: Empty flash at 0x010d7524 ends at 0x010d7594
    2. [ 1.837221] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x010d7594: 0xff7f instead
    3. [ 1.847216] jffs2: Empty flash at 0x010d7598 ends at 0x010d779c
    4. [ 1.853350] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x010d779c: 0xfbff instead
    5. [ 1.863321] jffs2: Empty flash at 0x010d77a0 ends at 0x010d77bc

    mkfs.jffs2 -s 的参数问题 对照FLASH的大小再重新生成镜像文件过即可

    4.Requested init /linuxrc failed

    1. [ 1.107416] jffs2: notice: (1) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
    2. [ 1.123603] mmcblk0: mmc0:aaaa SN32G 29.7 GiB
    3. [ 1.128943] VFS: Mounted root (jffs2 filesystem) on device 31:3.
    4. [ 1.135455] mmcblk0: p1
    5. [ 1.138285] devtmpfs: error mounting -2
    6. [ 1.143043] Freeing unused kernel memory: 264K
    7. [ 1.147853] Kernel panic - not syncing: Requested init /linuxrc failed (error -2).
    8. [ 1.155847] Rebooting in 10 seconds..

    解决办法:busybox编译时采用静态编译,这种情况遇到的较少,可以看下自己的具体原因。

  • 相关阅读:
    scrcpy用法大全
    瑞吉外卖部署篇---Nginx
    android junit 单元测试与输出日志信息查看处理
    在Linux中eth0旁边的lo是什么
    MySQL数据库八股文
    【设计模式】【第四章】【订单状态流转】【状态模式 + 享元模式+模板方法模式】
    CSS伪元素详解以及伪元素与伪类的区别
    为什么2023年一定要用OKR?
    MongoDB基础之数据库,集合,文档
    铝阳极氧化废水除铝
  • 原文地址:https://blog.csdn.net/weixin_43839785/article/details/134443772