EBC Exercise 11a Device Trees

From eLinux.org
Revision as of 09:49, 17 September 2013 by Yoder (Talk | contribs) (Added more details)

Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder

The Device Tree (DT), and Device Tree Overlay are a way to describe hardware in a system. This introduction is heavily based on Adafruit's Introduction to the BeagleBone Black Device Tree using Derek Molloy's gpio example.

The purpose of this exercise is to learn how to set the pin mux and enable the pullup or pulldown resistors.

Pin Muxing

The am335x processor on the BeagleBone has more internal 'pins' than external pins. The solution is to have each external pin attached to a multiplexer that can be 'muxed' to one of eight internal pins. A nice chart that shows what can connect to where can be found by

beagle$ git clone git://github.com/derekmolloy/boneDeviceTree.git 
beagle$ cd boneDeviceTree/docs
beagle$ ls
BeagleboneBlackP8HeaderTable.pdf  BeagleboneBlackP9HeaderTable.pdf

These two pdf files show where each of the pins on the P8 and P9 headers can be muxed. The initial muxing is set at boot time using the Device Tree (DT). To change the pin mux we'll get an overlay that works and edit it.

beagle$ cd ../overlay
beagle$ cp DM-GPIO-Test.dts ~/MAY-GPIO-set.dts  // Copy to a place of your choice
                                                      // Use your initials
beagle$ gedit MAY-GPIO-SET.dts

Here's the part of the file we'll edit

   compatible = "ti,beaglebone", "ti,beaglebone-black";
   part-number = "MAY-GPIO-set";
   version = "00A0";

   fragment@0 {
       target = <&am33xx_pinmux>;
       __overlay__ {
           pinctrl_test: 'MAY-GPIO-set' {
       pinctrl-single,pins = <

           0x078 0x07  /* P9_12 60 OUTPUT MODE7 - The LED Output */
           0x184 0x2f  /* P9_24 15 INPUT  MODE7 none     - The Button Input */
           0x034 0x37  /* P8_11 45 INPUT  MODE7 pullup   - Yellow Wire */
           0x030 0x27  /* P8_12 44 INPUT  MODE7 pulldown - Green Wire */
           0x024 0x2f  /* P8_13 23 INPUT  MODE7 none     - White Wire */
           /* OUTPUT  GPIO(mode7) 0x07 pulldown, 0x17 pullup, 0x?f no pullup/down */
           /* INPUT   GPIO(mode7) 0x27 pulldown, 0x37 pullup, 0x?f no pullup/down */



beagle$ dtc -O dtb -o MAY-gpio-set-00A0.dtbo -b 0 -@ MAY-gpio-set.dts

Compiling the overlay from .dts to .dtbo


beagle$ cp MAY-gpio-set-00A0.dtbo /lib/firmware
beagle$ echo MAY-gpio-set > $SLOTS


Check to be sure it worked

beagle$ cat $SLOTS 
0: 54:PF--- 
1: 55:PF--- 
2: 56:PF--- 
3: 57:PF--- 
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
7: ff:P-O-L Override Board Name,00A0,Override Manuf,MAY-gpio-set

Now check with

beagle$ cd exercises/gpio
beagle$ ./findGPIO.js P8_12

{ name: 'GPIO1_12',

 gpio: 44,
 mux: 'gpmc_ad12',
 eeprom: 28,
 key: 'P8_12',
 muxRegOffset: '0x030',
  [ 'gpmc_ad12',
    'gpio1_12' ] }

pin 12 (44e10830) 00000027 pinctrl-single

Mode: 7 (gpio1_12) pulldown Receiver Active

Looks like it worked, now check the others.


It's appeared in slot 7. You can remove it with

beagle$ echo -7 > $SLOTS

Be careful though, the current versions appear unstable when removing this way.

thumb‎ Embedded Linux Class by Mark A. Yoder