Install and configure the TFTP service in Ubuntu

Source: Internet
Author: User

In embedded development, we often need to configure some network services in advance so that the Development Board can easily download or mount the kernel and file system of the host. After bootloader is started, the system downloads the Linux kernel image to run in memory through TFTP, starts the target file system on the Linux host through NFS, and assigns an IP address to the Development Board through the DHCP server. This is just to build a server environment. There are usually many problems when configuring the TFTP service. After several failed attempts, the following experiences are summarized to share:

 

1. Check whether TFTP has been installed

Caoyi @ Ubuntu:/home/study $ sudo netstat-nulg | grep 69
UDP 0 0 0.0.0.0: 69 0.0.0.0 :*

Or

Caoyi @ Ubuntu:/home/study $ sudo netstat-au | grep TFTP
UDP 0 0 *: TFTP *:*

It indicates that the installation is successful. If the above information is not displayed or if the row information is correct, it indicates that there is an error!

1. Check whether the related services are installed (generally none)

First, make sure that your host or virtual machine is connected to the Internet and that the download process is reliable.

(1) install TFTP (client) and tftpd (server)

Caoyi @ Ubuntu:/home/study $ sudo apt-Get install tftpd TFTP

 

(2) install tftpd-HPA and TFTP-HPA (TFTP server with enhanced functions)

Caoyi @ Ubuntu:/home/study $ sudo apt-Get install tftpd-hpa tftp-HPA

 

(3) install OpenBSD-inetd xinetd (Network Management Service. In ubuntu, TFTP cannot run independently and must be supported by the network management server .)

Caoyi @ Ubuntu:/home/study $ sudo apt-Get install xinetd OpenBSD-inetd

Ii. Configure the TFTP Server

(1) Configure tftpd-HPA (server)

Caoyi @ Ubuntu:/home/study $ sudo Vim/etc/default/tftpd-HPA

1 #/etc/default/tftpd-HPA

2 run_daemon = "yes"

3 tftp_username = "TFTP"

4 tftp_directory = "/tftpboot" here is the TFTP Server Directory

5 tftp_address = "0.0.0.0: 69"

6 tftp_options = "-l-S/tftpboot"

(2) Configure inetd
Caoyi @ Ubuntu:/home/study $ sudo Vim/etc/inetd. conf

TFTP dgram udp wait nobody/usr/sbin/tcpd/usr/sbin/in. tftpd/tftpboot (added at the end)

(3) create a configuration file
Create a configuration file TFTP under/etc/xinetd. d/

Sudo Vim TFTP

Enter the following content in the file:
Service tftp
{

Socket_type = dgram
Protocol = UDP

Wait = Yes

User = root

Server =/usr/sbin/in. tftpd

Server_args =-S/tftpboot

Disable = No

Per_source = 11

CPIs = 100 2

Flags = IPv4
}
Save and exit

 

(4) Restart TFTP services

 

Caoyi @ Ubuntu:/home/study $ sudo/etc/init. d/OpenBSD-inetd reload

* Reloading Internet Superserver inetd [OK]

Caoyi @ Ubuntu:/home/study $ sudo/etc/init. d/OpenBSD-inetd restart
* Restarting Internet Superserver inetd [OK]

Caoyi @ Ubuntu:/home/study $ sudo service tftpd-HPA restart (if there is no response, reinstall sudo apt-Get install tftpd-hPa)

Tftpd-HPA start/running

Caoyi @ Ubuntu:/home/study $ sudo/etc/init. d/xinetd restart
* Stopping Internet Superserver xinetd [OK]
* Starting Internet Superserver xinetd [OK]

Iii. Test

(1) Create the TFTP server directory under the local root directory.

Caoyi @ Ubuntu:/home/study $ CD/

Caoyi @ Ubuntu:/home/study $ sudo mkdir tftpboot

Then, place some test files. Here I put the uimage and the empty file a. c.

Caoyi @ Ubuntu:/home/study $ SDO chmod 777-r tftpboot

Caoyi @ Ubuntu:/home/study $ ls/tftpboot

A. c uimage

(2) Go to the/home directory to download the uimage file under the/tftpboot/directory (the/tftpboot/directory is set as the default service directory of TFTP ):

Caoyi @ Ubuntu:/home/study $ sudo TFTP 127.0.0.1
TFTP> Get uimage
Received 1508808 bytes in 0.2 seconds
TFTP> quit
Caoyi @ Ubuntu:/home/study $ ls
Uimage
Then, upload files to the/tftpboot/directory.

Caoyi @ Ubuntu:/home/study $ sudo TFTP 127.0.0.1
TFTP> put B. C
Error Code 2: access violation

(Note: to upload a TFTP file, you must have a file of the same name to be uploaded in the/tftpboot/directory)

(3) In front of my/tftpboot/directory, there is an empty a. c file, so I can upload a file named A. C to it.
Caoyi @ Ubuntu:/home/study $ sudo TFTP 127.0.0.1
TFTP> put a. c
Sent 15 bytes in 0.0 seconds
TFTP> quit
Caoyi @ Ubuntu:/home/study $

(4) test on the Development Board. First, set the parameters for automatic download: Then boot

Fs2410 # boot
TFTP from server 192.168.7.112; our IP address is 192.168.7.239
Filename 'uimage '.
Load address: 0x30800000
Loading: ######################################## #########################
######################################
Done

 

Now, the TFTP service configuration in Linux is complete! In the meantime, some versions or other errors may also occur. You should repeat to confirm that you have installed all the services, and then continuously restart and test them!

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.