jffs2文件系统的制作和移植

本文介绍了如何制作jffs2文件系统,包括使用mkfs.jffs2脚本生成映像文件,以及在不同Flash设备上调整参数。同时,详细阐述了在内核中添加jffs2支持的过程,包括设置bootcmd和bootargs,以实现系统的成功启动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    jffs2文件系统(Journalling Flash FileSystem Version2)——基于flash的文件系统

一.通过工具mkfs.jffs2制作文件系统

1.制作mkfs.jffs2通过脚本实现,这里用的是我们小组长修改的脚本完成的,步骤如下

1.1安装依赖库

yum install glibc-static zlo-devel zlib-static

1.2执行脚本文件


生成工具mtd-utils-1.4.9/mkfs.jffs2

sudo cp mkfs.jffs2 /usr/bin/        /*拷贝到shell环境变量下的一个路径*/


2.制作jffs2映像文件

在 rootfs(文件夹)所在的目录下:

sudo mkfs.jffs2 -n -s 2048 -e 128KiB -d rootfs -o rootfs.jffs2 --pad=0x1400000

/*

-n    Don't add a cleanmarker to every eraseblock

-s    Use page size (max data node size) SIZE (default: 4KiB)

-e    Use erase block size SIZE (default: 64KiB)

-d    Build file system from directory DIR (default: cwd)

-o    Output to FILE (default: stdout)

--pad   Pad output to SIZE bytes with 0xFF. If SIZE is not specified, the output is padded to the end of the final erase block

要注意,不同的flash, page sizeblock size会不一样


*/

这样就生成文件rootfs.jffs2(映像文件)


3.添加内核支持

vt100

make menuconfig

File systems  --->
Miscellaneous filesystems  --->
<*> Journalling Flash File System v2 (JFFS2) support
           (0)   JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
           [*]   JFFS2 write-buffering support
           [ ]   JFFS2 summary support (EXPERIMENTAL) 
           [ ]   JFFS2 XATTR support (EXPERIMENTAL) 
           [ ]   Advanced compression options for JFFS2 

4.u-boot环境下操作

[fl2440@lingyun]# set bkrj 'tftp 30008000 uImage_jffs2.bin;nand erase 100000 f00000;nand write 30008000 100000 800000'
[fl2440@lingyun]# set bootcmd_jffs2 'nand read 30008000 100000 800000;bootm 30008000'
[fl2440@lingyun]# set bootargs_jffs2 'noinitrd root=/dev/mtdblock2 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200'
[fl2440@lingyun]# set bootargs 'noinitrd root=/dev/mtdblock2 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200'

/*参数说明

noinitrd: 当你没有使用ramdisk启动系统的时候,你需要使用noinitrd这个参数

root:用来指定rootfs的位置

rootfstype:指明文件系统的类型

init:init指定的是内核启起来后,进入系统中运行的第一个脚本,一般init=/linuxrc

console=ttyS0,115200:表示串口使用COM1,波特率为115200


[fl2440@lingyun]# set bootcmd 'run bootcmd_jffs2'
[fl2440@lingyun]# save
[fl2440@lingyun]# run bkrj
[fl2440@lingyun]# run bjffs2
[fl2440@lingyun]# boot


>: mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,relatime)
proc on /proc type proc (rw,relatime)
tmpfs on /tmp type tmpfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)


>: ls -l /dev

lrwxrwxrwx    1 root     root             9 Dec 31 17:00 root -> mtdblock2



参考博客:https://www.sfantree.com/rootfs_jffs2/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值