Book Image

GNU/Linux Rapid Embedded Programming

By : Rodolfo Giometti
Book Image

GNU/Linux Rapid Embedded Programming

By: Rodolfo Giometti

Overview of this book

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.
Table of Contents (26 chapters)
GNU/Linux Rapid Embedded Programming
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Embedded world terms


Before putting our hands on our new boards, it is recommended that you acquaint yourselves with some terms that a user should know in order to avoid misunderstandings. People who have already worked with some GNU/Linux and/or embedded systems may skip this part. The developer kits shown here are tiny single-board computers that can be embedded into a device, so the user should be familiar with some terms used in the wonderful world of embedded programming:

Term

Description

Target

The target system is the embedded computer that we wish to manage.

Usually, it is an ARM platform, but this is not a fixed rule. In fact, PowerPC and MIPS are other (less) common platforms. Even the x86 platform (a standard PC) can be an embedded computer.

Host

The host system is the computer we will use to manage the target system. Usually, it is a normal PC (x86 platform or MAC), but even other platforms can be used (for example, years ago, I used a PowerPC-based computer as a host PC).

Normally, the host system is more powerful than the target one since it's usually used for heavy compiling tasks that the target cannot perform at all or for tasks that it takes a long time to perform.

Serial console

This is the most important communication port in an embedded system.

Using the serial console, the user has complete control of the system.

It's not only indispensable for debugging, but is also the last resort if, by chance, the operating system files are messed up and the board refuses to boot.

Without the serial console, the user can still control the system (if correctly set up), but for the developer/debugger, it's a must-have!

Compiler (or native compiler)

The native compiler is just a compiler! This is the compiler running on a machine (host or target) that builds the code for the current machine (that is, the compiler running on a PC builds the code for the PC, like the one running on an ARM machine builds the code for ARM itself).

Cross-compiler

Strictly speaking, the cross-compiler is just a compiler that builds the code for a foreign platform (that is, a cross-compiler can run on a PC in order to generate binaries for an ARM platform). However, usually, by using this term, the embedded developers also mean the complete compilation suite, that is, the compiler, linker, binutils, libc, and so on.

Toolchain

A toolchain is a set of programming tools that is used to create a software product, that is, another computer program or a set of related programs.

The term toolchain is due the fact that the tools forming a toolchain are executed consecutively as in a chain, so the output of each tool becomes the input for the next one. However, this is not a fixed rule. In fact, the tools in a toolchain are not necessarily executed consecutively.

A simple software development toolchain may consist of a compiler, a linker (plus other binutils), one or more libraries (which provide interfaces to the operating system), and a debugger (used to debug programs).

Distribution

A distribution (or Linux distribution, often called distro for short) is an operating system made from a software collection based on Linux (the kernel) and several software packages (most from the GNU project or based on a Libre Software license) managed by a package management system.

There are several distributions, and they are available for a wide variety of systems ranging from embedded devices (OpenWrt or Yocto) and personal computers to powerful supercomputers.

Root filesystem

The root filesystem (or rootfs) is the filesystem contained on the same partition on which the root directory is located.

This is the most important filesystem in an UNIX system, and it's the first one to be mounted by the kernel. All the other filesystems are mounted on it.

System on chip

A system on chip (SoC) is an integrated circuit that integrates a CPU and different kinds of peripherals (SATA and SD/MMC controller, GPIOs, I2C/SPI/W1 controllers, ADC/DAC converters, audio/video signals, and Ethernet or UART ports) into a single chip.

These chips are widely used in embedded systems where they found their typical application.

Microcontroller

A microcontroller (MCU) is a small computer on a single integrated circuit (like a SoC) that contains a processor core, memory, and programmable IO peripherals. So, the main difference between a SoC is that it has the flash memory (where the program is stored) as well as a small amount of RAM (to execute the program) included on its chip.

Microcontrollers are designed for embedded applications where the tasks to be accomplished are not too complex. They are also used when we need have time constraints or just because they are cost effective.

Flash memory

Flash memory is an electronic non-volatile computer storage medium that can be electrically erased and reprogrammed.

In contrast to a normal PC, this kind of memory is widely used on embedded applications as mass storage due the fact it has no moving parts and it has better resistance to a hostile environment.

Now that some important terms have been pointed out, we are ready to step into the next section and discover our developer kits!