Configuring Pins Mode Beaglebone

Margarita Gonzalez picture Margarita Gonzalez · Jun 1, 2013 · Viewed 35.5k times · Source

In the beagleboard or beaglebone are different modes to work the pin. With the previous kernel they are located in /sys/kernel/debug/omap_mux. Do u know with the last Kernel where are those files?

Answer

Martin J.H. picture Martin J.H. · Jun 12, 2013

Don Branson's answer is a great introduction on how to read GPIO pins, but unfortunately it does not cover how you can change a pin's mode, e.g. from GPIO to SPI. This became more complicated with kernels 3.8.13 (?) and up. For a number of reasons, the kernel developers switched to the "device tree model".

As of now, the details on how to use the device-tree-models seem to be in flux, so I will only describe the general process. You start out by describing the pins that you want to interact with in a file called "device tree source". The pins and their modes are specified using hexadecimals numbers that you have to look up in the documentation of the processor.

You then compile this file using dtc into a "device tree binary" and place this binary into /lib/firmware. Finally, you enable the pin modes by echoing the name of the binary file (you can omit the .dtb extension) to /sys/devices/bone_capemgr.*/slots.

A very informative example is layed out in this great blogpost:

http://hipstercircuits.com/enable-spi-with-device-tree-on-beaglebone-black-copy-paste/

I will try to expand my answer as I learn more about this topic myself. Or maybe someone can suggest edits or hopefully even a more expansive answer of their own? The information that is currently available seems to be a bit sparse...

The best of luck to you!