Introduction

This is the chapter web page to support the content in Chapter 2 of the book: Exploring BeagleBone – Tools and Techniques for Building with Embedded Linux. The summary introduction to the chapter is as follows:

In this chapter, you are introduced to the Linux operating system and software tools that can be used with the BeagleBone. This chapter aims to ensure that you can connect to your BeagleBone and control it. By the end of this chapter you should be able to “blink” a system LED having followed a step-by‐step guide that demonstrates how you can use Linux shell commands in a Linux terminal window. In this chapter, you are also introduced to a library of BeagleBone functions, called BoneScript, which can be used with Node.js and the Cloud9 integrated development environment to build code that flashes the same system LED.

Learning Outcomes

After completing this chapter, you should be able to:

  • Communicate with the BBB from your desktop computer using network connections such as Internet‐over‐USB and regular Ethernet.
  • Communicate with the BBB using fallback serial connections such as Serial‐over‐USB or by using a custom USB‐to‐TTL 3.3 V cable.
  • Interact with and control the BBB using simple Linux commands.
  • Perform basic file editing using a Linux terminal.
  • Manage Linux packages and set the system time.
  • Use Linux sysfs to affect the state of BBB hardware.
  • Safely shut down and reboot the BBB.
  • Use Node.js, Cloud9, and BoneScript to write basic applications and code that interacts with BBB hardware.

If you are installing the BeagleBone Black under Windows 8/Windows 8.1, please ensure that you use the latest certified drivers, which are available from: Install the certified drivers directly from: https://github.com/beagleboard/beaglebone-getting-started/tree/master/Drivers/Windows

This book has been written and tested using the Debian 2014-05-14 release. It is recommended that you work through the book using this image and then update to the latest image once you have completed the book.

In March 2015, a new image was added as the official release: Debian 2015-03-01, which requires a revision C board (or booting from the SD card) — Notes are available on each chapter webpage for any impacts that new image have on the content in the book. Please use the comments section at the bottom of the chapter web pages if you notice any other compatibility differences that should be noted.

Updates for Debian (2015-03-01 Release)

Changes to the U-boot Partitioning Layout

On page 26 there is a note to warn you not to alter the MLO, u-boot.img and uEnv.txt files on the FAT partition. As of Linux 3.8.13-bone70 that is no longer an issue. These files were moved to create a more distribution friendly default bootloader. As alluded to in the note on page 26, you can now find these files in the /boot directory on the main Linux partition:

It is not necessary to use these files at this point in the book, but please note this fact for future reference, particularly when performing tasks such as disabling the HDMI overlay by editing the uEnv.txt file.

Writing a New Image to the BBB

Although the BBB is supplied with a Linux distribution already on its eMMC, one of the first steps you may carry out is updating your BBB to have the latest Linux distribution. If you wish, you can skip this section for the moment and come back to it later.

The beagleboard.org website has very clear instructions on writing a new system image to the BBB, so this section only details observations and additional steps that may be useful in achieving a successful upgrade.

Creating an SD Card Image

The instructions that follow will work for any BBB Linux distribution:

  • The latest BBB Linux images are available from BeagleBoard.org/latest-images. There are two versions to choose from: a version that runs directly from the micro-SD Card; or a version that writes to the BBB’s on-board eMMC, called a “flasher” image. The advantage of the eMMC version is that once it is written to the eMMC (which takes about 5–25 minutes) the BBB will boot in about 10 seconds from then on, and the micro-SD card slot will remain available for additional removable storage. For the remaining steps, the eMMC flasher image is chosen and Windows is used as the desktop operating system.
If you are planning to flash the eMMC with a new image, please ensure that you download a “flasher” image — the name of the downloaded image should contain the word flasher. The latest flasher images are available at: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian and the latest image that is currently supported in this book is: BBB-eMMC-flasher-debian-7.8-lxde-4gb-armhf-2015-03-01-4gb.img.xz
  • Using a web browser, download the image file to the desktop computer. You should end up with a file of the form BBB-eMMC-flasher-distro-YYYY.MM.DD.img.xz.
  • Check whether your desktop computer can open the .xz format file. If it cannot, then please see www.7-zip.org for an open-source file archiving tool, which is capable of extracting the .xz format—a lossless data compression format that uses the Lempel-Ziv-Markov Algorithm (LZMA).
  • If the archive extraction is successful, the result will be a single file with the .img extension (SD image file) of the form BBB-eMMC-flasher-distro-YYYY.MM.DD.img.
  • Under Windows, install “Win32 Disk Imager” from sourceforge.net/projects/win32diskimager/files/latest/download. Extract it to a folder that you can find again in the future, and execute Win32DiskImager.exe directly from within that folder. You will have to “elevate it” by right-clicking and choosing “Run as administrator”. Please note that there is a similar tool for Mac OS X called “Pi Filler”.
  • Place a micro-SD card that has sufficient capacity (ideally 4GB+) into your computer’s SD card reader/writer and then start the Disk Imager tool. Once the disk imager software has started, it will not detect the SD card when it is inserted into the computer, so please insert the SD card first. A Class 10 Micro-SD card or greater is preferable.
  • Using Win32 Disk Imager, write the .img file to your SD card (using its drive letter for the SD reader on your desktop). This will take some time (about 5–15 minutes), which varies according to card speed, writer speed, and the distribution used. See Figure 2.A1 below for a screen capture of Win32 Disk Imager in action. When you are done, you will have a micro-SD card that you can use to flash your BBB’s eMMC.

Figure 2.A1: The Win32 Disk Imager writing to the micro-SD card.

Desktop Linux Alternative

If you are not familiar with Linux then please ignore this section—it is here for reference. Here are the steps required to create the SD card image on Linux:

  1. Find the micro-SD Card device (for example, mine is sdd). Type the following:

  1. Download the flasher image file (get the URL from BeagleBoard.org/latest-images). For example:

  1. Decompress the .xz file:

This gives you the image file: BBB*.img. Write the image to the memory card (please check that you have the correct SD card device—in my case it is /dev/sdd)

where BBB*.img is the full name of the image file—use the Tab key to autocomplete. /dev/sdX is your specific SD card reader device. It should take 5 to 10 minutes for this write to complete.

Flashing the BBB with the SD Card Image

At this point you should have a micro-SD card containing a “flasher” Linux image. Here are the steps to flash the eMMC:

  1. You should perform this process with only a single 5V 2A power supply plugged into the DC jack. Alternatively, you can use a USB adapter for power. Disconnect the Ethernet cable and remove any shields and USB peripherals.
  2. Power off your BBB by physically disconnecting the USB/power cable.
  3. Plug the micro-SD card into the BBB’s micro-SD card slot.
  4. Hold the Boot Button (S2) on the top right (near the SD card slot) and, while holding this button, insert the USB/power lead to connect the power. Keep holding the button until the LEDs start to flash. The blue on-board LEDs should light in sequence and then continue to flash for the next 5–25 minutes (depending on the distribution used and the speed of the SD card). The latest distribution flashes in a Cylon/Knightrider pattern.
  5. Wait until the LEDs stop blinking and all 4 LEDs are fully lit (the latest image then powers the board down). This process can take 5-25 minutes depending on the image used. If the flashing procedure fails—for example, no LEDs flash, or it keeps running for more than 45 minutes —then disconnect the power and try restarting the BBB with the S2 button pressed.
  6. Remove the micro-SD card. This is important, as you could end up flashing the eMMC again by accident.
  7. Finally, press the Power button (S3) to power up the board and you should have the latest image installed.

Digital Media Resources

Here the digital resources referred to in the chapter web page are provided. There are high-resolution versions of some of the important figures and links to videos, resources and websites that are described in the chapter.

Source Code

Octocat_smallAll of the source code that is described in this book is available in a public GitHub repository: Derek Molloy Exploring BeagleBone repository.

You can clone this repository on a Linux desktop computer or your BeagleBone using the command:

You can also install a Windows GitHub desktop application or a Mac OS X GitHub desktop application. Alternatively, you can download a full ZIP archive of the code using the following link: Download Source Code (this is a live link that automatically provides you with the very latest files). The Source Code web page lists all recent updates to this repository.

There is only a small amount of code in this chapter that is related to Node.js using the Cloud9 IDE. The code can be accessed in the chp02 folder of the cloned repository. The formatted code is provided here for your convenience.


Related Video

Getting started with Internet-over-USB

The chapter web page includes a video on getting started with Internet‐over‐USB

External Resources

Zenmap is described in the chapter as a tool for scanning your network to find a network-attached BeagleBone. You are searching for an entry that has three to five open ports (e.g., 22 for SSH, 80 for the BBB guide, 8080 for the Apache web server, and 3000 for the Cloud 9 IDE). It may also identify itself with Texas Instruments. You can see the Zenmap application in action in the image to the left where 192.168.1.25 is the location of the BeagleBone on my network.

Important Documents

External Web Sites

The AM335x Technical Reference Manual (TRM)

The BeagleBone Black System Reference Manual (SRM)

The BeagleBoard.org website provides the main support for this platform, with software guides, community links, and downloads to support your development. An excellent “Getting Started” guide and blog is available at the website

Recommended Books on the Content in this Chapter:

       

Errata

None for the moment.