IOTA Masked Authenticated Messages on OpenSTLinux of STMicroelectronics Discovery Kit
The full article was originally published by Bernardo Rodrigues on Medium. Read the full article here.
This time I decided to move in the direction of Industrial IoT Hardware. STMicroelectronics is a leading Integrated Device Manufacturer delivering solutions that are key to Smart Driving, Smart Industry, Smart Home & City and Smart Things. The IOTA Foundation recenlty published “IOTA Links with STMicroelectronics to Accelerate IoT Technology Integration”. The cornerstone of this cooperation was the integration of the IOTA Tangle into STM32Cube expansion software for the industry-leading STM32 32-bit MCU (Cortex-M*) ecosystem, the X-CUBE-IOTA1. And now meta-iota is adding a new path for this collaboration, for the OpenSTLinux side of things. OpenSTLinux is a Linux distribution based on the OpenEmbedded build framework, and you can find information about it on its official OpenSTLinux Wiki.
So let’s talk about the hardware. The STM32MP157C-DK2 Discovery Kit leverages the capabilities of STM32MP1 Series microprocessors to allow users easily develop OpenSTLinux applications for the ARM Dual Cortex A7 main processor, as well as STM32CubeMP1 software for the Cortex M4 coprocessor. While the X-CUBE-IOTA1 toolkit is useful for the M4 coprocessor, we’re going to focus on the OpenSTLinux of the Cortex A7.
For this Proof of Concept, we’re going to send Masked Authenticated Messages (MAM) from OpenSTLinux into the Tangle. We will use the MAM examples provided in the EnTangle’d repository, although I’m hosting them in my own repository to ease the integration into its BitBake recipe.
MAM is the result of a research collaboration between the IOTA Foundation and the Belarusian State University (BSU). In a nutshell, MAM acts as a second layer data communication protocol that adds functionality to send and receive encrypted data streams over the Tangle. MAM aims at the important need for integrity and privacy in the IoT industry because how the IOTA consensus protocol encapsulates those message streams. For more in-depth explanations of MAM, please refer to:
- Introducing Masked Authenticated Messaging, by Paul Handy
- IOTA: MAM Eloquently Explained, by ABmushi
- IOTA tutorial 19: Masked Authenticated Messaging, by Mobilefish
- MAM Update: C Libraries and Release, by Aaron Alsop
- How is authenthicity and confidentiality maintained for MAM channels on the IOTA Tangle? by Marius Ødegard
For this tutorial we will take a different workflow, when compared to the previous ones. Instead of building a whole image, we will use the stock distribution provided by ST with the board. It already contains a prebuilt image of the OpenSTLinux distribution. You can also download it from ST’s website and flash it into the SD card. We will build .deb packages of entangled-mam-examples and its dependencies, and install them on the OpenSTLinux environment.
Preparing the STM32MP157C-DK2 board
When you purchase the STM32MP157C-DK2 board, it comes with an SD Card pre-flashed with OpenSTLinux. But you can always follow the steps described in the Getting Started section of the STM32 MPU Wiki to get OpenSTLinux installed in the SD Card of the board.
Start by connecting minicom to the /dev/ttyACM0 device so you can interact with the board via UART through the ST-LINK/V2–1 cable (microUSB). Make sure the board has an Ethernet cable connected to your LAN router. After turning the board on, wait until Linux finishes booting up, and then find out the board’s local IPv4 address with the ifconfig command (look for eth0 device). In my case, it’s 10.0.0.111.
BitBaking the .deb packages
Now we’re going to use BitBake to generate .deb packages of entangled-mam-examples and its dependencies. We’re going to set everything up so the resulting packages are matching with the OpenSTLinux distribution running on the board, so we can install them with the dpkg package manager.
1. Prepare your workstation for Yocto/OpenEmbedded development. Refer to Yocto’s official documentation for more details on setting up.
Assuming you are using Ubuntu 18.04: