现在的位置: 首页 > 综合 > 正文

ubuntu11.10搭建tftp服务器以及在开发板上使用tftp

2018年03月16日 ⁄ 综合 ⁄ 共 2064字 ⁄ 字号 评论关闭

 

最近在将做的嵌入式项目移植到ARM开发板上,宿主机用的ubuntu11.10,目标机为mini2440的ARM开发板,使用arm-linux-gcc编译项目后,要将项目拷贝到目标机运行,使用可以使用U盘直接拷贝,也可以通过tftp服务。

一、ubuntu11.10搭建tftp服务器

 

  (1) $ sudo apt-get install tftpd tftp openbsd-inetd

       (2) $ sudo vi /etc/inetd.conf

       在这个配置文件里面找到下面的位置:

            #:BOOT: TFTP service is provided primarily for booting. Most sites

       # run this only on machines acting as "boot servers."

       #tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp

       #我把上面的默认的配置文件用井号注释掉了,自己配置了tftp的主工作目录为/tftp

       tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftp

       (3):wq 保存文件退出。

       (4)创建TFTP服务器的文件目录。

      $cd /  

           $sudo mkdir tftp

      $sudo chmod 777 /tftp

      如果有需要下载的文件这时可以拷贝进去,也用chmod 777命令把所有权限打开。

 

      (5)启动(或重启)xinetd服务

      $sudo /etc/init.d/openbsd-inetd restart

      (6)查看69端口是否有打开,使用下面命令

     netstat -an | more

     打印出的东西中找到如下即可:

     udp 0 0 0.0.0.0:69 0.0.0.0:*

        

       (7)在本机测试一下:

           a.在/tftp目下新建一个文件,并写入数据:

           yishugao@yishugao-PC:/tftp$ echo helloworld > zhang.txt

           yishugao@yishugao-PC:/tftp$ cat zhang.txt

           helloworld

          b. 到/home目录下

           yishugao@yishugao-PC:/home$ sudo tftp 221.204.110.99

           [sudo] password for yishugao:

           tftp> get zhang.txt

           Received 12 bytes in 0.0 seconds

           tftp> quit

           yishugao@yishugao-PC:/home$ cat zhang.txt

           helloworld

           yishugao@yishugao-PC:/home$

           行了,本地测试成功!

二、在开发板上使用tftp

      [root@FriendlyARM /zhang]# tftp

BusyBox v1.13.3 (2010-07-24 19:11:35 CST) multi-call binary

Usage: tftp [OPTION]... HOST [PORT]

Transfer a file from/to tftp server

Options:

        -l FILE Local FILE

        -r FILE Remote FILE

        -g      Get file

        -p      Put file

        -b SIZE Transfer blocks of SIZE octets

      [root@FriendlyARM /zhang]# tftp -l /zhang/main -r /tftp/main_arm_v4 -g 192.168.1.37

      注:表示将远程主机上的/tftp/main_arm_v4下载到本地主机/zhang/目录下,并改名为main文件。。。

             -l :localhost      -r :remote   -g:get     192.168.1.37是远程主机ip

             同理,如果要将本地文件上传到远程服务器,把 -g 该为 -p ,p为put的意思。。。

      [root@FriendlyARM /zhang]# ls

      main

      [root@FriendlyARM /zhang]# chmod 777 main

      [root@FriendlyARM /zhang]# ./main /dev/video0

      行了。。。。能运行。。。

 

抱歉!评论已关闭.