嵌入式系統中,常常在更新韌體或是作業系統時,都需要利用TFTP主機來上傳或下載

The below steps will allow you to set up a TFTP server on Linux but specifically on a CentOS server. All you need to do is install a couple files with yum, enable the server, and restart xinetd.

  1. Install TFTP Server: Use the below syntax to install the TFTP server on CentOS.
  2. 1 [root@centos-server ~]#yum install tftp-server
     
  3. Install Xinetd: The TFTP server will run via xinetd so you need to make sure xinetd is installed using the bellow command.
  4. 1 [root@centos-server ~]#yum install xinetd
    <附註1> 
     
  5. setting up:

         vi /etc/xinetd.d/tftp

         Find disable = yes, make it no
         And you can set the tftp path in this file!

   4.   Enable TFTP and Xinetd: Use chkconfig to ensure that xinetd and tftp starts on reboot. 

1 [root@centos-server ~]#chkconfig tftp on

2 [root@centos-server ~]#chkconfig xinetd on
 
   5.   Modify TFTPBOOT Permissions: Use the below syntax to modify the permissions of the /tftpboot directory to allow tftp transfers to and from this directory. The /tftpboot directory is the default directory where files are transfered to and from using TFTP.
 
1 [root@centos-server ~]#chmod 777 /tftpboot
 

    6.   Example TFTP Command: The below is an example of use of the TFTP command.

[root@centos-server ~]#tftp -v 192.168.1.100 -c put file-example.txt

or

    [root@centos-server ~]#tftp

TFTP Server MultiThreaded Version 1.62 Unix Built 1621

starting TFTP...
username: root
alias / is mapped to /home/
permitted clients: all
server port range: all
max blksize: 65464
default blksize: 512
default timeout: 3
file read allowed: Yes
file create allowed: No
file overwrite allowed: No
thread pool size: 1
listening on: 0.0.0.0:69

Accepting requests..

7.   now tftp server is ready and standby.

============================================================================

 附註1: 

Inetd Super Server

˙ standalone:由常駐在記憶體內的 daemon 直接監聽某特定 port 的連線需求,平時無論有無須求處理,都會佔用一定的系統資源。
˙ inetd:由 inetd 這個 super daemon 代為幫一些服務程式監聽其相關 port 的連線請求 ; 平時若無需求進來時,只有 inetd 本身會佔用系統資源,而其他靠 inetd 所呼叫的服務程式當然就呈現休息狀態。

inetd 的相關檔案

/etc/services
將系統所提供的服務名稱及其相對應的 port 列出

/etc/xinetd.conf
這個檔案是定義所有經由 inetd 來提供服務的相關設定


xinetd 相關檔案修改完後,請使用以下任何一種方式來重新執行 inetd:

# service xinetd restart
# /etc/rc.d/init.d/xinetd restart

====================================================================

在ARM 板子上的TFTP client操作如下: 

[說明]下面是busybox裡面的解釋:

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

Transfer a file from/to tftp server using "octet" mode

Options:
        -l FILE Local FILE
        -r FILE Remote FILE
        -g      Get file
        -p      Put file
        -b SIZE Transfer blocks of SIZE octets

 

[實作]

進入可讀寫的 tmp 目錄,

cd /tmp

執行

/tmp # tftp -g -r abc.txt  172.17.x.x

(註:要被傳送的檔案 abc.txt 要放在 Server端的 /home目錄之下)

如此 ARM 板上就可以收到 abc.txt 文件了!

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 rodney2009 的頭像
    rodney2009

    羅德尼IT

    rodney2009 發表在 痞客邦 留言(0) 人氣()