目标板的IP为: 192.168.2.120 |
第一步, 配置NFS
在嵌入式Linux环境下进行交叉开发时, 往往不需要将目标代码烧写到目标板的flash中: 只需将宿主机的文件系统(宿主机中生成目标代码之所在)mount到目标板上!
首先要确定宿主机提供了NFS服务, 可参考我的另一篇文章: NFS配置
首先ping一下,看看网络是否接通,再在minicom中运行:
(若上句不成功,改为:
mount XXX.XXX.XXX.XXX:/home/zp /mnt -o nolock,rsize=1024,wsize=1024,timeo=15)
没有什么问题的话, 就把主机的/home/zp/share目录挂载到开发板的/mnt目录了.
但是随后我在板子上运行宿主机上的程序时, 总是出现这样的提示:
nfs:server 192.168.2.1 not responding, still trying
在华恒论坛里查了查, 找到了这样的解决方法:
nfs: server xxx.xxx.xxx.xxx not responding, still trying的现象是mount正常,但PING的时候丢包率比较大,拷贝或运行一些数据量大于1K的程序将马上出现这个提示,然后几乎无响应;
这个问题的解决办法如下: |
第二步, 配置TFTP服务
tftp一般用于向目标板中下载镜像文件.
1, 安装tftp
Ubuntu/Debian 上默认是没有安装tftp, tftpd的, 首先安装它们
$ sudo apt-get install tftp tftpd
tftp和tftp分别是客户端和服务器端程序.
2, 设置
在根目录新建一个tftpboot目录, 并将读写权限设置为777
$ sudo mkdir /tftpboot
$ sudo chmod 777 /tftpboot
注意这里的目录名称要和后面添加到/etc/inetd.conf中的目录名称相同! |
/etc/inetd.conf 设定了tftp可以访问的文件目录. 如果没有设定它们, 那么tftp使用默认的目录 (在Ubuntu6.06中, 目录被设置成了/srv/tftp)
默认的/etc/inetd.conf内容如下:
#
tftp
dgram udp wait
nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /boot
在Debian/Ubuntu中, 更新/etc/inetd.conf之后运行$ sudo /etc/init.d/inetd reload 在别的系统中, 可以运行: $ sudo kill -HUP inetd-pid |
按照在Debian上安装tftpd服务的方法, 能配置 /etc/inetd.conf, 却怎么也找不到inetd进程, 这是怎么回事呢?
tftp是有inetd控制的. inetd是管理其他守护进程的守护进程, 使用RPC的守护进程的端口号由portmap分配.
可我在ubuntu上没有与inetd相关的任何命令或者manual. $ ps aux | grep inetd 找不到inetd进程.
最后才发现, 原来Ubuntu是没安装inetd的. 晕了, 这个怎么回没有? 装上它:
$ sudo apt-get install netkit-inetd
The inetd server is a network daemon program that
specializes in managing incoming network connections. It's
configuration file tells it what program needs to be run when an
incoming connection is received. Any service port may be configured for either of the tcp or udp protcols. 安装netkit-inetd, 它会修改/etc/inetd.conf的内容. 此时要开启tftp服务, 应该再该文件中加入: tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot 最后一项/tftpboot是tftp的下载目录,要与上述第二步中新建的目录名称相同. |
3, 重新加载inetd进程
在Debian/Ubuntu中, 更新/etc/inetd.conf之后运行$ sudo /etc/init.d/inetd reload
在别的系统中, 可以运行: $ sudo kill -HUP inetd-pid
4, 测试tftp
在/tftpboot中任意放置一个文件, 比如foo, 到另外一个目录中.
$ tftp localhost
tftp> get foo
Received 7615 bytes in 0.0 seconds
安装, 配置inetd后会更改/etc/hosts.deny和/etc/hosts.allow文件内容. 最好回过头去重新设置它们. (在Ubuntu6.06中) |
参考资料
(1) 本人blog中的Debian/Ubuntu NFS设置.
(2)在debian中安装tftp服务(简略)
(3)Ubuntu中还有其他版本的tftp可用: