Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "EBC Exercise 11a Device Trees"

Jump to: navigation, search
m (Replaced GPIO with gpio)
m (Noted initials)
Line 17: Line 17:
  beagle$ '''cd ../overlay'''
  beagle$ '''cd ../overlay'''
  beagle$ '''cp DM-gpio-Test.dts ~/MAY-gpio-set.dts'''  // Copy to a place of your choice
  beagle$ '''cp DM-gpio-Test.dts ~/MAY-gpio-set.dts'''  // Copy to a place of your choice
                                                      // Use your initials
                                                // Use your initials instead of '''MAY'''
  beagle$ '''gedit MAY-gpio-SET.dts'''
  beagle$ '''gedit MAY-gpio-SET.dts'''

Revision as of 23:06, 17 September 2013

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:// 
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 instead of MAY
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. First check for errors.

beagle$ dmesg | tail
[   83.795688] pinctrl-single 44e10800.pinmux: pin 44e10990 already requested by 48038000.mcasp; cannot claim for helper.14
[   83.807174] pinctrl-single 44e10800.pinmux: pin-100 (helper.14) status -22
[   83.814392] pinctrl-single 44e10800.pinmux: could not request pin 100 on device pinctrl-single
[   83.823421] bone-pinmux-helper helper.14: Failed to select default state

Looks like I can't use that pin.

Then check the slots.

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