Overview
Lingua Franca's C-runtime supports the Zephyr RTOS. This enables developing and
programming hundreds
of resource-constrained microcontrollers. In this guide we will see how LF
programs can be built, programmed and debugged both in emulation and on real
hardware. When developing LF programs for Zephyr we use a west
-centric
approach. Using west
, which is the preferred build tool for Zephyr projects,
requires structuring the code base and development flow as expected by west
.
We use a T3 Forest
Topology
for our workspace. This means that we create a workspace where multiple
different LF Zephyr projects can be hosted together with a single copy of the
Zephyr RTOS sources.
Prerequisites​
- Linux or macOS development system. (The guide is written for Linux)
- nrf52 Development Kit (optional)
Getting started
The first step is to set up a proper Zephyr development environment. Follow the steps in the Install dependencies and Install Zephyr SDK sections of the official Zephyr Getting Started Guide. Do not perform the steps under Get Zephyr and install Python dependencies. These steps will be performed inside the LF Zephyr workspace we are going to create next.
Setting up the LF Zephyr workspace​
- Clone the template repository into a workspace directory of Zephyr projects
git clone https://github.com/lf-lang/lf-west-template lf-zephyr-workspace && cd lf-zephyr-workspace
- Setup and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
- Install
west
pip3 install west
Now west
is installed within a virtual environment. This environment has to
be activated every time you want to use west with LF
- Get the Zephyr source code
west update
- Export CMake packages for Zephyr
west zephyr-export
- Install Python dependencies
pip install -r deps/zephyr/scripts/requirements.txt
Workspace organization​
Now you should have the following installed:
-west
; Verify with west boards
- Zephyr SDK located at
/opt/zephyr-sdk-VERSION
- Zephyr RTOS pulled down to
deps/zephyr
- A few example applications under
apps/
This workspace is meant to house all of your different LF Zephyr apps, as long as they are using the same version of Zephyr. Each app has to contain the following:
<app>
├── app.overlay
├── prj.conf
├── Kconfig
└── src
└── MyApplication.lf
Our custom west-extension will invoke lfc
and create a src-gen
directory
structured as a Zephyr
application.
This generated project can then be built, emulated or flashed by west
.