用Qemu模拟vexpress-a9 (四) --- u-boot引导kernel,用nfs挂载根文件系统

时间:2023-03-10 04:52:56
用Qemu模拟vexpress-a9 (四) --- u-boot引导kernel,用nfs挂载根文件系统

环境介绍

Win7 64 + Vmware 11 + ubuntu14.04 32

u-boot 版本:u-boot-2015-04

Linux kernel版本:linux-3.16.y

busybox版本:1_24_stable

交叉编译工具链:arm-linux-gnueabi-

qemu版本:stable-2.4

目的

这篇博文的目的是实现NFS根文件系统的挂载。具体步骤如下。

步骤

1、参照上一篇博文,以保证Qemu的网络是可以用的。

2、配置u-boot的环境变量bootargs

setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.11.20:/nfs_rootfs/rootfs init=/linuxrc console=ttyAMA0 ip=192.168.11.5'

3、配置kernel

配置内核,使其支持nfs挂载根文件系统

make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm O=./out_vexpress_3_16/ menuconfig

配置:

File systems  --->

[*] Network File Systems  --->

<*>   NFS client support

<*>     NFS client support for NFS version 3

[*]       NFS client support for the NFSv3 ACL protocol extension

[*]   Root file system on NFS

然后重新编译内核

make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm O=./out_vexpress_3_16 LOADADDR=0x60003000 uImage -j2

将生成的uImage拷贝到/tftpboot下

4、启动

qemu-system-arm -M vexpress-a9 \
-kernel /root/tq2440_work/u-boot/u-boot/u-boot \
-nographic \
-m 512M \
-net nic,vlan= -net tap,vlan=,ifname=tap0
-sd /root/tq2440_work/busybox_study/a9rootfs.ext3

注:这里的-sd参数此时可以不用设置。

启动信息:

VFS: Mounted root (nfs filesystem) on device :.
Freeing unused kernel memory: 236K (805c2000 - 805fd000) Please press Enter to activate this console.
[root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]# mount
rootfs on / type rootfs (rw)
192.168.11.20:/nfs_rootfs/rootfs on / type nfs (rw,relatime,vers=,rsize=,wsize=,namlen=,hard,nolock,proto=udp,timeo=,retrans=,sec=sys,mountaddr=192.168.11.20,mountvers=,mountproto=udp,local_lock=all,addr=192.168.11.20)
proc on /proc type proc (rw,relatime)
tmpfs on /tmp type tmpfs (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=)

此时我们由于指定了-sd参数,所以我们还可以访问原来的根文件系统,方法如下:

[root@vexpress ]# ls /dev/mmcblk0  -lh
brw-rw---- , Dec : /dev/mmcblk0
[root@vexpress ]# df -h
Filesystem Size Used Available Use% Mounted on
192.168.11.20:/nfs_rootfs/rootfs
.6G .1G .7G % /
tmpfs 250.7M 250.7M % /tmp
tmpfs 250.7M 250.7M % /dev
[root@vexpress ]# mount -t ext3 /dev/mmcblk0 /mnt/tmp
random: nonblocking pool is initialized
kjournald starting. Commit interval seconds
EXT3-fs (mmcblk0): using internal journal
EXT3-fs (mmcblk0): mounted filesystem with writeback data mode
[root@vexpress ]# ls /mnt/tmp/
bin etc linuxrc mnt root sys usr
dev lib lost+found proc sbin tmp var
[root@vexpress ]#

5、开启图形界面

  • 修改u-boot参数
setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.11.20:/nfs_rootfs/rootfs init=/linuxrc console=ttyAMA0 console=tty0 ip=192.168.11.5'
  • 执行命令
qemu-system-arm -M vexpress-a9 \
-kernel /root/tq2440_work/u-boot/u-boot/u-boot \
-serial stdio \
-m 512M \
-net nic,vlan= -net tap,vlan=,ifname=tap0 \
-sd /root/tq2440_work/busybox_study/a9rootfs.ext3

截图:

用Qemu模拟vexpress-a9 (四) --- u-boot引导kernel,用nfs挂载根文件系统

未完待续。