Can’t find “newbie” section, so posting here…
Online examples (mainly, Cookbook, Chapter Sensors) have button press shorting GPIO pins to either
- 0V – if it was “1” default, or
- 3.3V – if it was “0” default.
I would detect the value by
gpioget --by-name P8_12 # chip=1, line=12 --> gpio44
gpioget --by-name P9_12 # chip=1, line=12 --> gpio60
Questions:
- P8_12 defaults to “0” or “inactive”, whereas P9_12 defaults to “1” or “active”. Is this hard wired? Or, is it set by U-Boot?
- Is “shorting” to 0V or 3.3V, the proper way to implement button press?
Have a look here and make sure you use a 100Ω resistor in series,
before you “short” anything to ground, in case the pin is an output.
Also, have a look at “kernel gpio-key”;
you’ll need the knowledge to make a proper device-tree overlay.
The repository for Beagle device-trees are here.
You’ll want to look under src/arm.
I get this part, but the rest is outside of my area. 
My reason for asking, why some pin float to “high” while other pins float to “low”, is that if the default flips to opposite, then I have flip the button also.
The behaviour of pins is squarely up to the function to which they is assigned,
so if you want to know what’s going on, make sure to check the schematic.
The AM335x processor has so many peripherals that most pins have up to 7
different modes besides “just” being a GPIO, so there really is no simple answer
to your question; it depends.
That’s why I pointed you towards the device-trees; they tell the kernel what mode to use.
Okay, I found where defaults are set.
src/arm/ti/omap/am335x-bone-common-univ.dtsi:
BONE_PIN(P8_12, default, P8_12(PIN_OUTPUT_PULLDOWN | INPUT_EN | MUX_MODE7))
BONE_PIN(P9_12, default, P9_12(PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE7))
As long as it doesn’t change, I’m fine. I’m certainly not going to touch it.
Yes, I settled on an easy to remember pair, P8_12 and P9_12, from
gpioinfo | grep -e chip -e '"P[89]_[0-9]*"'
This is when I noticed that P8_12 and P9_12 have opposite default values. Hence, my original question.
Follow up question:
Can you change the default value, after system has booted? Just in case, someone decides to change the .dtsi file.
1 Like
I don’t see anything stopping you from changing P8_12 to PIN_OUTPUT_PULLUP if you wanted.
If you want to be safe, make a copy of the file and use that in your setup; make it yours.