cancel
Showing results for 
Search instead for 
Did you mean: 

How to control GPIO using DT in Application?

BKwak.1
Associate

I want to control defined GPIO in DT in Applicatoin code.

But I can't control this, please let me know how to control gpio with DT in applicatoin.

1) I can control GPIO in Application without DT . (unused at gpioinfo)

2) I can't control GPIO in application with DT, like below.

  • gpioinfo​

  line 14:   unnamed "stm32mp:green:user" output active-low [used]

​ occurred error massage when running application code

Failed to issue GET LINEHANDLE IOCTL (-25)

Failed to issue GPIOHANDLE_SET_LINE_VALUES_IOCTL (-25)

Failed to issue GPIOHANDLE_SET_LINE_VALUES_IOCTL (-25)

Failed to issue GPIOHANDLE_SET_LINE_VALUES_IOCTL (-25)

reference code

https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_userspace

Device Tree - add green led

led {

compatible = "gpio-leds";

blue {

label = "heartbeat";

gpios = <&gpiod 9 GPIO_ACTIVE_HIGH>;

linux,default-trigger = "heartbeat";

default-state = "off";

};

green {

label = "stm32mp:green:user";

gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;

default-state = "on";

};

};

This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
OlivierK
ST Employee

​Hello BKwak.1 (Community Member),

You should care not to mix user space and kernel space. Either you control the GPIO in user space using gpiolib,  like it is specified in:https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_userspace

or you modify the DT and you control the GPIO in kernel space.

https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_kernel_space

For the specific gpio-leds driver, you can refer to

https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Developer_Package

Regards,

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.
BillR
Senior

Hi, so to be clear - Is there in fact no way to enable a pull-down at the low level, like (preferably) u-boot or kernel device tree, but then be able to control the GPIO from user space as we are now? We forgot an external pull down to a FET and would prefer not to rework it if possible.