Skip to main content
Visitor II
June 14, 2021
Question

Can not controll GPIO from Kernel Space

  • June 14, 2021
  • 3 replies
  • 2098 views

Hello i wanted to use the GPIOLib to control my pin manualy. so i added this in my device tree.

&usart3 {

pinctrl-names = "default", "sleep", "idle";

pinctrl-0 = <&usart3_pins_c>;

pinctrl-1 = <&usart3_sleep_pins_c>;

pinctrl-2 = <&usart3_idle_pins_c>;

uart-has-rtscts;

status = "ok";

ethernet {

compatible = "st,stm32_usart_net";

local-mac-address = [ A0 B0 C0 D0 E0 F0 ];

pinctrl-names = "default";

rts-gpios = <&gpioa 11 GPIO_ACTIVE_LOW>;

cts-gpios = <&gpioa 12 GPIO_ACTIVE_LOW>;

  };

};

and in my code i wanted to change the pin state like that:

rtsGpio = devm_gpiod_get(&serdev->dev, "rts-gpios", GPIOD_OUT_HIGH);

   

  ssleep(1);

gpiod_set_value(rtsGpio, 1);

but when i look at it the pin is not changing the status. and i get this log message:

gpiod_set_value: invalid GPIO (errorpointer)

    This topic has been closed for replies.

    3 replies

    Super User
    June 14, 2021

    I tagged this as MPU rather than MCU.

    SAman.1Author
    Visitor II
    June 15, 2021

    Ok thanks fpr it. Is there a way to check if devm_gpiod_get was sucessfull or not?

    SAman.1Author
    Visitor II
    June 16, 2021

    i tried diffent pins but i always get the same result. in my configuration i want to use the pin 3 and 5.

    Technical Moderator
    June 25, 2021

    Hi @SAman.1​ ,

    Usage of GPIOLib is to control GPIO from Userspace.

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

    And here you want to drive a pin which is allocate to usart3 .. which is not possible.

    Pin allocate to UART might be drive through UART driver.

    What do you want to achieve ?

    Olivier