Home » Development and Build » Development Environment Setup » How to setup and use tftp client on Ubuntu ?

How to setup and use tftp client on Ubuntu ?

[addthis tool="addthis_inline_share_toolbox"]

Following is the procedure which will guide you for setting up the Linux PC as a tftp client. We are using Ubuntu as tftp client to demonestrate tftp client usecase, normally Ubuntu is used as tftp server and your embedded target is used as tftp client, so same below commands will also work on embedded target tftp client.

Setting up TFTP server ( This commands are also mentioned in our another post “How to setup tftp server on Ubuntu ?”

  sudo apt-get install tftpd-hpa 
 sudo apt-get install tftp 
 sudo service tftpd-hpa start 

Above steps will install tftp server, creates directory /srv/tftp on Ubuntu 20.04 and start the tftp server, which you can check using below command,

$ ps -ax | grep tftp
  32850 ?        Ss     0:00 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure /srv/tftp

On other Ubuntu versions, you may see tftp server started with directory /var/lib/tftpboot

One we have setup, tftpserver now we will need to copy images which we want to flash on the target.

$ sudo cp -r FOLDER_WITH_FILES/*   /var/lib/tftpboot

Using TFTP Client

Once you have the TFTP server setup, for this example, we will assume the IP address of Ubuntu machine where you setup TFTP server is 192.168.0.100

Note: since below command download or upload from current working directory, make sure you “cd” to that respectivie directory where you want to download the files from tftp server or where your files which you want to upload to tftp server are present.

$ cd YOUR_WORKSPACE_DIRECTORY

Connect to TFTP server using below command,

$ tftp YOUR_TFTP_SERVER_IP

for example, $ tftp 192.168.0.100 will connect your tftp client to your tftp server.

Once you connected to tftp server, you will get a tftp prompt as,

tftp>

You can press question make to check the supported commands,

tftp> ?
Commands may be abbreviated.  Commands are:

connect 	connect to remote tftp
mode    	set file transfer mode
put     	send file
get     	receive file
quit    	exit tftp
verbose 	toggle verbose mode
trace   	toggle packet tracing
status  	show current status
binary  	set mode to octet
ascii   	set mode to netascii
rexmt   	set per-packet retransmission timeout
timeout 	set total retransmission timeout
?       	print help information

Now, we must know in advance what are the filenames of the files exists in tftp server, which you want to download . So, suppose we want to download helloworld.txt file from tftp server, then we can use get command as,

Set the verbose mode ON for our understanding by typing “verbose” command on tftp console.

tftp> verbose
Verbose mode on.

Now, use “get” command to download “helloworld.txt”

tftp> get helloworld.txt
getting from 192.168.0.100:helloworld.txt to helloworld.txt [netascii]
Received 25700 bytes in 0.1 seconds [2056000 bits/sec]

Leave a Comment