Wednesday, June 5, 2013

BeagleBone Black, Linux 3.8, and Device Tree

I have been working to get the hardware side of things running under the Linux 3.8 kernel with device tree, which is pretty much required for the BeagleBone Black.  Since LinuxCNC requires the Xenomai patches, and there is a known bug with these patches on the Linux 3.2 kernel, even the BeagleBone White will need Device Tree support in the near future.

Anyway, I have successfully gotten the PRU and GPIO ports functioning as required under Linux 3.8, using a device tree overlay.  The pins that conflict with the on-board MMC on the Black have been commented out, as I am not yet sure the MMC is held in reset if you don't load it's driver.  If you would like to try out the device tree overlay, you can do so without the full LinuxCNC install.  The general procedure is:
  • Add "capemgr.disable_partno=BB-BONELT-HDMI" to your Linux kernel command line in uEnv.txt.  If you're using an SD card, this should be reasonably straight-forward.  If you're booting the Black from it's on-board MMC, it seems to have a default compiled-in configuration you need to over-ride somehow.  I don't currently know how to do this...if you have any details, let me know!
  • Reboot your system, and verify the HDMI cape is not loaded.  It will still show up in the slots file, but there won't be an "L":
    $ cat /sys/devices/bone_capemgr.*/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-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI 
  • As root, execute the BeBoPr.setup.sh script to export the GPIO pins.  This makes sure they are initialized properly (ie: their clock has been enabled and the GPIO registers were taken out of reset).  Without this step, you will get cryptic errors like:
    Unhandled fault: external abort on non-linefetch (0x1018) at 0xb6d1e134
    When you try to talk to the memory-mapped GPIO control registers.
At this point, you are ready to run code that directly talks to the PRU and GPIO pins (see the dts file for which pins are muxed to the PRU and which pins are GPIO).  If you're running LinuxCNC, just run linuxcnc and select the BeBoPr configuration.  If you are writing your own code, now is the time to make it do it's thing!

I hope to get the analog inputs sorted fairly soon.  I have them working with the stock cape-bone-iio overlay, but this throws away a bunch of ADC resolution (0-1800 instead of 0-4095).  I'm working on fixing that without having to write a kernel driver, and I'll try and hook it into LinuxCNC HAL via python like I did under the 3.2 kernel.

Stay tuned!!!

No comments:

Post a Comment