文章的摘录与参与网址:
http://www.eetop.cn/blog/html/98/510998-20964.html
http://www.cnitblog.com/zouzheng/archive/2007/11/16/36384.html
http://www.eefocus.com/flytercel/blog/11-07/227192_0e8b7.html
http://bbs.realqwh.cn/read-htm-tid-90954.html
http://hi.baidu.com/caosicong/blog/item/05b6e382ccf3acbc6d811973.html
有关问题:http://www.diybl.com/course/6_system/linux/Linuxjs/2008827/137950.html
刚一看觉得很头疼,但是真正做起来,很容易
1.配置linux内核支持jffs2
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)
[*] JFFS2 POSIX Access Control Lists
[*] JFFS2 Security Labels
[*] Advanced compression options for JFFS2
[*] JFFS2 ZLIB compression support
[*] JFFS2 RTIME compression support
[ ] JFFS2 RUBIN compression support
JFFS2 default compression mode (priority)
选上MTD支持
Device Drivers --->
Memory Technology Devices (MTD) --->
<*> Memory Technology Device (MTD) support
[ ] Debugging
<*> MTD concatenating support
[*] MTD partitioning support
< > RedBoot partition table parsing
[*] Command line partition table parsing
<*> ARM Firmware Suite partition parsing
--- User Modules And Translation Layers
<*> Direct char device access to MTD devices
<*> Caching block device access to MTD devices
<*> FTL (Flash Translation Layer) support
<*> NFTL (NAND Flash Translation Layer) support
[ ] Write support for NFTL
2.制作mkfs.jffs2工具
??????? $ tar xjf mtd-utils-05.07.23.tar.bz2
???????? $ cd mtd-utils-05.07.23/util
???????? $ make
???????? $ make install
3.制作jffs2格式的文件
mkfs.jffs2 -r (需要的根文件目录)/rootfs -o rootfs.jffs2 -n
具体选项含义:
选项含义(man a mkfs.jffs2)
mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree
Options:
-p,--pad[=SIZE]?????? 用16進制來表示所要輸出檔案的大小,也就是root.jffs2的size。
?????????????????????????????????????? 很重要的是,為了不浪費flash空間,這個值最好符合flash driver所規劃的區塊大小。
?????????????????????????????????????? 如果不足则使用0xff来填充补满。
-r,-d,--root=DIR????? 指定要做成image的源資料夾.(默认:当前文件夹)
-s,--pagesize=SIZE???? 节点页大小(默认: 4KiB)
-e,--eraseblock=SIZE?? 设定擦除块的大小为(默认: 64KiB)
-c,--cleanmarker=SIZE Size of cleanmarker (default 12)
-m,--compr-mode=MODE?? Select compression mode (default: priortiry)
-x,--disable-compressor=COMPRESSOR_NAME
????????????????????????? Disable a compressor
-X,--enable-compressor=COMPRESSOR_NAME
????????????????????????? Enable a compressor
-y,--compressor-priority=PRIORITY:COMPRESSOR_NAME
????????????????????????? Set the priority of a compressor
-L,--list-compressors Show the list of the avaiable compressors
-t,--test-compression Call decompress and compare with the original (for test)
-n,--no-cleanmarkers?? 指明不添加清楚标记(nand flash 有自己的校检块,存放相关的信息。)
????????????????????????? 如果挂载后会出现类似:
????????????????????????? CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0
????????????????????????? 的警告,则加上-n 就会消失。
-o,--output=FILE?????? 指定輸出image檔案的文件名.(default: stdout)
-l,--little-endian???? 指定使用小端格式
-b,--big-endian??????? 指定使用大端格式
-D,--devtable=FILE???? Use the named FILE as a device table file
-f,--faketime????????? Change all file times to '0' for regression testing
-q,--squash??????????? Squash permissions and owners making all files be owned by root
-U,--squash-uids?????? 将所有文件的拥有者设为root用户
-P,--squash-perms????? Squash permissions on all files
????? --with-xattr??????? stuff all xattr entries into image
????? --with-selinux????? stuff only SELinux Labels into jffs2 image
????? --with-posix-acl??? stuff only POSIX ACL entries into jffs2 image
-h,--help????????????? 显示这些文字
-v,--verbose?????????? Verbose operation
-V,--version?????????? 显示版本
-i,--incremental=FILE Parse FILE and generate appendage output for it
实例:mkfs.jffs2 -r rootfs -o rootfs.jffs2 -e 0x4000 --pad=0x1000000 -s 0x200 -n
刚做完,等板子回来后,再看看这个东东能不能起作用。
查看文件大小:du -h file/ls -lht ?file
?相关工具下载:http://download.csdn.net/detail/yongan1006/4143004
?
?
补充:
-p,--pad[=SIZE]??????? Pad output to SIZE bytes with 0xFF. If SIZE is
????????????????????????? not specified,the output is padded to the end of
????????????????????????? the final erase block
-r,--root=DIR????? Build file system from directory DIR (default: cwd)
-s,--pagesize=SIZE???? Use page size (max data node size) SIZE (default: 4KiB)
-e,--eraseblock=SIZE?? Use erase block size SIZE (default: 64KiB)
-c,--cleanmarker=SIZE Size of cleanmarker (default 12)
-m,--compression-mode=MODE?? Select compression mode (default: priortiry)
-x,--disable-compressor=COMPRESSOR_NAME
????????????????????????? Disable a compressor
-X,--enable-compressor=COMPRESSOR_NAME
????????????????????????? Enable a compressor
-y,--compressor-priority=PRIORITY:COMPRESSOR_NAME
????????????????????????? Set the priority of a compressor
-L,--list-compressors Show the list of the avaiable compressors
-t,--test-compression Call decompress and compare with the original (for test)
-n,--no-cleanmarkers?? Don't add a cleanmarker to every eraseblock
-o,--output=FILE?????? Output to FILE (default: stdout)
-l,--little-endian???? Create a little-endian filesystem
-b,--big-endian??????? Create a big-endian filesystem
-D,--devtable=FILE???? Use the named FILE as a device table file
-f,--faketime????????? Change all file times to '0' for regression testing
-q,--squash??????????? Squash permissions and owners making all files be owned by root
-U,--squash-uids?????? Squash owners making all files be owned by root
-P,--squash-perms????? Squash permissions on all files
-h,--help????????????? Display this help text
-v,--verbose?????????? Verbose operation
-V,--version?????????? Display version information
?
??来自:http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece763105392230e54f73f6b92914a398e8448e4380c075a24b2a6657341598fd27c1043f50b4beb846d24200256b798cf8a5dddbfce73799f2642731c8d4116d20dea960673ce7fc30fb2fe0ee7cba069d5f18192864353bb514f6d818088510a13dd6f81486ca5b19939410257e6bb&p=882a9645d08119f817be9b7a5b08a5&user=baidu&fm=sc&query=magic+bitmask+0x1985+not+found&qid=e6c4ba8f1e5af07e&p1=13???????
创建jffs2文件系统注意事项
??????????? 引导过程中出现的数十行”jffs2_scan_eraseblock(): Magic bitmask 0x198
??????????? 5 not found…”信息说明jffs2文件系统有问题。另外,如果我先用远程NFS根文件
??????????? 系统引导,然后在目标机系统中直接 mount -t jffs2 /dev/mtdblock/2 /mnt 也会
??????????? 得到同样的警告信息,不过可以在 /mnt 下面看到正确的文件系统内容。
??????????? 为了解决这个问题,我首先仔细看了 mkfs.jffs2 的手册页,发现 --erasebl
??????????? ock 参数似乎比较重要,而我没有使用,于是找到该参数值 0x20000,用该参数重
??????????? 新生成了映像文件。测试表明问题仍然存在。
??????????? 查找资料发现,有人强调在 mkfs.jffs2 时使用 -p 选项,其作用是从文件末
??????????? 尾到最后一个erase block填充0xFF。这时我意识到FLASH的未分配空间必须以0xFF
??????????? 填充。而我先前的做法不能保证这一点。首先没有指定-p选项;其次,由于-l参数
??????????? 指定了远远大于实际映像文件大小的长度,而将内存区域中大量垃圾数据写到了FL
??????????? ASH中。
??????????? 因此,重新带参数-p制作jffs2文件系统映像,并改-l 0x200000为0x140000写
??????????? FLASH,这样再次mount该设备就OK了,没有再出现警告信息。但是Kernel panic仍
??????????? 然存在,这是另外一个问题。
???????????
??????????? 6.1.3 /dev/mtdblock/2 还是 /dev/mtdblock2
??????????? (首先说明,’2’只是个例子./dev/mtdblock/n,n=0,1,2,3,…)
??????????? 看起来这两个设备节点应该是完全等效的。至少我原来是这么认为。所看到的
??????????? 资料中,有的用/dev/mtdblock/2,有的用/dev/mtdblock2。能够看到的差别就是,
??????????? 如果需要多个MTD块设备节点的话,把这些节点放在单独的/dev/mtdblock目录中,
??????????? 而不是统统放在/dev下面,可以使/dev看起来清爽一些。因此,我在制作根文件系
??????????? 统的时候,选择了前者,即在/dev/mtdblock目录下面创建了0-7共8个设备节点。
??????????? 然而,“Kernel panic: VFS: Unable to mount root fs on 1f:00”错误说明
??????????? 内核没有从引导参数“root=/dev/mtdblock/2”正确定位到根文件系统(即使已经
??????????? 解决了上一个问题,保证jffs2文件系统没有问题)。
??????????? 在考虑排除了多种可能性之后,无奈之下我决定试一下“root=/dev/mtdblock
??????????? 2”。奇迹发生了,引导成功!特别注意,这时我并没有修改/dev设备节点,而仅仅
??????????? 是修改了引导参数的写法。也就是说,不论你创建的MTD设备节点是/dev/mtdblock
??????????? /2还是/dev/mtdblock2,内核引导参数都应该是“root=/dev/mtdblock2”!
??????????? 为了不致于引起更多迷惑,我还是把设备节点改变为了/dev/mtdblock2的形式?
??????????? 。那么内核引导参数中到底可不可以使用/dev/mtdblock/2的形式呢?后来我猜测内
??????????? 核如果支持 devfs 的话应该是可以的。devfs 的目的不就是把/dev从一塌糊涂的扁
??????????? 平结构改成清晰的层次结构嘛?不过我还没有验证。
??????????? 另外,在内核引导参数中使用“主设备号、次设备号”的形式来指定根文件系
??????????? 统的位置也是可以的。如下所示,“root=1f02”同样指定了/dev/mtdblock2。0x1
??????????? f=31是MTD块设备的主设备号,0x02=2是次设备号,即mtdblock2.
?
?
实践体会:
mkfs.jffs2 -r ./rootfs -o rootfs.jffs2 -e 0x4000 -s 0x200 -n
mkfs.jffs2 -r ./rootfs -o rootfs.jffs2 -e 0x4000? -n
上面的两条命令制作出来的镜像,加上-s 0x200的要多出将20M,我的flash pagesize=(512+16)B
但是不加-s也能板子也能跑起来。默认的pagesize=4K
但是板子跑起来,有一个问题:
jffs2_scan_eraseblock(): Magic bitmask 0x198?5 not found…
将命令改成:mkfs.jffs2 -r ./rootfs -o rootfs.jffs2 -e 0x4000?-p ?-n即可
?
尚待解决的问题:
qt应用程序在linux启动后,开机启动会出现:
Initializing QFontEngineQPF failed for /opt/qt/lib/fonts/DejaVuSans.ttf
但是linux在nfs方式启动时,QT应用程序开机启动便没有。 ?