This is a west-centric project template for Lingua Franca applications targeting the Zephyr RTOS using the micro-c (uc) target of Lingua Franca.
- Linux or macOS operating system
- reactor-uc cloned to your system and
REACTOR_UC_PATH
environment variable pointing to it.
Press Use template
in the upper right corner and choose Create a new repository
. Then clone this new repository to your machine.
To start developing in your new repo, you must first install the Zephyr dependencies, toolchains and SDK.
This requires you to follow selected parts of the Zephyr official Getting Started guide.
-
Install the dependencies used by Zephyr by following the steps in Install Dependencies
-
Then install the Zephyr toolchains and SDK by following the steps in Install the Zephyr SDK
Within your newly cloned project, create and activate a virtual environment for this project.
python3 -m venv ./venv
source ./venv/bin/activate
IMPORTANT: Remember to always activate the virtual environment before using the template.
Install the west, the Zephyr build tool
pip install west
Pull down the Zephyr RTOS sources using west (this can take a while)
west update
Install Python dependencies
pip install -r deps/zephyr/scripts/requirements.txt
Export a CMake package
west zephyr-export
To build and emulate the provided HelloWorld.lf using the native_posix
target, do:
west build -t run
To build for a different board, e.g. the qemu_cortex_m3
emulation. Either change the BOARD
variable in CMakeLists.txt, or using west
:
west build -b qemu_cortex_m3 -p always -t run
Note the -p always
which is a west
option for cleaning the build directory. This must be used when changing the target board. Alternatively west clean
can be run in between.
The LF_MAIN
CMake variable decides which LF application to build. This can either be modified in CMakeLists.txt or from the command line. To build Blinky.lf for Adafruit Feather do:
west build -b adafruit_feather -p always -- -DLF_MAIN=Blinky
With west
, CMake arguments are separated from west
arguments with a --
.
The log level of the LF app can be changed by setting the variable LOG_LEVEL
in CMakeLists.txt or by modifying it on the command line:
west build -t run -p always -- -DLOG_LEVEL=LF_LOG_LEVEL_DEBUG
By passing -p always
to west
, the build
folder is cleaned and the project is reconfigured by CMake. However, this does not clean the files generated by lfc
. For this we provide a custom west command west clean
defined in clean.py which also cleans the files generated by LFC. Use it to do a complete reset.
west clean
To flash an application onto a board, simply use west flash
. This may require the installation of additional, vendor-specific tools. See the official docs for more information.
This template integrates the Lingua Franca compiler lfc
into a west
-based project. This requires that the user understands how to use west
and zephyr. Please refer to the official docs for more information.
Command 'west' not found, did you mean:
or
Traceback (most recent call last):
File "/home/erling/dev/lf-west-template/deps/zephyr/scripts/build/gen_kobject_list.py", line 62, in <module>
import elftools
ModuleNotFoundError: No module named 'elftools'
Activate the virtual environment where the Zephyr dependencies are installed.