LekaOS repository is made to be easy to use:
- simple directory structure
- compile with CMake (based on USCRPL/mbed-cmake)
- code completion with VSCode + CMake Tools + clangd/vscode-clangd
- format with
.clang-format
and.editorconfig
Before starting, make sure you've read the mbed documentation.
We'll guide you in the process, just follow the steps.
To get up and running, you need a few tools installed on your system.
First install the Command Line Tools and brew: https://brew.sh/
# install CLT
xcode-select --install
# install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install the tools:
# first install GNU core utilities
brew install coreutils
# 💡 don’t forget to add `$(brew --prefix coreutils)/libexec/gnubin` to your `$PATH`
# then the prerequisites
brew install git curl python3
# and finally the needed tools
brew install make cmake ninja lcov gcovr stlink ccache open-ocd clang-format
To start with:
# Clone the repository
git clone https://github.com/leka/LekaOS && cd LekaOS
# Pull dependencies: mbed-os & mcuboot
make pull_deps
I recommend the manual install. Make sure to follow the instructions from mbed:
https://os.mbed.com/docs/mbed-os/v6.15/build-tools/install-and-set-up.html
python3 -m pip install -U --user -r ./requirements.txt --break-system-packages
python3 -m pip install -U --user -r ./tools/config/mbed_requirements.txt --break-system-packages
brew tap brew tap osx-cross/arm
brew install arm-gcc-bin
We put together an handy Makefile
to make it easier to configure and compile your projects.
# first configure the project
make config
# you can also specify a build type (default is Release)
make config BUILD_TYPE=Debug
# the build os, spikes
make
Make sure you have OpenOCD installed.
make flash BIN_PATH=_build/path/to/binary_file.bin
# first configure unit tests
make config_unit_tests
# build and run them
make ut
# if you want to see coverage
make utc
The firmware of the robot is located in ./app/os
& ./app/bootloader
.
firmware = bootloader + os
Sometimes, you might need to create a simple, very basic example project to test a new features, investigate a bug or try a different solution to a problem.
These can be added to the spikes
directory inside their own directory. You'll need at leat a main.cpp
and a CMakeLists.txt
. See mbed_blinky
for a working example.
We use VSCode and a handful of plugins to work on LekaOS:
- Better C++ Syntax
- Better Comments
- Clang-Format
- clangd
- CMake
- CMake Tools
- Cortex-Debug
- EditorConfig for VSCode
It is highly recommended to install them for a better experience and to make sure you comply with our coding style.
Settings for those plugins are shared in the repos as template files.
To create a local copy of the settings and configure the differents plugins and tools, you must run the following:
cp .vscode/settings.template.json .vscode/settings.json
Then, to configure autocompletion and code checking using clangd
:
- run
make config_tools
in your terminal - in VSCode, run
CMake: Configure
from theCommand Palette
(withCmd ⌘ + Shift ⇧ + P
)
💡 Apple Silicon - If you're working on an Apple Silicon computer, you'll need to edit the clangd
settings in your local copy of .vscode/settings.json
and comment/uncomment the --query-driver=/path/to/arm-none-eadi-*
lines.