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 Socket Echo Server 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
- 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.
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 Socket Echo Server sample application. In this example, the qemu_x86 board is used.
In terminal #2, type:
west build -t run
Using CMake and ninja:
cmake -B build -GNinja -DBOARD=qemu_x86 -DOVERLAY_CONFIG=overlay-e1000.conf samples/net/sockets/echo_server ninja -C build run