AI Inference on ARM Cortex-M4

Stavros Kalapothas
4 min readMay 10, 2020

Bringing AI to the Edge

The B-L475E-IOT01A is an IoT development board based on STM32L4 (ARM Cortex-M4) that includes a plethora of sensors and wireless connectivity options such as WiFi, Sub-GHz and BLE. It also supports expansion modules using the Arduino shield form-factor and via the single PMOD connector. Thus, it can be an ideal candidate for your next project covering many IoT use-case scenarios.

Here’s a list with the key features, below:

  • Ultra-low-power STM32L4 Series MCUs based on Arm® Cortex®-M4 core with 1 Mbyte of Flash memory and 128 Kbytes of SRAM, in LQFP100 package
  • 64-Mbit Quad-SPI (Macronix) Flash memory
  • Bluetooth® V4.1 module (SPBTLE-RF)
  • Sub-GHz (868 MHz or 915 MHz) low-power-programmable RF module (SPSGRF-868 or SPSGRF-915)
  • 802.11 b/g/n compliant Wi-Fi® module from Inventek Systems (ISM43362-M3G-L44)
  • Dynamic NFC tag based on M24SR with its printed NFC antenna
  • 2 digital omnidirectional microphones (MP34DT01)
  • Capacitive digital sensor for relative humidity and temperature (HTS221)
  • High-performance 3-axis magnetometer (LIS3MDL)
  • 3D accelerometer and 3D gyroscope (LSM6DSL)
  • 260–1260 hPa absolute digital output barometer (LPS22HB)
  • Time-of-Flight and gesture-detection sensor (VL53L0X)
  • 2 push-buttons (user and reset)

On my purchase decision, I took into consideration not only the compelling net price (49€) and the rich collection of sensors included in a single board which can be hard to find but, mainly my desire to delve into the native STM32Cube.AI support. The latter, is a solution to embed Artificial Neural Networks in your project as offered by the X-CUBE-AI expansion package.

Therefore, the most intriguing part for me was to test data analytics and machine learning algorithms with the use of NN and actually perform deep learning directly on the MCU. Hence, I started by deploying the available examples already included in the package, using the STM32CubeIDE. In the screenshots below, I tried to depict the process:

  • load the project code:
  • check/edit the user code:
  • compile the code:
  • firmware upload:
  • and the board is ready to go:

Hence, we are now ready to proceed with data acquisition. More specifically, using an android app(ST BLE Sensor), we are able to monitor, in real-time, data coming from the various sensors onboard, which are transmitted wirelessly, via BLE, to the app. Check below some screenshots taken from the running android app:

The most essential part comes next, though. More precisely, all the data being collected and logged locally, can also be fed into a pre-trained NN which is optimized to run on MCUs that have a floating point units like the STM32L4. Therefore, the NN can inference in real-time, based on the data values and the corresponding thresholds, the various “situations” (classification) of the person’s activity e.g. being stationary, walking, jogging, riding, or driving and even classify the ambient system, e.g. being in-house or outdoors. In the following screenshots you can check the classification status (activity type) along with the confidence levels of the algorithm being used:

You can read more on the ST’s official website: https://www.st.com/content/st_com/en/stm32-ann.html

In conclusion, the provided solution can offer to engineers and enthusiasts, a framework with all the tools needed to implement AI to the Edge, leveraging the ability to create predictive applications in various fields like industrial, medical and home automation.

--

--