Book Image

BeagleBone Black Cookbook

Book Image

BeagleBone Black Cookbook

Overview of this book

There are many single-board controllers and computers such as Arduino, Udoo, or Raspberry Pi, which can be used to create electronic prototypes on circuit boards. However, when it comes to creating more advanced projects, BeagleBone Black provides a sophisticated alternative. Mastering the BeagleBone Black enables you to combine it with sensors and LEDs, add buttons, and marry it to a variety of add-on boards. You can transform this tiny device into the brain for an embedded application or an endless variety of electronic inventions and prototypes. With dozens of how-tos, this book kicks off with the basic steps for setting up and running the BeagleBone Black for the first time, from connecting the necessary hardware and using the command line with Linux commands to installing new software and controlling your system remotely. Following these recipes, more advanced examples take you through scripting, debugging, and working with software source files, eventually working with the Linux kernel. Subsequently, you will learn how to exploit the board's real-time functions. We will then discover exciting methods for using sound and video with the system before marching forward into an exploration of recipes for building Internet of Things projects. Finally, the book finishes with a dramatic arc upward into outer space, when you explore ways to build projects for tracking and monitoring satellites.
Table of Contents (16 chapters)
BeagleBone Black Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Package management – Installing packages using apt-get


If you are a newcomer on Linux, you will find that managing software on your BBB is a very different experience from the one on your Windows or Mac box. Linux distributions have a very different sensibility when it comes to installing and supervising your software.

In some ways, it is akin to what your smart phone universe is like: you go to a centralized place (Google Play, App Store, and so on) and download a vetted application.

Of course, there are huge differences in Land o' Linux. Firstly, everything is free. Secondly, everything is (mostly) open source. Thirdly, pieces of your package—dependencies, libraries, and so on—that evolve and improve are treated as separate entities that only need to be conjoined when you are ready to actually install a piece of software.

This means that you're always getting the freshest, most stable build. Whereas in Closed Source Land, executables are built to be self-contained. Any new module or better library that is built after the binary was compiled….well, too bad. You will have to wait for the next release, whenever that might be. And then you have to pay for the upgrade.

Software applications for Linux are referred to as packages. Henceforth, we will mainly use the term package in lieu of application. In this section, we will learn the basics of package management through the following topics:

  • Updating packages

  • Upgrading packages

  • Installing packages

Note

These recipes assume that you have internet connectivity working via any of the methods explained in the earlier Connectivity section.

For our recipes throughout this book, we will principally use the apt-get command for package management. Although there are other methods, apt-get is the easiest and most common way to handle packages for a beginner.

Getting ready

Use the following steps to install packages:

  1. Updating packages: Before actually installing new software in Linux, it's best practice to ensure that you have downloaded the most current versions of your local package lists along with information about their dependencies. You execute one of the most common commands in the Linux repertoire:

    $ sudo apt-get update
    

    As a result of this command, we get a resynchronized package index file that is targeted not only at your specific Linux distributions, but your hardware environment as well. For the BBB, this means that your package manager knows to only grab packages that are Debian-savvy and compatible with the Arm board architecture.

  2. Upgrading packages: Next, you want to grab and upgrade to new versions of the packages already installed on your BBB, which the apt-get update will presumably have chronicled, through the following command:

    $ sudo apt-get upgrade
    
  3. Finally, you get to install your new whizzy tool or app! Use this command:

    $ sudo apt-get install pkg_name
    

How to do it…

Let's do a real package, though, one that we will be using in a later chapter. For our recipes focused on debugging in Chapter 3, Physical Computing Recipes Using JavaScript, the BoneScript Library, and Python, we will use a tool called gdb, also known as GNU Debugger, which is a standard tool in the Linux arsenal thus:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install gdb

Once you've installed the pretty package on your BBB, it's useful—and often interesting—to take a peek inside. So, another apt-get variant gives you some interesting insight:

$ sudo apt-cache show package-name

In our case, this would be as follows:

$ sudo apt-cache show gdb
Package: gdb
Version: 7.4.1+dfsg-0.1
Installed-Size: 5192
Maintainer: Hector Oron <[email protected]>
Architecture: armhf
Depends: libc6 (>= 2.13-28), libexpat1 (>= 2.0.1), libgcc1 (>= 1:4.4.0), libncurses5 (>= 5.5-5~), libpython2.7 (>= 2.7), libreadline6 (>= 6.0), libtinfo5, zlib1g (>= 1:1.2.0), gdbserver
Suggests: gdb-doc
Description-en: The GNU Debugger
 GDB is a source-level debugger, capable of breaking programs at
 any specific line, displaying variable values, and determining
 where errors occurred. Currently, gdb supports C, C++, D,
 Objective-C, Fortran, Java, OpenCL C, Pascal, assembly, Modula-2,
 and Ada. A must-have for any serious programmer.
Homepage: http://www.gnu.org/s/gdb/
Description-md5: 8132571fab028a898d029eecd88e571e

See also

To list all installed packages, enter:

dpkg --list

Alternatively, you can use this command:

dpkg --list | less

You can also run the following command:

dpkg --list | grep -i 'http'

Note the grep option as part of the command string. One of the most popular commands on Linux, grep is a powerful search mechanism to find a particular file, a directory, a pattern or chunk of code.