Hi Matthias and Peter, On 16.09.21 11:33, Matthias Brugger wrote:
On 16/09/2021 10:01, Guillaume Gardet wrote:
-----Original Message----- From: Peter Suetterlin <pit@astro.su.se> Sent: 15 September 2021 17:52 To: arm@lists.opensuse.org Subject: GPIO trouble
Hi list,
slowly trying to get known with my Pi 4 running Tumbleweed. I added a fan, and wanted to control it via GPIO. But I fail to actually control the pins :(
I was trying to follow this description: https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature- python that uses GIOP17. [...] So I wanted to get most basic and tried echo 17 > /sys/class/gpio/export but that gave me only "write error: Invalid argument"
Indeed the directory only lists Pi4:~ # ls /sys/class/gpio export gpiochip446 gpiochip454 unexport
which suggests lowest GPIO available is 446!?
What am I missing?
Did you have a look at https://en.opensuse.org/openSUSE:GPIO for standard packages to access GPIO instead of downstream, RPi specific, software?
You can use 'gpioinfo gpiochip446' and 'gpioinfo gpiochip454' to get info about the gpio available.
You can try to use an offset of 446, so try to set gpio 463 (446 + 17). Not sure why there is such an offset, though. Matthias, any idea?
Unfortunately not. Maybe it would be something worth to investigate as users regularly get confused about that.
I remember that we had that discussion in the past, but can't recall what was the outcome. Andreas do you remember?
Raspberry Pi have a downstream patch that's hardcoding numbers to align with their schematics or whatever. That's not acceptable to upstream. With multiple GPIO chip devices there's no guarantees of their relative probing order and thus number, so the best way is to use DT overlays to specify GPIOs as input or output to the respective driver, if there is. Then userspace doesn't need to deal with GPIO numbers at all. In fact there is a gpio-fan binding that might just be used here: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/Doc... Also, the sysfs GPIO interface is documented as obsolete, so with Factory it may break at some point. https://www.kernel.org/doc/html/latest/driver-api/gpio/intro.html#gpio-inter... libgpiod is the designated replacement since multiple years. https://build.opensuse.org/package/show/hardware/libgpiod Not familiar with which of the interfaces which Python packages consume. Regards, Andreas -- SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)