从nfs启动的话,要具备的条件是:
a. 你的uboot支持网络;
b. 你的宿主机的nfs已经启动,并可以被正常挂载;
c. 你的宿主机的tftp已经启动,并可以从上面下载(也可以直接把你编译的支持nfs启动的内核烧进开发板去,这样就直接启动开发板就可以了)
要做的事有:
这里只讲从nfs启动需要的选项,其他的选项请参考其他博客上的内核配置的文章;
要用nfs文件系统的话配置内核的时候,必须选上:
File Systems -->
Network File Systems -->
Root file system on NFS; (这个必须选上)
以上是完整的选项路径
然后编辑.config,找到CONFIG_CMDLINE="",然后设置成
CONFIG_CMDLINE="root=/dev/nfs nfsroot=宿主机ip:nfs目录 ip=开发板ip rw console=ttySAC0 mem=256M"
我设置参考:
CONFIG_CMDLINE="root=/dev/nfs nfsroot=192.1.1.231:/nfs ip=192.1.1.119 rw console=ttySAC0 mem=256M"
配置好了之后编译内核,然后把内核放到tftp目录下,以供启动时下载内核;
设置ip,这里的ip要和你配置内核时设置的一致,设置子网掩码,网关;
然后还要设置一个bootargs;设置为:
setenv bootargs "root=/dev/nfs nfsroot=宿主机ip:/nfs目录 开发板ip:子网掩码:eth0:off console=ttySAC0,115200"
我的配置参考:
setenv bootargs "root=/dev/nfs nfsroot=192.1.1.231:/nfs ip=192.1.1.119:255.255.255.0:eth0:off console=ttySAC0,115200"
saveenv,然后reset,在uboot处停住,printenv 看一下有没有保存配置;若已保存则下一步。
停在uboot的时候,先从tftp服务器下载uImage,把它下载到内存:
tftp c0800000 uImage
然后从内存启动内核:
bootm c0800000
启动完毕就可以在串口超级终端操作你的开发板了。
以上来源与: <http://blog.sina.com.cn/s/blog_77c2e1cb0101hs29.html>
我在挂载的时候出现了如下的错误:
s3c6400_setup_sdhci_cfg_card: CTRL 2=c0004120, 3=80808080
rpcbind: server 192.1.1.108 not responding, timed out
Root-NFS: Unable to get nfsd port number from server, using default
Looking up port of RPC 100005/1 on 192.1.1.108
rpcbind: server 192.1.1.108 not responding, timed out
Root-NFS: Unable to get mountd port number from server, using default
Root-NFS: Server returned error -101 while mounting /ok6410/FileSystem/rootfs
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
b300 3813376 mmcblk0 driver: mmcblk
b301 3710976 mmcblk0p1
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
[<c002c694>] (unwind_backtrace+0x0/0xec) from [<c033a3d8>] (panic+0x54/0x174)
[<c033a3d8>] (panic+0x54/0x174) from [<c0009040>] (mount_block_root+0x1d0/0x210)
[<c0009040>] (mount_block_root+0x1d0/0x210) from [<c00092d8>] (prepare_namespace+0x164/0x1bc)
[<c00092d8>] (prepare_namespace+0x164/0x1bc) from [<c00085f4>] (kernel_init+0x10c/0x14c)
[<c00085f4>] (kernel_init+0x10c/0x14c) from [<c0027e2c>] (kernel_thread_exit+0x0/0x8)
开发板可以加载内核,但是不能够挂载NFS文件系统,可能出现的问题是:
1. 自己制作的内核有问题
2. 自己虚拟机上linux的nfs配置的有问题
首先检测下linux的NFS是否正常,我的虚拟机软件里面有两个linux,一个是ubuntu(ip = 192.1.1.108),一个是RedHat(ip = 192.1.1.231),两个处于同一个网段,而且可以相互ping通,ubuntu上的nfs可以用命令:mount -t nfs 192.1.1.108:/ok6410/FileSystem/rootfs /mnt
它的/etc/exports的内容如下:
ubuntu自己将nfs目录挂载到/mnt下面成功:
用RedHat挂载ubuntu上的nfs也成功了:
这就是说ubuntu的NFS是成功安装了,外部的终端可以挂载nfs根目录。(可以用别人跑着linux的开发板来远程mount一下ubuntu的nfs,应该是可以的),所以问题应该是处在了内核的编译上面。
我在网上下载了一个可以引导NFS的内核,在开发板上试验:
先设置开发板参数:
setenv bootargs "root=/dev/nfs rw nfsroot=192.1.1.231:/nfs ip=192.1.1.119:255.255.255.0:eth0:off console=ttySAC0,115200"
保存参数:
saveenv
(下载并启动内核:nfs c0800000 192.1.1.231:/nfs/uImage3.0;bootm c0800000)
下载内核:
tftp c0800000 uImage3.0
启动内核:
bootm c0800000
其中服务器linux中/etc/exports内容如下:
nfs目录内容:
开发板启动的界面:
测试一个小程序:
在/nfs下新建hello.c
编译:arm-linux-gcc -static hello.c -o hello
开发板上执行:
./hello
===========================================================================
开发板的参数:
下载内核:
nfs c0800000 192.1.1.108:/ok6410/FileSystem/rootfs/uImage3.0;bootm c0800000
但是还是出错了:
这就是ubuntu的NFS有问题了,查看/etc/exports的内容:
修改成:
然后重启nfs服务:
/etc/init.d/nfs-kernel-server restart
在下载测试:
还是有问题:
不知道什么原因。。。。。。。。。。。。得再查查错误