首先重启Ubuntu 服务器的 tftp 和nfs
sudo /etc/init.d/xinetd restart 命令 重启 xinetd tftp服务
sudo /etc/init.d/nfs-kernel-server restart 重启nfs
应该设置的环境变量
setenv serverip 192.168.1.100
setenv client_ip 192.168.1.103
setenv root_dir /home/topeet/targetNFS
setenv fdtfile am335x-boneblack.dtb
run nfsboot
==============================================================================
讲解:
-----run nfsboot-----
就是从脚本的下面的语句开始执行
nfsboot=echo Booting from ${server_ip} ...; setenv nfsroot ${server_ip}:${root_dir}${nfs_options}; setenv ip ${client_ip}:${server_ip}:${gw_ip}:${netmask}:${hostname}:${device}:${autoconf}; setenv autoload no; setenv serverip ${server_ip}; setenv ipaddr ${client_ip}; tftp ${loadaddr} ${tftp_dir}${bootfile}; tftp ${fdtaddr} ${tftp_dir}dtbs/${fdtfile}; run nfsargs; bootz ${loadaddr} - ${fdtaddr}
nfsargs=setenv bootargs console=${console} ${optargs} ${cape_disable} ${cape_enable} root=/dev/nfs rw rootfstype=${nfsrootfstype} nfsroot=${nfsroot} ip=${ip} ${cmdline}
其中需要自己配置的环境变量有server_ip(ubuntu的ip)、root_dir(ubuntu中文件系统的路径)、client_ip(开发板ip)、fdtfile(设备树文件名),nfsroot(根文件系统在ubuntu中的路径),配置完之后如下:
nfsboot=echo Booting from 192.168.1.100 ...;
setenv nfsroot 192.168.1.100:/home/topeet/targetNFS;
setenv ip 192.168.1.103:192.168.1.100:192.168.1.1:255.255.255.0::eth0:off;
setenv autoload no;
setenv serverip 192.168.1.100;
setenv ipaddr 192.168.1.103;
tftp 0x82000000 zImage; //通过tftp服务器下载zImage 到0x82000000
tftp 0x88000000 dtbs/am335x-boneblack.dtb; //下载am335x-boneblack.dtb 到0x88000000
run nfsargs; //加载跟文件系统
bootz 0x82000000 - 0x88000000