一、Ubuntu安装NFS服务并进行下载测试
1、首先安装nfs服务
sudo apt-get install nfs-kernel-server rpcbind
2、建立存放待传输文件的文件夹
mkdir /home/Ubuntu用户名/linux/nfs
比如我的是:
/home/likaiqin/linux/nfs
3、使用vi编辑器配置nfs
sudo vi /etc/exports
在文件的最后加入:
/home/ubuntu用户名/linux/nfs *(rw,sync,no_root_squash)
4、重启nfs服务
sudo /etc/init.d/nfs-kernel-server restart
5、使用nfs下载文件到开发板
在保证ping通的条件下,使用命令向开发板下载文件(前提是zImage已经通过Filezilla软件放到nfs文件加中):
nfs 80800000 192.168.43.111:/home/likaiqin/linux/nfs/zImage
由上图可得,出现错误:File lookup fail!
二、问题所在
经过一系列查找,发现是nfs版本问题导致的不兼容(大概意思就是,Ubuntu中的nfs是高版本,而正点原子开发板提供的uboot中的nfs服务是低版本)。
三、解决方案
修改/etc/default/nfs-kernel-server 文件:
sudo vim /etc/default/nfs-kernel-server
# Number of servers to start up
#RPCNFSDCOUNT=8
RPCNFSDCOUNT="-V 2 8"
# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0
# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
#RPCMOUNTDOPTS="--manage-gids"
RPCMOUNTDOPTS="-V 2 --manage-gids"
# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD=""
# Options for rpc.svcgssd.
RPCSVCGSSDOPTS="--nfs-version2,3,4 --debug --syslog"
四、报错“TTTTTTTTTTTTT”
正常运行一段时间之后出现“TTTTTTT"。
解决方案如下:sudo vi /etc/hosts
五、修改后演示
首先重启nfs服务:
sudo /etc/init.d/nfs-kernel-server restart
然后在uboot中输入指令,将文件zImage下载到DRAM的80800000地址处:
nfs 80800000 192.168.43.111:/home/likaiqin/linux/nfs/zImage
回到Ubuntu中查看zImage的大小,发现下载到DRAM的0大小和zImage文件大小完全一致,并且下载过程中没有异常。
六、验证
可以看到使用notepad++打开的zImage文件前0x100(256个)字节完全相同,表明下载成功!
注:如果出现Retry count exceed;starting again的错误,请关闭物理机的防火墙。
欢迎大家加入嵌入式linux技术交流群(QQ:100479172),也欢迎大家一起讨论C语言、C++、单片机、数据结构、Qt、Linux、IMX6ULL等技术