This project includes a limited build environment to build projects for embedded baremetal cross-platform targets, on macOS and Linux hosts.
It focuses on using:
- CMake to generate the build scripts/files, i.e. autoconf-free
- Ninja as the small build system, i.e. Make-free
- LLVM as the compiler infrastructure, i.e. no GCC, and restricted use of binutils:
- Newlib as the C library for embedded baremetal targets
- Python3 as the main language for tools,
- Dash as the POSIX shell interpreter.
- Docker community edition to run pre-build toolchain binaries
The environment is dedicated to demonstrate the use of clang/LLVM to build projects for baremetal targets such as ARM Cortex-M series.
Replacing the pervasive GNU GCC/Binutils toolchain with clang/LLVM is not always straightforward for non-mainstream targets - which are x86_64/ARM for Linux/macOS/iOS/Windows.
This repository shows that clang/LLVM can be used as a drop-in replacement of GNU tools even for small embedded baremetal targets.
It builds on top of the armeabi Homebrew repository, which has been used for over 3 years to build real products.
It also shows that GNU Make is not the only option to efficiently build embedded applications for small targets from the command line.
- ARMv7em Cortex-M4 (with or without FPU)
- ARMv6m Cortex-M0+
Adding other 32-bit Cortex-M cores would be quite straightforward.
host/
directory contains tools and configuration that run on the hostlibrary/
contains libraries and Python modules required by host tools- other top-level directories contain target specific projects, named after the actual target device.
Projects directories are managed as Git submodules.
The projects are organized as one top-level directory for each target type.
Applications are located within the app/
directory, which may also be
managed as Git submodules.
All tools should be started from the top-level directory
host/bin/build.sh
is the main script from which all projects are built, whatever the actual target. Neither CMake or Ninja are directly invoked from the command line,build.sh
acts as a wrapper to perform builds.host/bin/dockbuild.sh
is a wrapper script that invokebuild.sh
from a Dockerized environment. When a toolchain is not available on the host, this script should be used rather thanhost/bin/build.sh
. It takes care of downloading/installating the proper toolchain images required to build the project for the selected targets.host/bin/pyterm.py
is a small Python terminal client to retrieve, format and optionally logs debug traces from a remote target, using a serial line interface. It is recommended but not mandatory to installpyftdi
Python module to use with a USB-Serial FTDI adapter.
There are two ways to use Tiny Development Environment:
- Install all the required tools on the host, and use
host/bin/build.sh
to build projects. See the following sections for details - Install Docker
engine, and use
host/bin/dockbuild.sh
to build projects. This method is simpler and work on Linux and macOS.
Docker Engine Community Edition that matches your host environment.
-
Ensure the Docker engine is started, and runs with at least 2GB per core: either increase the memory available to docker, or decreases the count of available core, as some LLVM source files require a lot of memory to be built.
-
Define
DOCKERHUB_USER
as local:export DOCKERHUB_USER=local
-
Execute
host/bin/dockgen.sh
and grab a cup of coffee.
From Homebrew
/usr/bin/ruby -e \
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap eblot/armeabi
brew tap eblot/devtools
brew install cmake coreutils curl dash dos2unix doxygen gawk gettext git
brew install m4 makedepend mspdebug ninja openssl pkg-config python
brew install sqlite subversion wget xz
brew install arm-none-eabi-llvm arm-none-eabi-gdb arm-none-eabi-binutils
brew install armv6m-cortex-m0plus armv7em-cortex-m4 armv7em-cortex-m4f
brew install --HEAD openocd-nrf52
# be sure no brew tool get the priority to build native Python extensions
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
pip3 install six crcmod bpython sphinx pyusb pyserial gnureadline \
netifaces ruamel.yaml protobuf sphinx_rtd_theme tabulate \
sphinx_autodoc_typehints paramiko breathe
exit
From top-level directory, run
git submodules init
git submodules update
stm32l432 : ChibiOS-based projects for STM32L432 (Cortex-M4)
- This project contains a demo application: USB-CDC-ACM (USB-Serial) bridge
nrf52 : nRF52 OS-less SDK (Cortex-M4)
-
This project contains no application, only the nRF5 SDK w/ S132 and S140 SoftDevices.
-
bleadv is an application submodules for nRF52, it implements a BLE advertiser application demo.