Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

BeagleBone For Dummies
BeagleBone For Dummies
BeagleBone For Dummies
Ebook763 pages5 hours

BeagleBone For Dummies

Rating: 0 out of 5 stars

()

Read preview

About this ebook

The definitive, easy-to-use guide to the popular BeagleBone board

BeagleBone For Dummies is the definitive beginner's guide to using the popular BeagleBone board to learn electronics and programming. Unlike other books that require previous knowledge of electronics, Linux, and Python, this one assumes you know nothing at all, and guides you step-by-step throughout the process of getting acquainted with your BeagleBone Original or BeagleBone Black. You'll learn how to get set up, use the software, build the hardware, and code your projects, with plenty of examples to walk you through the process. You'll move carefully through your first BeagleBone project, then get ideas for branching out from there to create even better, more advanced programs.

The BeagleBone is a tiny computer board – about the size of a credit card – that has all the capability of a desktop. Its affordability and ease of use has made it popular among hobbyists, hardware enthusiasts, and programmers alike, and it's time for you to join their ranks as you officially dive into the world of microcomputers. This book removes the guesswork from using the popular BeagleBone board and shows you how to get up and running in no time.

  • Download the operating system and connect your BeagleBone
  • Learn to navigate the desktop environment
  • Start programming with Python and Bonescript
  • Build your first project, and find plans for many more

To learn BeagleBone, you could spend hours on the Internet and still never find the information you need, or you can get everything you need here. This book appeals to all new and inexperienced hobbyists, tinkerers, electronics gurus, hackers, budding programmers, engineers, and hardware geeks who want to learn how to get the most out of their powerful BeagleBone.

LanguageEnglish
PublisherWiley
Release dateJan 26, 2015
ISBN9781118992920
BeagleBone For Dummies

Related to BeagleBone For Dummies

Related ebooks

Hardware For You

View More

Reviews for BeagleBone For Dummies

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    BeagleBone For Dummies - Rui Santos

    Getting Started with the BeagleBone

    9781118992913-pp0101.tif

    webextras.eps Visit www.dummies.com/cheatsheet/beaglebone for additional For Dummies content and resources.

    In this part …

    Getting to know the BeagleBone and all its features

    Discovering other components that you may need

    Preparing your BeagleBone with the latest operating system

    Booting your BeagleBone for the first time

    Getting started in digital electronics by blinking an LED

    Chapter 1

    Introducing the BeagleBone

    In This Chapter

    arrow Getting acquainted with the BeagleBone

    arrow Exploring the key differences between the two BeagleBone versions

    arrow Exploring the possibilities the BeagleBone offers

    arrow Determining what else you need

    Welcome to the world of BeagleBone, the low-cost embedded Linux computer for hobbyists and developers used by hundreds of thousands of people all around the world

    The BeagleBone is a tiny board, but don’t be fooled by its size: Its potential is huge. That board has a brain — the processor — that’s almost as smart as the latest popular smartphones, yet you can buy the BeagleBone at a fraction of the cost. Use it to control your home remotely, host your own server, or build a robot. You’re limited only by your imagination.

    Actually, there’s no right or wrong way to use this small computer. Some people want to use it for programming; others want to use it find out about electronics. Still other people (such as the authors of this book) prefer to mix the two worlds to produce some awesome projects.

    The day this tiny board hit the market, the price for entrée into the world of programming and electronics was significantly lowered — both in terms of actual money and in terms of ease of understanding. With the BeagleBone’s easy-to-use libraries and project examples, a novice can start creating a project in no time.

    technicalstuff.eps If you’re already familiar with these concepts — in the sense that you’ve worked with a microcontroller before, such as an Arduino — you’ll find that the BeagleBone can help you one-up your projects because it offers a lot more computational power and, consequently, a lot more capabilities than the Arduino and similar microcontrollers. With the BeagleBone, there are very few hardware limitations or software constraints, so you are able to tackle the most ambitious projects.

    With an ever-growing community of makers, designers, and programmers around the world sharing their projects on the Internet, the BeagleBone is hands down one of the best ways to express your enthusiasm for technology. We highly encourage that you share your knowledge with others when you get to that point.

    Touring the Original BeagleBone and the BeagleBone Black

    When you first get your BeagleBone, you’ll find the board and a Mini USB cable inside the box. If you purchased an Original BeagleBone, you also get a 4GB microSD card. That’s everything you need to get started, along with your computer.

    There are two distinct versions of the BeagleBone: the Original BeagleBone and the BeagleBone Black. The two boards are similar except for a few small details, which we explain in the next two sections of this chapter.

    remember.eps The contents of this book will generally make sense whether you’re using the Original BeagleBone or the BeagleBone Black. Whenever there’s a need to differentiate the two, we do so appropriately.

    tip.eps Another familiar, common designation on the web for the BeagleBone Black is BBB. We don’t use that designation throughout this book, but you may find it often if you do online research about matters related to the BeagleBone Black.

    Whenever we simply use the term BeagleBone, there’s no difference between the two versions with regard to the concept we’re exploring.

    At a first glance, you may feel intimidated about grabbing such bare boards (see Figure 1-1 and Figure 1-2). They are so tiny and seemingly fragile, yet so powerful. Certainly, you’re curious to understand all the tiny components sitting on top of your BeagleBone.

    Following are the components featured in both the Original BeagleBone and the BeagleBone Black:

    Processor: You can call the processor the brains of your BeagleBone. Both boards feature an ARM Cortex-A8 operating at a maximum speed of 720MHz for the Original BeagleBone and 1GHz for the BeagleBone Black. This means that the latter makes a decision/calculation every 0.000000001 second!

    RAM: The Original BeagleBone has 256MB of DDR2 (Double Data Rate 2), whereas the BeagleBone Black has 512MB of DDR3.

    9781118992913-fg0101.tif

    Photo courtesy of Adafruit Industries

    Figure 1-1: The Original BeagleBone.

    microSD card slot: The Original BeagleBone doesn’t have any built-in memory, so it always needs to have a microSD card inside to be able to work. By default, it comes with a 4GB microSD card. The BeagleBone Black doesn’t come with a microSD card because it has built-in memory. Regardless, you can still insert a microSD card into it to install or update your operating system or because you want to have more available memory to play around with.

    DC power connector: Your BeagleBone needs 5 volts (V) and 500 milliamps (mA) of direct current to power up.

    tip.eps Connecting the BeagleBone to your computer with a USB cable also provides the necessary power for the board to power up.

    warning.eps If you have a connector that fits into your BeagleBone connector, that doesn’t necessarily mean that it’s the right power adapter! Not all power adapters provide exactly 5V; some of them actually provide 12V. You also need to check for the connector’s polarity; the center ring has to provide the 5V and the outer ring has to provide Ground (GND). You need to be careful. Even though the board has a voltage regulator, feeding it excess power or wrong polarity could permanently damage it!

    9781118992913-fg0102.tif

    Figure 1-2: The BeagleBone Black.

    USB client: Both boards offer an USB client for powering up, communications, and debugging.

    USB host: Both boards include one USB port. This port enables you to connect peripherals such as a keyboard or a USB stick.

    Ethernet: Both boards feature a standard RJ45 Ethernet port. By plugging an Ethernet cable in it and connecting the BeagleBone directly to a router or by sharing the Wi-Fi connection of your computer, you can easily manage software on your BeagleBone, as well as build projects that require an Internet connection.

    Headers: The BeagleBone headers, labeled P8 and P9, can be used in many ways. You can use them to insert capes or supply power, for example, and you can program them to establish communications with other devices or act as inputs or outputs.

    USR LEDs: The USR LEDs indicate the status of your board:

    USR0: Blinks for as long as the system is running

    USR1: Blinks whenever the microSD card is being accessed

    USR2: Blinks to indicate that the central processing unit (CPU) is active

    USR3: For the BeagleBone Black, this LED blinks when the eMMC (embedded MultiMediaCard) memory is being accessed

    Reset button: This button resets your board when you press it. Keep in mind, though, that your BeagleBone is just like a regular computer; you should reboot it this way only when it crashes.

    Besides the previously mentioned components, the BeagleBone Black has a few additional components (refer to Figure 1-2). These are:

    eMMC: The eMMC memory is the built-in memory on your BeagleBone Black. The amount you have depends on your BeagleBone Black’s revisions (Rev):

    BeagleBone Black Rev A and B: 2GB of eMMC memory

    BeagleBone Black Rev C: 4GB of eMMC memory

    Micro HDMI: This port is used to connect your BeagleBone Black to a computer display or a television set.

    Serial header: The BeagleBone Black has a separate header for one of its serial ports, enabling you to easily connect a USB-to-TTL serial cable (read Chapter 3 for more on this topic).

    Power button: If you press the power button, the board shuts down after a few seconds. You can turn it ON once more by pressing the power button again. You can also do a full power cycle by pressing the board for about 10 seconds; the board turns OFF and then comes back ON. You should avoid this, though, as it may corrupt the eMMC or SD card. Use it only if your board is not responding to your commands.

    User boot button: By default, your BeagleBone Black boots from onboard memory with the operating system (OS) installed there. By holding down this button when you power the board, you indicate that you want it to boot from the microSD card. You also use this button to install an operating system on the eMMC.

    remember.eps If you’re buying a BeagleBone now, it’s very unlikely that you’ll find an Original BeagleBone.

    tip.eps You can find all the boards available if you visit http://beagleboard.org/boards. At the bottom of the page, you also see a table that compares the features of the boards. Additionally, at that same link you can find distributors all around the world that have the BeagleBone Black (and perhaps the other boards) available for purchase.


    Original BeagleBone and BeagleBone Black interfaces

    If you’re an advanced user, knowing the supported interfaces is often quite important, so they’re listed here. If the following list makes no sense to you, don’t worry; the book covers some of these concepts. For now, the important thing to know is that both the Original BeagleBone and the BeagleBone Black support a huge number of different interfaces, enabling you to connect with most devices and components.

    The following list includes interfaces featured on both boards:

    4x UART

    8x PWM

    LCD

    GPMC

    MMC1

    2x SPI

    2x I2C

    A/D converter

    2x CAN

    Bus

    4 timers

    Additionally, the Original BeagleBone features two other interfaces:

    FTDI USB to serial

    JTAG via USB



    Discovering the BeagleBoard and BeagleBoard-xM

    The BeagleBoard appeared on the scene in 2008. The BeagleBoard xM showed up two years later. These two boards differ somewhat from the BeagleBone Black and the Original BeagleBone, so this book wasn’t written with support for these platforms in mind.

    Despite being older, these boards still offer a lot of capabilities and may even be advantageous for some very specific, high-end projects. For hobbyists, however, the BeagleBone Black is hands down the best option due to its reduced cost and great versatility. Also, it’s a much better tool to use to get initiated in electronics and computation.


    Exploring Uses for the BeagleBone

    The BeagleBone is one of the best tools to use to discover programming and electronics. It’s also a good way to see and understand more closely how a computer works. Throughout this book, you explore some of the many capabilities that this board offers.

    You can create electronics projects, for example, by using BoneScript (see Chapters 7 and 8) and Python (see Chapters 9 and 10). You can use the BeagleBone to build a web page (see Chapter 13) and to run a home automation webserver (see Chapter 15). You can build projects to automatically access your email, notify you when a new one arrives and display it on an external screen (see Chapter 14).

    You can control your BeagleBone remotely with the Linux terminal (see Chapter 4) and even set up the BeagleBone Black as a desktop computer (see Chapter 12). For such a low-cost device, the variety of uses for the BeagleBone is nothing short of amazing. And all these ideas are just scratching the surface. Just as a beagle is often a person’s best friend, so is your imagination when it comes to playing around with the BeagleBone.

    Accessorizing Your BeagleBone

    Digital Electronics can quickly become an expensive hobby, but to get started, you need to spend only a few bucks on a BeagleBone Black. With a BeagleBone Black and a Mini USB cable, you have everything you need to create your first project: making the onboard LEDs blink. Don’t feel overwhelmed by all the accessories listed in this section, because you don’t need all of them right out of the gate. You may find that you already have most of these accessories on hand, so you may need to purchase only some of the accessories to complete our projects.

    Here’s a list of all the accessories you may need for the projects covered in this book:

    USB A–to–Mini B cable: The BeagleBone comes with one Mini USB cable. This cable not only powers up your BeagleBone, but also enables you to connect your BeagleBone to your computer. (Read more about this topic in Chapter 3.)

    microSD card: The Original BeagleBone doesn’t have any kind of internal memory, so you need a microSD card to install and run the operating system; the Original BeagleBone already comes with a microSD card. On the other hand, the BeagleBone Black Rev A and B have 2GB of built-in memory, and Rev C has 4GB. The operating system can be run on the built-in memory and so these boards don’t include a microSD card in their standard package

    tip.eps You must have a microSD card to install a new operating system or to update the existing one, however. We recommend that you get a branded microSD card with at least 4GB of storage for your BeagleBone Black.

    microSD card adapter and writer: Most computers have a slot for SD cards, so you can insert your microSD card into a microSD card adapter (see Figure 1-3) and connect it to your computer. If your computer doesn’t have an SD card slot, you might consider buying an SD card writer.

    9781118992913-fg0103.tif

    Figure 1-3: A microSD card, microSD card adapter, and external SD card writer.

    tip.eps There are many different types of microSD cards and SD card writers. Generally, their prices are based on the speed at which data is written on them. We recommend that you go for branded versions of both the writer and the card, and that you get at least a class 4 microSD card.

    Ethernet cable: Connecting your BeagleBone to your router with an Ethernet cable enables you to install and update software; additionally, the BeagleBone is a great platform to create Internet-related projects. It also provides you an extra way to control your BeagleBone remotely. (Read more about this topic in Chapter 3.)

    5V DC power supply: The BeagleBone can be powered up with a Mini USB cable by just being connected to your computer, but if you want to use your BeagleBone at maximum performance, capability, and featuring lots of USB peripherals — and/or for portable applications — we recommend that you use the 5V barrel connector. The power adapter that’s required needs to provide 5V over a 5.5mm outer diameter and 2.1mm inner diameter. It must supply a minimum of 500 mA to power up your BeagleBone.

    tip.eps A USB connection provides either 500 mA or 900 mA of current (depending on whether it is USB 2.0 or USB 3.0). This is generally enough to have a BeagleBone connected through Ethernet and powering several electrical components. However, if you connect many USB peripherals, you are advised to go for an external 1.2A to 2A power supply.

    Display: Most displays with an HDMI output work with the BeagleBone Black. You can also buy an LCD cape that’s specially designed to act as a display (see Chapter 6).

    remember.eps Not all displays are compatible with the BeagleBone Black. Make sure that you carefully read the sidebar at the end of this chapter to find out more about compatible accessories.

    The Original BeagleBone doesn’t have a built-in Micro HDMI port. Worry not, though: You can still output image and sound with an LCD cape.

    HDMI–to–Micro HDMI cable: If you have a BeagleBone Black with an HDMI–to–Micro HDMI cable, you can output video and sound to a display (see Figure 1-4).

    USB keyboard and mouse: Most standard USB keyboards and mice are compatible with the BeagleBone. Keep in mind, though, that the board has only a single USB host port, so you have to connect a USB hub if you want to add more than one peripheral (see Figure 1-4).

    9781118992913-fg0104.tif

    Figure 1-4: BeagleBone Black as a desktop computer, connected to a display, a mouse, and a keyboard.

    USB hub: The USB hub enables you to expand the number of USB ports on your BeagleBone. This accessory is essential if you want to have multiple peripherals connected at the same time (see Figure 1-4).

    USB-to-TTL serial cable: If you have a BeagleBone Black, this cable could be useful to debug your BeagleBone Black during the booting process.

    tip.eps The Original BeagleBone has this feature built in, so you don’t need the extra cable.

    Other cables: If your display doesn’t have an HDMI output, you may be able to use a Micro HDMI-to-VGA or Micro HDMI-to-DVI converter. That way, you can repurpose your old desktop display.

    warning.eps Using converters for the Micro HDMI adds a whole other layer of incompatibilities. We recommend that you check our sidebar at the end of this chapter.

    Case: The BeagleBone arrives without a case, and some people actually prefer that look and feel, but it’s important that your board stay away from static electricity, conductive metal, and liquids. It’s a piece of electronics, after all. The best way to protect your BeagleBone is with a case.

    Breadboard: Using a solderless breadboard is the best way to prototype. It’s really easy to use, as it doesn’t require any soldering. That means that you don’t make any permanent connections and can easily modify your circuit at any time.

    Multimeter: A multimeter is a useful device that measures many things related to electricity.

    Soldering iron: Solder is a metal that liquefies easily when heat is applied to it and quickly goes solid again the moment it’s exposed to air temperature. A soldering iron is used to melt solder to establish permanent metallic connections.

    Other components: Some projects in this book use extra components such as LEDs, servos, motion sensors, and electrical wires. You don’t need to get anything right away; we tell you when the time is right.


    tip.eps Compatible accessories for the BeagleBone Black

    If you’re looking for additional information regarding compatible accessories for your BeagleBone Black, visit http://elinux.org/Beagleboard:BeagleBone_Black_Accessories.

    Note: The accessories listed on that web page aren’t the only compatible accessories that exist, but the ones that are listed have been verified to work with the BeagleBone Black. If your accessory is not working properly, but you find its name on that list, then you can be sure that the problem is not an incompatibility, and you can continue to troubleshoot.


    Chapter 2

    Installing the Operating System

    In This Chapter

    arrow Getting to know Linux

    arrow Obtaining your Linux distribution

    arrow Preparing your microSD card

    arrow Preparing the onboard eMMC

    The BeagleBone is a tiny computer with all the features of today’s computers, which ultimately means that it also needs an operating system (OS). Because BeagleBone is an open-hardware project, it runs on Linux — an open-source OS. Using free software makes using the board less expensive and creates the perfect tool to use to learn programming.

    As with any other computer, you can use a BeagleBone to store files, surf the web, install applications, and do pretty much all the everyday stuff that you’re used to doing. The real advantage of your BeagleBone over a typical computer, however, is that the BeagleBone has input and output pins that bridge the gap between the realms of computing and electronics. With a BeagleBone, you can create and control interesting electronic projects with a very high degree of complexity. After all, the foundation of your project is a computer. Also, because the BeagleBone is a low-cost device, it doesn’t cost a fortune to replace it if you somehow break it!

    This chapter explains which distribution of Linux to use, as well as where you can download it and how to install it. In Chapter 4 and Chapter 12, you dive deeper and see how to use the Linux shell and its desktop environment.

    tip.eps If your BeagleBone has just arrived, and you haven’t done anything with it yet, your board already has a fresh OS installed. To prevent unexpected issues, however, you should be running the latest version of the same OS shown in this book, so we recommend that you follow the instructions in this chapter to ensure that everything throughout the book works for you.

    tip.eps The BeagleBoard Black comes from the factory with an empty microSD card slot. We highly recommend that you buy a microSD card with at least 4GB of storage to install the new Linux distribution as described in this chapter. If you have a 2GB card handy, however, you can use it to get started. Keep in mind, though, that there’ll be very little space left on the card after you install Linux. You’ll be able to use it to work through the procedures in the following chapters, but eventually, you’ll need more memory.

    Introducing Linux

    Linux was created as a free OS for personal computers. Because of its many advantages, it quickly made its way into a plethora of applications. Nowadays, Linux is used on a wide range of hardware platforms, such as mobile phones, tablets, embedded systems, servers, and routers.

    Linux is a good example of the strength of an open-source community. No company developed this OS. Instead, thousands of people all around the world contributed their knowledge to create and improve this software — at no cost at all.

    Linux is hands-down the most popular software around for programmers and developers, mainly because anyone can have full access to the code, modify it, study it, and distribute it. Read Chapter 4 for a more detailed description of Linux, including its advantages and proper use.

    remember.eps The Linux kernel is the core of your computer’s software. It’s the lowest level of software that interfaces with the hardware; it’s the code that controls everything, translating whatever you do on your computer into a language that the hardware can understand.

    Selecting a Distribution

    A distribution is a complete Linux package that contains the Linux kernel and a couple of other pieces of open-source software that provide a wide variety of functionalities.

    Knowing the factory defaults on your BeagleBone

    technicalstuff.eps We recommend that you follow the instructions in this chapter to install the latest Debian distribution, which is used throughout this book. Every new BeagleBone is configured to work out of the box by default, however. The original configuration depends on your board:

    The Original BeagleBone includes a microSD card that has the Ångström distribution installed.

    BeagleBone Black ships from the factory with Linux installed on the board’s eMMC memory and with an empty microSD card slot, which we recommend that you use to install Debian.

    The Linux distribution depends on the board version:

    BeagleBone Black Rev A and Rev B have Ångström installed in the built-in memory.

    BeagleBone Black Rev C comes with Debian preinstalled.

    We opted to use the Debian distribution for this book because Debian currently is the most-supported distribution in this embedded platform. The next sections of this chapter walk you through the procedure for installing Debian.

    technicalstuff.eps If you want to see a list of all OSes that are fully compatible with BeagleBone, visit http://elinux.org/Beagleboard:BeagleBoneBlack#Software_Resources.

    warning.eps Even though there are plenty of similarities between one Linux distribution and the next, there are also a few differences. The commands presented through this book assume that you’re using Debian, which means that some of the commands that we present won’t work in other distributions.

    Downloading your Linux distribution

    You need to use a computer to download the distribution from the Internet and flash your microSD card. (Flashing is the process used when you completely rewrite a data storage device rather than simply saving files on it.) You can use a Windows, Mac OS X, or Linux computer; we illustrate how to prepare your microSD card on all three systems. You can find the official distributions available for download at http://beagleboard.org/latest-images.

    The distribution you need to work with on this book depends on how you intend to run Linux and is subject to change with future releases. Regardless, the process of downloading the newest image should be very similar, as should the respective filenames. You have two alternatives:

    If you’re booting Linux from a microSD card on a BeagleBone Black or an Original BeagleBone, download Debian using the file labeled as Debian (BeagleBone, BeagleBone Black – 2GB SD) 2014-05-14.

    If you’re booting Linux from your BeagleBone Black’s eMMC memory, download Debian eMMC flasher using the file labeled as Debian (BeagleBone, BeagleBone Black – 2GB eMMC) 2014-09-04.

    If you have a BeagleBone Black and, thus, the chance to flash the eMMC memory, we recommend that you use the second option, which not only increases system performance, but is also much more practical. You won’t need to have the microSD card with you at all times.

    tip.eps If you don’t want to reflash the eMMC memory on the BeagleBone Black — in other words, if you want to keep the factory default OS — you can choose the standard Debian image and boot the OS directly from the microSD card.

    You can download the distribution in two ways. The first way is much simpler but may take some more time than the second way. Here are your options:

    Web browser: You can download the distribution directly from your web browser by clicking the distribution name. When you click the name of the distribution, a new web page opens. After about 3 seconds, your file should start downloading.

    BitTorrent: BitTorrent enables you to download larger files faster. It gathers all the small pieces of the file you want and starts downloading your file from people who already have them, maximizing the transfer speed. To use this method, you must have a BitTorrent application on your computer. When you open the BitTorrent link, a torrent file that’s compatible with the BitTorrent application is downloaded to your computer.

    tip.eps You can find a free BitTorrent application that works in all three OSes at www.utorrent.com.

    Decompressing your Linux distribution

    The Linux distribution you download is compressed in an .xz file. You have to decompress the .xz file so that you can access the .img file contained inside. The procedure you use to decompress the file depends on your computer’s OS.

    Windows

    If you’re using a Windows PC to decompress your Linux distribution, you need to install the application 7-Zip. Follow these steps:

    Go towww.7-zip.org/download.html.

    Download the.exefile.

    Run the.exefile to install 7-Zip.

    With 7-Zip installed, you’re ready to decompress your .xz file. Follow these steps:

    Open the 7-Zip application.

    Click the Extract icon.

    The Extract dialog box opens (see Figure 2-1).

    9781118992913-fg0201.tif

    Figure 2-1: Decompressing your Linux distribution by using 7-Zip for Windows 8.1.

    Navigate to the folder where you saved your Linux distribution.

    Save the file in your preferred folder, and click OK.

    Your .img file is extracted.

    Mac OS X

    If you’re using a Mac to decompress your Linux distribution, follow these steps:

    Go to the App Store.

    Search for and install the free application The Unarchiver.

    Navigate to your Downloads folder.

    Double-click your.xzfile.

    The decompressing process starts immediately.

    Linux

    If you’re using Linux, you don’t need to install a new decompression application because Linux already has built-in software that can decompress .xz files. You see how to extract the .img file in Linux later in section "Flashing a microSD Card in Linux."

    Flashing and Inserting

    Enjoying the preview?
    Page 1 of 1