Skip to content

Commit

Permalink
readme: update for zephyr net-tools and qemu user networking
Browse files Browse the repository at this point in the history
This will allow us to run most examples without tun / tap in macOS.

Fixes #59

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
  • Loading branch information
cfriedt committed Mar 22, 2022
1 parent 8a33833 commit a368a71
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 46 deletions.
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This repository contains a Zephyr module to support Thrift.
## Getting Started

Before getting started, make sure you have a proper Zephyr development
environment. You can follow the official
environment by following the official
[Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html).

### Installing Thrift Binary
Expand All @@ -19,38 +19,46 @@ Aside from the dependencies in the Zephyr Getting Started Guide above, you will

### Initialization

The first step is to initialize the workspace folder (``my-workspace``) where
The first step is to initialize the workspace folder (``~/my-workspace``) where
the ``thrift-for-zephyr`` and all Zephyr modules will be cloned. You can do
that by running:

```shell
export WS=~/my-workspace
# initialize my-workspace for thrift-for-zephyr (main branch)
west init -m https://github.com/cfriedt/thrift-for-zephyr --mr main my-workspace
west init -m https://github.com/cfriedt/thrift-for-zephyr --mr main ${WS}
# update Zephyr modules
cd my-workspace
cd ${WS}
west update
```

### One-time Setup

If this is the first time building the module, please set up your `~/.zephyrrc` file:
If this is the first time building Zephyr, please set up your `~/.zephyrrc` file:
```shell
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
# Will vary based on the installed SDK version
export ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk-0.13.1
```

### Create a Unix socket at /tmp/slip.sock
### Qemu Setup

When running Zephyr inside of Qemu, a UNIX domain socket is used as a virtual serial port.
Run this command in the background (with `&`). Later, the process can be stopped with
`fg` and `Ctrl+C`.
```shell
${WS}/net-tools/loop-socat.sh &
```

Additionally, Qemu user-mode networking is used, and we forward incoming TCP/IP traffic
on port 4242 to the Qemu instance.

Zephyr expects this socket to be open for Qemu to communicate over as an emulated serial interface. Since Zephyr [net-tools](https://docs.zephyrproject.org/latest/guides/networking/qemu_setup.html#prerequisites) only supports Linux currently, we provide a utility for this so that you can also test on MacOS. In a separate terminal run:
```./tools/create_serial_socket.py```

### Build & Run the Hello Test App
### Build & Run the Testsuite

Back in your main terminal, the application can be built by running:
Run the testsuite with:
```shell
cd my-workspace/thrift-for-zephyr
source ~/.zephyrrc
export ZEPHYR_BASE=${PWD}/../zephyr
cd ${WS}/thrift-for-zephyr
source zephyr-env.sh
west build -p auto -b qemu_x86_64 -t run tests/lib/thrift/hello
```
5 changes: 5 additions & 0 deletions tests/lib/thrift/hello/boards/qemu_x86_64.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_NET_QEMU_USER=y
CONFIG_NET_QEMU_USER_EXTRA_ARGS="net=192.168.0.0/24,hostfwd=tcp::4242-:4242"
CONFIG_PCIE=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_ETH_E1000=y
33 changes: 0 additions & 33 deletions tools/create_serial_socket.py

This file was deleted.

3 changes: 3 additions & 0 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ manifest:
remote: cfriedt
path: thrift-for-zephyr/.upstream
revision: 9ae087df932c65f8de9e0fc2d12b828b8306b234
- name: net-tools
remote: zephyrproject-rtos
revision: master
- name: zephyr
remote: zephyrproject-rtos
revision: main
Expand Down
12 changes: 12 additions & 0 deletions zephyr-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if [ ! -f ${PWD}/zephyr-env.sh ]; then
echo "Please source this script from the 'thrift-for-zephyr' directory"
fi

if [ -f ~/.zephyrrc ]; then
. ~/.zephyrrc;
fi

export ZEPHYR_BASE="$(cd "${PWD}"/../zephyr; pwd)"
if ! echo "${PATH}" | grep -q "scripts"; then
export PATH=${ZEPHYR_BASE}/scripts:${PATH}
fi

0 comments on commit a368a71

Please sign in to comment.