Skip to content

Project example that uses the elastic-ai.runtime.enV5 as a dependency

Notifications You must be signed in to change notification settings

es-ude/enV5-base-project

Repository files navigation

enV5 Base Project

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.

Setup

For compiling the project, the required tools are:

Prerequisites
  • gcc (local C compiler)

  • arm-non-eabi-gcc (C compiler for RP2040)

  • CMake (Build Script Generator)

  • Ninja (Build Tool)

Local Setup
  1. Install all required tools (see Prerequisites)

  2. Clone the repo to your local machine

  3. 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:

  • WiFi Name: -D WIFI_SSID:STRING=<ssid>

  • WiFi Password: -D WIFI_PWD:STRING=<password>

  • MQTT Host/IP: -D MQTT_HOST:STRING=<host>

  • MQTT Port: -D MQTT_PORT:STRING=<port>

  • MQTT Broker User: -D MQTT_USER:STRING=<user>

  • MQTT Password for User: -D MQTT_PWD:STRING=<password>

CMake

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.

Profiles
# 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).

Target: Local Machine

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.

Unit Tests

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.

Target Pico

Build all Targets

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.

Hardware Tests

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.

Flashing the Elastic Node version 5 (enV5)

  1. Press and hold MCU BOOT on the Elastic Node

  2. Press MCU RST on the Elastic Node

  3. Release MCU BOOT

  4. Copy the *.uf2 File to the RPI-RP2 device

CMD line output

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)
  1. -b 115200 → baud rate for connection

  2. -o → disable modem initialisation

  3. -D /dev/ttyACM0 → serial port

The serial port differs depending on the host machine! It can be found via ls /dev/tty* (Linux) or ls /dev/tty.* (macOS) from the terminal.

Debug Output

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 specific settings

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.

Project structure

This project contains various folders:

Folder Description

build

contains all CMake generated build scripts

out

contains all executables (*.uf2 binary files) for the enV5

src

contains Main.c, helpers and your own source code

test/hardware/

contains your own hardware tests

test/unit

contains your own unit tests

Further Reading

About

Project example that uses the elastic-ai.runtime.enV5 as a dependency

Resources

Stars

Watchers

Forks

Releases

No releases published