Networking with QEMU Ethernet¶
This page describes how to set up a virtual network between a (Linux) host and a Zephyr application running in QEMU.
In this example, the Echo server (advanced) sample application from the Zephyr source distribution is run in QEMU. The Zephyr instance is connected to a Linux host using a tuntap device which is modeled in Linux as an Ethernet network interface.
On the Linux Host, fetch the Zephyr
net-tools project, which is located
in a separate Git repository:
git clone https://github.com/zephyrproject-rtos/net-tools
For the steps below, you will need two terminal windows:
Terminal #1 is terminal window with net-tools being the current directory (
Terminal #2 is your usual Zephyr development terminal, with the Zephyr environment initialized.
When configuring the Zephyr instance, you must select the correct Ethernet driver for QEMU connectivity:
Intel(R) PRO/1000 Gigabit Ethernet driverEthernet driver. Driver is called
e1000in Zephyr source tree.
TI Stellaris MCU family ethernet driverEthernet driver. Driver is called
stellarisin Zephyr source tree.
SMSC911x/9220 Ethernet driverEthernet driver. Driver is called
smsc911xin Zephyr source tree.
Intel(R) PRO/1000 Gigabit Ethernet driverEthernet driver is selected by default.
Before starting QEMU with network connectivity, a network interface should be created in the host system.
In terminal #1, type:
You can tweak the behavior of the
net-setup.sh script. See various options
net-setup.sh like this:
Build and start the Echo server (advanced) sample application. In this example, the qemu_x86 board is used.
In terminal #2, type:
west build -b qemu_x86 samples/net/sockets/echo_server -- -DEXTRA_CONF_FILE=overlay-e1000.conf west build -t run
Exit QEMU by pressing CTRL+A x.