嵌入式系統中,常常在更新韌體或是作業系統時,都需要利用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.
- Install TFTP Server: Use the below syntax to install the TFTP server on CentOS.
- Install Xinetd: The TFTP server will run via xinetd so you need to make sure xinetd is installed using the bellow command.
- setting up:
1 |
[root@centos-server ~] #yum install tftp-server |
1 |
[root@centos-server ~] #yum install xinetd |
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 |
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 文件了!
留言列表