GPIO using kernel ioctrl interface
My UP board has Ubilinux v 4 on it with some minor changes to udev that enables a group to access GPIO rather than just root.
I have some code to control GPIOs using the kernel interface (ioctl) that runs perfectly on a Raspberry Pi. It uses the BCM pin numbers to control outputs and respond to inputs. The hardware connected to the GPIOs are the LEDs and Buttons on a Pi Rainbow Hat.
The kernel sees this on the PI:
[email protected]:~ $ sudo cat /sys/kernel/debug/gpio gpiochip0: GPIOs 0-53, parent: platform/3f200000.gpio, pinctrl-bcm2835: gpio-16 ( |Button C ) in hi IRQ gpio-19 ( |digital_output ) out lo gpio-20 ( |Button B ) in hi IRQ gpio-21 ( |Button A ) in hi IRQ gpio-26 ( |digital_output ) out lo gpio-29 ( |led0 ) out lo gpiochip1: GPIOs 128-135, brcmexp-gpio, can sleep: gpio-130 ( |led1 ) out lo
You can see the "digital_output" and "Button X" labels where my software has connected to the appropriate lines.
The same code on the UP board runs without error, but the pin outputs do not change, and touching the buttons causes no interrupt to my software.
The numbering of the gpio controlled by the gpiochip0 is very different on the UP board:
[email protected]:~$ sudo cat /sys/kernel/debug/gpio
gpiochip4: GPIOs 0-27, parent: platform/up-pinctrl, up-pinctrl:
gpiochip3: GPIOs 318-372, parent: platform/INT33FF:03, INT33FF:03: gpiochip2: GPIOs 373-396, parent: platform/INT33FF:02, INT33FF:02: gpio-386 ( |up-pinctrl ) out lo gpio-388 ( |up-pinctrl ) out hi gpio-396 ( |up-pinctrl ) in lo gpiochip1: GPIOs 397-455, parent: platform/INT33FF:01, INT33FF:01: gpio-418 ( |up-pinctrl ) out hi gpiochip0: GPIOs 456-511, parent: platform/INT33FF:00, INT33FF:00: gpio-472 ( |Button C ) in hi IRQ gpio-475 ( |digital_output ) out lo gpio-476 ( |Button B ) in hi IRQ gpio-477 ( |Button A ) in hi IRQ gpio-482 ( |digital_output ) out lo gpio-499 ( |up-pinctrl ) out hi
Where are the numbers such as gpio-472 coming from? My code connects using BCM number 16 for Button C, and on the PI, this matches directly.
Do I need to use numbers other than the BCM values when using the ioctrl interface on the UP board? If so, where do I find the correct mapping?
Thanks in advance.
- 261 All Categories
- 103 Announcements & News
- 33 Product News - New Product/Product Change Notice/ End-of-life
- 174 Welcome Developers!
- 47 Unboxing & Project Sharing
- 14 Tech Updates
- 177 UP Products
- 14 UP Squared Pro
- 100 UP Xtreme
- 744 UP Squared
- 1.3K UP Board
- 79 UP Core Plus
- 205 UP Core
- UP Xtreme Lite
- 34 UP AI Edge
- 207 Starter Kits & Peripheral