graycatlabs / PyBBIO

A Python library for Arduino-style hardware IO support on the Beaglebone
https://github.com/graycatlabs/PyBBIO/wiki
MIT License
251 stars 89 forks source link

GPIO configuration bug #109

Open jonturner53 opened 7 years ago

jonturner53 commented 7 years ago

It appears that in some cases, the order of pinMode calls affects the pin configuration. For example, a test program containing the following two lines

pinMode(GPIO0_2, OUTPUT, 0) pinMode(GPIO0_20, INPUT, 0)

works as expected. Specifically, in the pins file we find

pin 84 (44e10950) 00000007 pinctrl-single pin 109 (44e109b4) 0000002f pinctrl-single

pin number 84 corresponds to GPIO0_2 and 109 corresponds to GPIO0_20. However, if you reverse the order of the two pinMode calls, you get

pin 84 (44e10950) 00000007 pinctrl-single pin 109 (44e109b4) 00000007 pinctrl-single

That is, both signals are configured as outputs.

jonturner53 commented 7 years ago

Followup to my post. I have just discovered that while the pins file is not correct, it appears that the exported configuration in /sys/class/gpio is correct. In particular, the value of /sys/class/gpio/gpio_20/direction is "in", even though the pins file shows that signal as an output. ARGH!!!

So, it now appears that the bug may actually be in the Linux kernel. Or perhaps I am mistaken my understanding of the pins file.

If anyone out there understands what's going on, please enlighten me.

jonturner53 commented 7 years ago

Hit the wrong button. This issue is not closed.