tomazbracic

tomazbracic

Hey everyone,

I want to share something I have been working on for a while. I built a custom Nerves system for the STM32MP157F-DK2 board from STMicroelectronics and decided to publish it so others can use it too.

Repo:

## Why this board?

The STM32MP157F-DK2 is a dual-core board — two Cortex-A7 cores running Linux (where Nerves and BEAM live) plus a Cortex-M4 coprocessor on the same chip. They talk to each other through shared memory via RPMsg. This means you can run Elixir for the high-level stuff and have a real-time microcontroller for time-critical work, all on one chip. No external MCU, no SPI hacks.

The board also has proper Gigabit Ethernet (RGMII, not USB-bridged like on the Pi), WiFi, BLE, a 4-inch touchscreen, USB host ports, and hardware crypto. For an IoT gateway it is a really nice platform.

Nobody had a Nerves system for the STM32MP1 family, so I made one.

BTW: STM32MP157D-DK1 is done as well. Series of blog posts is coming in really near future. Together with Compulab (including proper SECURE BOOT), …

## What works

  • Ethernet, SSH, mDNS — all working out of the box

  • A/B OTA firmware updates with fwup

  • WiFi and BLE kernel drivers enabled

  • Display and touchscreen drivers enabled

  • M4 remoteproc and RPMsg ready in the kernel (just load your firmware)

  • F2FS writable app partition at /root

  • Pre-built artifacts available — macOS and Linux users can just mix deps.get, no need to build from source

## How to use it

Create a new Nerves project and edit mix.exs:

  1. Set @all_targets [:stm32mp157f_dk2]

  2. Add the dependency:


{:nerves_system_stm32mp157f_dk2,

github: "tomazbracic/nerves_system_stm32mp157f_dk2", tag: "v1.3.0",

runtime: false, targets: :stm32mp157f_dk2}

Then:


export MIX_TARGET=stm32mp157f_dk2

mix deps.get

mix firmware

mix burn

And you get an IEx prompt over SSH. That simple.

## The story behind it

I have been using Nerves for some time now — Raspberry Pi, BeagleBone, the usual targets. But I realized I did not really understand what was happening underneath. Device trees, boot chains, TF-A, U-Boot — I knew the words but not the details.

So I picked a board with no existing Nerves support and built everything from scratch. It was not easy. I hit 25+ build errors along the way. Wrong toolchain producing broken U-Boot binaries (silent hang, no output, fun to debug). Device tree files that do not exist for my board variant. Block offset calculation that wiped the bootloader. Each one was a lesson.

I documented the whole journey in a blog series that I will publish soon:

  1. Why build a custom Nerves gateway

  2. The STM32MP1 boot chain — what happens when you apply power

  3. Device trees demystified

  4. Building the Nerves system — all 25+ errors and how I solved them

  5. From learning project to community system

The blog posts go deep into the “why” behind every decision. If you ever wanted to understand how a Nerves system actually works under the hood — the boot chain, device trees, Buildroot, fwup partition layout — I think you will find it useful.

## What is coming next

This is part of a bigger project. The plan (might change):

  • just now Adding support for display that is on DK2

  • next SECURE BOOT (DK2 supports it, DK1 doesn’t)

  • really soon Adding LTE support and TPM (work related)

  • Phase 2: Embedded Rust firmware on the M4 coprocessor, talking to Nerves over RPMsg

  • Phase 3: BLE gateway using a Micro:bit v2 (nRF52833) running Embassy Rust, connected to M4 over UART

  • Phase 4: Surface UI on the 4-inch touchscreen

  • Phase 5: Full gateway — MQTT, NervesHub OTA, the whole thing

The end goal is a complete IoT gateway for various tasks, like being part of bigger energy management system. Elixir on the A7 for orchestration, Rust on the M4 for real-time.

Blog series coming soon…

## Known limitations

Two things to be aware of:

  • The system uses Bootlin’s GCC 14.3 toolchain instead of the standard Nerves one. The Nerves GCC 13.2 toolchain produces U-Boot binaries that crash silently on STM32MP1. This is documented in the repo.

  • Boot-counting auto-revert does not fully work yet — U-Boot ignores the saved environment. Manual revert via Nerves.Runtime.revert() works fine.

## Feedback welcome

This is my first time publishing a Nerves system so I am sure there are things I can improve. If you have the board (or the C variant — they are software-compatible), please try it and let me know how it goes.

Thanks to the Nerves team for building such an amazing platform. This project would not exist without the foundation you created.

Tomaz

Where Next? Top

Trending in Guides/Tuts Top

c4lliope
# ~/src/livebook/.iex.exs System.cmd("xdg-open", [ LivebookWeb.Endpoint.access_url() ] ) Because Livebook requires a unique passcode on ...
New
krasenyp
You probably already know that <span>{nil}</span> in a HEEX template produces <span> </span> when rendered. I fin...
New
tomazbracic
Hey everyone, I want to share something I have been working on for a while. I built a custom Nerves system for the STM32MP157F-DK2 board...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews