折腾了两晚后,终于在 linux-2.6.22.6 上把根文件系统建立起来了,现记录于此。
一、参考资料tekkaman 的《构建基本的嵌入式Linux根文件系统》
二、实验环境
board :FL2440
bootloader:u-boot-1.1.6
kernel :linux-2.6.22.6
rootfs :busybox-1.9.1 + tinylogin
交叉编译工具:
(1)网上下载的 3.3.2 版本的 arm-linux-gcc
(2)网上下载的 3.4.1 版本的 arm-linux-gcc
(3)arm-linux-gcc version 4.3.2 (自己制作的crosstool-NG-1.9.3-hyh)
三、发现问题
1.我的 kernel 的编译工具是自己用 crosstool-NG-1.9.3 制作的 4.3.2 版本的编译工具编译的。按照 tekkaman 的步骤移植后我用同样的编译工具(4.3.2)制作了根文件系统,但是在 nfs 挂载了后输出下面的信息后就停止了
- ......
- Looking up port of RPC 100003/2 on 192.168.1.6
- eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
- Looking up port of RPC 100005/1 on 192.168.1.6
- VFS: Mounted root (nfs filesystem).
- Freeing init memory: 112K
3.把我制作的 rootfs 和 tekkaman 的进行了认真的比对,发现基本是一致的。另外,调试输出的“VFS: Mounted root (nfs filesystem).”说明内核是已经挂载上根文件系统了。这说明我的制作方法和主机的 nfs 都是没问题的。
4.那问题出在哪里呢?答案是交叉编译工具链(4.3.2)与目标机的 kernel(linux-2.6.22.6)不兼容。
四、解决问题
我分别用 3.3.2、3.4.1、4.3.2的交叉编译工具进行了试验,发现发现只有 3.4.1 制作出来的根文件系统能够正常的运行在 2.6.22.6 的 kernel 上。
1.使用 4.3.2 的交叉编译工具
试验时,目标机在输出 "Freeint init memory:112k" 后就停止运行了。后来我参考了下http://blog.csdn.net/qq345160153/article/details/7090439,修改内核配置后,目标机输出"FATAL: kernel too old,Kernel panic – not syncing: Attempted to kill init!"即停止。我用 file rootfs/lib/libc-2.9.so 发现这个运行库支持的是 linux-2.6.32 的内核,遂决定采用低版本交叉编译工具试试。
2.使用 3.3.2 的交叉编译工具
用 3.3.2 制作的根文件系统还是不行,目标机在停止之前提示找不到共享库文件。于是我参考的方法:
- From: Mike Frysinger
- To: busybox@xxxxxxxxxxx
- Cc: Bob Zhang
- Date: 2007年6月23日 上午2:32
- Attachments: signature.asc
- On Friday 22 June 2007, Bob Zhang wrote:
- I have used busybox 1.6.0 and 1.5.1
- I used the kernel 2.6.18 from Montavista ,used arm_v5t_le-gcc to
- compile kernel and busybox , but my busybox can't enter shell
- this is rarely a busybox problem
- see if booting with init=/bin/sh works
- if it doesnt, create a static application that just displays "hello" and boot
- that with init=
- if the static works but the dynamic fails, it's a toolchain problem ... go
- talk to the people who made it
- -mike
3.使用 3.4.1 的交叉编译工具
这次终于成功了。