1)、安装服务器: 见《GEC210-Linux开发环境搭建与体验》第44页 “1.9 TFTP 实验”
提示:如果发现不能更新安装,可更新 apt 源,编辑前请备份。
#vim /etc/apt/sources.list
清空该文件并加入:(这是国内网易更新源,速度超快)deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
然后#sudo apt-get update 命令,就可以输入安装 tftp 服务命令了。
2)、修改配置文件
sudo vim /etc/default/tftpd-hpa
打开 tftpd-hpa 文件,进行修改。
修改内容为:
#TFTP_DIRECTORY="/var/lib/tftpboot"
//注释原来的共享路径
TFTP_DIRECTORY="/tftpboot"
//添加自己更改的路径
#TFTP_OPTIONS="--secure"
//注释
TFTP_OPTIONS="-l -s -c"
//添加
完后保存退出
建立 tftpboot 文件夹,改变/tftpboot 文件夹权限,避免开发板发文件到 PC 时出现权
限问题
#mkdir /tftpboot
#chmod 777 /tftpboot
重新启动服务
#sudo /etc/init.d/xinetd restart
# sudo /etc/init.d/tftpd-hpa restart
#netstat –au
(查看当前网络服务)
将要下载的文件放在 tftp 服务器共享目录下
3)、启动服务
配置 ubuntu 网络
#ifconfig eth0 192.168.1.100 (必须在同一网段内)
#ifconfig eth0 down
#ifconfig eth0 up
tfttp 客户端(GEC210 开发板)
启动 GEC210 开发板后,执行
#ifconfig eth0 192.168.1.110
#ifconfig eth0 down
#fconfig ethp0 up
下载文件到开发板:
#tftp 192.168.1.100 –g –r xxx (下载的文件名) (需先把要下载的文件放到服务端,刚创建的/tftpboot 文件夹,否则找不到文件)
上传文件到 ubuntu
#tftp –p –l filename 192.168.1.100
问题:
[root@GEC210 /tmp]#tftp 222.16.25.185 -g -r button_driver.ko
tftp: timeout
[root@GEC210 /tmp]#
分析:无法传送文件
解决:服务器端的TFTP服务未开启,故在服务器端(即主机linux)执行一下命令:
重新启动服务
#sudo /etc/init.d/xinetd restart
# sudo /etc/init.d/tftpd-hpa restart
[root@GEC210 /tmp]#tftp 222.16.25.185 -r helloworld_driver.ko -g
tftp: server error: (0) Permission denied
分析:/tftpboot文件夹的权限不够
解决:root@ubuntu:/# chmod -R 777 tftpboot/