Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Embedded Linux Programming

You're reading from   Mastering Embedded Linux Programming Unleash the full potential of Embedded Linux with Linux 4.9 and Yocto Project 2.2 (Morty) Updates

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781787283282
Length 478 pages
Edition 2nd Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Mr. Chris Simmonds Mr. Chris Simmonds
Author Profile Icon Mr. Chris Simmonds
Mr. Chris Simmonds
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Starting Out FREE CHAPTER 2. Learning About Toolchains 3. All About Bootloaders 4. Configuring and Building the Kernel 5. Building a Root Filesystem 6. Selecting a Build System 7. Creating a Storage Strategy 8. Updating Software in the Field 9. Interfacing with Device Drivers 10. Starting Up – The init Program 11. Managing Power 12. Learning About Processes and Threads 13. Managing Memory 14. Debugging with GDB 15. Profiling and Tracing 16. Real-Time Programming

Hardware used in this book

The worked examples in this book are intended to be generic, but to make them relevant and easy to follow, I have had to choose specific hardware. I have chosen two exemplar devices: the BeagleBone Black and QEMU. The first is a widely-available and cheap development board which can be used in serious embedded hardware. The second is a machine emulator that can be used to create a range of systems that are typical of embedded hardware. It was tempting to use QEMU exclusively, but, like all emulations, it is not quite the same as the real thing. Using a BeagleBone Black, you have the satisfaction of interacting with real hardware and seeing real LEDs flash. I could have selected a board that is more up-to-date than the BeagleBone Black, which is several years old now, but I believe that its popularity gives it a degree of longevity and it means that it will continue to be available for some years yet.

In any case, I encourage you to try out as many of the examples as you can, using either of these two platforms, or indeed any embedded hardware you may have to hand.

The BeagleBone Black

The BeagleBone and the later BeagleBone Black are open hardware designs for a small, credit card sized development board produced by CircuitCo LLC. The main repository of information is at https://beagleboard.org/. The main points of the specifications are:

  • TI AM335x 1 GHz ARM® Cortex-A8 Sitara SoC
  • 512 MiB DDR3 RAM
  • 2 or 4 GiB 8-bit eMMC on-board flash storage
  • Serial port for debug and development
  • MicroSD connector, which can be used as the boot device
  • Mini USB OTG client/host port that can also be used to power the board
  • Full size USB 2.0 host port
  • 10/100 Ethernet port
  • HDMI for video and audio output

In addition, there are two 46-pin expansion headers for which there are a great variety of daughter boards, known as capes, which allow you to adapt the board to do many different things. However, you do not need to fit any capes in the examples in this book.

In addition to the board itself, you will need:

  • A mini USB to full-size USB cable (supplied with the board) to provide power, unless you have the last item on this list.
  • An RS-232 cable that can interface with the 6-pin 3.3V TTL level signals provided by the board. The Beagleboard website has links to compatible cables.
  • A microSD card and a means of writing to it from your development PC or laptop, which will be needed to load software onto the board.
  • An Ethernet cable, as some of the examples require network connectivity.
  • Optional, but recommended, a 5V power supply capable of delivering 1 A or more.

QEMU

QEMU is a machine emulator. It comes in a number of different flavors, each of which can emulate a processor architecture and a number of boards built using that architecture. For example, we have the following:

  • qemu-system-arm: ARM
  • qemu-system-mips: MIPS
  • qemu-system-ppc: PowerPC
  • qemu-system-x86: x86 and x86_64

For each architecture, QEMU emulates a range of hardware, which you can see by using the option—machine help. Each machine emulates most of the hardware that would normally be found on that board. There are options to link hardware to local resources, such as using a local file for the emulated disk drive. Here is a concrete example:

$ qemu-system-arm -machine vexpress-a9 -m 256M -drive 
file=rootfs.ext4,sd -net nic -net use -kernel zImage -dtb vexpress-
v2p-ca9.dtb -append "console=ttyAMA0,115200 root=/dev/mmcblk0" -
serial stdio -net nic,model=lan9118 -net tap,ifname=tap0

The options used in the preceding command line are:

  • -machine vexpress-a9: Creates an emulation of an ARM Versatile Express development board with a Cortex A-9 processor
  • -m 256M: Populates it with 256 MiB of RAM
  • -drive file=rootfs.ext4,sd: Connects the SD interface to the local file rootfs.ext4 (which contains a filesystem image)
  • -kernel zImage: Loads the Linux kernel from the local file named zImage
  • -dtb vexpress-v2p-ca9.dtb: Loads the device tree from the local file vexpress-v2p-ca9.dtb
  • -append "...": Supplies this string as the kernel command-line
  • -serial stdio: Connects the serial port to the terminal that launched QEMU, usually so that you can log on to the emulated machine via the serial console
  • -net nic,model=lan9118: Creates a network interface
  • -net tap,ifname=tap0: Connects the network interface to the virtual network interface tap0

To configure the host side of the network, you need the tunctl command from the User Mode Linux (UML) project; on Debian and Ubuntu, the package is named uml-utilites:

$ sudo tunctl -u $(whoami) -t tap0

This creates a network interface named tap0 which is connected to the network controller in the emulated QEMU machine. You configure tap0 in exactly the same way as any other interface.

All of these options are described in detail in the following chapters. I will be using Versatile Express for most of my examples, but it should be easy to use a different machine or architecture.

You have been reading a chapter from
Mastering Embedded Linux Programming - Second Edition
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781787283282
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image