ToBeReplaced
ToBeReplaced

Reputation: 3584

Misunderstanding beaglebone GPIO pinmux

I'm using a beaglebone black using Linux kernel 3.17.4, Fedora 21 ARM. If I consider kernel pin 8 (gpio0[8], or P8.35)...

$ sudo grep 'pin 8 ' /sys/kernel/debug/pinctrl/44e10800.pinmux/pinmux-pins yieldspin 8 (44e10820.0): (MUX UNCLAIMED) (GPIO UNCLAIMED)

$ sudo grep 'pin 8 ' /sys/kernel/debug/pinctrl/44e10800.pinmux/pins yields pin 8 (44e10820.0) 00000027 pinctrl-single

So as far as I can tell, pin 8 is receive enabled with a pull down resistor in mode 7.

Then $ echo 8 | sudo tee -a /sys/class/gpio/export creates /sys/class/gpio/gpio8. $ echo out | sudo tee -a /sys/class/gpio/gpio8/direction sets it to out. $ echo 1 | sudo tee -a /sys/class/gpio/gpio8/value should set the pin high.

My observation is that although the value file reads high, the voltage from the gpio pin is low.

If I change "8" to "60", I am able to control the pin, but the filesystem starts going funky, presumably because that pin was being used for something. Notably, pins shows: pin 60 (44e108f0.0) 00000030 pinctrl-single.

So my question is -- Why isn't pin 8 (gpio0[8], or P8.35) working?

Upvotes: 1

Views: 1653

Answers (1)

ToBeReplaced
ToBeReplaced

Reputation: 3584

I incorrectly thought that kernel pins were calculated as 32 * N + M for gpioN[M]. The kernel pin is determined by the offset from 44e10.

pin 8 above has offset 820, which corresponds to gpio0[22] and p8.19. If you export 22 and check p8.19, the desired result is produced.

Interestingly, much of the blogger documentation on this fact is incorrect. I will not link to those sites to prevent them from proliferating. On the other hand, this post was entirely accurate and helped me understand what was going on:

http://www.valvers.com/embedded-linux/beaglebone-black/step04-gpio/

Upvotes: 3

Related Questions