【内核】在Linux内核中添加对jffs2的支持

时间:2023-01-18 15:41:29

海思最新出了一款超低内存的芯片HI3518EV201(内存只有32M)

在开发过程中对内核的裁剪考验相当大,当然海思也提供了参考的裁剪方案《hi3518ev20x_mini_config.txt》。

但是不能完全按照海思提供的裁剪方案来玩,因为该内核不支持USB、不支持frame buf、不支持以太网及nfs、不支持进程间通信等。

其中不支持进程间通信是指将内核配置 General setup中的System V IPC选项去掉;System V IPC共有三种类型:System V消息队列、System V 信号量、System V 共享内存区。即是不支持消息队列、信号量和共享内存三种进程间通信方式。

1.修改Makefile,在首行位置添加以下两行:

ARCH=arm

CROSS_COMPILE=arm-hisiv300-linux-

在make menuconfig 后在File systems  ---> 中看到:

a.该内核只支持ext4文件系统

b.[ ] Miscellaneous filesystems  --->选项压根就没有勾选上,及时勾选上进去也看不到jffs2的选项

2.在Miscellaneous filesystems  --->选项中添加jffs2选项卡:

Device Drivers  --->

  <*> Memory Technology Device (MTD) support  --->(这个选项一选上后,File systems  ---> 中的Miscellaneous filesystems  --->就会变成必选项了) 保存

3.去掉对ext4文件系统的支持,添加对jffs2和squashfs文件系统的支持

去掉:

File systems  ---> 

   < > The Extended 4 (ext4) filesystem  

添加:

File systems  ---> 

  -*- Miscellaneous filesystems  --->

     <*>   Journalling Flash File System v2 (JFFS2) support 

    和<*>   SquashFS 4.0 - Squashed file system support 

4.编译一遍 make uImage,然后将zImage烧到板子上go 0x81000000, /etc/init.d/S00devs脚本中有两句

mount -t squashfs /dev/mtdblock2 /mnt/app
mount -t jffs2 /dev/mtdblock3 /mnt/app_ext/

发现以下错误:

mount: mounting /dev/mtdblock2 on /mnt/app failed: No such device or address
mount: mounting /dev/mtdblock3 on /mnt/app_ext/ failed: No such device

5.解决mount 出错:

Device Drivers --->
  <*> Memory Technology Device (MTD) support --->
    [*] Command line partition table parsing

6.再编译一遍 make uImage,然后将zImage烧到板子上go 0x81000000,因为squashfs文件系统默认是ZLIB压缩算法的,而我们使用的是压缩率最高的XZ算法,因此会发现以下错误:

SQUASHFS error: Filesystem uses "xz" compression. This is not supported
mount: mounting /dev/mtdblock2 on /mnt/app failed: Invalid argument

7.解决xz压缩算法出错:

File systems --->
  -*- Miscellaneous filesystems --->
    <*> Journalling Flash File System v2 (JFFS2) support 下面的
    [*] Include support for ZLIB compressed file systems(去掉勾选)
    [*] Include support for XZ compressed file systems (加上勾选)

8.跑起来后,boot.sh脚本中对jffs2文件系统进行操作时,发现以下错误,因为加密算法类型0x07没有打到内核中:

jffs2: compression type 0x07 not available
jffs2: Error: jffs2_decompress returned -5

9.解决xz压缩算法出错:

File systems ---> 
  -*- Miscellaneous filesystems ---> 
    [*]     Advanced compression options for JFFS2 下面的
    [*]       JFFS2 LZO compression support  (加上勾选) 

10.ok了,接下来就是遇到一些简单的错误,不再做详细阐述。