1. 修改u-boot,用tftp加载kernel和device tree,用nfs加载rootfs
修改include/configs/zynq_zc70x.h中的IP Address的配置为需要的值
/* Default environment */
#define CONFIG_IPADDR 10.10.70.102
#define CONFIG_SERVERIP 10.10.70.101
修改include/configs/zynq_common.h中关于sdboot的配置为
"sdboot=echo Copying Linux from tftp to RAM...;" \
"tftp 0x3000000 ${kernel_image};" \
"tftp 0x2A00000 ${devicetree_image};" \
"bootm 0x3000000 0x2000000 0x2A00000\0" \
说明:
board/Xilinx/zynq_common/board.c/board_late_init()会去读取Address= 0xF800025C的BOOT_MODE寄存器,然后生成u-boot下环境变量modeboot。
注意:
Devicetree的地址是bootm的第三个参数,所以用bootm启动时第二个参数(ramdisk的地址)就不能少。如果不加载ramdisk,就会出现ramdisk校验问题。所以现在还要做一次无用的ramdisk加载,以骗过bootm。
确认内核里面已经包含NFS Client的支持
File Systems->Network File Systems
File Systems->Network File Systems->NFS Client support
File Systems->Network File Systems->NFS Client support-> NFS Client support for NFS version 3
File Systems->Network File Systems->Root file system on NFS
加载后发现rootfs还是在ramdisk上,在shell里面测试nfs,发现有问题
~ # mount -t nfs 192.168.1.20:/nfsroot ramdisk/
svc: failed to register lockdv1 RPC service (errno 111).
mount: mounting 192.168.1.20:/nfsroot on ramdisk/ failed: Connection refused
~ # mount -o nolock 192.168.1.20:/nfsroot ramdisk/
~ # ls ramdisk/
bin etc linuxrc opt root sys usr
dev lib mnt proc sbin tmp var
~ # df -h
Filesystem Size Used Available Use% Mounted on
/dev/root.old 7.7M 7.0M 768.0K 90% /
none 504.5M 0 504.5M 0% /tmp
192.168.1.20:/nfsroot/
28.3G 4.7G 22.2G 17% /root/ramdisk
~ #
注意:需要加一个-o nolock才可以mount上nfs
因此修改device tree里面的bootargs为
console=ttyPS0,115200 ip=192.168.1.10 root=/dev/nfs rw nfsroot=192.168.1.20:/nfsroot,nolock earlyprintk
结果发现rootfs还是在ramdisk上,原来ramdisk的优先级高于nfs
继续修改device tree里面的bootargs为
noinitrd console=ttyPS0,115200 ip=192.168.1.10 root=/dev/nfs rw nfsroot=192.168.1.20:/nfsroot,nolock earlyprintk
至此终于把nfs mount上了。