Subscribe to Make Magazine Today!

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.


BeagleBone

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.

Matt Richardson

Matt Richardson

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.


53 Responses to How-To: Get Started with the BeagleBone

Your Thoughts?

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  1. miroslav von schlockbaum on said:

    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?

    • rocketguy1701 on said:

      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…)

      • 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.

    • 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. Pingback: Embedded Linux | Boondocks Electronics

  4. Pingback: BeagleBone | Boondocks Electronics

  5. Pingback: Twiddling an LED using the BeagleBone’s embedded Linux - Hack a Day

  6. Pingback: Twiddling an LED using the BeagleBone’s embedded Linux | ro-Stire

  7. Pingback: Twiddling an LED using the BeagleBone’s embedded Linux » Dirty Old Device

  8. Pingback: Twiddling an LED using the BeagleBone’s embedded Linux » Geko Geek

  9. 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. =(

  10. Pingback: Twiddling an LED using the BeagleBone’s embedded Linux | Orange Claymore Red Slime

  11. Pingback: Twiddling an LED using the BeagleBone’s embedded Linux « Hackaday « Cool Internet Projects

  12. 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).

    • Matt Richardson on said:

      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.

  13. Pingback: Beaglebone Coding 101: Buttons and PWM | GigaMegaBlog

  14. Pingback: matt richardson: How-To: Get Started with the BeagleBone

  15. “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) ?

    • Matt Richardson on said:

      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)

  16. Thanks for that.
    I am currently struggling with opkg errors (unstable feed)

    • Matt Richardson on said:

      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.

  17. Ram Radhakrishnan on said:

    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.

    • Matt Richardson on said:

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

  18. 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

  19. acasto on said:

    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.

    • Matt Richardson on said:

      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.

  20. Pingback: » Cracking PDF-file passwords using a BeagleBone board Wunderkammer

  21. Pingback: MAKE | How-To: LCD Controlled by BeagleBone

  22. 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).

  23. Pingback: Beaglebone(1) « stastaka's Blog

  24. Pingback: Embedded! « Adonis2101's Blog

  25. Pingback: Beaglebone and ExtJs Web App « Isola Software

  26. 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?

    • Matt Richardson on said:

      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.

  27. Pingback: MAKE | Innovate The Future With Texas Instruments

  28. Pingback: Getting Started with Beaglebone « Tayken's Blog

  29. Dipto on said:

    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.

  30. Pingback: MAKE | Makey Awards 2012 Nominee 03: BeagleBone, Hackable Gadgets

  31. sparkgimp on said:

    why would you want a Beagleboard rather than a raspberry pi?

  32. Pingback: So8ra6 - How-To: Get Started with the BeagleBone

  33. Pingback: How-To: Get Started with the BeagleBone | How to Videos, Articles & More |How To - Tips for your phone, tablet, computer, home theater

  34. Pingback: MAKE | New to BeagleBone?

  35. Pingback: New to BeagleBone?

  36. Emin Vilgenoğlu on said:

    Hi friends, I am new beaglebone user and I obtained PyBBIO from https://github.com/alexanderhiam/PyBBIO/wiki/Using-PyBBIO . I tried to implement the examples there. However there was a problem about “run” command. Could anyone help to me ?

  37. jhon arnold mateos on said:

    Hello, I´m trying to use the configuration of the PWM like input, can you help me please?

  38. jhon arnold mateos on said:

    Hello, Can i work without use the Linux system, i mean can i work with the Windows system also?

  39. Pingback: BeagleBone Update 3 Apr 13 | brain.rand()

  40. Pingback: BeagleBone usb console driver Mac OS X | fortune datko

  41. Andreas, OE8APR on said:

    “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??

  42. Pingback: Beaglebone links | Sonicherd Digital Blog

  43. Pingback: One BeagleBone Black for All Kinds of Weekend Projects! | MAKE

Related Supplies at Maker Shed