Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GPIO Module #6

Open
jensdrenhaus opened this issue Jul 5, 2024 · 6 comments · May be fixed by #112
Open

Implement GPIO Module #6

jensdrenhaus opened this issue Jul 5, 2024 · 6 comments · May be fixed by #112
Milestone

Comments

@jensdrenhaus
Copy link
Member

GPIO (Buttons and Switches at DUT), support for one the following interfaces: sysfs, /dev/gpiomem

@jensdrenhaus jensdrenhaus added this to the MVP 1 milestone Jul 5, 2024
@jensdrenhaus
Copy link
Member Author

jensdrenhaus commented Oct 13, 2024

Controlling GPIO (on the RaspberryPi) via sysfs seems to be deprecated.

Using memory mapping with /dev/gpiomem seems to be the most basic and straight forward option. There is golang library go-rpio implementing that.
Although the last contributions are more than 3 years old, it is highly rated (2.2k stars)
A potential drawback on the first look might be, that it uses /dev/mem by default and only falls back to dev/gpiomem if the Linux user has no root privileges.

There is also a newer interface to GPIO via Linux character device [1], which is recommende by the Raspberry Pi Foundation. This approach is also already implemented in the golang library gpiocdev .
It seems a bit more sophisticated but also a bit bloated.

I tend to stick with the dev/gpiomem approach, but character device seems to be the new way to go.

[1] https://pip.raspberrypi.com/categories/685-whitepapers-app-notes/documents/RP-006553-WP/A-history-of-GPIO-usage-on-Raspberry-Pi-devices-and-current-best-practices.pdf

@jensdrenhaus
Copy link
Member Author

@sylv-io any thoughts on this?

@sylv-io
Copy link
Contributor

sylv-io commented Oct 14, 2024

@sylv-io any thoughts on this?

IMHO we should support gpiomem and sysfs as separate dutctl gpio modules 👍
We can then prioritize the use of gpiomem and still fall back to sysfs if it is not available.

@jensdrenhaus
Copy link
Member Author

What about that newer kernel interface via character device? Leave it out completely for now?

@sylv-io
Copy link
Contributor

sylv-io commented Oct 15, 2024

Sure, we should support all possible GPIO interfaces. Either by adding a module that supports them all via module options, or by implementing a separate module for each interface. I think the former option fits the best.

@macpijan
Copy link

If I may add, sysfs GPIO is already marked as obsolete, and disabled by default. If you are looking for a future-proof solution, gpiocdev is likely the way to go.

As for the sysfs interface, maybe you find some of these useful: https://github.com/3mdeb/RteCtrl/blob/master/pkg/gpioControl/gpioControl.go

@jensdrenhaus jensdrenhaus linked a pull request Nov 21, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants