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

Enable GPIO support on RPi4 #974

Closed
raballew opened this issue Sep 25, 2021 · 6 comments
Closed

Enable GPIO support on RPi4 #974

raballew opened this issue Sep 25, 2021 · 6 comments
Assignees

Comments

@raballew
Copy link

Describe the enhancement
As FCOS is being included in more edge deployments (amd64 and arm64), there are integrations with devices needed (sensors, cameras, etc.), which is not included. My current usecase is, that I would like to use GPIO pins on my Raspberry Pi's to build a sensor cluster.

Impact
Blocks certain edge use-cases.

System details

  • Bare Metal, PXE
  • 34.20210904.3.0

Additional information
An option would be to enable certain kernel options (CONFIG_GPIOLIB=y, CONFIG_GPIO_SYSFS=y and CONFIG_SYSFS=y) so that /sys/class/gpio/... is present, and /dev/gpiomem is present.

@dustymabe
Copy link
Member

We just use the built Fedora kernels so we take whatever options are configured by the kernel maintainers there. Though I do notice for CONFIG_GPIOLIB and CONFIG_SYSFS:

$ grep -P 'CONFIG_GPIOLIB=|CONFIG_SYSFS=' /lib/modules/5.13.16-200.fc34.x86_64/config
CONFIG_GPIOLIB=y
CONFIG_SYSFS=y

For CONFIG_GPIO_SYSFS, seems like that interface is deprecated now and there's a new recommended way to interact via GPIO.

@raballew
Copy link
Author

raballew commented Sep 26, 2021

@dustymabe Thats interesting. So basically it's recommended to use /dev/gpiochip* character device files now for GPIO manipulations (instead of sysfs way) but I can not find such devices on any of my booted FCOS Raspberry Pi's. Also many softwares for Raspberry Pi unfortunately still use the GPIO sysfs interface (/sys/class/gpio), while the kernel is compiled without this support due to deprecation. I think I would be able to workaround this following the steps mentioned here.

For now I see one problem:

Why are there no /dev/gpiochip* character device files?

@dustymabe
Copy link
Member

For now I see one problem:

Why are there no /dev/gpiochip* character device files?

Yeah. I have a pi4 running and I don't see any /dev/gpiochip* device either. I assume it's because I'm using a uefi firmware and it doesn't seem to expose everything it should. Will have to look into this more later, but we should leave this issue open because there's clearly an issue under some conditions.

@raballew
Copy link
Author

Yeah. I have a pi4 running and I don't see any /dev/gpiochip* device either. I assume it's because I'm using a uefi firmware and it doesn't seem to expose everything it should. Will have to look into this more later, but we should leave this issue open because there's clearly an issue under some conditions.

The issue linked mentioned some problems with ACPI so I checked journalctl -b and found (journalctl.log):

[core@localhost ~]$ journalctl -b
[...]
Sep 24 09:50:26 localhost kernel: hci_uart_bcm serial0-0: Unexpected ACPI gpio_int_idx: -1
Sep 24 09:50:26 localhost kernel: Bluetooth: HCI UART protocol QCA registered
Sep 24 09:50:26 localhost kernel: hci_uart_bcm serial0-0: Unexpected number of ACPI GPIOs: 0
[...]

Also it seems that the device-tree did not load successfully:

[core@localhost ~]$ ls /proc/device-tree/
ls: cannot access '/proc/device-tree/': No such file or directory

While /proc/devices show a list of device drivers configured into the currently running kernel including gpiochip:

[core@localhost ~]$ cat /proc/devices
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  7 vcs
 10 misc
 13 input
 21 sg
 29 fb
128 ptm
136 pts
162 raw
180 usb
188 ttyUSB
189 usb_device
204 ttyAMA
207 ttymxc
226 drm
234 ttyDBC
235 hidraw
236 usbmon
237 wwan_port
238 ttyLP
239 ttyTHS
240 ttyHS
241 ttyMSM
242 ttyMSM
243 ttyAML
244 bsg
245 watchdog
246 ptp
247 pps
248 lirc
249 rtc
250 dma_heap
251 dax
252 tpm
253 ttyMV
254 gpiochip

Block devices:
  7 loop
  8 sd
  9 md
 11 sr
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp
259 blkext

@dustymabe
Copy link
Member

Also it seems that the device-tree did not load successfully:

correct. We don't currently include any SBC specific files in FCOS. That's why I'm using the UEFI firmware. We'd like to do more investigation on this front and make things easier in the future. For context see #855 (comment)

@dustymabe dustymabe changed the title Enable GPIO support Enable GPIO support on RPi4 Oct 7, 2021
@dustymabe dustymabe self-assigned this Oct 13, 2021
@dustymabe
Copy link
Member

I think we're going to deal with this for now as a documentation concern. I've tried to address it in coreos/fedora-coreos-docs#336 - landed in the docs site at https://docs.fedoraproject.org/en-US/fedora-coreos/provisioning-raspberry-pi4/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants