This repository aims to provide a clean start for projects concerning the Elastic-AI Node Version 5 (enV5) hardware platform. It includes the hardware support libraries from the elastic-ai.runtime.enV5 repository as well as other required dependencies like the pico-sdk or Unity.
For compiling the project, the required tools are:
-
gcc (local C compiler)
-
arm-non-eabi-gcc (C compiler for RP2040)
-
CMake (Build Script Generator)
-
Ninja (Build Tool)
-
Install all required tools (see Prerequisites)
-
Clone the repo to your local machine
-
Open the project in your preferred C/C++ IDE
ℹ️
|
If you use the CLion IDE as recommended, the build script generation is done by the IDE itself. If you want to do this by yourself, please refer to CMake. |
❗
|
You have to adjust the network/mqtt broker credentials as mentioned in the network README! Alternatively, you can pass these settings via CMake Flags to the Profile initialization:
|
There are three CMake Profiles provided with the CLion settings: Debug, Release, and UnitTests.
Only the UnitTests profile allows you to compile source code for your local machine and therefore run the unit tests. The Debug and Release targets differ only in the amount of printed information when the software is executed on an enV5-device.
# Unit-test profile
cmake -B build/unit-test -G Ninja -D CMAKE_BUILD_TYPE=DEBUG -D UNIT_TEST:BOOL=ON -D DEBUG_MODE:BOOL=ON
# Debug profile
cmake -B build/debug -G Ninja -D CMAKE_BUILD_TYPE=DEBUG -D UNIT_TEST:BOOL=OFF -D DEBUG_MODE:BOOL=ON
# Release profile
cmake -B build/release -G Ninja -D CMAKE_BUILD_TYPE=RELEASE -D UNIT_TEST:BOOL=OFF -D DEBUG_MODE:BOOL=OFF
The flag -G Ninja
tells CMake to use Ninja as the build tool.
If this flag is not passed, CMake will use the default build tool on your machine (mostly Makefiles).
The local execution of the source code requires a different hal implementation, due to the fact that the hal implementation from the src
folder is directly connected to the pico-sdk which forces the compiler to build for the RP2040 arm-based platform instead of your local machine.
The enV5 repository provides the hal dummies for the local machine.
The unit-tests can be build and executed by running:
# build the unit-tests
cmake --build build/unit-test -j 4 --clean-first
# execute the unit-tests
ctest --test-dir build/unit-test/test/unit --output-on-failure
The built unit-tests can then be found under build/unit-tests/test/unit as executables.
The debug targets can be built by executing:
cmake --build build/debug -j 4
The release targets can be built by executing:
cmake --build build/release -j 4
The *.uf2
files to flash the pico can than be found under the
out folder.
The hardware tests can be build using
cmake --build build/debug -j 4 --target <test_name>
replacing <test_name>
with the name of the test.
The resulting <test_name>.u2f
files to flash the pico can be found under the out folder.
-
Press and hold
MCU BOOT
on the Elastic Node -
Press
MCU RST
on the Elastic Node -
Release
MCU BOOT
-
Copy the
*.uf2
File to the RPI-RP2 device
If the pico is connected to the local machine the printf()
statements inside the code will be redirected to the USB and are available as serial port output.
This output can be read via a serial port reader like screen, minicom or putty.
The following example shows how to use minicom on a Unix-based system:
minicom \
-b 115200 \ #(1)
-o \ #(2)
-D /dev/ttyACM0 #(3)
-
-b 115200
→ baud rate for connection -
-o
→ disable modem initialisation -
-D /dev/ttyACM0
→ serial port
❗
|
The serial port differs depending on the host machine!
It can be found via |
To enable enhanced Debug output, add the flag -D DEBUG_OUTPUT:BOOL=ON
to the CMake Setup call (or add it in the CLion CMake options).
This enables the PRINT_DEBUG(…)
from the common_lib of the enV5 repository in all targets.
Clion automatically detects targets and adds them to the configurations in the upper right corner. These can be built via one of the profiles. There are three profiles in total:
-
Debug
: build targets for the RP2040 with debug logs -
Release
: build targets for the RP2040 without debug logs -
Unit Test
: regular unit test executables
Switching the profiles also “fixes” include paths, so if you have a unit test open, Clion will not recognize the inclusion of the unity.h file, as it is only included under the Unit Test
profile.
This project contains various folders:
Folder | Description |
---|---|
contains all CMake generated build scripts |
|
contains all executables ( |
|
contains Main.c, helpers and your own source code |
|
contains your own hardware tests |
|
contains your own unit tests |