zephyr/samples/net/tftp_client
Robert Lubos 1ee4a8b52c samples: net: tftp-client: Configs cleanup
As native_posix is no longer supported, due to incompatibility with
CONFIG_POSIX_API, remove a dedicated config for it.
A config for qemu_cortex_m3 needed to enable RNG, as otherwise it's not
available for the platform and gives build error.
Finally,  enable qemu_cortex_m3 build in the CI.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-21 11:51:27 +01:00
..
boards samples: net: tftp-client: Configs cleanup 2024-05-21 11:51:27 +01:00
src samples: net: Change to use CONFIG_POSIX_API 2024-03-27 13:40:13 -05:00
CMakeLists.txt sample: net: add tftp client sample 2023-08-23 10:05:19 +02:00
Kconfig sample: net: add tftp client sample 2023-08-23 10:05:19 +02:00
prj.conf samples: net: Change to use CONFIG_POSIX_API 2024-03-27 13:40:13 -05:00
README.rst docs: Networking with native_posix: Rename 2023-11-15 10:03:17 +01:00
sample.yaml samples: net: tftp-client: Configs cleanup 2024-05-21 11:51:27 +01:00

.. zephyr:code-sample:: tftp-client
   :name: TFTP client
   :relevant-api: tftp_client

   Use the TFTP client library to get/put files from/to a TFTP server.

Overview
********

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:
:zephyr_file:`samples/net/tftp_client`.

Requirements
************

- :ref:`networking_with_eth_qemu`, :ref:`networking_with_qemu` or :ref:`networking_with_native_sim`
- Linux machine

Building and Running
********************

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

- :file:`prj.conf`
  This is the standard default config.

Build the tftp-client sample application like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/tftp_client
   :board: <board to use>
   :conf: <config file to use>
   :goals: build
   :compact:

The easiest way to setup this sample application is to build and run it
as a native_sim application or as a QEMU target using the default configuration :file:`prj.conf`.
This requires a small amount of setup described in :ref:`networking_with_eth_qemu`, :ref:`networking_with_qemu` and :ref:`networking_with_native_sim`.

Build the tftp-client sample application for :ref:`native_sim <native_sim>` like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/tftp_client
   :host-os: unix
   :board: native_sim
   :goals: run
   :compact:

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 192.0.2.2 and default port is 69.
To specify an IP server address and/or port, change configurations in ``prj.conf``::

    CONFIG_TFTP_APP_SERVER="10.0.0.10"
    CONFIG_TFTP_APP_PORT="70"

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

    CONFIG_DNS_RESOLVER=y
    CONFIG_TFTP_APP_SERVER="my-tftp-server.org"

Sample output
==================================

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

   net-setup.sh

.. code-block:: console

    <inf> net_config: Initializing network
    <inf> net_config: IPv4 address: 192.0.2.1
    <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