Written: 2024-08-05
Summary
About the STM32MP135 and the M5Stack board
First off: I'm not associated with M5Stack at all, and have no personal stake in promoting it. I do however like the form factor and have written previously about the ESP32 M5Stack.
Although the STM32MP135 shares the "STM32" prefix used by the popular line of Cortex MCUs from ST, it is not the Cortex-M architecture, but the Cortex-A application processor. Which means, among other things, it runs faster (1GHz) and comes with a memory management unit. The main upshot is, you can readily run linux. It also comes with two on-chip gigabit ethernet MACs.
The M5Stack puts this chip onto a board with all the basic accessories, and in a DIN-rail ready package with a small touch screen, and connectors for:
- (2) USB 2.0 type A host ports
- (1) DisplayPort for a monitor
- (1) 4-pin I2C connector
- (1) 4-pin USART connector
- (2) RJ45 Ethernet connectors
- (2) CAN bus connectors (both support CAN FD)
- (1) RS485 bus connector
- (1) micro-SD slot
- (1) USB 2.0 OTG type-C connector (This is on a separate USB controller from the other ports, and can be used as a host or device)
It even includes a little built in speaker!
Why I'm replacing a RaspPi 4
For me, this is going to be a vastly superior raspberry PI 4 replacement. It's inferior in some ways: mainly in processing power, and RAM (The M5Stack CoreMP135 has only 0.5GB of RAM). But, for a lot of applications (including mine!) that's not a problem. I'm currently using a Raspberry PI as a controller/monitor/logger for a camper van conversion. It just has to talk to smart batteries, read sensors, control some load switches, log a small amount of data and serve it up to grafana for display. Simple stuff.
How's it better?
- Power
The M5Stack currently is using about 20% of the power of the raspberry PI.
- Built in CAN and RS485
I am using a CAN bus run throughout the van for talking to sensors and an e-ink display, so the built-in CAN means I can get rid of a USB-to-CAN adapter. This is actually a huge win, because I have had a persistent problem with the Raspberry PI USB stack where it will occasionally (~2weeks) fail in some weird way that requires a power-cycle to recover from. It's been manageable, but is annoying.
Additionally, my Renogy smart LiFeP batteries have RS485 modbus ports for communicating with the battery controller for, e.g. monitoring state of charge and current draw.
- Smaller footprint
It will take less space than a PI.
- Better connectors
The raspberry PI pretty much has USB ports, ethernet, and a really terrible to use 0.1" header for all other IO. The more industrial oriented M5Stack, in addition to having a nice DIN rail mounting, comes with connectorized screw terminals for wiring.
- Touchscreen
The little integrated touch screen is nice for basic status display and some interactive control. For example, I want to be able to switch modes between active and parked in the driveway. Although I can set up a webserver and use my phone to do this, I think having the touchscreen as an alternative will also be nice.
I really like this little device and hope to use it elsewhere too. BUT, the software build process can be a bit intimidating compared to, e.g. running Ubuntu on a RaspPi. Also, the documentation from M5Stack is...a little spotty. So now, I'm going to try to document my process for using buildroot and rust to build a linux image which demonstrates the
Why buildroot
Buildroot is a linux distribution tailored to making small, bespoke images for small embedded linux systems. It's main alternative is called Yocto. I chose to use buildroot because I've used it before and because M5Stack has already creating buildroot configurations for the target.