Helion


Szczegóły ebooka

GNU/Linux Rapid Embedded Programming

GNU/Linux Rapid Embedded Programming


An annotated guide to program and develop GNU/Linux Embedded systems quickly

About This Book

  • Rapidly design and build powerful prototypes for GNU/Linux Embedded systems
  • Become familiar with the workings of GNU/Linux Embedded systems and how to manage its peripherals
  • Write, monitor, and configure applications quickly and effectively, manage an external micro-controller, and use it as co-processor for real-time tasks

Who This Book Is For

This book targets Embedded System developers and GNU/Linux programmers who would like to program Embedded Systems and perform Embedded development. The book focuses on quick and efficient prototype building. Some experience with hardware and Embedded Systems is assumed, as is having done some previous work on GNU/Linux systems. Knowledge of scripting on GNU/Linux is expected as well.

What You Will Learn

  • Use embedded systems to implement your projects
  • Access and manage peripherals for embedded systems
  • Program embedded systems using languages such as C, Python, Bash, and PHP
  • Use a complete distribution, such as Debian or Ubuntu, or an embedded one, such as OpenWrt or Yocto
  • Harness device driver capabilities to optimize device communications
  • Access data through several kinds of devices such as GPIO's, serial ports, PWM, ADC, Ethernet, WiFi, audio, video, I2C, SPI, One Wire, USB and CAN
  • Practical example usage of several devices such as RFID readers, Smart card readers, barcode readers, z-Wave devices, GSM/GPRS modems
  • Usage of several sensors such as light, pressure, moisture, temperature, infrared, power, motion

In Detail

Embedded computers have become very complex in the last few years and developers need to easily manage them by focusing on how to solve a problem without wasting time in finding supported peripherals or learning how to manage them. The main challenge with experienced embedded programmers and engineers is really how long it takes to turn an idea into reality, and we show you exactly how to do it. This book shows how to interact with external environments through specific peripherals used in the industry. We will use the latest Linux kernel release 4.4.x and Debian/Ubuntu distributions (with embedded distributions like OpenWrt and Yocto).

The book will present popular boards in the industry that are user-friendly to base the rest of the projects on - BeagleBone Black, SAMA5D3 Xplained, Wandboard and system-on-chip manufacturers.

Readers will be able to take their first steps in programming the embedded platforms, using C, Bash, and Python/PHP languages in order to get access to the external peripherals. More about using and programming device driver and accessing the peripherals will be covered to lay a strong foundation. The readers will learn how to read/write data from/to the external environment by using both C programs or a scripting language (Bash/PHP/Python) and how to configure a device driver for a specific hardware.

After finishing this book, the readers will be able to gain a good knowledge level and understanding of writing, configuring, and managing drivers, controlling and monitoring applications with the help of efficient/quick programming and will be able to apply these skills into real-world projects.

Style and approach

This practical tutorial will get you quickly prototyping embedded systems on GNU/Linux. This book uses a variety of hardware to program the peripherals and build simple prototypes.

  • GNU/Linux Rapid Embedded Programming
    • GNU/Linux Rapid Embedded Programming
    • Credits
    • About the Author
    • About the Reviewer
    • www.PacktPub.com
      • Why subscribe?
    • Customer Feedback
    • Preface
      • What this book covers
      • What you need for this book
        • Software prerequisite
        • Hardware prerequisite
      • Who this book is for
      • Conventions
        • Codes and command lines
        • Kernel and logging messages
        • File modifications
        • Serial & network connections
        • Other conventions
      • Reader feedback
      • Customer support
        • Downloading the example code
        • Downloading the color images of this book
        • Errata
        • Piracy
        • Questions
    • 1. Installing the Developing System
      • Embedded world terms
      • Systems overview
        • The BeagleBone Black
        • The SAMA5D3 Xplained
        • The Wandboard
      • Installing a development system
        • Setting up the host machine
          • Basic tools
          • The cross-compiler
        • Setting up the BeagleBone Black
          • Serial console for the BeagleBone Black
          • U-Boot (with MLO)
          • Linux kernel for the BeagleBone Black
          • Debian 8 (jessie) for the BeagleBone Black
        • Setting up the SAMA5D3 Xplained
          • Serial console for SAMA5D3 Xplained
          • U-Boot (with boot.bin)
          • Linux kernel for SAMA5D3 Xplained
          • Debian 8 (jessie) for SAMA5D3 Xplained
        • Setting up the Wandboard
          • Serial console for the Wandboard
          • U-Boot (with SPL)
          • Linux kernel for the Wandboard
          • Debian 8 (jessie) for the Wandboard
      • Setting up the developing system
        • BeagleBone Black - USB, networking, and overlays
        • SAMA5D3 Xplained - USB and networking
        • Wandboard - USB and networking (wired and wireless)
        • Common settings
      • Summary
    • 2. Managing the System Console
      • Basic OS management
        • File manipulation and Co
          • echo and cat
          • dd
          • grep and egrep
          • tr and sed
          • head and tail
          • od and hexdump
          • file
          • strings
          • strace
        • Package management
          • Searching a software package
          • Installing a package
          • apt-get and friends versus aptitude
          • The deb files
        • Managing the kernel messages
      • A quick tour into the bootloader
        • The environment
        • Managing the storage devices
          • MMC
          • Managing the flash
        • GPIO management
        • Accessing an I2C device
        • Loading files from the network
        • The kernel command line
      • Summary
    • 3. C Compiler, Device Drivers, and Useful Developing Techniques
      • The C compiler
        • Native and foreign machine architecture
        • Compiling a C program
          • The native compilation
          • The cross-compilation
        • Compiling a kernel module
      • The Kernel and DTS files
        • Recompiling the kernel
        • The device tree
      • What is a device driver?
        • Char, block, and net devices
        • Modules versus built-in devices
        • The modutils
        • Writing our own device driver
      • The root filesystem (rootfs)
        • The /dev directory
        • The tmpfs
        • The procfs
        • The sysfs
      • The Network FileSystem (NFS)
        • Exporting an NFS on the host
        • Setting up the kernel to mount an NFS
        • U-Boot and the kernel command line to use a NFS
        • Developing into an NFS
      • Using an emulator
        • Executing a program
        • Entering into an ARM rootfs tree
      • Summary
    • 4. Quick Programming with Scripts and System Daemons
      • Setting up the system
      • System daemons
        • Useful and ready-to-use daemons
        • System daemons management
          • syslogd
            • syslogd in Bash
            • syslogd in C
            • syslogd in PHP
            • syslogd in Python
          • cron
          • xinetd
          • sshd
          • Apache
          • MySQL
            • MySQL in Bash
            • MySQL in C
            • MySQL in PHP
            • MySQL in Python
      • Scripting languages
        • Managing a LED in PHP
          • The LAMP solution
          • The built-in server solution
        • Managing a LED in Python
        • Managing a LED in Bash
      • Writing a custom daemon
        • A daemon in C
        • A daemon in PHP
        • A daemon in Python
        • A daemon in Bash
      • Summary
    • 5. Setting Up an Embedded OS
      • MTD versus block devices
        • What is an MTD device?
        • Managing an MTD device
        • Filesystems for flash memories
          • JFFS2 versus UBIFS
          • Building a JFFS2 filesystem
          • Building a UBIFS filesystem
      • OpenWrt
        • Using the default configuration
        • Adding a (quasi) LAMP system
        • Adding a custom package
      • Yocto
        • Using the default recipe
        • Adding the graphic support
        • Adding a custom recipe
      • Summary
    • 6. General Purposes Input Output signals GPIO
      • What is a GPIO line?
        • GPIOs lines on the BeagleBone Black
        • GPIOs on the SAMA5D3 Xplained
        • GPIOs on the Wandboard
      • GPIOs in Linux
      • Getting access to GPIOs
        • Bash
        • C
      • Using GPIOs with scripting languages
        • PHP
        • Python
      • Managing GPIO into the kernel
        • An input device using GPIOs
        • LEDs and triggers
      • Summary
    • 7. Serial Ports and TTY Devices - TTY
      • What are TTY, serial, and UART lines?
        • The electrical lines
        • TTYs on the BeagleBone Black
        • TTYs on the SAMA5D3 Xplained
        • TTYs on the Wandboard
      • Implementations of serial ports
      • The serial ports in Linux
      • The communication parameters
      • Getting access to TTYs
        • Distance sensor
        • RFID LF reader
      • Managing TTY in the kernel with SLIP
      • Summary
    • 8. Universal Serial Bus - USB
      • What is the universal serial bus?
        • The electrical lines
        • USB ports on the BeagleBone Black
        • USB ports on the SAMA5D3 Xplained
        • USB ports on the Wandboard
      • The USB bus in Linux
        • Acting as a host
        • Acting as a device
          • The Multi gadget
          • The configfs gadget
      • The USB tools
      • The raw USB bus
        • Accessing as a host
      • Summary
    • 9. Inter-Integrated Circuits - I2C
      • What is the Inter-Integrated Circuit bus?
        • The electrical lines
        • I2C ports on the SAMA5D3 Xplained
        • I2C ports on the Wandboard
      • The I2C bus in Linux
      • The I2C tools
      • Getting access to I2C devices
        • EEPROM, ADC and IO Expander
          • EEPROM
          • ADC
          • IO Expander
        • The temperature/humidity and pressure sensors
        • Serial port
      • The Raw I2C Bus
        • Writing data in C
        • Reading data in Python
      • Summary
    • 10. Serial Peripheral Interface - SPI
      • What is the Serial Peripheral Interface bus?
        • The electrical lines
        • SPI ports on the BeagleBone Black
        • SPI ports on the SAMA5D3 Xplained
        • SPI ports on the Wandboard
      • The SPI bus in Linux
      • The SPI tools
      • Getting access to SPI devices
        • LCD display
        • Serial port
      • The raw SPI bus
        • Exchanging data in C
        • Exchanging data in Python
      • Summary
    • 11. 1-Wire - W1
      • What is the 1-Wire Bus?
        • The electrical lines
        • 1-Wire ports on the BeagleBone Black
        • 1-Wire ports on the SAMA5D3 Xplained
        • 1-Wire ports on the Wandboard
      • The 1-Wire bus in Linux
      • Getting access to 1-Wire devices
        • Using the GPIO interface
        • Using an external controller
      • Summary
    • 12. Ethernet Network Device - ETH
      • What is an Ethernet network device?
        • Electrical lines
        • Ethernet port on the BeagleBone Black
        • Ethernet ports on the SAMA5D3 Xplained
        • Ethernet port on the Wandboard
      • The Ethernet devices in Linux
      • The net tools
      • Communicating with a remote device
        • A simple TCP client/server application
        • Using ready-to-use networking tools
      • The raw Ethernet bus
      • Simple Ethernet bridging
      • Summary
    • 13. Wireless Network Device - WLAN
      • What is a wireless network device?
        • The electrical lines
        • WLAN device on the BeagleBone Black
        • WLAN device on the SAMA5D3 Xplained
        • WLAN device on the Wandboard
      • WLAN devices in Linux
        • Pluggable external WLAN devices
        • The Wi-Fi operation modes
      • The wireless tools
      • The WPA supplicant
      • The Hostapd daemon
      • Summary
    • 14. Controller Area Network - CAN
      • What is the CAN bus?
        • The electrical lines
        • CAN ports on the BeagleBone Black
        • CAN ports on the SAMA5D3 Xplained
        • CAN ports on the Wandboard
      • The CAN bus in Linux
      • The can-utils package
      • The raw CAN bus
      • Exchanging data via the CAN bus
        • Using the on-board controller
        • Using an external controller
      • Summary
    • 15. Sound Devices - SND
      • What is a sound device?
        • The electrical lines
        • Sound on the BeagleBone Black
        • Sound on the SAMA5D3 Xplained
        • Sound on the Wandboard
      • Sound in Linux
      • The audio tools
        • The ALSA utils
        • Madplay
        • Mplayer
        • Sox
      • The USB audio device class
      • Managing sound devices
        • Adding an audio codec
        • A simple oscilloscope
      • Summary
    • 16. Video devices - V4L
      • What is a video device?
        • The electrical lines
        • Video on the BeagleBone Black
        • Video on the SAMA5D3 Xplained
        • Video on the Wandboard
      • Video in Linux
      • The video tools
      • The USB video class device 
      • Managing video devices
        • Streaming video over the Web
        • Capturing motion
      • Summary
    • 17. Analog-to-Digital Converters - ADC
      • What is an analog-to-digital converter device?
        • The electrical lines
        • ADCs on the BeagleBone Black
        • ADCs on the SAMA5D3 Xplained
        • ADCs on the Wandboard
      • ADCs in Linux
      • Detecting a gas
      • Summary
    • 18. Pulse-Width Modulation - PWM
      • What is a PWM device?
        • The electrical lines
        • PWMs on the BeagleBone Black
        • PWMs on the SAMA5D3 Xplained
        • PWMs on the Wandboard
      • PWM devices in Linux
      • Managing a servo motor
      • Summary
    • 19. Miscellaneous Devices
      • Digital sensors
        • Water sensor
        • Infrared sensor
      • Analog sensors
        • Moisture sensor
        • Pressure sensor
        • Light sensor
      • GSM/GPRS modem
      • Smart card reader
      • RFID reader
      • Z-Wave
        • Z-Wave controllers
        • The Z-Wave wall plug sensor
        • The Z-Wave multi sensor
      • Summary