GNU/Linux Rapid Embedded Programming

Book description

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 be able to easily manage embedded computer projects by focusing on problem solving; they should not have to waste time finding supported peripherals or learning how to manage them. This book shows you how to interact with external environments through specific peripherals used in the industry. It focuses on the latest Linux kernel release 4 and Debian/Ubuntu distributions (with embedded distributions such as OpenWRT and Yocto).

    This book presents popular and user-friendly boards in the industry – such as Beaglebone Black, Atmel Xplained, Wandboard, and system-on-chip manufacturers – and lets you explore corresponding projects that make use of these boards. You will first program the embedded platforms using the C, Bash, and Python/PHP languages in order to get access to the external peripherals. You will gain a strong foundation in using embedded systems by learning how to program the device driver and access the peripherals. You will also learn how to read and write data from/to the external environment by using C programs or a scripting language (such as Bash/PHP/Python) and see how to configure a device driver for specific hardware.

    The final chapter shows you how to use a micro-controller board – based on the most used microcontroller – to implement real-time or specific tasks that are normally not carried out on the GNU/Linux system. After finishing this book, you will be capable of applying these skills to your personal and professional 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.

    Table of contents

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

    Product information

    • Title: GNU/Linux Rapid Embedded Programming
    • Author(s): Rodolfo Giometti
    • Release date: March 2017
    • Publisher(s): Packt Publishing
    • ISBN: 9781786461803