cancel
Showing results for 
Search instead for 
Did you mean: 

How do you control the GPIO pins on an STM32MP1?

msche.1
Associate III

Is micro python an option?

1 ACCEPTED SOLUTION

Accepted Solutions

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 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Olivier GALLIEN
ST Employee

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

Olivier GALLIEN
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.

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?

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 'Accept as Solution' on the reply which solved your issue or answered your question.