Difference between revisions of "EBC Exercise 11a Device Trees"
m |
m (→Verify: Fixed indentation) |
||
Line 77: | Line 77: | ||
beagle$ '''cd exercises/gpio''' | beagle$ '''cd exercises/gpio''' | ||
beagle$ '''./findGPIO.js P8_12''' | beagle$ '''./findGPIO.js P8_12''' | ||
− | { name: 'GPIO1_12', | + | { name: 'GPIO1_12', |
− | + | gpio: 44, | |
− | + | mux: 'gpmc_ad12', | |
− | + | eeprom: 28, | |
− | + | key: 'P8_12', | |
− | + | muxRegOffset: '0x030', | |
options: | options: | ||
[ 'gpmc_ad12', | [ 'gpmc_ad12', | ||
Line 92: | Line 92: | ||
'pr1_pru0_pru_r30_14', | 'pr1_pru0_pru_r30_14', | ||
'gpio1_12' ] } | 'gpio1_12' ] } | ||
− | pin 12 (44e10830) 00000027 pinctrl-single | + | pin 12 (44e10830) 00000027 pinctrl-single |
− | + | ||
− | Mode: 7 (gpio1_12) pulldown Receiver Active | + | Mode: 7 (gpio1_12) pulldown Receiver Active |
Looks like it worked, now check the others. | Looks like it worked, now check the others. |
Revision as of 13:53, 17 September 2013
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.
Contents
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 */ >; }; }; };
Compile
beagle$ dtc -O dtb -o MAY-gpio-set-00A0.dtbo -b 0 -@ MAY-gpio-set.dts
Compiling the overlay from .dts to .dtbo
Install
beagle$ cp MAY-gpio-set-00A0.dtbo /lib/firmware beagle$ echo MAY-gpio-set > $SLOTS
Verify
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', options: [ 'gpmc_ad12', 'lcd_data19', 'mmc1_dat4', 'mmc2_dat0', 'eqep2a_in', 'pr1_mii0_txd2', 'pr1_pru0_pru_r30_14', 'gpio1_12' ] } pin 12 (44e10830) 00000027 pinctrl-single Mode: 7 (gpio1_12) pulldown Receiver Active
Looks like it worked, now check the others.
Removing
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.
Embedded Linux Class by Mark A. Yoder