Other Boards Technology
How-To: Get Started with the BeagleBone

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:

Subscribe to How-Tos with Matt Richardson in iTunes, download the m4v video directly, or watch it on YouTube and Vimeo.

106 thoughts on “How-To: Get Started with the BeagleBone

  1. Very nice video. good timing to compare with the eventual arrival of the raspberry-pi. please make more that highlight the distinctions.

  2. Wow is this ever an eloquent exposition for why Linux-based ANYTHING just ain’t there yet for most of us. “Just type echo 38 to sys class gps export” Yikes.

    I *so badly* wanted to grok this, but there are just too many barriers there for me.

    Is the concept of an embedded Linux microcontroller inherently more powerful than Arduino’s friendlier playground? Does this power justify wading through Linux bumpf?

    Can someone familiar with both platforms talk about what Beagle can do that justifies all this Linux gibberish? Or is it just a case of use what you’re used to?

    1. Short version: Yes.

      Linux takes a while to understand, but it’s actually quite simple for the level of power it provides. Or perhaps not simple, but fairly elegant, given the complexity of a full fledged operating system.

      It is vastly more flexible and powerful than Arduino, but then, there are lots of things I’d rather use Arduino for. If it needs just a little brains- Arduino. If you need a webserver that could survive on the actual internet, attached to something with a lot of I/O’s, then the BB looks pretty attractive. (I’ve tried the Arduino webserver, it’s “cute” but not a real server by any means, and I cringe at the idea of having it out on a public address.)

      Just depends on how much computing power and software support you need to do the job. The BB is roughly equivalent to a modern low end computer with a huge software library, whereas the Arduino is equivalent to an Apple][, more or less. (I still have one, maybe someday I’ll benchmark them both…)

      1. Great analogy actually. and I did love my apple II.

        Two of the most attractive things about the arduino (for me) are the large number shields out there, and the vibrant support community. I guess beagle being linux has real advantages in terms of software library, code integration with bigger projects etc. and I guess once you get past hello world stage you can whip up all kinds of macros and shortcuts that make common basic operations look normal.

        I need to find a smoother beagle tutorial environment — the equivalent of the adafruit arduino tutorials would be ideal.

    2. Hi Seth,

      Don’t let the jargon prevent you from getting started with Linux. To be fair, Matt said “you type ‘echo 38 to sys class gpio…'” BUT at the same time the video shows:

      root@beaglebone:~$ echo 38 > /sys/class/gpio/export

      This is a simple way of writing “38” to a file. In Windows or Mac you can fire up a text editor, enter “38” and save it to that file. In fact, you could do that in Linux too. And you can use echo on Windows and Mac too. It is worth learning these commands, and Linux will never get rid of them (neither will Mac or Windows) because they make simple things (such as writing a value to a file) quick.

  3. After reading through the article and watching the video I am kind of embarrassed that I have no idea how I would still go around using this board…
    And I am coming from Computer Engineering background, currently working as a programmer.
    Maybe I should brush up on my Arduino skills. =(

  4. Any particular reason you didn’t use node.js and the BoneScript library? For rudimentary stuff, it’s a lot like Arduino. The cloud9 IDE is much better than Wiring (imho).

    1. I noodled around with node.js and BoneScript for quite a while, but had a very hard time wrapping my head around how to use node properly. I concluded (and perhaps incorrectly) that using Python meant that the code would be much easier to understand and much more Arduino-like. Also, when I started trying out BoneScript, digitalRead wasn’t yet implemented.

  5. “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.”

    Can you share how, specifically how to disable the bone.js running (under Angstrom) ?

    1. I decided I didn’t want to dismantle the bone.js server (yet) so I set lighttpd to listen for connections on port 81. (edit /etc/lighttpd.conf so that server.port is uncommented and set to 81)

    1. I’m not sure what that could be about. If you have the latest build of Angstrom installed, I would check with the BeagleBone Google Group or #beagle on the freenode IRC network.

  6. I wonder is anyone has attempted to program the BeagleBone without Linux, actually without any OS ? For those of us who like to “program on the metal” all the extra learning simply to flip a bit seems too much.
    Besides I bet all that OS overhead reduces the Port IO way down.

    1. That’s a good question, I don’t know if anyone has tried to program the board without Linux. But as I said in the video, using a Linux computer to blink an LED is definitely overkill. The true potential for the device comes out when you need to use complex TCP/IP protocols, file systems, secure remote login, and so on. It could be a lot of work implementing those features “on the metal.”

  7. Hi Matt,

    It is a great video! As a beginner to linux and embedded programming, it is the best source on the Internet that one can find. I hope you will post more source and documents for beaglebone.

    Thank you

  8. Having a decade+ of Linux sysadmin experience I’m really looking forward to trying out the BeagleBone. Once I get a bit more practical electronics under my belt I’ll probably go ahead and order one.

    1. Glad to hear it! People like you are well poised to take advantage of the platform. Because of all the power that Linux provides “out of the box,” that I think you’ll be doing awesome stuff in no time. Let us know how it goes.

  9. Thanks, Matt! I’d been looking for a quick getting-started tutorial on Beagleboard, and you did the job perfectly. Now I have the confidence to start on some more complicated projects (cameras, WiFi, OpenCV).

  10. I appreciate the simple video tutorial and the sample led examples you reference. In your current download file I noticed a mrbbio.pyo file. I assume this calls the pyo audio C-code? Do you have examples using this environment?

    1. The pyo files are a byproduct of the Python compiler. They’re optimized, precompiled files so that the compiler doesn’t have to keep recompiling the modules that don’t change. The Python experts out there can probably give a more exact explanation.

  11. I am buying a Beaglebone shortly, I was curious about the boot up sequence of the board, I think the reference manual does not state it clearly, my apologies if I have missed it out in the manual. I am looking for details like, which device it first looks into after power on, is it the EEPROM ? Then after that does it jump to the micro sd card, what is the address range of the micro SD etc.

    My objective of working on this board is to understand the Linux device drivers thoroughly. May be write my own I2C drivers instead of the existing one and so on. Thank you.

  12. Pingback: New to BeagleBone?
  13. “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.”

    How did you get PHP to work with I/O’s??

Comments are closed.


Matt Richardson is a San Francisco-based creative technologist and Contributing Editor at MAKE. He’s the co-author of Getting Started with Raspberry Pi and the author of Getting Started with BeagleBone.

View more articles by Matt Richardson