Skip to main content
msche.1
Associate III
January 25, 2022
Solved

How do you control the GPIO pins on an STM32MP1?

  • January 25, 2022
  • 3 replies
  • 2812 views

Is micro python an option?

This topic has been closed for replies.
Best answer by Kevin HUBER

Hello @msche.1​ ,

As explained on the wiki you can displays information and controls the gpiochip line with "gpiodetect", "gpioinfo", "gpioget", etc: https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_userspace

The mapping of the GPIO is available in the datasheet, from page 93:

https://www.st.com/resource/en/datasheet/stm32mp157c.pdf

If you want the information of pin PA8 for example, you can first do a:

root@stm32mp1:~# gpiodetect
gpiochip0 [GPIOA] (16 lines)
gpiochip1 [GPIOB] (16 lines)
gpiochip2 [GPIOC] (16 lines)
gpiochip3 [GPIOD] (16 lines)
gpiochip4 [GPIOE] (16 lines)
gpiochip5 [GPIOF] (16 lines)
gpiochip6 [GPIOG] (16 lines)
gpiochip7 [GPIOH] (16 lines)
gpiochip8 [GPIOI] (16 lines)
gpiochip9 [GPIOZ] (16 lines)

You see that GPIOA is gpiochip0:

Then you can use:

root@stm32mp1:~# gpioget gpiochip0 8
0

Same thing with gpioset.

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

3 replies

Olivier GALLIEN
ST Technical Moderator
January 25, 2022

Hi @msche.1​ ,

There's already several posts addressing this question.

I found for you How to code to control GPIO from python (st.com)

Don't hesitate to browse this community and the stm32mpu wiki.

Hope it help,

Olivier

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
msche.1
msche.1Author
Associate III
January 25, 2022

Thanks for the link, I have found that exact post, but I didn't find a way to figure out the mapping from (gpiochipX, line) to PIN. Do you know where I can find this mapping?

Kevin HUBER
Kevin HUBERBest answer
ST Employee
March 10, 2022

Hello @msche.1​ ,

As explained on the wiki you can displays information and controls the gpiochip line with "gpiodetect", "gpioinfo", "gpioget", etc: https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_userspace

The mapping of the GPIO is available in the datasheet, from page 93:

https://www.st.com/resource/en/datasheet/stm32mp157c.pdf

If you want the information of pin PA8 for example, you can first do a:

root@stm32mp1:~# gpiodetect
gpiochip0 [GPIOA] (16 lines)
gpiochip1 [GPIOB] (16 lines)
gpiochip2 [GPIOC] (16 lines)
gpiochip3 [GPIOD] (16 lines)
gpiochip4 [GPIOE] (16 lines)
gpiochip5 [GPIOF] (16 lines)
gpiochip6 [GPIOG] (16 lines)
gpiochip7 [GPIOH] (16 lines)
gpiochip8 [GPIOI] (16 lines)
gpiochip9 [GPIOZ] (16 lines)

You see that GPIOA is gpiochip0:

Then you can use:

root@stm32mp1:~# gpioget gpiochip0 8
0

Same thing with gpioset.

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.