libgpiod pin mappings

Post Reply
sgjava
Posts: 67
Joined: Mon Dec 29, 2014 7:47 am
languages_spoken: english
ODROIDs: C1, C1+, C2, XU4
Has thanked: 1 time
Been thanked: 3 times
Contact:

libgpiod pin mappings

Post by sgjava » Wed May 20, 2020 11:23 pm

On most of my other SBCs there's usually only 2 GPIO chips, so it's easier to figure out pin mappings. On the XU4 there's a lot of "chips". Has anyone figured out the mappings of the pins to the GPIO character device?

Code: Select all

gpiochip0 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip1 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed  "power key"   input   active-low [used]
	line   4:      unnamed  "interrupt"   input  active-high [used]
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip10 - 8 lines:
	line   0:      unnamed      "reset"  output   active-low [used]
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip11 - 6 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
gpiochip12 - 4 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
gpiochip13 - 6 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
gpiochip14 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip15 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip16 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip17 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip18 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip19 - 2 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
gpiochip2 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip20 - 6 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
gpiochip21 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip22 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip23 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip24 - 2 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
gpiochip25 - 4 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
gpiochip26 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed "ads7846_pendown" input active-high [used]
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed        "sda"   input  active-high [used]
	line   7:      unnamed        "scl"   input  active-high [used]
gpiochip27 - 6 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
gpiochip28 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed     "spi1.0"  output  active-high [used]
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip29 - 5 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
gpiochip3 - 8 lines:
	line   0:      unnamed         "w1"   input  active-high [used]
	line   1:      unnamed     "spi1.1"  output  active-high [used]
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip30 - 5 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
gpiochip31 - 4 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
gpiochip32 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip33 - 2 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
gpiochip34 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip35 - 7 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
gpiochip4 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed        "hpd"   input  active-high [used]
gpiochip5 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip6 - 8 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
gpiochip7 - 7 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
gpiochip8 - 4 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
gpiochip9 - 2 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 

User avatar
tobetter
Posts: 5113
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 161 times
Been thanked: 509 times
Contact:

Re: libgpiod pin mappings

Post by tobetter » Thu May 21, 2020 7:13 am

Are you running 4.14 kernel?

sgjava
Posts: 67
Joined: Mon Dec 29, 2014 7:47 am
languages_spoken: english
ODROIDs: C1, C1+, C2, XU4
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: libgpiod pin mappings

Post by sgjava » Fri May 22, 2020 10:12 am

4.14.180

User avatar
tobetter
Posts: 5113
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 161 times
Been thanked: 509 times
Contact:

Re: libgpiod pin mappings

Post by tobetter » Fri May 22, 2020 10:14 am

sgjava wrote:
Fri May 22, 2020 10:12 am
4.14.180
Are you able to build and install the kernel by yourself if you have a patch?

User avatar
tony.hong
Posts: 120
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 27 times
Been thanked: 35 times
Contact:

Re: libgpiod pin mappings

Post by tony.hong » Fri May 22, 2020 2:00 pm

Code: Select all

"""
Samsum Exynos5422
Ref:
    Linux kernel 4.14.y (hardkernel)
"""

GPIOA0_0 = GPIO171 = Pin((26, 0))
GPIOA0_1 = GPIO172 = Pin((26, 1))
GPIOA0_2 = GPIO173 = Pin((26, 2))
GPIOA0_3 = GPIO174 = Pin((26, 3))
GPIOA0_4 = GPIO175 = Pin((26, 4))
GPIOA0_5 = GPIO176 = Pin((26, 5))
GPIOA0_6 = GPIO177 = Pin((26, 6))
GPIOA0_6 = GPIO178 = Pin((26, 7))

GPIOA2_0 = GPIO185 = Pin((28, 0))
GPIOA2_1 = GPIO186 = Pin((28, 1))
GPIOA2_2 = GPIO187 = Pin((28, 2))
GPIOA2_3 = GPIO188 = Pin((28, 3))
GPIOA2_4 = GPIO189 = Pin((28, 4))
GPIOA2_5 = GPIO190 = Pin((28, 5))
GPIOA2_6 = GPIO191 = Pin((28, 6))
GPIOA2_7 = GPIO192 = Pin((28, 7))

GPIOB3_0 = GPIO207 = Pin((32, 0))
GPIOB3_1 = GPIO208 = Pin((32, 1))
GPIOB3_2 = GPIO209 = Pin((32, 2))
GPIOB3_3 = GPIO210 = Pin((32, 3))
GPIOB3_4 = GPIO211 = Pin((32, 4))
GPIOB3_5 = GPIO212 = Pin((32, 5))
GPIOB3_6 = GPIO213 = Pin((32, 6))
GPIOB3_7 = GPIO214 = Pin((32, 7))

GPIOX1_0 = GPIO16 = Pin((2, 0))
GPIOX1_1 = GPIO17 = Pin((2, 1))
GPIOX1_2 = GPIO18 = Pin((2, 2))
GPIOX1_3 = GPIO19 = Pin((2, 3))
GPIOX1_4 = GPIO20 = Pin((2, 4))
GPIOX1_5 = GPIO21 = Pin((2, 5))
GPIOX1_6 = GPIO22 = Pin((2, 6))
GPIOX1_7 = GPIO23 = Pin((2, 7))

GPIOX2_0 = GPIO24 = Pin((3, 0))
GPIOX2_1 = GPIO25 = Pin((3, 1))
GPIOX2_2 = GPIO26 = Pin((3, 2))
GPIOX2_3 = GPIO27 = Pin((3, 3))
GPIOX2_4 = GPIO28 = Pin((3, 4))
GPIOX2_5 = GPIO29 = Pin((3, 5))
GPIOX2_6 = GPIO30 = Pin((3, 6))
GPIOX2_7 = GPIO31 = Pin((3, 7))

GPIOX3_0 = GPIO32 = Pin((4, 0))
GPIOX3_1 = GPIO33 = Pin((4, 1))
GPIOX3_2 = GPIO34 = Pin((4, 2))
GPIOX3_3 = GPIO35 = Pin((4, 3))
GPIOX3_4 = GPIO36 = Pin((4, 4))
GPIOX3_5 = GPIO37 = Pin((4, 5))
GPIOX3_6 = GPIO38 = Pin((4, 6))
GPIOX3_7 = GPIO39 = Pin((4, 7))

I2C1_SDA = GPIOB3_2
I2C1_SCL = GPIOB3_3
I2C5_SDA = GPIOA2_2
I2C5_SCL = GPIOA2_3

UART0_TX = GPIOA0_1
UART0_RX = GPIOA0_0

SPI1_SCLK = GPIOA2_4
SPI1_MISO = GPIOA2_6
SPI1_MOSI = GPIOA2_7
SPI1_CS0 = GPIOA2_5
These users thanked the author tony.hong for the post:
sgjava (Sat May 23, 2020 10:59 am)

sgjava
Posts: 67
Joined: Mon Dec 29, 2014 7:47 am
languages_spoken: english
ODROIDs: C1, C1+, C2, XU4
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: libgpiod pin mappings

Post by sgjava » Sat May 23, 2020 6:45 am

I just using Armbian. I can get gpioinfo using libgpiod, but unlike some other SBCs it only lists the line descriptions for lines in use. Let me try what you provided and see if it responds on my scope.
Last edited by sgjava on Sat May 23, 2020 11:06 am, edited 1 time in total.

sgjava
Posts: 67
Joined: Mon Dec 29, 2014 7:47 am
languages_spoken: english
ODROIDs: C1, C1+, C2, XU4
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: libgpiod pin mappings

Post by sgjava » Sat May 23, 2020 11:03 am

Tony, those mappings are correct. I tested using my Java userspace library https://github.com/sgjava/java-periphery

Code: Select all

uname -a
Linux odroidxu4 5.4.41-odroidxu4 #trunk.143 SMP PREEMPT Fri May 22 07:40:19 CEST 2020 armv7l armv7l armv7l GNU/Linux

Code: Select all

java -cp java-periphery-1.0.0-SNAPSHOT.jar:java-periphery-1.0.0-SNAPSHOT-linux32.jar com.codeferm.periphery.demo.GpioPerf -d /dev/gpiochip26 -l 0
21:46:10.283 [main] INFO  com.codeferm.periphery.demo.GpioPerf - Running write test with 10000000 samples
21:47:54.386 [main] INFO  com.codeferm.periphery.demo.GpioPerf - 192180.19 writes per second
21:47:54.389 [main] INFO  com.codeferm.periphery.demo.GpioPerf - Running read test with 10000000 samples
21:48:46.113 [main] INFO  com.codeferm.periphery.demo.GpioPerf - 193341.32 reads per second
I figured it would be a little faster, but I was happy to get it to work.

Image
These users thanked the author sgjava for the post (total 2):
tony.hong (Mon May 25, 2020 9:27 am) • odroid (Mon May 25, 2020 9:45 am)

User avatar
tony.hong
Posts: 120
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 27 times
Been thanked: 35 times
Contact:

Re: libgpiod pin mappings

Post by tony.hong » Mon May 25, 2020 9:35 am

Gpiod is slightly slower than memory access control. But it is much safer. Enjoy your Odroid time ~ 8-)

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 1 guest