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:
-
Set
@all_targets [:stm32mp157f_dk2] -
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:
-
Why build a custom Nerves gateway
-
The STM32MP1 boot chain — what happens when you apply power
-
Device trees demystified
-
Building the Nerves system — all 25+ errors and how I solved them
-
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
Trending in Guides/Tuts
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming









