Wiley.com
Print this page Share

Exploring BeagleBone: Tools and Techniques for Building with Embedded Linux

ISBN: 978-1-118-93512-5
600 pages
December 2014
Exploring BeagleBone: Tools and Techniques for Building with Embedded Linux (1118935128) cover image

Description

In-depth instruction and practical techniques for building with the BeagleBone embedded Linux platform

Exploring BeagleBone is a hands-on guide to bringing gadgets, gizmos, and robots to life using the popular BeagleBone embedded Linux platform. Comprehensive content and deep detail provide more than just a BeagleBone instruction manual—you’ll also learn the underlying engineering techniques that will allow you to create your own projects. The book begins with a foundational primer on essential skills, and then gradually moves into communication, control, and advanced applications using C/C++, allowing you to learn at your own pace. In addition, the book’s companion website features instructional videos, source code, discussion forums, and more, to ensure that you have everything you need.

The BeagleBone’s small size, high performance, low cost, and extreme adaptability have made it a favorite development platform, and the Linux software base allows for complex yet flexible functionality. The BeagleBone has applications in smart buildings, robot control, environmental sensing, to name a few; and, expansion boards and peripherals dramatically increase the possibilities. Exploring BeagleBone provides a reader-friendly  guide to the device, including a crash course in computer engineering. While following step by step, you can:

  • Get up to speed on embedded Linux, electronics, and programming
  • Master interfacing electronic circuits, buses and modules, with practical examples
  • Explore the Internet-connected BeagleBone and the BeagleBone with a display
  • Apply the BeagleBone to sensing applications, including video and sound
  • Explore the BeagleBone’s Programmable Real-Time Controllers

Hands-on learning helps ensure that your new skills stay with you, allowing you to design with electronics, modules, or peripherals even beyond the BeagleBone. Insightful guidance and online peer support help you transition from beginner to expert as you master the techniques presented in Exploring BeagleBone, the practical handbook for the popular computing platform.

See More

Table of Contents

Introduction xxv

Part I BeagleBone Basics 1

Chapter 1 The BeagleBone Hardware 3

Introduction to the Platform 3

Who Should Use the BeagleBone 5

When to Use the BeagleBone 6

When You Should Not Use the BeagleBone 6

BeagleBone Documentation 7

The BeagleBone Hardware 8

BeagleBone Versions 9

The BeagleBone Black Hardware 11

BeagleBone Accessories 14

Highly Recommended Accessories 14

Micro?]SD Card (for Flashing the BBB) 14

External 5V Power Supply (for Flashing and Peripherals) 15

Ethernet Cable (for Network Connection) 15

HDMI Cable (for Connection to Monitors/Televisions) 15

USB to Serial UART TTL 3.3 V (for Finding Problems) 16

Optional Accessories 17

USB Hub (to Connect Several USB Devices to a USB Host) 17

Micro-HDMI to VGA adapters (for VGA Video and Sound) 17

Wi-Fi Adapters (for Wireless Networking) 18

USB Webcam (for Capturing Images and Streaming Video) 18

USB Keyboard and Mouse (for General-Purpose Computing) 18

Capes 19

How to Destroy Your BeagleBone! 20

Summary 22

Support 22

Chapter 2 The BeagleBone Black Software 23

Linux on the BeagleBone 24

Linux Distributions 24

Communicating with the BBB 25

Installing Drivers 26

Network Connections 26

Internet?]over?]USB 26

Regular Ethernet 29

Ethernet Crossover Cable 30

Communicating with the BBB 31

Serial Connection over USB 31

Serial Connection with the USB?]to?]TTL 3.3 V Cable 33

Connecting through Secure Shell (SSH) 33

Secure Shell Connections using PuTTY 34

Chrome Apps: Secure Shell Client 34

Transferring Files Using PuTTY/psftp over SSH 35

Controlling the BeagleBone 37

Basic Linux Commands 37

First Steps 37

Basic File System Commands 38

Environment Variables 40

Basic File Editing 41

What Time Is It? 42

Package Management 44

Interacting with the BBB On?]board LEDs 45

Shutdown 47

Node.js, Cloud9, and BoneScript 48

Introduction to Node.js 48

Introduction to the Cloud9 IDE 50

Introduction to BoneScript 51

Summary 52

Further Reading 53

Chapter 3 Exploring Embedded Linux Systems 55

Embedded Linux Basics 55

What Embedded Linux Offers 57

Is Linux Open Source and Free? 57

Booting the BeagleBone 58

The BeagleBone Bootloaders 58

Kernel Space and User Space 62

System V init (SysVinit) 63

Managing Linux Systems 67

The Super User 67

System Administration 68

The Linux File System 68

Linking to Files and Directories 69

Users and Groups 71

File System Permissions 74

Exploring the File System 75

Commands for File Systems 75

find and whereis 81

more or less 82

Linux Commands 82

Standard Input and Output Redirection (>, >>, and <) 82

Pipes (| and tee) 83

Filter Commands (from sort to xargs) 84

echo and cat 86

diff 87

tar 88

md5sum 88

Linux Processes 89

Controlling Linux Processes 89

Foreground and Background Processes 90

The BusyBox Multi?]call Binary 92

Other Linux Topics 93

Git 93

Getting Started with Git 94

Cloning a Repository (git clone) 95

Getting the Status (git status) 96

Adding to the Staging Area (git add) 96

Committing to the Local Repository (git commit) 97

Pushing to the Remote Repository (git push) 97

Advanced Git 98

Creating a Branch (git branch) 98

Merging the Branch (git merge) 100

Deleting a Branch (git branch ?]d) 100

Conclusions on Git 101

Desktop Virtualization 102

Code for This Book 103

Summary 104

Further Reading 104

Chapter 4 Interfacing Electronics 105

Recommended Equipment 105

Digital Multimeter 106

Oscilloscopes 106

Basic Circuit Principles 108

Voltage, Current, Resistance, and Ohm’s Law 109

Voltage Division 110

Current Division 112

Implementing Circuits on a Breadboard 113

Digital Multimeters (DMMs) and Breadboards 114

Example Circuit: Voltage Regulation 115

Discrete Components 117

Diodes 117

Light?]Emitting Diodes (LEDs) 118

Smoothing and Decoupling Capacitors 121

Transistors 123

Transistors as Switches 124

Field Effect Transistors (FETs) as Switches 127

Optocouplers/Opto?]isolators 128

Switches and Buttons 130

Hysteresis 132

Logic Gates 133

Floating Inputs 137

Pull?]Up and Pull?]Down Resistors 138

Open?]Collector and Open?]Drain Outputs 139

Interconnecting Gates 140

Analog?]to?]Digital Conversion 141

Sampling Rate 142

Quantization 142

Operational Amplifiers 143

Ideal Operational Amplifiers 143

Negative Feedback and Voltage Follower 146

Positive Feedback 146

Concluding Advice 147

Summary 147

Further Reading 148

Chapter 5 Practical BeagleBone Programming 149

Introduction 149

Performance of Different Languages 150

Setting the BBB CPU Frequency 153

Scripting Languages 153

Scripting Language Options 154

Bash 155

Perl 157

Python 158

JavaScript and Java 161

JavaScript and Node.js on the BBB 161

Java on the BBB 164

C and C++ on the BeagleBone 167

C and C++ Language Overview 169

Compiling and Linking 170

Writing the Shortest C/C++ Program 172

Variables and Operators in C/C++ 174

Pointers in C/C++ 177

C?]Style Strings 180

LED Flashing Application in C 181

The C of C++ 183

First Example and Strings in C++ 183

Passing by Value, Pointer, and Reference 185

Flashing the LEDs Using C++ (non?]OO) 186

Writing Your Own Multi?]Call Binary 186

C++ with Classes 187

Overview of Object?]Oriented Programming 188

Classes and Objects 188

Encapsulation 189

Inheritance 190

Object?]Oriented LED Flashing Code 191

/Proc—Process Information File System 195

GLIBC and Syscall 195

Summary 197

Further Reading 197

Part II Interfacing, Controlling, and Communicating 199

Chapter 6 Interfacing to the BeagleBone Input/Outputs 201

General?]Purpose Input/Outputs 201

Introduction to GPIO Interfacing 202

GPIO Digital Output 204

GPIO Digital Input 207

GPIO Confi guration 208

Internal Pull?]up and Pull?]down Resistors 208

GPIO Pin Configuration Settings 209

C++ Control of GPIOs 214

The Linux Device Tree 219

The Flattened Device Tree (FDT) 219

Device Tree Overlays (DTOs) 221

Writing an Overlay 221

Compiling and Deploying an Overlay 222

The BBB Cape Manager 222

Loading a Device Tree Overlay 223

Removing an Overlay 225

Loading an Overlay on Boot 226

Analog Inputs and Outputs 226

Analog Inputs 226

Enabling the Analog Inputs 227

Input Application—A Simple Light Meter 228

Analog Outputs (PWM) 231

Output Application—Controlling a Servo Motor 233

Advanced GPIO Topics 235

More C++ Programming 235

Callback Functions 235

POSIX Threads 236

Linux poll (sys/poll.h) 238

Enhanced GPIO Class 239

GPIO?]KEYS 243

Using GPIOs without Using sudo 247

Summary 248

Further Reading 249

Chapter 7 Cross?]Compilation and the Eclipse IDE 251

Setting Up a Cross?]Compilation Toolchain 251

A Toolchain for Debian 252

Testing the Toolchain 254

Cross?]Compilation with Third?]Party Libraries (Multiarch) 255

Installing a Change Root 257

Installing an armhf Change Root 257

Emulating the armhf Architecture 258

Cross?]Compilation Using Eclipse 260

Installing Eclipse on Desktop Linux 260

Configuring Eclipse for Cross?]Compilation 261

Remote System Explorer 263

Integrating GitHub into Eclipse 265

Remote Debugging 266

Automatic Documentation (Doxygen) 269

Adding Doxygen Support in Eclipse 270

Building Debian for the BBB 271

Summary 273

Further Reading 274

Chapter 8 Interfacing to the BeagleBone Buses 275

Introduction to Bus Communication 276

I2C 276

I2C Hardware 277

The ADXL345 Accelerometer 279

Using Linux I2C?]Tools 280

i2cdetect 280

i2cdump 281

i2cget 283

i2cset 285

I2C Communication in C 286

Wrapping I2C Devices with C++ Classes 288

SPI 291

SPI Hardware 291

SPI on the BBB 293

Enabling the First SPI Bus (SPI0) 294

Testing the SPI Bus 295

A First SPI Application (74HC595) 296

Wiring the 74HC595 Circuit 296

SPI Communication Using C 297

Bidirectional SPI Communication in C++ 300

The Second SPI Bus (SPI1) 301

The ADXL345 SPI Interface 301

Connecting the ADXL345 to the BBB 302

Wrapping SPI Devices with C++ Classes 303

Three?]Wire SPI Communication 307

Multiple SPI Slave Devices on the BBB 308

UART 309

UARTs on the BBB 310

The Arduino UART Example 312

BeagleBone to Arduino Serial Communication 314

Echoing the Minicom Program 314

UART Echo Example in C 316

UART Command Control of an Arduino 318

Logic?]Level Translation 321

Summary 324

Further Reading 324

Chapter 9 Interacting with the Physical Environment 325

Interfacing to Actuators 326

DC Motors 327

A BBB DC Motor Driver Circuit 329

Controlling a DC Motor Using sysfs 330

Controlling a DC Motor Using C++ 331

Stepper Motors 333

The EasyDriver Stepper Motor Driver 334

A BBB Stepper Motor Driver Circuit 335

Controlling a Stepper Motor Using C++ 336

Relays 338

Interfacing to Analog Sensors 340

Protecting the BBB ADC Inputs 342

Diode Clamping 342

Op?]Amp Clamping 343

Analog Sensor Signal Conditioning 345

Scaling Using Voltage Division 345

Signal Offsetting and Scaling 346

Analog Interfacing Examples 349

Infrared Distance Sensing 349

ADXL335 Conditioning Example 353

Interfacing to Display Modules 354

Seven?]Segment Displays 354

Character LCD Modules 359

Remote Control BeagleBone 363

Managing Services with Systemd 364

BBB Serial Connection to Desktop 366

Starting a Custom Service on Boot 369

Bluetooth 370

Installing an Adapter 370

Loadable Kernel Modules 371

Configuring a Bluetooth Adapter 372

Making the BBB Discoverable 373

Android Application Development with Bluetooth 374

Building Dynamic Linked Libraries 376

Summary 376

Further Reading 377

Part III Advanced BeagleBone Systems 379

Chapter 10 The Internet of Things 381

The Internet of Things (IoT) 382

More Sensors (Things!) 384

A Room Temperature Sensor 384

Texas Instruments SensorTag 385

Connecting to Bluetooth Smart Devices 385

Building a Linux Package 386

Controlling a Bluetooth Smart Device 387

The BeagleBone as a Web Server 388

Installing a Web Server 389

Configuring an Apache Web Server 389

Creating Web Pages and Web Scripts 390

PHP on the BeagleBone 392

Replacing Bone101 with the Custom Web Server 393

A C/C++ Web Client 394

Network Communications Primer 395

A C/C++ Web Client 396

Secure Communication Using OpenSSL 398

The BeagleBone as a Web Sensor 399

ThingSpeak 400

The Linux Cron Scheduler 402

System crontab 402

User crontab 404

Xively 405

Getting Started with Xively's PaaS 406

The Xively C Library 407

Sending E-mail from the BBB 409

If This Then That (IFTTT) 411

The C++ Client/Server 412

Managing Remote IoT Devices 415

BeagleBone Remote Monitoring 416

Linux Watchdog Timer 416

IoT Physical Networking 418

The BeagleBone and Wi-Fi 418

Wireless Network Adapters 419

Static IP Addresses 422

Power over Ethernet (PoE) 423

PoE Power Extraction Modules (PEMs) (Advanced Topic) 424

Summary 425

Further Reading 426

Note 426

Chapter 11 BeagleBone with a Rich User Interface 427

Rich UI BBB Architectures 428

The BBB as a General?]Purpose Computer 428

Connecting a Bluetooth Input Peripheral 430

BBB with a LCD Touch Screen Cape 431

Virtual Network Computing (VNC) 432

VNC Using VNC Viewer 433

VNC with Xming and PuTTY 433

VNC with a Linux Desktop Computer 434

Fat?]Client Applications 435

Rich UI Application Development 435

Introduction to GTK+ on the BBB 436

The “Hello World” GTK+ Application 436

The Event?]Driven Programming Model 437

The GTK+ Temperature Application 438

Introduction to Qt on the BBB 441

Installing Qt Development Tools on the BBB 442

The “Hello World” Qt Application 442

Qt Primer 444

Qt Concepts 444

The QObject Class 445

Signals and Slots 446

Qt Development Tools 447

A Qt Temperature Sensor GUI Application 448

Simple Qt Cross?]Platform Development 453

Remote UI Application Development 455

Fat?]Client Qt GUI Application 455

Multi?]Threaded Server Applications 458

A Multi?]Threaded Temperature Service 461

The Fat?]Client as a Server 463

Parsing Stream Data 465

The BBB Client Application 467

Cross?]Compiling Qt Applications 468

Building the Qt Libraries from Source 470

Remote Deploying a Test Application 470

Summary 471

Further Reading 472

Chapter 12 Images, Video, and Audio 473

Capturing Images and Video 474

USB Webcams 474

Video4Linux2 (V4L2) 476

Image Capture Utility 477

Video4Linux2 Utilities 479

Writing Video4Linux2 Programs 480

Streaming Video 482

Image Processing and Computer Vision 483

Image Processing with OpenCV 484

Computer Vision with OpenCV 486

Boost 489

BeagleBone Audio 489

Core Audio Software Tools 490

Audio Devices for the BBB 491

HDMI and USB Audio Playback Devices 491

Internet Radio Playback 493

Recording Audio 494

Audio Network Streaming 496

Bluetooth A2DP Audio 496

Text?]to?]Speech 499

Online Text-to-Speech 499

Offline Text-to-Speech 500

A Bluetooth Speaking Clock and Temperature Sensor 500

Summary 502

Further Reading 502

Chapter 13 Real?]Time BeagleBone Interfacing 503

Real?]Time BeagleBone 504

Real?]Time Kernels 504

Real?]Time Hardware Solutions 505

The PRU?]ICSS Architecture 506

Important Documents 508

Getting Started with the PRU?]ICSS 508

PRU?]ICSS Enhanced GPIOs 509

PRU?]ICSS Device Tree Overlay 509

The PRU?]ICSS Package 511

A First PRU Program 512

The PRU?]ICSS in Detail 516

Registers 516

Local and Global Memory 517

PRU Assembly Instruction Set 519

Applications of the PRU?]ICSS 521

PRU?]ICSS Performance Tests 522

Utilizing Regular Linux GPIOs 522

A PRU PWM Generator 525

A PRU Sine Wave Generator 527

An Ultrasonic Sensor Application 530

Additional PRU?]ICSS Tools 535

The PRU Debugger 535

The TI PRU C Compiler 536

Summary 538

Further Reading 539

Index 541

See More

Author Information

Dr. Derek Molloy is a Senior Lecturer in the School of Electronic Engineering at Dublin City University, Ireland. Derek produces a popular YouTube series on the BeagleBone platform and a wide variety of embedded Linux topics. His videos and personal blog have introduced millions of people to the BeagleBone, embedded Linux, and digital electronics.

See More

Downloads

Download TitleSizeDownload
Read Me 957 bytes Click to Download
Chapter 02 1.61 KB Click to Download
Chapter 03 2.59 KB Click to Download
Chapter 05 135.97 KB Click to Download
Chapter 06 561.65 KB Click to Download
Chapter 08 65.94 KB Click to Download
Chapter 09 2.68 MB Click to Download
Chapter 10 424.41 KB Click to Download
Chapter 11 138.19 KB Click to Download
Chapter 12 12.97 MB Click to Download
Chapter 13 118.59 KB Click to Download
Library 274.11 KB Click to Download
License 12.04 KB Click to Download
See More

Related Titles

Back to Top