This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

TFTP client


Trivial File Transfer Protocol (TFTP) is a simple lockstep File Transfer Protocol based on UDP, and is designed to get a file from or put a file onto a remote host.

This TFTP client sample application for Zephyr implements the TFTP client library and establishes a connection to a TFTP server on standard port 69.

The source code for this sample application can be found at: samples/net/tftp_client.


Building and Running

There are configuration files for various setups in the samples/net/tftp_client directory:

  • prj.conf This is the standard default config.

Build the tftp-client sample application like this:

west build -b <board to use> samples/net/tftp_client -- -DCONF_FILE=<config file to use>

The easiest way to setup this sample application is to build and run it as native POSIX application or as a QEMU target using the default configuration prj.conf. This requires a small amount of setup described in Networking with QEMU Ethernet, Networking with QEMU and Networking with native_posix board.

Build the tftp-client sample application for native_posix like this:

west build -b native_posix samples/net/tftp_client
west build -t run

Download and run a TFTP server (like TFTPd), then create file1.bin (with data) and newfile.bin.

Please note that default IP server address is and default port is 69. To specify an IP server address and/or port, change configurations in prj.conf:


To connect to server using hostname, enable DNS resolver by changing these two configurations in prj.conf:


Sample output

Sample run on native_posix platform with TFTP server on host machine Launch in net-tools .. code-block:: console

<inf> net_config: Initializing network
<inf> net_config: IPv4 address:
<inf> net_tftp_client_app: Run TFTP client
<inf> net_tftp_client_app: Received data:
        74 65 73 74 74 66 74 70  66 6f 72 7a 65 70 68 79 |testtftp forzephy
        72 0a                                            |r.
<inf> net_tftp_client_app: TFTP client get done
<inf> net_tftp_client_app: TFTP client put done