1.开发背景
tftp 即文件传输协议,主要通过网络通讯的方式实现文件跨机器传输
2.开发需求
搭建 ubuntu 下的服务端,嵌入式开发板请求传输 ubuntu 下文件到板卡上
3.开发环境
ubuntu20.04 + 嵌入式开发板
4.实现步骤
4.1 搭建ubuntu服务器
4.1.1 安装服务器软件
            
            
              bash
              
              
            
          
          sudo apt-get install tftp-hpa tftpd-hpa  
sudo apt-get install xinetd  
        4.1.2 创建传输路径
            
            
              bash
              
              
            
          
          mkdir tftp  
chmod 777 tftp  # 实测权限771可以,根据实际情况配置
        4.1.3 添加配置文件 tftp
创建配置文件:/etc/xinetd.d/tftp,指定路径:/home/xxx/
            
            
              bash
              
              
            
          
          sudo vi /etc/xinetd.d/tftp
        
            
            
              bash
              
              
            
          
          server tftp  
{  
    socket_type = dgram  
    protocol = udp  
    wait = yes  
    user = root  
    server = /usr/sbin/in.tftpd  
    server_args = -s /home/xxx/  
    disable = no  
    per_source = 11  
    cps = 100 2
    flags = IPv4  
} 
        4.1.4 修改配置文件 tftpd-hpa
修改配置文件 /etc/default/tftpd-hpa
            
            
              bash
              
              
            
          
          # /etc/default/tftpd-hpa  
TFTP_USERNAME="tftp"  
TFTP_DIRECTORY="/home/xxx/"     # 这里是你的tftpd-hpa的服务目录  
TFTP_ADDRESS="0.0.0.0:69"  
TFTP_OPTIONS="-l -c -s" # -c是可以上传文件的参数,-s是指定tftpd-hpa服务目录
        4.1.5 重启服务器
            
            
              bash
              
              
            
          
          sudo service tftpd-hpa restart
        4.1.6 自检测试
拷贝文件 test.txt 到目录 /home/xxx/
            
            
              bash
              
              
            
          
          tftp 127.0.0.1    
tftp>get test.txt  
tftp>put test1.txt  
tftp>q 
        5. 参考链接
https:/4/blog.csdn.net/oxiaoxue12356789/article/details/81558959