STM32MP157F-DK2 and GPIO Pin Access

Hello TechForum,

I purchased a couple STM32MP157F-DK2 kits. I was able to use STM32’s getting started and made the demo project, the hello world app for the touchscreen. It seemed to be part of the OS and I had to compile it

I’ve not been able to do much more. I’m specifically looking to use an array of different sensors, accelerometers, ambient sensors, motor controllers, daughter boards…basically any of the Arduino and Raspberry Pi parts that this board is designed to interface with.

Sadly, I cannot seem to find any examples or solid documentation, nor any getting started examples, etc.

I am not sure if, I need to reinstall the OS every time I want to access the M4 and IOs, like do I have to turn pins on/off, or describe who is doing what (like is digital I/O: set digital I or O, or set pins to I2C_One). What are the GPIO names? (because LED_Green means nothing to me in the documentation…I see the User Manual actually does call out proper IO names, but is there better documentation on API and programming for these?).

Or does the OS know these things exist and I simple need the API to program things like create I2C_Name located on Pin_Name and do such and such?

Do any of the Raspberry Pi CLI tools work like $pinout ? (I guess I can try this, lol). Or can they be installed?

The hello world example was programmed off board. Is there a way to program on the board? Can I tell the device I want to use C or C++ libraries, or that I want to use Python, or CircuitPython?

I know this is a lot of questions. Thank you for the chance to ask!

So unlike the Raspberry Pi, most SBC’s do not have libraries for easly access to every pin.

On the STM32MP157F-DK2, you’ll need to reference the schematic design, and utilze /sys/class/gpio/ to export the pins you’d like to use…

Which pins, interface, etc are you trying to use on the STM32MP157F? in most cases it’s easier to just patch the device tree and use the standard linux interfaces…


Thank you! I will start with the /sys/class/gpio.
I didn’t know there are standard linux interfaces for these.
I’m guessing then, I’m basically going to be writing my own comms drivers then? Like read/write as I would for any instrument control? Like having a server with RedHat commanding an Agilent Power Supply through GPIB or Network?

Which interface does this actually use? In most cases Linux probably already supports it…

Then it’s just a matter of configuring the correct pins, and wiring an adapter…


This was hugely helpful. I did some web searches for terms you stated like linux interfaces and programming linux GPIO and found the specific answers right away. It is easy to get focused on STM32, Arduino, and R.Pi examples right away, when I needed to step back and approach this from a “Hey, I’m programming for Linux and need to approach as a Linux programmer.” Thank you!

I’ve spent a few days and there is more than just calling pins through Linux. They have to be added into the Kernel first. Then the kernel has to be rebuilt(?). STM wants the user to use their CubeMX then CubeIDE which failed for me. The IDE won’t recognize and open the MX project. Another option is Bootlin, but after a couple days and getting the image installed, the username and password didn’t work, so I cannot remote into the device. This looks to be a common issue and I couldn’t find the solution. The third option which I will start on is using this Digi-Key example:

So, the correct solution to being able to use the GPIOs through the R.Pi and Arduino connectors is that they have to be setup in the OS, then the OS has to be (re)built, then the I/Os are accessible through the OS.

This just requires a Device-Tree change… On the STM32MP157F, which bus (i2c/spi) and gpio’s are you looking to utilize?

I did a demo a few weeks ago with an i2c expansion board pluggged in…