我的硬件链接图如下:PC端操作系统centos6.5,开发板JZ2440,预先在Nor flash中烧写了u-boot.bin。
PC端:
一,因为用的无线网卡上网,默认有线网卡是停用的,手动使能有线网卡
ifconfig -a
ifconfig p3p1 up
ifconfig p3p1 192.168.2.100
注意我的无线网卡ip为192.168.0.7,这里有线网卡与开发板直连的通道ip要与无线通道设置为不同网段,如2.100
二,安装并运行tftp服务器软件(网摘出自:Linux中TFTP使用详解)
TFTP是用来下载远程文件的最简单网络协议,它其于UDP协议而实现。
linux服务器端tftp-server的配置
1、安装tftp服务器
需要安装xinetd(守护tftp)、tftp和tftp-server 3个软件
1)如果能上网,通过yum安装:
sudo yum install xinetd
sudo yum install tftp
sudo yum install tftp-server
2、配置tftp服务器
修改/etc/xinetd.d/tftp文件,将其中的disable=yes改为disable=no。开启TFTP服务
主要是设置TFTP服务器的根目录,开启服务。修改后的文件如下:
service tftp
{ socket_type =dgram
protocol =udp
wait =yes
user =root
server =/usr/sbin/in.tftpd
server_args =-s /home/mike/tftpboot -c
disable =no
per_source =11
cps =100 2
flags =IPv4
}
说明:修改项server_args= -s
参数-s指定chroot,-c指定了可以创建文件。
我的操作:vi /etc/xinetd.d/tftp
disable = 0
server_args = -s /home/jello/tftpboot -c
每次修改后都要如下3重启tftp服务才能生效
3、启动tftp服务器并关闭防火墙
RedHat7+
systemctl disable firewall;systemctl stop firewall
systemctl enable xinetd;systemctl start xinetd
Redhat7-
/etc/init.d/iptables stop //关闭防火墙
sudo /sbin/service xinetd start
或service xinetd restart
/etc/init.d/xinetd start
看到启动[OK]就可以了
4、查看tftp服务是否开启
netstat -a | grep tftp
显示结果为
udp 0 0 *:tftp *:*
表明服务已经开启,就表明tftp配置成功了。
5、tftp使用
复制一个文件到tftp服务器目录,然后在主机启动tftp软件,进行简单测试。
登陆
tftp 192.168.1.2
tftp>get
tftp>put
tftp>q
6、tftp命令用法如下
tftp your-ip-address
【进入TFTP操作】
connect:连接到远程tftp服务器
mode:文件传输模式
put:上传文件
get:下载文件
quit:退出
verbose:显示详细的处理信息
tarce:显示包路径
status:显示当前状态信息
binary:二进制传输模式
ascii:ascii传送模式
rexmt:设置包传输的超时时间
timeout:设置重传的超时时间
help:帮助信息
?:帮助信息
7、如果出现“AVC Denial, click icon to view”的错误,并不能传输文件
修改/etc/sysconfig/selinux,将SELINUX设定为disable
使用命令setenforce 0让selinux配置文件生效
我的操作:(PC端测试tftp的使用)
mkdir /home/jello/tftpboot
vi /home/jello/tftpboot/testfile
tftp 192.168.0.7 //登录
tftp> get testfile //不能写绝对路径/home/jello/tftpboot/testfile,否则会显示File not found
tftp> q //退出
# ls /root //会找到下载的testfile,默认路径/root
# mv /root/testfile /root/testfile11
# tftp 192.168.0.7
tftp> put testfile11 //同样不能用绝对路径
tftp> q
# ls /home/jello/tftpboot/ //能找到上传的testfile11
开发板端:(PC终端执行minicom操作开发板Nor flash上的u-boot)
OpenJTAG> set ipaddr 192.168.2.17 //设置为与PC有线网卡同网段
OpenJTAG> set serverip 192.168.2.100
OpenJTAG> save
OpenJTAG> ping 192.168.2.100 //显示host192.168.2.100 is alive
OpenJTAG> tftp 30000000 testfile //显示TFTP Server192.168.2.100; our address ip is 192.168.2.17……done下载成功。