ubuntu: 20
uboot: 2016.03
1、pc机搭建nfs服务器和tftp服务器
-
安装tftpd
sudo apt-get install tftpd-hpa -
配置tftp服务
sudo vim /etc/default/tftpd-hpa# /etc/default/tftpd-hpa TFTP_USERNAME="tftp" TFTP_DIRECTORY="/svr/tftp" TFTP_ADDRESS=":69" TFTP_OPTIONS="-l -c -s"
sudo chown tftp:tftp /srv/tftp
-
重启tftp服务
sudo service tftpd-hpa restart -
安装nfs服务
sudo apt install nfs-kernel-server -
配置nfs服务
sudo vim /etc/exports/src/nfs *(rw,sync,no_subtree_check)
sudo systemctl restart nfs-kernel-server.service
-
查看版本
sudo cat /proc/fs/nfsd/versions -
虚拟机新建网卡,桥接模式。
设置固定ip
sudo vim /etc/netplan/01-network-manager-all.yaml# Let NetworkManager manage all devices on this system network: ethernets: ens38: dhcp4: no addresses: [192.168.100.10/24] optional: true gateway4: 192.168.100.1 version: 2 renderer: NetworkManager
sudo netplan apply
-
若板卡ping不同虚拟机,查看vmware虚拟机的桥接网卡指向有线网卡还是无线网卡。
-
板卡挂载
#mount -o nolock,nfsvers=3,vers=3 192.168.100.10:/srv/nfs tmp
mount -o nolock,nfsvers=3 192.168.100.10:/srv/nfs tmp
2、uboot添加nfs支持
- tftp 下载kernel到内存启动: tftp 12000000 zImage
- tftp 下载dtb到内存:tftp 18000000 imx6q-c-sabresd.dtb
-
bootz命令启动:bootz 12000000 -18000000
启动之前需要设置bootargs。
- 本地mmc文件系统:
setenv bootargs console=${console},${baudrate} ${mxcfb0} ${mxcfb1} ${ldbmode} ${smp} root=${mmcroot} fec.macaddr=${fec_mac}
- nfs文件系统:
// 参考:
// bootargs1
setenv bootargs 'console=${console},${baudrate} ${smp} root=/dev/nfs rootwair rw nfsroot=${serverip}:${nfsroot},v3,tcp'
// bootargs2
setenv bootargs 'console=${console},${baudrate} root=/dev/nfs rootwait rw nfsroot=${serverip}:${nfsroot} ip=192.168.100.10:192.168.100.1:192.168.100.1:255.255.255.0::eth0:off'
// bootargs3
setenv bootargs 'console=ttymxc0,115200 root=/dev/nfs rw nolock ip=192.168.100.11:192.168.100.10:192.168.100.1:255.255.255.0::eth0:off nfsroot=192.168.100.10:/srv/nfs/rootfs,v3,tcp'
3、linux kernel添加支持
make menuconfig
执行make menuconfig失败,: fatal error: ncurses.h: No such file or directory。
sudo apt install libncurses5-dev
File systems ---->
[*]Network File Systems --->
[*] NFS client suport
[*] NFS client support for NFS version 3
[*] NFS client support for NFS version 4
[*] Root file system on NFS
4、启动
(1)、tftp 下载内核和设备树(tftp服务器准备好,启动文件准备好)
tftp 12000000 zImage
tftp 18000000 imx6q-c-sabresd.dtb
setenv bootargs 'console=ttymxc0,115200 root=/dev/nfs rw nolock ip=192.168.100.11:192.168.100.10:192.168.100.1:255.255.255.0::eth0:off nfsroot=192.168.100.10:/srv/nfs/rootfs,v3,tcp'
bootz 12000000 -18000000
(2)、本地加载内核和设备树(本地已提前下载好启动文件)
fatload mmc 2:1 12000000 zimage
fatload mmc 2:1 18000000 imx6q-c-sabresd.dtb
setenv bootargs 'console=ttymxc0,115200 root=/dev/nfs rw nolock ip=192.168.100.11:192.168.100.10:192.168.100.1:255.255.255.0::eth0:off nfsroot=192.168.100.10:/srv/nfs/rootfs,v3,tcp'
bootz 12000000 - 18000000