Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!

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 Brooklyn-based creative technologist, Contributing Editor at MAKE, and Resident Research Fellow at New York University’s Interactive Telecommunications Program (ITP). He’s the co-author of Getting Started with Raspberry Pi and the author of Getting Started with BeagleBone.


Related

Comments

  1. miroslav von schlockbaum says:

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

  2. Seth Meyers says:

    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. rocketguy1701 says:

      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. Seth Meyers says:

        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. [...] Geting started with BeagleBone, MAKE Magazine. [...]

  4. [...] Geting started with BeagleBone, MAKE Magazine. [...]

  5. [...] If you comfortable working with 8-bit microcontrollers, the thought of moving to a hardware platform running embedded Linux may be a bit daunting. After all, there’s a lot going on between you and the chips on a board like the BeagleBone seen above. But [Matt Richardson] shows how easy it can be to get at the pins on this device. He put together a primer on hardware control from the embedded shell. [...]

  6. [...] If you comfortable working with 8-bit microcontrollers, the thought of moving to a hardware platform running embedded Linux may be a bit daunting. After all, there’s a lot going on between you and the chips on a board like the BeagleBone seen above. But [Matt Richardson] shows how easy it can be to get at the pins on this device. He put together a primer on hardware control from the embedded shell. [...]

  7. [...] If you comfortable working with 8-bit microcontrollers, the thought of moving to a hardware platform running embedded Linux may be a bit daunting. After all, there’s a lot going on between you and the chips on a board like the BeagleBone seen above. But [Matt Richardson] shows how easy it can be to get at the pins on this device. He put together a primer on hardware control from the embedded shell. [...]

  8. [...] If you comfortable working with 8-bit microcontrollers, the thought of moving to a hardware platform running embedded Linux may be a bit daunting. After all, there’s a lot going on between you and the chips on a board like the BeagleBone seen above. But [Matt Richardson] shows how easy it can be to get at the pins on this device. He put together a primer on hardware control from the embedded shell. [...]

  9. Wulf says:

    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. [...] If you comfortable working with 8-bit microcontrollers, the thought of moving to a hardware platform running embedded Linux may be a bit daunting. After all, there’s a lot going on between you and the chips on a board like the BeagleBone seen above. But [Matt Richardson] shows how easy it can be to get at the pins on this device. He put together a primer on hardware control from the embedded shell. [...]

  11. [...] If you comfortable working with 8-bit microcontrollers, the thought of moving to a hardware platform running embedded Linux may be a bit daunting. After all, there’s a lot going on between you and the chips on a board like the BeagleBone seen above. But [Matt Richardson] shows how easy it can be to get at the pins on this device. He put together a primer on hardware control from the embedded shell. [...]

  12. mike hogan says:

    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. Matt Richardson says:

      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. [...] Beaglebone has also popping up on some popular hobbyist sites, like Make Magazine and [...]

  14. [...] latest how-to for MAKE is about getting started with BeagleBone, the open embedded Linux platform created by several employees of Texas [...]

  15. Jan says:

    “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. Matt Richardson says:

      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. Jan says:

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

    1. Matt Richardson says:

      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 says:

    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. Matt Richardson says:

      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. Sven says:

    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 says:

    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. Matt Richardson says:

      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. [...] embedded system retailing for about $85. For more information I recommend checking out the “Getting Started Guide” by Matt Richardson @ Make magazine, in addition to the official BeagleBone [...]

  21. [...] How-To: Get Started with the BeagleBone Share this: Pin ItLike this:LikeBe the first to like this post. Makers in this post:Nuno Alves [...]

  22. levyswluedu says:

    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. [...] first order of business was to test out IO. Using a multimeter and this great make article, running pyBBIO was trivial. So I decided to write my own library, in [...]

  24. [...] Quick start: http://blog.makezine.com/2012/03/14/how-to-get-started-with-the-beaglebone/ [...]

  25. scott says:

    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. Matt Richardson says:

      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.

  26. [...] We recently covered this promising product, and will continue to do so. It is a powerful, inexpensive, and tiny board that can be set up to run Linux in seconds. There is also a great community of developers creating applications and tools for it. At $89, it is definitely recommended to get you started with embedding Linux in your next project. [...]

  27. [...] you want to mess around a little more, Make Magazine has a nice blog post & video about using GPIO pins. Like this:LikeBe the first to like [...]

  28. Dipto says:

    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.

    1. Joe Doe says:

      I’d like to know this too.

  29. [...] default Angstrom Linux distribution. Sound interesting? Check out our own Matt Richardson’s Getting Started with BeagleBone tutorial, or pick one up in the Maker Shed (you’ll probably want the DVI-D Cape as [...]

  30. sparkgimp says:

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

  31. [...] info: http://blog.makezine.com/2012/03/14/how-to-get-started-with-the-beaglebone/   Tags: Beagle, beagleboard, beaglebone, blink, Board, Bone, electronics, ethernet, [...]

  32. [...] giving you a solid foundation. Previous to writing the piece for the magazine, Matt had done a great starter blog post that has a good comment thread you might want to check [...]

  33. [...] giving you a solid foundation. Previous to writing the piece for the magazine, Matt had done a great starter blog post that has a good comment thread you might want to check [...]

  34. Emin Vilgenoğlu says:

    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 ?

  35. jhon arnold mateos says:

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

  36. jhon arnold mateos says:

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

  37. [...] following the Make magazine‘s tutorial on getting started with the BeagleBone, but realized it was much more involved [...]

  38. [...] How-To: Get Started with the BeagleBone (makezine.com) [...]

  39. Andreas, OE8APR says:

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

  40. […] x x x x x x x x x x x x x x x x […]

In the Maker Shed