完成了Linux 2.6.39的移植后,接下来先建立个NFS文件系统,使用“构建最小根文件系统.doc”文档中建立的文件系统(201407090326_fs_mini.tar.bz2 http://pan.baidu.com/s/1gdorX9h)作为NFS根文件系统。此步骤可参考搭建NFS的相关文档,这里不再说明。
a) 修改启动参数后重启
# setenv bootargs 'mem=64M console=ttySAC0,115200 mac=00:60:6E:42:BA:80 root=/dev/nfs nfsroot=192.168.2.222:/opt/MICRO2440/3.Filesystem/NFS ip=192.168.2.123:192.168.2.222:192.168.2.1:255.255.255.0:sbc2440.arm9.net:eth0:off'
# saveenv
完成启动参数修改后,重新通过TFTP下载内核镜像并启动。如下图所示,提示“VFS: Unable to mount root fs via NFS, trying floppy.”经测试,启动参数和NFS服务器都是没有问题的。在AT91SAM9260EK开发板上也同样遇到过这个问题,剩下的就只是DM9000驱动问题了。
b) 修改DM9000驱动
Linux-2.6.39中已经包含DM9000 网卡驱动,但并不是完全的适合mini2440/micro2440,所以还是需要修改,修改DM9000 所用的位宽寄存器。
# vim drivers/net/dm9000.c
Ø 增加头文件
#include <asm/delay.h> #include <asm/irq.h> #include <asm/io.h>
#include "dm9000.h"
#include <mach/regs-mem.h> //lsh
/* Board/System/Debug information/definition ---------------- */
#define DM9000_PHY 0x40 /* PHY address 0x01 */ |
Ø 修改初始化函数
/* * Initialize dm9000 board */ static void dm9000_init_dm9000(struct net_device *dev) { board_info_t *db = netdev_priv(dev); unsigned int imr; unsigned int ncr;
//lsh add start unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON; unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4; *((volatile unsigned int *)S3C2410_BWSCON) = (oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 | S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4; *((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c; //lsh add end
dm9000_dbg(db, 1, "entering %s\n", __func__); |
重新编译uImage后通过TFTP下载内核运行。如下图所示,经过DM9000驱动修改,已经可以挂载NFS了。但仍然卡在“Kernel panic - not syncing: Attempted to kill init!”中。
这种情况可能由于编译busybox时,使用的编译器版本引起的。在AT91SAM9260EK开发板上也同样遇到过这个问题,可打开内核的EABI配置来解决。
c) 打开内核EABI选项目
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)
重新编译uImage后通过TFTP下载内核运行。还是提示“Kernel panic - not syncing: Attempted to kill init!”错误。
经测试,使用友善之臂提供的文件系统可以正常启动,这就证明是我所制作的文件系统有问题。
d) 重新编译busybox并制作文件系统
经分析,打开EABI后仍然出现“Kernel panic - not syncing: Attempted to kill init!”错误是因为busybox编译没有选择静态编译,即在make menuconfig时没有选上Build BusyBox as a static binary 。这个选项是一定要选择的,这样才能把busybox编译成静态链接的可执行文件,运行时才独立于其他函数库。否则必需要其他库文件才能运行,在单一个linux内核不能使它正常工作。后面证实不需要用此方法,后面红色字体所述方法即可。
根据“构建最小根文件系统.doc”重新制作根文件系统,并且选上busybox的Build BusyBox as a static binary编译选项,如下所示。
Busybox Settings --->
Build Options --->
[*] Build BusyBox as a static binary (no shared libs)
重新编译uImage后通过TFTP下载内核运行。可以正常挂载根文件系统了。将重新制作的文件系统保存为201407240718_fs_mini_micro2440.tar.bz2,并上传至网盘(http://pan.baidu.com/s/1bn6bvDd)。
在后面制作LINUX上烧写YAFFS2镜像时发现调用nandwrite等后编译的程序时会提示“Illegal instruction”错误。后经调试发现在是文件系统下的lib文件有问题,在制作最小文件系统时我使用的是“/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/lib/”目录下的,应该使用/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/才对,这样的话就不需要重新编译BUSYBOX,也不需要选静态编译。
将修复lib库文件后的文件系统保存为201407281804_fs_mini.tar.bz2,上传到网盘(http://pan.baidu.com/s/1qWqHQW0)。