GPIO pin is reset to default value after release.

Andrew Jeffery andrew at aj.id.au
Wed Jan 6 12:12:26 AEDT 2021



On Wed, 6 Jan 2021, at 02:57, Thu Nguyen wrote:
> Hi,
> 
> 
> Current I'm using two difference GPIO libs gpiod and gpioplus to setting 
> GPIO pins.
> 
> I can set the GPIO pin to expected value in a service. And GPIO keep 
> unchanging when the service is running.
> 
> But when the service is exited, the GPIO handler is released then GPIO 
> is reset to default value.
> 
> 
> Do we have any gpio lib which don't reset the GPIO when the handler is 
> released?

No. This is a property of the GPIO chardev interface provided by the kernel. libgpiod makes the kernel interface a bit nicer to consume in user space, but isn't where this behaviour is contracted (i.e. any use of the chardev interface might result in this behaviour, libgpiod or otherwise).

At the moment the way to get the behaviour you desire is to keep the line handle open.

The deprecated approach is to use the sysfs interface instead, but that's strongly discouraged.

That said, your problem is something I have on my to-do list to address with upstream. I'll Cc the openbmc list whenever I get to it.

Cheers,

Andrew


More information about the openbmc mailing list