[SOLVED] GPIO Pin Numbers


#1

EDIT:
Here is a table of all the pins user settable for GPIO:

NAME          GPIONUM
PWM0            34
AP-EINT3        35
TWI1-SCK        47
TWI1-SDA        48
TWI2-SCK        49
TWI2-SDA        50
LCD-D2          98 (USED BY 1-WIRE BUS)
LCD-D3          99
LCD-D4         100
LCD-D5         101
LCD-D6         102
LCD-D7         103
LCD-D10        106
LCD-D11        107
LCD-D12        108
LCD-D13        109
LCD-D14        110
LCD-D15        111
LCD-D18        114
LCD-D19        115
LCD-D20        116
LCD-D21        117
LCD-D22        118
LCD-D23        119
LCD-CLK        120
LCD-DE         121
LCD-HSYNC      122
LCD-VSYNC      123
CSIPCK         128
CSICK          129
CSIHSYNC       130
CSIVSYNC       131
CSID0          132
CSID1          133
CSID2          134
CSID3          135
CSID4          136
CSID5          137
CSID6          138
CSID7          139
AP-EINT1       193
UART1-TX       195
UART1-RX       196
XIO-P0         408 (4.3) / 1016 (4.4.11) / 1013 (4.4.13-ntc-mlc)
XIO-P1         409 (4.3) / 1017 (4.4.11) / 1014 (4.4.13-ntc-mlc)
XIO-P2         410 (4.3) / 1018 (4.4.11) / 1015 (4.4.13-ntc-mlc)
XIO-P3         411 (4.3) / 1019 (4.4.11) / 1016 (4.4.13-ntc-mlc)
XIO-P4         412 (4.3) / 1020 (4.4.11) / 1017 (4.4.13-ntc-mlc)
XIO-P5         413 (4.3) / 1021 (4.4.11) / 1018 (4.4.13-ntc-mlc)
XIO-P6         414 (4.3) / 1022 (4.4.11) / 1019 (4.4.13-ntc-mlc)
XIO-P7         415 (4.3) / 1023 (4.4.11) / 1020 (4.4.13-ntc-mlc)

ORIGINAL POST:
I know that the gpio numbers for XIO-P0 to P7 are 408 to 415 (4.3 kernel) and that the CSI-D0 to D7 are 132 to 139.

What are the gpio numbers for the LCD pins. I’ve looked through the pinctrl-sunxi code, but can’t seem to decode where the gpio numbers for sysfs are coming from.


Where are gpio pins defined?
Proper pinout-diagram?
Incorrect information on the documentation regarding GPIO pins for the latest kernel
Interrupt/Edge-triggered GPIO in python
TFT Display on C.H.I.P?
TFT Display on C.H.I.P?
LEDs with GPIO?
Does 4.4.13-ntc-mlc support SPI out of the box?
GPIO Direction - How to see which pins are HIGH or LOW when DRIVING
Need for more GPIO pins
C.H.I.P. BASH GPIO tutorials
CHIP IO: Library for interfacing with all the things (v0.7.1)
[SOLVED] GPIO direct access
[SOLVED] Problem with GPIO access
#2

is this what you are searching for?


#3

Nope, found all of that information.

What I need is the translation from Pin to the GPIO number:
XIO-P0 = gpio408
CSI-D0 = gpio132
LCD-D2 = gpioXXX
PWM0 = gpioYYY

I’m working on porting over the Beaglebone Black IO code to be used by the port of the Adafruit GPIO. This new port will allow for edge detection and other advanced features of the Adafruit Library that isn’t currently implemented. Plus, I’d like to be able to support GPIO on the other pins.


#4

Hi,

the number of the gpios is based on the SoC pin it’s connected to.

If you look at the spreadsheet above, you’ll find for example that LCD_D2 is connected to PD2.

The formula is then “D” - “A” * 32 + 2 = 98.


#5

is it gpio098 or gpio98?


#6

So based on what I’m interpreting the equation as:

CSI-D0 is on PE4. I break up the PE4 to get E and 4.

so that would be
E - A * 32 + 4 = 204

That isn’t right because it is gpio132.


#7

I’m not sure how you got to 204:
E = 5th letter of the alphabet
A = 1st letter of the alphabet
(5 - 1) * 32 + 4 = 132


#8

That makes sense! Thanks foe the clarification @CapnBry.

I was treating the E and A as hex…


#9

Huh? Lol, I don’t think you found your root problem yet.
Hex
E=14
A=10
No. in alphabet
E=5
A=1

14 - 10 = 5 - 1 = 4

Additionally, if x = E - A
32x + 4 = 204 subtracting 4 from both sides
32x = 200 dividing both sides by 32
x = 6.25 …
But x must be a whole number, the subtraction of two whole numbers results in a whole number.

I’m not trying to be mean, I’m just bored and needed to kill a few minutes. And I like math problems.


#10

No worries amigo.

I had a long day at work and whatever I was doing in the Win7 calculator while sitting on a telecon came up with 204. I did have the thought @Biggy that I might be doing it wrong, but wasn’t sure of any other special sauce to decode @mripard said.


#11

You also going do a file for chip to rpi? I need infor for a gpio adapter to try and get adafruit pitft working.


#12

@pyro0139 are you thinking of a translation table between CHIP GPIO and Raspberry PI GPIO?

All I’m doing right now is working on porting this https://github.com/adafruit/adafruit-beaglebone-io-python to the CHIP. At this moment, I have the GPIO working for all of the R8 based GPIO, the code segfaults when trying to setup the XIO pins.

My port of the beaglebone io code will be able to be used by my port of the Adafruit_GPIO library in the future.


#13

Hey @xtacocorex, I didn’t know you went back and edited your post to include this wonderful table! The BBS software don’t flag it in any obvious way. Next time you edit an earlier post to include valuable additional information, please also add a post to the end of the thread announcing the edit. Or add the new content at the end and edit the initial post with a pointer to the solution. Or just ignore my rantings since I love the table and am glad you added it however you want to! (It just took me till now to notice it.)


#14

Sorry about that @fordsfords! I compiled the table and immediate went back to working on this: https://github.com/xtacocorex/CHIP_IO.

Feel free to test away at this. I just added PWM support, based on information from this pull request: https://github.com/NextThingCo/CHIP-linux/pull/4. I don’t have a kernel yet that has PWM support to be able to test, nor can i remember where my servo’s went.


#15

Whoa! It’s 9 AM, do you know where your servos are? Hardly a week goes by that you don’t read about a servo from a good family that gets in trouble with the laws of physics. Oh sure, their designers taught them all about duty cycles, but some servos have poor self control loops and demand wider and wider pulse widths, until one day they connect directly to Vcc and end up in the gutter, carrying on about how back in their days, insulation was considered a luxury, and REAL motors were synchronous to 60 Hz.

You better find those little babies and give them some PWM love.

(P.S. - as a C programmer, I’ll be slow to use your Python library. Someday I’ll break down and join the popular kids crusing down Python Highway, but for now I’ll keep bumping along the caverns of C.)


#16

The underlying code to the Python library is C, so I’m sure you could easily strip it out if needed :slightly_smiling:


#17

Friends don’t let friends write drivers in Python :scream:

C is generic assembly language and is kinda like a medieval broadsword - it’s dizzyingly powerful, but there’s no hilt, handle, or other built-in safety features. So, you’re just as likely to lop off an appendage (including one’s head) as you are to do anything productive until you learn The Force and implement your own handle via double dereferencing … and make sure you also use reference counts so you know when it’s safe to free up memory :sunglasses:


#18

@xtacocorex I’ve liked your post but that doesn’t express enough how much I reference your gpio pin number list so I wanted to thank you directly for providing something that is quite vital to jerks like me plugging away coding interfaces against the gpio ports.


#19

Thanks! It ws definitely a group effort in helping me compile the list. Thanks for your help. :slight_smile:


#20

Hi All,

Sorry to drag up an old thread - but I’m trying to work out what the updated numbers are for firmware 4.4…

The GPIO ping numbers in sysfs now start from 1016 as a base. I’ve got the XIO-P[0-7] pins working, however I can’t seem to find the LCD pins.

Has anyone successfully got the pin numbers for the LCD pins on the 4.4 firmware version?
Any help would be much appreciated!