I’ve had my eye on embedded Linux platforms for quite a while now, but wasn’t sure how to get started. When I saw that our own Maker Shed started carrying the BeagleBone I put in a call to get a trial unit. The system reference manual that comes with the board is a bit daunting, and isn’t meant as a getting started guide (despite the fact that there’s plenty of useful reference information in there). After a bit of researching online, I started to get the grasp of using Linux’s virtual file system, sysfs, to read and control the GPIO pins on the BeagleBone. In parallel, I taught myself just enough Python to script these operations. With a basic digitalRead and digitalWrite functions, I had many of the tools I needed to do some cool projects with the board.
However, I spent a lot of time going back and forth between my board, the system reference manual, and my script as I worked towards getting blinking LEDs and buttons. Translating between the physical pin on the header to the pin I’d be referencing in the script meant going through two steps of translation, which quickly became frustrating. I updated my Python functions to do this translation for me and packaged it up into its own module. I didn’t have the intention to make this module available publicly, but I figured it could be a lot of help to anyone who’s getting started. This module, mrBBIO, is available at Github and I welcome anyone to make any improvements to it. If you’re looking for something more advanced, check out PyBBIO, which uses memory registers to do the same thing.
Now that I’ve got a good grasp on this, I’m eager to start using it in a “real” project. I managed to get the lighttpd web server with PHP running and I even wrote a PHP script that could set pins high and low. This will make it so much easier to put my electronics projects online, something that can be quite a challenge to do on less capable microntrollers.
I couldn’t cover every possible detail involved in working with the BeagleBone’s GPIO pins, but I hope this list of resources will fill in any gaps:
- Nathan Dumont’s blog post on Hardware Interfacing on the BeagleBone was a huge breakthrough for me in figuring out how to control GPIO pins with sysfs.
- A lot of my Google searches lead me to The Embedded Linux Wiki at eLinux.org. There are some BeagleBoard and BeagleBone specific pages, but the other pages are a very helpful resource as well.
- Nuno Alves wrote a great post on how to load a new beaglebone OS into a SD card using Mac OS X
- For quick questions, the #beagle IRC channel on Freenode was a big help. You’ll find me lurking there if you need any help with this particular project. Just mention “MattRichardson” and I’ll get an alert.
- Akademii’s blog post on BeagleBone GPIO Testing helped me through a common pin multiplexing pitfall on the BeagleBone.
- GigaMegaBlog has a post about using serial and analog input on the BeagleBone. I haven’t dug into these topics much, but they may be good for people who want to get beyond digitalRead and digitalWrite. Be sure to check out all of the Beagle posts at GigaMegaBlog; there’s a lot of great content there.
- Alexander Hiam’s pyBBIO gave me a good idea of how to make the mrbbio module take a simple setup and loop function, just like Arduino code.
- Mark Lutz’s Learning Python, 3rd Edition helped me figure out how Python works.
Subscribe to How-Tos with Matt Richardson in iTunes, download the m4v video directly, or watch it on YouTube and Vimeo.