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

Showing Posts 1 to 1

lawik

lawik

Nerves Core Team

Awesome! It is very satisfying to start understanding all the moving parts of a Nerves system. It can also be a hair-pulling amount of frustration, like the block offset and boot loader fun that it sounds like you hit :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
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
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
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

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
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
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews