Skip to content

Building and Flashing

This guide will guide you through the steps needed to get the tests and firmware compiled. The prerequisites for the development environment are:

  • PlatformIO compatible IDE (VSCode is recommended) with the PlatformIO plugin installed

  • Modern version of Python 3.x

  • Modern version of CMake and an C/C++ compiler (favoriably MSVC (under Windows) or GCC (Linux and Mac OS))

  • Preferably a VT100 compatible terminal emulator (Putty is recommended)

  • Local copy of this git repository (git clone)

Install an c/c++ compiler

This is needed for compiling the unit-tests and configuring some parts of the build-system.

Installation

Step 1: Download the VS Buildtools installer and launch the installer.

Step 2: Accept the EULA and continue: VS build tools installer UELA screen

If done correctly this screen should show up.. Wait for the download to finish :) VS build tools download screen

Step 3: Select the following options and click on the install button: VS build tools installation options

C++ Clang tools for Windows

Clang has tools for static code analysis and code formatting (besides being an compiler frontend (llvm)).

Which might be very useful when trying to write consistent code following code rules.

Step 4: Wait for the installation to finish :w

Done, your setup is now ready :)

The fastest way to install the compiler and required tools in linux is by using the terminal.

Step 1: Open a terminal and enter:

sudo apt-get install gcc cmake

Done, your setup is now ready :)

The fastest way to install the compiler and required tools in linux is by using the terminal.

Step 1: Open a terminal and enter:

sudo pacman -S gcc cmake

In Mac os the same principle applies as would to linux. The fastest way is using HomeBrew in the terminal.

Step 1:

brew install gcc cmake

Done, your setup is now ready :)

Setup VSCode

This section is dedicated to describing the steps needed to setup the VSCode editor to support our development environment. The following plugins will have to be installed:

  • C/C++

  • CMake

  • CMake Tools

  • PlatformIO IDE

Step 1: Open VS Code and head to the extensions tab (4th icon in the left sidebar).

Extensions tab in VS Code

Step 2: Search and install the following plugins:

Plugin C/C++

Search for the plugin in the search bar: C/C++ from publisher: ms-vscode or Microsoft. Click on install... C/C++ Plugin

Plugins CMake and CMake Tools

Search for the plugin in the search bar: CMake. Install the plugins CMake and CMake Tools from publisher: twxs and Microsoft. And Click on install...

CMake plugins

Plugin PlatformIO IDE

Search for the plugin in the search bar: PlatformIO IDE from publisher: PlatformIO. Click on install... PlatformIO plugin

Congratulations🎉 VS code is now set-up!

Building Projects (SensorHub_FW and ActuatorHub_FW)

Step 1: Open the SensorHub_FW or ActuatorHub_FW project folder in vs code

Open VS code and select File->Open Folder. Open folder

Open the SensorHub_FW or ActuatorHub_FW folder. SensorHub_FW folder Inside SensorHub_FW folder

Step 2: Configure CMake

VS code will ask automatically to configure the project using CMake. Configure project with CMake

Select the right compiler from the list: Select kit When asked to always configure projects upon opening. Select No!

Step 3: Build the project using PlatformIO

Select the build icon in the bottom left toolbar in VS code. Build After some time passes you will get this output...

Build Success

Congratulations🎉 You succesfully built the mcu binary

Formatter and unit-tests

Advanced features like the auto-formatter and unit tests are very useful and help keeping code quality consistent.

How to use the auto-formatter

Step 1: Press CTRL+SHIFT+P and type "format document" auto-formatter

This uses the rules defined in the .clang-format file

How to use the unit testing features in vs code

toolbar

Note

The red icon is the flash icon, when a board is connected via micro-usb the mcu binary will be flashed to the MCU.

The purple icon is the clean icon, when pressed all build files will be deleted.

The green icon is the build icon for the unit tests, when pressed the unit-tests will be build using CMake.

The orange icon is the CTest icon, when pressed the unit tests will be run.

Step 1: Click on the Build icon for the unit tests (Gear icon with the text "Build").

Step 2: Click on the Run CTest button.