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 6

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:

tomazbracic

tomazbracic OP

Now I can play :wink:

AlexGx

AlexGx

Can’t wait to read the series!

tomazbracic

tomazbracic OP

Hi,

a week or two ago I published that I created new Nerves (base) system for STM32MP157 → 2 models. D-DK1 and F-DK2. I posted a github repo for base system as well and mentioned, that I will add some blog posts / series of posts on my page. You can find series around NXP’s i.MX8M Plus - fully secure boot covered.

I published some of the posts/series today, so if anyone interested you can read it on link below.

I will be publishing more content in the coming weeks… with focus on these boards and specifically **secure boot** process, and OTA. Next is secure boot on STM32 (the one above)

There will be other posts as well, so keep checking.

Hope this helps someone in the future.

Bye!

lawik

lawik

Nerves Core Team

For the compulab imx8m plus did you work from the redwire system for the iotgate (not din rail version) as a base or do it from scratch?

tomazbracic

tomazbracic OP

I am aware of imx8m, did check it, but I did mine from scratch. Also added DIO and RS485 extension module as this is what I need at work also.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
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
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews