Introduction

The Beagle platform continues to amaze! Given the proliferation of smartphones, the idea of holding in one hand a computer that is capable of performing two billion instructions per second is easy to take for granted—but the fact that you can modify the hardware and software of such small yet powerful devices and adapt them to suit your own needs and create your own inventions is nothing short of amazing. Even better, you can purchase a board for as little as $25 in the form of a PocketBeagle.

The Beagle boards on their own are too complex to be used by a general audience; it is the capability of the boards to run Linux that makes the resulting platform accessible, adaptable, and powerful. Together, Linux and embedded systems enable ease of development for devices that can meet future challenges in smart buildings, the Internet of Things (IoT), robotics, smart energy, smart cities, human-computer interaction (HCI), cyber-physical systems, 3D printing, smart manufacturing, interactive art, advanced vehicular systems, and many, many more applications.

The integration of high-level Linux software and low-level electronics represents a paradigm shift in embedded systems development. It is revolutionary that you can build a low-level electronics circuit and then install a Linux web server, using only a few short commands, so that the circuit can be controlled over the internet. You can easily use a Beagle board as a general-purpose Linux computer, but it is vastly more challenging and interesting to get underneath the hood and fully interface it to electronic circuits of your own design—and that is where this book comes in!

This book should have widespread appeal for inventors, makers, students, entrepreneurs, hackers, artists, dreamers—in short, anybody who wants to bring the power of embedded Linux to his or her products, inventions, creations, or projects and truly understand the Beagle platform in detail. This is not a recipe book—with few exceptions, everything demonstrated here is explained at a level that will enable you to design, build, and debug your own extensions of the concepts presented here. Nor is there any grand design project at the end of this book for which you must purchase a prescribed set of components and peripherals to achieve a specific outcome. Rather, this book is about providing you with enough background knowledge and “under-the-hood” technical details to enable and motivate your own explorations.

I strongly believe in learning by doing, so I present examples using low-cost, widely available hardware so that you can follow along. Using these hands-on examples, I describe what each step means in detail so that when you substitute your own hardware components, modules, and peripherals you will be able to adapt the content in this book to suit your needs. As for that grand project or invention—that is left up to you and your imagination!

When writing this book, I had the following aims and objectives:

  • To explain embedded Linux and its interaction with electronic circuits—taking you through the topics from mystery to mastery!
  • To provide in-depth information and instruction on the Linux, electronics, and programming skills that are required to master a pretty wide and comprehensive variety of topics in this domain.
  • To create a collection of practical “Hello World” hardware and software examples on each and every topic in the book, from low-level interfacing, general-purpose input/outputs (GPIOs), analog-to-digital converters (ADCs), buses, and UARTs, to high-level libraries such as OpenCV, Qt, and complex and powerful topics, such as real-time interfacing with the PRU-ICSS, and Linux kernel programming.
  • To ensure that each circuit and segment of code is specifically designed to work with a Beagle board. Every circuit and code example in this book was built and tested on the BeagleBone Black wireless and PocketBeagle boards.
  • To use the “Hello World” examples to build a library of code that you can use and adapt for your own Beagle projects.
  • To make all of the code available on GitHub in an easy-to-use form.
  • To support this book with strong digital content, such as the videos on the DerekMolloyDCU YouTube channel, and a custom website, www.exploringbeaglebone.com.
  • To ensure that by the end of this book you have everything you need to imagine, create, and build advanced Beagle board projects.

I wrote this second edition because of the popularity of the first edition of Exploring BeagleBone. The number of pages in this edition is more than 20 percent of the first edition, increased to include the following major additions:

  • Full coverage of new Beagle boards, with a particular emphasis on the PocketBeagle and BeagleBone Black wireless boards
  • Updated content to account for all recent changes to the Linux kernel and operating system
  • Inclusion of electronics interfacing approaches, such as protection of I/O pins using optocouplers, the CAN bus, and many additional interfacing application examples using external I/O circuits
  • New work on real-time interfacing using external slave processors, with a particular emphasis on building I2C digital sensors
  • A full account of new Internet of Things (IoT) full-stack frameworks, with an emphasis on MQTT and interfacing to Adafruit IO
  • Full coverage of building wireless sensor networks using technologies such as Wi-Fi, Bluetooth, NFC, and ZigBee
  • A complete rewrite of the PRU-ICSS chapter to account for Texas Instruments' decision to move away from UIO to Linux Remoteproc
  • Inclusion of new work on writing Linux loadable kernel modules (LKMs)

Why the BeagleBone and PocketBeagle?

The Beagle boards are powerful single-board computers (SBCs), and while there are other SBCs available on the market, such as the Raspberry Pi and Intel NUC boards, the Beagle platform has one key differentiator—it was built to be interfaced to! For example, the Beagle board's microprocessor package even contains two additional on-chip microcontrollers that can be used for real-time interfacing—an area in which other Linux SBCs have significant difficulty.

Unlike most other SBCs, the Beagle boards are fully open-source hardware. The BeagleBoard.org Foundation provides source schematics, hardware layout, a full bill of materials, and comprehensive technical reference manuals, enabling you to modify the design of the Beagle platform and integrate it into your own product. In fact, you can even fork the hardware design onto Upverter (www.upverter.com) under a Creative Commons Attribution-ShareAlike license (see tiny.cc/beagle001 for the full schematics). This is a useful feature should you decide to take your newest invention to market!

How This Book Is Structured

There is no doubt that some of the topics in this book are quite complex—the Beagle boards are complex devices! However, everything that you need to master the devices is present in the book within three major parts.

  • Part I, “Beagle Board Basics”
  • Part II, “Interfacing, Controlling, and Communicating”
  • Part III, “Advanced Beagle Board Systems”

In the first part in the book, you learn about the hardware and software of the Beagle board platform in Chapters 1 and 2 and subsequently gain more knowledge through these three primer chapters:

  • Chapter 3, “Exploring Embedded Linux Systems”
  • Chapter 4, “Interfacing Electronics”
  • Chapter 5, “Practical Beagle Board Programming”

If you are a Linux expert, electronics wizard, and/or software guru, then feel free to skip the primer chapters; however, for everyone else, you'll find a concise but detailed set of materials to ensure that you gain all the knowledge required to effectively and safely interface to your Beagle boards.

The second part of the book, Chapters 6 to 10, provides detailed information on interfacing to the Beagle board GPIOs, analog inputs, buses (I2C, SPI, CAN bus), UART devices, USB peripherals, and real-time interfacing to slave processors. You'll learn how you can configure a cross-compilation environment so that you can build large-scale software applications. This part also describes how you can combine hardware and software to provide your board with the ability to interact effectively with its physical environment.

The final part of the book, Chapters 11 to 16, describes how the Beagle board can be used for advanced applications such as Internet of Things (IoT); rich user interfaces; images, video, and audio; real-time interfacing using the PRU-ICSS; and kernel programming. Along the way you will meet many technologies, including TCP/IP, ThingSpeak, Adafruit IO, PoE, Wi-Fi, Bluetooth, Zigbee, RFID, MQTT, cron, Apache, PHP, e-mail, IFTTT, VNC, GTK+, Qt, XML, JSON, multi-threading, client/server programming, V4L2, video streaming, OpenCV, Boost, USB audio, Bluetooth A2DP, text-to-speech, and Remoteproc.

Conventions Used in This Book

This book is filled with source code examples and snippets that you can use to build your own applications. Code and commands are shown as follows:

This is what source code looks like.

When presenting work performed in a Linux terminal, it is often necessary to display both input and output in a single example. A bold type is used to distinguish the user input from the output. Here's an example:

debian@ebb:~$ ping www.exploringbeaglebone.com
PING lb1.reg365.net (195.7.226.20) 56(84) bytes of data.
64 bytes from lb1.reg365.net (195.7.226.20): icmp_req=1 ttl=55 time=25.6 ms
64 bytes from lb1.reg365.net (195.7.226.20): icmp_req=2 ttl=55 time=25.6 ms
 

The $ prompt indicates that a regular Linux user is executing a command, and a # prompt indicates that a Linux superuser is executing a command. The ellipsis symbol () is used whenever code or output not vital to understanding a topic has been cut. I've edited the output like this to enable you to focus on only the most useful information. You are encouraged to repeat the steps in this book yourself, whereupon you will see the full output. In addition, the full source code for all examples is provided along with the book.

There are some additional styles in the text. Here are some examples:

  • New terms and important words appear in italics when introduced.
  • Keyboard strokes appear like this: Ctrl+C.
  • All URLs in the book appear in this font: www.exploringbeaglebone.com.
  • A URL-shortening service is used to create aliases for long URLs that are presented in the book. These aliases have the form tiny.cc/beagle102 (e.g., link 2 in Chapter 1). Should the link address change after this book is published, the alias will be updated.

There are several features used in this book to identify when content is of particular importance or when additional information is available.

What You'll Need

Ideally you should have a Beagle board before you begin reading this book so that you can follow along with the numerous examples in the text. If you do not yet have a board, it would be worth reading Chapter 1 before placing an order. Currently the board is manufactured by both CircuitCo and Embest—the boards from either manufacturer are compatible with the designs and operations in this book. You can purchase one of the boards in the United States from online stores such as Adafruit Industries, Digi-Key, Mouser, SparkFun, and Jameco Electronics. They are available internationally from stores such as Farnell, Radionics, Watterott, and Tigal.

A full list of recommended and optional accessories for the Beagle platform is provided in Chapter 1. In addition, each chapter contains a list of the electronics components and modules required if you want to follow along with the text. The book website provides details about where these components can be acquired.

Errata

I have worked really hard to ensure that this book is error free; however, it is always possible that something was overlooked. A full list of errata is available on each chapter's web page at the companion website. If you find any errors in the text or in the source code examples, I would be grateful if you could send the errors using the companion website so that I can update the web page errata list and the source code examples in the code repository.

Digital Content and Source Code

The primary companion site for this book is www.exploringbeaglebone.com. It contains videos, source code examples, and links to further reading. Each chapter has its own individual web page. In the unlikely event that this website is unavailable, you can find the code at www.wiley.com/go/exploringbeaglebone2e.

All the source code is available through GitHub, which allows you to download the code to your Beagle board with one command. You can also easily view the code online at tiny.cc/beagle002. Downloading the source code to your board is as straightforward as typing the following at the Linux shell prompt:

debian@ebb:$ git clone https://github.com/derekmolloy/exploringbb.git

If you have never used Git before, don't worry—it is explained in detail in Chapter 3. Now, on with the adventures!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.94.171