ISBN-13: 9781119533160 / Angielski / Miękka / 2019 / 800 str.
ISBN-13: 9781119533160 / Angielski / Miękka / 2019 / 800 str.
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.
Introduction xxixPart I Beagle Board Basics 1Chapter 1 The Beagle Hardware Platform 3Introduction to the Boards 3Who Should Use the Beagle Platform 6When to Use Beagle Boards 7When Should You Not Use the Beagle Boards 7BeagleBone Documentation 8The Beagle Hardware 10BeagleBone Versions 10The Beagle Hardware 12Beagle Accessories 19Highly Recommended Accessories 19Headers for the PocketBeagle 20Micro-SD Card (for Booting or Flashing eMMCs) 20External 5V Power Supply (for Peripherals) 22Ethernet Cable (for Wired BBB Network Connection) 22HDMI Cable (for Connection to Monitors/Televisions) 22USB to Serial UART TTL 3.3 (for Finding Problems) 23Optional Accessories 24USB Hub (to Connect Several USB Devices to a USB Host) 25Micro-HDMI to VGA Adapters (for VGA Video and Sound) 25Wi-Fi Adapters (for Wireless Networking) 25USB Webcam (for Capturing Images and Streaming Video) 25USB Keyboard and Mouse (for General-Purpose Computing) 26Capes 26How to Destroy Your Board! 27Summary 29Support 29Chapter 2 Beagle Software 31Linux on the Beagle Boards 32Linux Distributions for Beagle Boards 32Create a Linux Micro-SD Card Image 33Communicating with the Boards 34Installing Drivers 34Wired Network Connections 35Internet-over-USB (All Boards) 36Regular Ethernet (BBB and BeagleBoard Only) 39Ethernet Crossover Cable (BBB and BeagleBoard Only) 40Communicating with Your Board 42Serial Connection over USB 42Serial Connection with the USB-to-TTL 3.3 V Cable 43Connecting Through Secure Shell 44Secure Shell Connections Using Putty 45Chrome Apps: Secure Shell Client 45Transferring Files Using Putty/psftp over SSH 46Controlling the Beagle Board 48Basic Linux Commands 48First Steps 49Basic File System Commands 50Environment Variables 52Basic File Editing 53What Time Is It? 54Package Management 56Beagle-Specific Commands 58Expand the File System on an SD Card 59Update the Kernel 60Interacting with the On-Board LEDs 61Shutdown 63Node.js, Cloud9, and BoneScript 64Introduction to Node.js 64Introduction to the Cloud9 IDE 66Introduction to BoneScript 67Summary 69Further Reading 69Chapter 3 Exploring Embedded Linux Systems 71Introducing Embedded Linux 72Advantages and Disadvantages of Embedded Linux 73Is Linux Open Source and Free? 74Booting the Beagle Boards 74Bootloaders 74Kernel Space and User Space 83The systemd System and Service Manager 85Managing Linux Systems 90The Superuser 90System Administration 92The Linux File System 92Links to Files and Directories 94Users and Groups 95File System Permissions 98The Linux Root Directory 102Commands for File Systems 103The Reliability of SD Card/eMMC File Systems 111Linux Commands 113Output and Input Redirection (>, >>, andPipes (| and tee) 114Filter Commands (from sort to xargs) 115echo and cat 117diff 118tar 119md5sum 120Linux Processes 121How to Control Linux Processes 121Foreground and Background Processes 122Other Linux Topics 124Using Git for Version Control 124A Practice-Based Introduction 126Cloning a Repository (git clone) 126Getting the Status (git status) 128Adding to the Staging Area (git add) 128Committing to the Local Repository (git commit) 129Pushing to the Remote Repository (git push) 129Git Branching 130Creating a Branch (git branch) 130Merging a Branch (git merge) 132Deleting a Branch (git branch -d) 132Common Git Commands 133Desktop Virtualization 134Code for This Book 135Summary 136Further Reading 136Bibliography 137Chapter 4 Interfacing Electronics 139Analyzing Your Circuits 140Digital Multimeter 140Oscilloscopes 141Basic Circuit Principles 143Voltage, Current, Resistance, and Ohm's Law 143Voltage Division 145Current Division 146Implementing Circuits on a Breadboard 147Digital Multimeters and Breadboards 149Example Circuit: Voltage Regulation 150Discrete Components 152Diodes 152Light-Emitting Diodes 153Smoothing and Decoupling Capacitors 156Transistors 158Transistors as Switches 159Field Effect Transistors as Switches 162Optocouplers/Optoisolators 164Switches and Buttons 166Hysteresis 168Logic Gates 169Floating Inputs 173Pull-Up and Pull-Down Resistors 173Open-Collector and Open-Drain Outputs 174Interconnecting Gates 175Analog-to-Digital Conversion 177Sampling Rate 177Quantization 178Operational Amplifi ers 178Ideal Operational Amplifiers 178Negative Feedback and Voltage Follower 181Positive Feedback 181Concluding Advice 182Summary 182Further Reading 183Chapter 5 Practical Beagle Board Programming 185Introduction 186Performance of Different Languages 186Setting the CPU Frequency 190Scripting Languages 192Scripting Language Options 192Bash 193Lua 196Perl 197Python 198Dynamically Compiled Languages 201JavaScript and Node.js on the Beagle boards 201Java on the Beagle Boards 203C and C++ on the Beagle Boards 207C and C++ Language Overview 210Compiling and Linking 211Writing the Shortest C/C++ Program 213Static and Dynamic Compilation 215Variables and Operators in C/C++ 215Pointers in C/C++ 219C-Style Strings 221LED Flashing Application in C 223The C of C++ 224First Example and Strings in C++ 225Passing by Value, Pointer, and Reference 226Flashing the LEDs Using C++ (non-OO) 227Writing a Multicall Binary 228Overview of Object-Oriented Programming 229Classes and Objects 229Encapsulation 230Inheritance 231Object-Oriented LED Flashing Code 233Interfacing to the Linux OS 236Glibc and Syscall 237Improving the Performance of Python 239Cython 239Boost.Python 242Summary 244Further Reading 244Bibliography 244Part II Interfacing, Controlling, and Communicating 245Chapter 6 Interfacing to the Beagle Board Input/Outputs 247General-Purpose Input/Outputs 248Introduction to GPIO Interfacing 248GPIO Digital Output 250GPIO Digital Input 255GPIO Confi guration 257Internal Pull-Up and Pull-Down Resistors 258GPIO Pin Configuration Settings 258Interfacing to Powered DC Circuits 265C++ Control of GPIOs 267The Linux Device Tree 271Flattened Device Tree on the Beagle Boards 272Modifying a Board Device Tree 276Boot Confi guration Files 278Analog Inputs and Outputs 280Analog Inputs 280Enabling the Analog Inputs 280Analog Input Application--A Simple Light Meter 282Analog Outputs (PWM) 285Output Application--Controlling a Servo Motor 289BoneScript 290Digital Read and Write 290Analog Read 292Analog Write (PWM) 293GPIO Performance 294Advanced GPIO Topics 295More C++ Programming 295Callback Functions 295POSIX Threads 297Linux poll (sys/poll.h) 298Enhanced GPIO Class 299Using GPIOs without Using sudo 302Root Permissions with setuid 304Summary 306Further Reading 306Chapter 7 Cross-Compilation, Eclipse, and Building Linux 307Setting Up a Cross-Compilation Toolchain 308Cross-Compiling Under Debian 309Testing the Toolchain 311Emulating the armhf Architecture 312Cross-Compilation with Third-Party Libraries (Multiarch) 314Cross-Compilation Using Eclipse 315Installing Eclipse on Desktop Linux 315Confi guring Eclipse for Cross-Compilation 316Remote System Explorer 318Integrating GitHub into Eclipse 322Remote Debugging 322Automatic Documentation (Doxygen) 328Adding Doxygen Editor Support in Eclipse 330Cross-Building Linux 330Downloading the Kernel Source 331Building the Linux Kernel 332Building a Poky Linux Distribution (Advanced) 335Summary 340Chapter 8 Interfacing to the Beagle Board Buses 341Introduction to Bus Communication 342I2C 343I2C Hardware 343I2C on the Beagle Boards 344I2C Devices on the Beagle Boards 345An I2C Test Circuit 346A Real-Time Clock 346The ADXL345 Accelerometer 347Wiring the Test Circuit 348Using Linux I2C-Tools 348i2cdetect 348i2cdump 349i2cget 353i2cset 354I2C Communication in C 356Wrapping I2C Devices with C++ Classes 358SPI 360SPI Hardware 361SPI on the Beagle Boards 363Testing an SPI Bus 363A First SPI Application (74HC595) 365Wiring the 74HC595 Circuit 366SPI Communication Using C 367Bidirectional SPI Communication in C/C++ 370The ADXL345 SPI Interface 370Connecting the ADXL345 to the Beagle Boards 372Wrapping SPI Devices with C++ Classes 373Three-Wire SPI Communication 375Multiple SPI Slave Devices 376UART 377The Beagle Board UART 378UART Examples in C 380Beagle Board Serial Client 381LED Serial Server 383UART Applications: GPS 386CAN Bus 388Beagle Board CAN Bus 389SocketCAN 390A CAN Bus Test Circuit 392Linux CAN-utils 393A SocketCAN C Example 394Logic-Level Translation 396Summary 398Further Reading 399Chapter 9 Interacting with the Physical Environment 401Interfacing to Actuators 402DC Motors 403Driving Small DC Motors (up to 1.5 A) 406Controlling a DC Motor Using sysfs 407Driving Larger DC Motors (Greater Than 1.5 A) 409Controlling a DC Motor Using C++ 411Stepper Motors 412The EasyDriver Stepper Motor Driver 413A Beagle Board Stepper Motor Driver Circuit 414Controlling a Stepper Motor Using C++ 415Relays 417Interfacing to Analog Sensors 418Protecting the ADC Inputs 420Diode Clamping 421Op-Amp Clamping 422Analog Sensor Signal Conditioning 427Scaling Using Voltage Division 427Signal Offsetting and Scaling 428Analog Interfacing Examples 431Infrared Distance Sensing 431ADXL335 Conditioning Example 436Interfacing to Local Displays 438MAX7219 Display Modules 438Character LCD Modules 441Building C/C++ Libraries 445Makefi les 446CMake 447A Hello World Example 448Building a C/C++ Library 449Using a Shared (.so) or Static (.a) Library 452Summary 453Further Reading 454Chapter 10 Real-Time Interfacing Using External Slave Processors 455Real-Time Beagle Board 456Real-Time Kernels 456Real-Time Hardware Solutions 458Extended GPIO Availability 458The MCP23017 and the I2C Bus 460Controlling the GPIO LED Circuit 461Reading the GPIO Button State 462An Interrupt Configuration Example (Advanced) 463The MCP23S17 and the SPI Bus 464A C++ Class for the MCP23x17 Devices 465Adding External UARTs 468The Arduino 471An Arduino Serial Slave 474A UART Echo Test Example 475UART Command Control of an Arduino 478An Arduino I2C Slave 481An I2C Test Circuit 481I2C Register Echo Example 482I2C Temperature Sensor Example 484I2C Temperature Sensor with a Warning LED 486Arduino Slave Communication Using C/C++ 488An I2C Ultrasonic Sensor Application 490Summary 493Further Reading 493Part III Advanced Beagle Board Systems 495Chapter 11 The Internet of Things 497The Internet of Things 498A Beagle Board IoT Sensor 499The Beagle Board as a Sensor Web Server 501Installing and Configuring a Web Server 502Configuring the Apache Web Server 503Creating Web Pages and Web Scripts 503PHP on the Beagle Board 506GNU Cgicc Applications (Advanced) 508Replacing Bone101 with Apache 511A C/C++ Web Client 512Network Communications Primer 513A C/C++ Web Client 514Secure Communication Using Open SSL 516A Beagle Board as a "Thing" 518Thing Speak 518The Linux Cron Scheduler 521System crontab 521User crontab 523Sending E-mail from the Beagle Board 524If This Then That 526IoT Frameworks 528MQ Telemetry Transport 529MQTT Server/Broker 531MQTT Publisher/Subscriber on a Beagle Board 533The mqtt-spy Debug Tool 534Writing MQTT Code 535A Paho MQTT Publisher Example 535A Paho MQTT Subscriber Example 537Adafuit IO 539Configuring the Adafruit IO Account 540Connecting to Adafruit IO with MQTT 542An MQTT Node.js Publish Example 543The C++ Client/Server 545IoT Device Management 548Remote Monitoring of a Beagle Board 548Beagle Board Watchdog Timers 549Static IP Addresses 551Power over Ethernet 551PoE Power Extraction Modules (Advanced Topic) 553Summary 554Chapter 12 Wireless Communication and Control 555Introduction to Wireless Communications 556Bluetooth Communications 557Installing a Bluetooth Adapter 558Checking the LKM 559Configuring a Bluetooth Adapter 560Making the Beagle Board Discoverable 561Android App Development with Bluetooth 563Wi-Fi Communications 564Installing a Wi-Fi Adapter 564The NodeMCU Wi-Fi Slave Processor 568Flashing with the Latest Firmware 569Connecting the NodeMCU to Wi-Fi 570Programming the NodeMCU 571The NodeMCU Web Server Interface 574JSON 575The NodeMCU and MQTT 577ZigBee Communications 579Introduction to XBee Devices 579AT versus API Mode 581XBee Confi guration 582XCTU 582Configuring an XBee Network Using XCTU 583An XBee AT Mode Example 584Setting Up the Arduino XBee Device (XBeeA) 584Setting Up the PocketBeagle XBee Device (XBeePB) 586An XBee API Mode Example 589Setting Up the PocketBeagle XBee Device (XBee1) 589Setting Up the Stand-Alone XBee Device (XBee2) 589XBee API Mode and Node.js 590XBee and C/C++ 592Near Field Communication 593Summary 596Chapter 13 Beagle Board with a Rich User Interface 599Rich UI Beagle Board Architectures 600Beagle Boards as General-Purpose Computers 601Connecting a Bluetooth Input Peripheral 603BeagleBone with a LCD Touchscreen Cape 604Virtual Network Computing 605VNC Using VNC Viewer 605VNC with Xming and PuTTY 606VNC with a Linux Desktop Computer 607Fat-Client Applications 608Rich UI Application Development 608Introduction to GTK+ on the Beagle Boards 609The "Hello World" GTK+ Application 609The Event-Driven Programming Model 610The GTK+ Temperature Application 611Introduction to Qt for the Beagle Board 612Installing Qt Development Tools 613The "Hello World" Qt Application 613Qt Primer 615Qt Concepts 615The QObject Class 617Signals and Slots 617Qt Development Tools 618A First Qt Creator Example 620A Qt Temperature Sensor GUI Application 621Remote UI Application Development 625Fat-Client Qt GUI Application 626Multithreaded Server Applications 629A Multithreaded Temperature Service 632Parsing Stream Data 634The Fat Client as a Server 635Parsing Stream Data with XML 638The Beagle Board Client Application 639Summary 641Further Reading 641Chapter 14 Images, Video, and Audio 643Capturing Images and Video 644USB Webcams 644Video4Linux2 (V4L2) 646Image Capture Utility 647Video4Linux2 Utilities 648Writing Video4Linux2 Programs 650Streaming Video 652Image Processing and Computer Vision 654Image Processing with Open CV 654Computer Vision with Open CV 656Boost 659BeagleBone Audio 660Core Audio Software Tools 661Audio Devices for the Beagle Boards 661HDMI and USB Audio Playback Devices 661Internet Radio Playback 664Recording Audio 664Audio Network Streaming 666Bluetooth A2DP Audio 666Text-to-Speech 669Summary 670Further Reading 670Chapter 15 Real-Time Interfacing with the PRU-ICSS 673The PRU-ICSS 674The PRU-ICSS Architecture 674The Remote Processor Framework 675Important Documents 676Development Tools for the PRU-ICSS 676The PRU Code Generation Tools 677The PRU Debugger 677Using the AM335x PRU-ICSS 679Setting Up the Board for Remoteproc 679Testing Remoteproc under Linux 680A First PRU Example 683PRU-ICSS Enhanced GPIOs 683A First PRU Program 686A First PRU Program in C 686A First PRU Program in Assembly 688The PRU-ICSS in Detail 691Registers 691Local and Global Memory 692PRU Assembly Instruction Set 696PRU-ICSS Applications 698PRU-ICSS Performance Tests 698Utilizing Regular Linux GPIOs 702A PRU PWM Generator 704A PRU Sine Wave Generator 708An Ultrasonic Sensor Application 709Summary 714Further Reading 714Chapter 16 Embedded Kernel Programming 717Introduction 718Why Write Kernel Modules? 718Loadable Kernel Module Basics 719A First LKM Example 720The LKM Make file 722Building the LKM on a Beagle Board 723Testing the First LKM Example 724Testing the LKM Parameter 726An Embedded LKM Example 727Interrupt Service Routines 729Performance 733Enhanced Button GPIO Driver LKM 733The object Interface 734Enhanced LED GPIO Driver LKM 741Kernel Threads 742Conclusions 744Summary 744Index 745
Dr. Derek Molloy is an Associate Professor 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.
1997-2024 DolnySlask.com Agencja Internetowa