100% found this document useful (1 vote)
17 views71 pages

Linux Driver Development With Raspberry Pi Practical Labs 1st Edition Alberto Liberal de Los Rios

Uploaded by

spungdavenz5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
17 views71 pages

Linux Driver Development With Raspberry Pi Practical Labs 1st Edition Alberto Liberal de Los Rios

Uploaded by

spungdavenz5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

Visit https://ebookfinal.

com to download the full version and


explore more ebook

Linux Driver Development with Raspberry Pi Practical


Labs 1st Edition Alberto Liberal De Los Rios

_____ Click the link below to download _____


https://ebookfinal.com/download/linux-driver-
development-with-raspberry-pi-practical-labs-1st-
edition-alberto-liberal-de-los-rios/

Explore and download more ebook at ebookfinal.com


Here are some recommended products that might interest you.
You can download now and explore!

Raspberry Pi Hacks Tips Tools for Making Things with the


Inexpensive Linux Computer 1st Edition Ruth Suehle

https://ebookfinal.com/download/raspberry-pi-hacks-tips-tools-for-
making-things-with-the-inexpensive-linux-computer-1st-edition-ruth-
suehle/
ebookfinal.com

Getting Started with Python and Raspberry Pi 1st Edition


Nixon

https://ebookfinal.com/download/getting-started-with-python-and-
raspberry-pi-1st-edition-nixon/

ebookfinal.com

Learning Raspberry Pi 1st Edition Shah

https://ebookfinal.com/download/learning-raspberry-pi-1st-edition-
shah/

ebookfinal.com

Raspberry Pi User Guide 1st Edition Gareth Halfacree

https://ebookfinal.com/download/raspberry-pi-user-guide-1st-edition-
gareth-halfacree/

ebookfinal.com
Raspberry Pi User Guide 4th Edition Eben Upton

https://ebookfinal.com/download/raspberry-pi-user-guide-4th-edition-
eben-upton/

ebookfinal.com

Raspberry Pi Robotics Projects 2nd Edition Richard


Grimmett

https://ebookfinal.com/download/raspberry-pi-robotics-projects-2nd-
edition-richard-grimmett/

ebookfinal.com

Raspberry Pi A Quick Start Guide 2nd Edition Maik Schmidt

https://ebookfinal.com/download/raspberry-pi-a-quick-start-guide-2nd-
edition-maik-schmidt/

ebookfinal.com

The Official Raspberry Pi Beginner s Guide 2nd Edition


Halfacree

https://ebookfinal.com/download/the-official-raspberry-pi-beginner-s-
guide-2nd-edition-halfacree/

ebookfinal.com

Raspberry Pi 3 Cookbook for Python Programmers Third


Edition Tim Cox

https://ebookfinal.com/download/raspberry-pi-3-cookbook-for-python-
programmers-third-edition-tim-cox/

ebookfinal.com
Linux Driver Development with Raspberry Pi Practical
Labs 1st Edition Alberto Liberal De Los Rios Digital
Instant Download
Author(s): Alberto Liberal de los Rios
ISBN(s): 9798516120688, 8516120686
Edition: 1
File Details: PDF, 5.95 MB
Year: 2021
Language: english
Linux Driver
Development with
Raspberry Pi®
Practical Labs
Copyright © 2021, Alberto Liberal. All rights reserved.

No part of this publication may be reproduced, photocopied, stored in a retrieval system, or


transmitted in any form or by any means, without the prior written permission of the publisher.

Linux is a registered trademark of Linus Torvalds. Other trademarks within this book are the
property of their respective owners.

The kernel modules examples provided with this book are released under the GPL license. This
license gives you the right to use, study, modify and share the software freely. However, when
the software is redistributed, modified or unmodified, the GPL requires that you redistribute the
software under the same license, with the source code.

Published by:

Alberto Liberal
[email protected]

Graphic Design: Signo Comunicación Consultores SLU


Imprint: Independently published
About the Author
Alberto Liberal is a Field Application Engineer at Arrow Electronics with over 15 years of
experience in embedded systems. For the last few years at Arrow, he has been supporting high-
end processors and FPGAs. Alberto is a Linux fan and has presented numerous technical seminars
and practical workshops about embedded Linux and Linux device drivers during the past few
years. Alberto´s other fields of expertise include multimedia SoCs and real-time operating systems
(RTOS). He currently lives in Madrid, Spain, and his great passion is taking long walks with his
daughter through the center of Madrid. He also enjoys reading about cinema and watching sci-fi
movies.

[1]
Table of Contents
Preface..................................................................................................................13
Chapter 1: Building the System..........................................................................19
Bootloader..............................................................................................................20
Linux kernel............................................................................................................22
System call interface and C runtime library............................................................25
System shared libraries..........................................................................................26
Root filesystem.......................................................................................................27
Linux boot process..................................................................................................28
Building an embedded Linux system for the Raspberry Pi.....................................29
Raspberry Pi OS.....................................................................................................30
Connect and set up hardware................................................................................32
Setting up an ethernet communication...................................................................36
Copying files to your Raspberry Pi.........................................................................36
Building the Linux kernel........................................................................................37
Chapter 2: The Linux Device and Driver Model.................................................41
Bus core drivers......................................................................................................42
Bus controller drivers..............................................................................................44
Device drivers.........................................................................................................44
Devices...................................................................................................................45
The sysfs filesystem...............................................................................................47
The kobject infrastructure.......................................................................................49
Introduction to the Device Tree...............................................................................53
Chapter 3: The Simplest Drivers.........................................................................61
Licensing.................................................................................................................62
LAB 3.1: "helloworld" module.................................................................................62
Listing 3-1: helloworld_rpi3.c......................................................................63
Listing 3-2: Makefile....................................................................................63
helloworld_rpi3.ko demonstration...............................................................64
LAB 3.2: "helloworld with parameters" module.......................................................65
Listing 3-3: helloworld_rpi3_with_parameters.c..........................................66
Listing 3-4: Makefile....................................................................................66

[3]
Table of Contents

helloworld_rpi3_with_parameters.ko demonstration...................................67
Chapter 4: Character Drivers..............................................................................69
LAB 4.1: "helloworld character" module.................................................................71
Registration and unregistration of character devices.............................................72
Listing 4-1: helloworld_rpi3_char_driver.c...................................................76
Listing 4-2: Makefile....................................................................................78
Listing 4-3: ioctl_test.c................................................................................78
helloworld_rpi3_char_driver.ko demonstration...........................................79
Creating device files with devtmpfs........................................................................79
LAB 4.2: "class character" module.........................................................................80
Listing 4-4: helloworld_rpi3_class_driver.c.................................................82
helloworld_rpi3_class_driver.ko demonstration..........................................84
Miscellaneous character driver...............................................................................85
Registering a minor number...................................................................................85
LAB 4.3: "miscellaneous character" module...........................................................86
Listing 4-5: misc_rpi3_driver.c....................................................................87
misc_rpi3_driver.ko demonstration.............................................................88
Chapter 5: Platform Drivers.................................................................................89
LAB 5.1: "platform device" module.........................................................................91
Listing 5-1: hellokeys_rpi3.c........................................................................93
hellokeys_rpi3.ko demonstration................................................................95
Documentation to interact with the hardware.........................................................96
Hardware naming convention.................................................................................96
Pin control subsystem.............................................................................................97
GPIO controller driver...........................................................................................106
GPIO descriptor consumer interface....................................................................110
Obtaining and disposing GPIOs........................................................................... 110
Using GPIOs......................................................................................................... 110
GPIOs mapped to IRQs........................................................................................ 111
GPIOs in the Device Tree..................................................................................... 112
Exchanging data between kernel and user spaces..............................................112
MMIO (Memory-Mapped I/O) device access........................................................113
LAB 5.2: "RGB LED platform device" module......................................................115

[4]
Table of Contents

LAB 5.2 hardware description.............................................................................. 116


LAB 5.2 Device Tree description.......................................................................... 117
LAB 5.2 code description of the "RGB LED platform device" module..................121
Listing 5-2: ledRGB_rpi3_platform.c.........................................................126
ledRGB_rpi3_platform.ko demonstration..................................................131
Platform driver resources......................................................................................132
Linux LED class....................................................................................................133
LAB 5.3: "RGB LED class" module.......................................................................136
LAB 5.3 Device Tree description..........................................................................136
LAB 5.3 code description of the "RGB LED class" module..................................137
Listing 5-3: ledRGB_rpi3_class_platform.c...............................................141
ledRGB_rpi3_class_platform.ko demonstration........................................145
Platform device drivers in user space...................................................................146
User defined I/O: UIO...........................................................................................148
How UIO works.....................................................................................................150
Kernel UIO API.....................................................................................................151
LAB 5.4: "LED UIO platform" module...................................................................153
LAB 5.4 Device Tree description..........................................................................153
LAB 5.4 code description of the "LED UIO platform" module...............................153
Listing 5-4: led_rpi3_UIO_platform.c........................................................156
Listing 5-5: UIO_app.c..............................................................................157
led_rpi3_UIO_platform.ko with UIO_app demonstration..........................160
Chapter 6: I2C Client Drivers.............................................................................161
The Linux I2C subsystem.....................................................................................163
Writing I2C client drivers.......................................................................................165
I2C client driver registration..................................................................................165
Declaration of I2C devices in the Device Tree......................................................167
LAB 6.1: "I2C I/O expander device" module.........................................................168
LAB 6.1 hardware description..............................................................................168
LAB 6.1 Device Tree description..........................................................................168
LAB 6.1 code description of the "I2C I/O expander device" module....................169
Listing 6-1: io_rpi3_expander.c.................................................................173
io_rpi3_expander.ko demonstration..........................................................176
LAB 6.2: "I2C multidisplay LED" module..............................................................177
LAB 6.2 hardware description..............................................................................178
LAB 6.2 Device Tree description..........................................................................178

[5]
Table of Contents

Unified device properties interface for ACPI and Device Tree..............................180


LAB 6.2 code description of the "I2C multidisplay LED" module..........................181
Listing 6-2: ltc3206_rpi3_led_class.c........................................................186
ltc3206_rpi3_led_class.ko demonstration.................................................192
Chapter 7: Handling Interrupts in Device Drivers...........................................195
Linux kernel IRQ domain for GPIO controllers.....................................................198
Device Tree interrupt handling..............................................................................204
Requesting interrupts in Linux device drivers.......................................................206
LAB 7.1: "button interrupt device" module............................................................207
LAB 7.1 hardware description..............................................................................207
LAB 7.1 Device Tree description..........................................................................208
LAB 7.1 code description of the "button interrupt device" module........................209
Listing 7-1: int_rpi3_key.c.........................................................................211
int_rpi3_key.ko demonstration..................................................................213
Deferred work.......................................................................................................214
Softirqs.................................................................................................................215
Tasklets.................................................................................................................217
Timers...................................................................................................................217
Threaded interrupts..............................................................................................221
Workqueues.........................................................................................................223
Locking in the kernel.............................................................................................226
Locks and uniprocessor kernels...........................................................................227
Sharing spinlocks between interrupt and process context...................................227
Locking in user context.........................................................................................227
Sleeping in the kernel...........................................................................................228
LAB 7.2: "sleeping device" module.......................................................................230
LAB 7.2 Device Tree description..........................................................................230
LAB 7.2 code description of the "sleeping device" module..................................232
Listing 7-2: int_rpi3_key_wait.c.................................................................235
int_rpi3_key_wait.ko demonstration..........................................................238
Kernel threads......................................................................................................239
LAB 7.3: "keyled class" module............................................................................240
LAB 7.3 hardware description..............................................................................241
LAB 7.3 Device Tree description..........................................................................241
LAB 7.3 code description of the "keyled class" module........................................242
Listing 7-3: keyled_rpi3_class.c................................................................249

[6]
Table of Contents

keyled_rpi3_class.ko demonstration.........................................................259
LAB 7.4: "GPIO expander device" module...........................................................262
LAB 7.4 hardware description..............................................................................263
LAB 7.4 Device Tree description..........................................................................264
LAB 7.4 GPIO controller driver description...........................................................265
Listing 7-4: CY8C9520A_rpi3.c ................................................................271
LAB 7.4 GPIO child driver description..................................................................283
Listing 7-5: int_rpi3_gpio.c .......................................................................285
LAB 7.4 GPIO based IRQ application..................................................................286
Listing 7-6: gpio_int.c ...............................................................................287
LAB 7.4 driver demonstration...................................................................289
LAB 7.5: "GPIO-PWM-PINCTRL expander device" module.................................293
LAB 7.5 GPIO irqchip description.........................................................................293
LAB 7.5 pin controller driver description...............................................................295
LAB 7.5 PWM controller driver description...........................................................299
Listing 7-7: CY8C9520A_pwm_pinctrl.c ..................................................302
LAB 7.5 driver demonstration...................................................................323
LAB 7.6: CY8C9520A Device Tree overlay..........................................................325
LAB 7.6 driver demonstration...................................................................332
Chapter 8: Allocating Kernel Memory..............................................................333
Linux address types..............................................................................................333
User process virtual to physical memory mapping...............................................335
Kernel virtual to physical memory mapping..........................................................336
Kernel memory allocators.....................................................................................337
Page allocator.......................................................................................................338
Page allocator API................................................................................................338
SLAB allocator......................................................................................................339
SLAB allocator API...............................................................................................342
Kmalloc allocator..................................................................................................343
LAB 8.1: "linked list memory allocation" module........................................................344
Listing 8-1: linkedlist_rpi3_platform.c..............................................................346
linkedlist_rpi3_platform.ko demonstration......................................................351
Chapter 9: DMA in Device Drivers....................................................................353
Cache coherency..................................................................................................353
Linux DMA Engine API..........................................................................................355
Types of DMA mappings.......................................................................................357

[7]
Table of Contents

LAB 9.1: "streaming DMA" module.......................................................................361


Listing 9-1: sdma_rpi3_m2m.c..................................................................366
sdma_rpi3_m2m.ko demonstration...........................................................370
Chapter 10: Input Subsystem............................................................................371
Input subsystem drivers........................................................................................372
LAB 10.1: "input subsystem accelerometer" module............................................374
Device Tree..........................................................................................................376
Input framework as an I2C interaction..................................................................376
Input framework as an input device......................................................................378
Listing 10-1: i2c_rpi3_accel.c....................................................................381
i2c_rpi3_accel.ko demonstration..............................................................383
LAB 10.2: “Nunchuk input subsystem” module....................................................384
LAB 10.2 hardware description............................................................................385
LAB 10.2 Device Tree description........................................................................386
LAB 10.2 Nunchuk controller driver description...................................................387
Listing 10-2: nunchuk.c.............................................................................393
nunchuk.ko demonstration........................................................................398
LAB 10.3: Nunchuk applications...........................................................................400
joystick_led.py application....................................................................................403
Listing 10-3: joystick_led.py......................................................................403
joystick_led.py demonstration...................................................................404
joystick_pwm.py application.................................................................................405
Listing 10-4: joystick_pwm.py...................................................................405
joystick_pwm.py demonstration................................................................406
joystick_pygame.py application............................................................................407
Listing 10-5: joystick_pygame.py..............................................................407
joystick_pygame.py demonstration...........................................................409
Using SPI with Linux.............................................................................................411
The Linux SPI subsystem.....................................................................................413
Writing SPI client drivers.......................................................................................416
SPI client driver registration..................................................................................416
Declaration of SPI devices in the Device Tree.....................................................417
LAB 10.4: "SPI accel input device" module..........................................................419
LAB 10.4 hardware description............................................................................419
LAB 10.4 Device Tree description........................................................................420

[8]
Table of Contents

LAB 10.4 code description of the "SPI accel input device" module......................420
Listing 10-6: adxl345_rpi3.c......................................................................430
adxl345_rpi3.ko demonstration.................................................................442
Chapter 11: Industrial I/O Subsystem...............................................................445
IIO device sysfs interface......................................................................................447
IIO device channels..............................................................................................447
The iio_info structure............................................................................................449
Buffers..................................................................................................................450
IIO buffer sysfs interface.......................................................................................450
IIO buffer setup.....................................................................................................450
Triggers.................................................................................................................452
Triggered buffers..................................................................................................452
Industrial I/O events..............................................................................................454
Delivering IIO events to user space......................................................................456
IIO utils..................................................................................................................458
LAB 11.1: "IIO Mixed-Signal I/O Device" module.................................................458
LAB 11.1 hardware description.............................................................................461
LAB 11.1 Device Tree description........................................................................463
LAB 11.1 driver description...................................................................................468
Listing 11-1: max11300-base.h.................................................................483
Listing 11-2: maxim,max11300.h..............................................................485
Listing 11-3: max11300.c..........................................................................486
Listing 11-4: max11300-base.c.................................................................489
LAB 11.1 driver demonstration..................................................................507
GPIO control through a character device............................................................. 511
Listing 11-5: gpio_device_app.c................................................................512
GPIO control through the gpiolibd library.............................................................513
Listing 11-6: libgpiod_max11300_app.c....................................................514
LAB 11.2: “Nunchuk provider and consumer” modules........................................515
Nunchuck provider module...................................................................................515
Listing 11-7: nunchuk_accel.c...................................................................519
Nunchuck consumer module................................................................................522
Listing 11-8: nunchuk_consumer.c............................................................523
LAB 11.2 Device Tree description........................................................................527
LAB 11.2 driver demonstration..................................................................529

[9]
Table of Contents

Chapter 12: Using the Regmap API in Device Drivers....................................531


LAB 12.1: "SPI regmap IIO device" module.........................................................537
Listing 12-1: adxl345_rpi3_iio.c................................................................547
adxl345_rpi3_iio.ko demonstration...........................................................558
Chapter 13: USB Device Drivers.......................................................................563
USB 2.0 bus topology...........................................................................................563
USB bus enumeration and device layout.............................................................564
USB data transfers...............................................................................................567
USB device classes..............................................................................................568
Human interface device class...............................................................................568
USB descriptors....................................................................................................569
USB device descriptors........................................................................................569
USB configuration descriptor................................................................................571
USB interface descriptor.......................................................................................572
USB endpoint descriptor.......................................................................................573
USB string descriptors..........................................................................................573
USB HID descriptor..............................................................................................574
The Linux USB subsystem...................................................................................576
Writing Linux USB device drivers.........................................................................577
USB device driver registration..............................................................................578
Linux host-side data types ...................................................................................579
USB request block (URB).....................................................................................581
LAB 13.1: USB HID Device Application................................................................584
STEP 1: Create a new project..............................................................................585
STEP 2: Configure Harmony................................................................................586
STEP 3: Modify the generated code.....................................................................589
STEP 4: Declare the USB State Machine states..................................................589
STEP 5: Add new members to APP_DATA type...................................................590
STEP 6: Declare the reception and transmission buffers.....................................591
STEP 7: Initialize the new members.....................................................................591
STEP 8: Handle the detach..................................................................................592
STEP 9: Handle the HID events...........................................................................592
STEP 10: Create the USB State Machine............................................................594
STEP 11: Schedule a new report receive request................................................596
STEP 12: Receive, prepare and send reports......................................................597
STEP 13: Program the application.......................................................................598

[ 10 ]
Table of Contents

LAB 13.2: "USB LED" module..............................................................................598


LAB 13.2 code description of the "USB LED" module .........................................599
Listing 13-1: usb_led.c..............................................................................602
usb_led.ko demonstration.........................................................................604
LAB 13.3: "USB LED and Switch" module............................................................605
LAB 13.3 code description of the "USB LED and Switch" module ......................606
Listing 13-2: usb_urb_int_led.c.................................................................610
usb_urb_int_led.ko demonstration............................................................615
LAB 13.4: "I2C to USB Multidisplay LED" module................................................616
LAB 13.4 code description of the "I2C to USB Multidisplay LED" module ..........622
Listing 13-3: usb_ltc3206.c.......................................................................627
usb_ltc3206.ko demonstration..................................................................633
References..........................................................................................................635
Index....................................................................................................................637

[ 11 ]
Preface
Embedded systems have become an integral part of our daily life. They are deployed in mobile
devices, networking infrastructure, home and consumer devices, digital signage, medical imaging,
automotive infotainment and many other industrial applications. The use of embedded systems
is growing exponentially. Many of these embedded systems are powered by an inexpensive yet
powerful system-on-chip (SoC) that is running a Linux operating system. The BCM2837 from
Broadcom is one of these SoCs, running quad ARM Cortex A53 cores at 1.2GHz. This is the SoC
used in the popular Raspberry Pi 3 boards.
This book follows the learning by doing approach, so you will be playing with your Raspberry
Pi since the first chapter. Besides the Raspberry Pi board, you will use several low-cost boards to
develop the hands-on examples. In the labs, it is described what each step means in detail so that
you can use your own hardware components adapting the content of the book to your needs.
You will learn how to develop Linux drivers for the Raspberry Pi boards. You will start with
the simplest ones that do not interact with any external hardware, then you will develop Linux
drivers that manage different kind of devices: Accelerometer, DAC, ADC, RGB LED, Buttons,
Joystick controller, Multi-Display LED controller and I/O expanders controlled via I2C and SPI
buses. You will also develop DMA drivers, USB device drivers, drivers that manage interrupts
and drivers that write and read on the internal registers of the SoC to control its GPIOs. To ease
the development of some of these drivers, you will use different types of Linux kernel subsystems:
Miscellaneous, LED, UIO, USB, Input and Industrial I/O. More than 30 kernel modules have been
written (besides several user applications), which can be downloaded from the book's GitHub
repository.
This book uses the Long Term Support (LTS) Linux kernel 5.4, which was released on November
2019 and will be maintained until December 2025.
This book is a learning tool to start developing drivers without any previous knowledge about
this field, so the intention during its writing has been to develop drivers without a high level of
complexity that both serve to reinforce the main driver development concepts and can be a starting
point to help you to develop your own drivers. And, remember that the best way to develop a
driver is not to write it from scratch. You can reuse free code from similar Linux kernel mainline
drivers. All the drivers written throughout this book are GPL licensed, so you can modify and
redistribute them under the same license.

[ 13 ]
Preface

How this book is structured


Chapter 1, Building the System, starts by describing the main parts of an embedded Linux
system. Next, it describes in detail how to build an embedded Linux system for the Raspberry
Pi. You will install on a Micro SD a Raspberry Pi OS image based on kernel 5.4.y, then you will
download the Raspberry Pi kernel sources from the rpi-5.4.y branch, configure the kernel with the
settings needed to develop the drivers, build the kernel, and finally, you will install the new kernel
on the Raspberry Pi Linux image. The generated Linux image will be used for the testing of drivers
and applications throughout the book.
Chapter 2, The Linux Device and Drivel Model, explains the relationship between "Bus" drivers,
"Bus controller" drivers and "Device" drivers. It also provides an introduction to the Device Tree
and the sysfs filesystem.
Chapter 3, The Simplest Drivers, covers several simple drivers that are not yet interacting
with user applications through "system calls". This chapter will let you check that your driver
development ecosystem is working properly.
Chapter 4, Character Drivers, describes the architecture of the character drivers. It explains how
driver´s operations are called from user space by using system calls and how to exchange data
between kernel and user spaces. It also explains how to identify and create each Linux device.
Several drivers will be written that exchange information with user space using different methods
for the creation of the device nodes. The first driver in this chapter will use the traditional
static device creation method by using the "mknod" command, the second one will show how
create device files with "devtmpfs", and the last one will create the device files by using the
"miscellaneous framework". This chapter also explains how to create a device class and a device
driver entry under the sysfs.
Chapter 5, Platform Drivers, describes what a platform driver is, how a platform device is
statically described in the Device Tree and the process of associating the device with the device
driver, called "binding". In this chapter, you will develop your first driver interacting with the
hardware. Before developing the driver, a detailed explanation will be provided on the way
the pads of a Raspberry Pi SoC can be multiplexed to the different functions and how to select
the required pin muxing option within the Device Tree. This chapter also describes the Pinctrl
Subsystem and the GPIO Descriptor Consumer Interface. You will develop drivers that control
GPIOs writing and reading registers on the SoC. You will also learn to write drivers that control
LEDs by using the Linux LED subsystem. Finally, this chapter explains how to develop a user
space driver by using the UIO subsystem.
Chapter 6, I2C Client Drivers, describes the Linux I2C subsystem, which is based on the Linux
device model. You will learn to declare I2C devices in the Device Tree, and you will develop

[ 14 ]
Preface

several I2C client drivers throughout this chapter. You will also see how to add "sysfs" support to
control the hardware from user space via sysfs entries.
Chapter 7, Handling Interrupts in Device Drivers, introduces interrupt hardware and software
operation on embedded processors running Linux. You will learn about the different structures
used to create Linux drivers for interrupt controllers and the different types of GPIO irqchips. You
will develop several drivers that manage interrupts coming from the GPIOs of the Raspberry Pi
SoC. In one of these drivers, you will see how a user application is put to sleep by using a "wait
queue" and woken up later via an interrupt. You will also develop a GPIO controller driver with
interrupt capabilities for an off-chip GPIO expander and a user application that requests interrupts
from the GPIO expander by using GPIOlib APIs. In this chapter, you will see how to introduce
new hardware support by using the Raspberry Pi Device Tree overlay mechanism.
Chapter 8, Allocating Kernel Memory, explains the different types of addresses used in Linux.
This chapter also describes the different kernel memory allocators.
Chapter 9, DMA in Device Drivers, describes the "Linux DMA Engine Subsystem" and the
different types of DMA mappings. You will develop a DMA driver for the Raspberry Pi that
manages memory to memory transactions without CPU intervention.
Chapter 10, Input Subsystem, introduces the use of frameworks to provide a coherent user space
interface for every type of device, regardless of the drivers. The chapter explains in the relationship
between the physical and logical parts of a driver that uses a kernel framework. It focuses on
the Input subsystem, which takes care of the input events coming from the human user. In this
chapter, you will develop a driver for the WII Nunchuk controller and several Python applications
that interact with the events generated by the Nunchuk driver. One of these applications will use
the Pygame Python modules, drawing the Nunchuk Joystick values on a screen connected to the
Raspberry Pi board. This chapter also describes the Linux SPI subsystem, which is based on the
Linux device model. You will develop an SPI client driver for an accelerometer device using the
Input subsystem.
Chapter 11, Industrial I/O Subsystem, describes the IIO subsystem, which provides support for
ADCs, DACs, gyroscopes, accelerometers, magnetometers, proximity sensors, etc. The set up of
IIO triggered buffers and Industrial I/O events will be explained in detail. You will create an IIO
driver to control the Maxim MAX11300 device, which integrates a PIXI™, 12-bit, multichannel,
analog-to-digital converter (ADC) and a 12-bit, multichannel, buffered digital-to-analog converter
(DAC) in a single integrated circuit (IC). In this driver, you will create a GPIO controller, which
configures and controls the MAX11300 ports. You will also develop one application that controls
a GPIO of the MAX11300 device through a character device and another application that controls
the same GPIO using the functions of the gpiolibd library. In this chapter, you will also develop
two drivers using a provider-consumer implementation: the first one is an IIO provider driver

[ 15 ]
Preface

which will read the 3-axis data from the Nunchuk´s accelerometer, and the second one is an Input
subsystem consumer driver which will read the IIO channel values from the IIO provider driver
and report them to the Input subsystem.
Chapter 12, Using the Regmap API in Device Drivers, provides an overview of the regmap API
and explains how it takes care of calling the relevant calls of the SPI or I2C subsystem. You will
transform the SPI Input subsystem driver of the Chapter 10, which uses specific SPI core APIs, into
an SPI IIO subsystem driver which uses the regmap API, keeping the same functionality between
both drivers. Finally, you will dive into the "IIO tools" applications to test the driver.
Chapter 13, USB Device Drivers, describes the Linux USB subsystem, which is based on the Linux
device model. You will learn how to create custom USB HID devices based on the Microchip
PIC32MX microcontroller that will send/receive data to/from a Raspberry Pi Linux USB device
driver. You will learn about main Linux USB data structures and functions and develop several
Linux USB device drivers throughout this chapter.

Download the kernel modules


You can download the Linux kernel modules for this book from the GitHub repository at
https://github.com/ALIBERA/linux_raspberrypi_book.

What you need to develop the drivers


The Linux drivers and applications developed in the labs have been ported to three different
Raspberry Pi boards: Raspberry Pi 3 Model B, Raspberry Pi 3 Model B+ and Raspberry Pi 4 Model
B. The specifications of these boards can be found at:
https://www.raspberrypi.org/products/raspberry-pi-3-model-b/
https://www.raspberrypi.org/products/raspberry-pi-3-model-b-plus/
https://www.raspberrypi.org/products/raspberry-pi-4-model-b/
In this book, the demonstration sections and Device Tree settings used during the development of
the labs are referred to the Raspberry Pi 3 Model B board. You can download the Linux drivers,
applications and Device Tree files for the three Raspberry Pi boards from the GitHub of the book.
Besides the Raspberry Pi board, to get the most out of the book (by working through the labs), you
will need the following hardware:
1. MikroElektronika Color click accessory board (used in LAB 5.2, LAB 7.3, LAB 10.3 and LAB
11.1):
https://www.mikroe.com/color-click

[ 16 ]
Preface

2. PCF8574 IO Expansion Board (used in LAB 6.1):


https://www.waveshare.com/pcf8574-io-expansion-board.htm
3. Analog Devices LTC3206 I2C Multidisplay board DC749A (used in LAB 6.2 and LAB 13.4):
https://www.analog.com/en/products/ltc3206.html#product-evaluationkit
4. MikroElektronika Button R click board (used in LAB 7.1, LAB 7.2 and LAB 7.3):
https://www.mikroe.com/button-r-click
5. MikroElektronika EXPAND 6 click board (used in LAB 7.4, LAB 7.5 and LAB 7.6):
https://www.mikroe.com/expand-6-click
6. MikroElektronika Accel click board (used in LAB 10.1, LAB 10.4 and LAB 12.1):
https://www.mikroe.com/accel-click
7. Olimex MOD-Wii-UEXT-NUNCHUCK (used in LAB 10.2, LAB 10.3 and LAB 11.2):
https://www.olimex.com/Products/Modules/Sensors/MOD-WII/MOD-Wii-UEXT-NUNCHUCK/open-
source-hardware
8. MikroElektronika PIXI click board (used in LAB 11.1):
https://www.mikroe.com/pixi-click
9. Microchip Curiosity PIC32MX470 Development Board (used in LAB 13.1, LAB 13.2, LAB 13.3
and LAB 13.4):
https://www.microchip.com/DevelopmentTools/ProductDetails/dm320103#additional-summary

Questions
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.

[ 17 ]
1
Building the System
The Linux kernel is one of the largest and most successful open source projects that has ever come
about. The huge rate of change and the number of individual contributors shows that it has a
vibrant and active community, constantly stimulating evolution of the kernel. This rate of change
continues to increase, as does the number of developers and companies involved in the process.
The development process has proved that it is able to scale up to higher speeds without trouble.
The Linux kernel together with GNU software and many other open-source components provides
a completely free operating system, GNU/Linux. Embedded Linux is the usage of the Linux kernel
and various open-source components in embedded systems.
Embedded Linux is used in embedded systems such as consumer electronics (e.g., set-top boxes,
smart TVs, PVRs (personal video recorders), IVI (in-vehicle infotainment), networking equipment
(such as routers, switches, WAPs (wireless access points) or wireless routers), machine control,
industrial automation, navigation equipment, spacecraft flight software, and medical instruments
in general).
There are many advantages of using Linux in embedded systems. The following list shows some
of these benefits:
• The main advantage of Linux is the ability to reuse components. Linux provides scalability
due to its modularity and configurability.
• Open source. No royalties or licensing fees.
• Ported to a broad range of hardware architectures, platforms and devices.
• Broad support of applications and communication protocols (e.g., TCP/IP stack, USB stack,
graphical toolkit libraries).
• Large support coming from an active community of developers.
These are the main components of an embedded Linux system: Bootloader, Kernel, System
call interface, C-Runtime library, System shared libraries and Root filesystem. Each of these
components will be described in more detail in the next sections.

[ 19 ]
Building the System Chapter 1

Bootloader
Linux cannot be started on an embedded device without a small amount of machine specific code
to initialize the system. Linux requires the bootloader code to do very little, although several
bootloaders do provide extensive additional functionality. The minimal requirements are:
• Configuration of the memory system.
• Loading of the kernel image and the Device Tree at the correct addresses.
• Optional loading of an initial RAM disk at the correct memory address.
• Setting of the kernel command-line and other parameters (e.g., Device Tree, machine type).
It is also usually expected that the bootloader initializes a serial console for the kernel in addition
to these basic tasks.
There are different bootloader options that come in all shapes and sizes. U-Boot is the standard
bootloader for ARM Linux. U-Boot source code is located at https://source.denx.de/u-boot/u-boot.
These are some of the main U-Boot features:
1. Small: U-Boot is a bootloader, and its primary purpose in the system is to load an
operating system. That means that U-Boot is necessary to perform a certain task, but it is
not worth spending significant resources on. Typically, U-Boot is stored in the relatively
small NOR flash memory, which is expensive compared to the much larger NAND
devices normally used to store the operating system and the application. A usable and
useful configuration of U-Boot, including a basic interactive command interpreter, support
for download over Ethernet and the capability to program the flash should fit in no more
than 128 KB.
2. Fast: The end user is not interested in running U-Boot. In most embedded systems, they
are not even aware that U-Boot exists. The user wants to run some application code, and
they want to do that as soon as possible after switching on the device. Initialize devices
only when they are needed within U-Boot, i.e., don't initialize the Ethernet interface(s)
unless U-Boot performs a download over Ethernet; don't initialize any IDE or USB devices
unless U-Boot actually tries to load files from these, etc.
3. Portable: U-Boot is a bootloader, but it is also a tool used for board bring-up, for
production testing and for other activities that are very closely related to hardware
development. So far, it has been ported to several hundreds of different boards on about
30 different processor families.
4. Configurable: U-Boot is a powerful tool with many, many extremely useful features.
The maintainer or user of each board will have to decide which features are important

[ 20 ]
Chapter 1 Building the System

and what shall be included with their specific board configuration to meet the current
requirements and restrictions.
5. Debuggable: U-Boot is not only a tool in itself, it is often also used for hardware bring-up,
so debugging U-Boot often means that you don't know if you are tracking down a problem
in the U-Boot software or in the hardware you are running on. Code that is clean and easy
to understand and debug is all the more important to everyone. One important feature of
U-Boot is to enable output to the (usually serial) console as soon as possible in the boot
process, even if this causes tradeoffs in other areas like memory footprint. All initialization
steps shall print some "begin doing this" message before they actually start and some
"done" message when they complete. The purpose of this is that you can always see which
initialization step was running if any problems occur. This is important not only during
software development, but also for the service people dealing with broken hardware in the
field. U-Boot should be debuggable with simple JTAG or BDM equipment. It should use a
simple, single-threaded execution model.

[ 21 ]
Building the System Chapter 1

Linux kernel
Linux is a clone of the operating system Unix, written from scratch by Linus Torvalds with
assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX and Single
UNIX Specification compliance.
It has all the features you would expect in a modern, fully-fledged Unix implementation, including
true multitasking, virtual memory, shared libraries, demand loading, shared copy-on-write
executables, proper memory management and multistack networking including IPv4 and IPv6.
Although originally developed for 32-bit x86-based PCs (386 or higher), today Linux also runs on a
multitude of other processor architectures, in both 32-bit and 64-bit variants.
The Linux kernel is the lowest level of software running on a Linux system. It is charged with
managing the hardware, running user programs and maintaining the overall security and integrity
of the whole system. It is this kernel, which, after its initial release by Linus Torvalds in 1991,
jump-started the development of Linux as a whole. The kernel is a relatively small part of the
software on a full Linux system (many other large components come from the GNU project, the
GNOME and KDE desktop projects, the X.org project and many other sources), but the kernel is
the core which determines how well the system will work and is the piece which is truly unique to
Linux.
The kernel, which forms the core of the Linux system, is the result of one of the largest cooperative
software projects ever attempted. Regular two-to-three month releases deliver stable updates to
Linux users, each with significant new features, added device support and improved performance.
The rate of change in the kernel is high and increasing, with over 10,000 patches going into each
recent kernel release. Each of these releases contains the work of more than 1,600 developers
representing over 200 corporations.
As kernels move from the mainline into the stable category, two things can happen:
1. They can reach End of Life after a few bugfix revisions, which means that kernel
maintainers will release no more bugfixes for this kernel version, or
2. They can be put into longterm maintenance, which means that maintainers will provide
bugfixes for this kernel revision for a much longer period of time.
If the kernel version you are using is marked EOL, you should consider upgrading to the next
major version, as there will be no more bugfixes provided in the kernel version you are using.
Linux kernel is released under GNU GPL version 2 and is therefore Free Software as defined by
the Free Software Foundation. You may read the entire copy of the license in the COPYING file
distributed with each release of the Linux kernel.

[ 22 ]
Chapter 1 Building the System

Some of the subsystems the kernel is comprised of are listed below:


• /arch/<arch>: Architecture specific code.
• /arch/<arch>/<mach>: Machine/board specific code.
• /Documentation: Kernel documentation. Do not miss it!
• /ipc: Inter process communication.
• /mm: Memory management.
• /fs: File systems.
• /include: Linux kernel headers.
• /include/asm-<arch>: Architecture and machine dependent headers.
• /include/linux: Linux kernel core headers.
• /init: Linux initialization (including main.c).
• /block: Linux kernel block layer code.
• /net: Networking functionality.
• /lib: Common kernel helper functions.
• /kernel: Common kernel structures.
• /arch: Architecture specific code.
• /crypto: Cryptography code.
• /security: Security components.
• /drivers: Built-in drivers (does not include loadable modules).
• Makefile: Top Linux makefile (sets arch and version).
• /scripts: Scripts for internal or external use.
The official home for the mainline Linux kernel source code is www.kernel.org. You can download
the source code either directly from the kernel.org website as a compressed tar.xz file, or you can
download it through git, the kernel´s preferred source code control system.
There are several main categories into which kernel releases may fall:
1. Prepatch: Prepatch or "RC" kernels are mainline kernel pre-releases that are mostly aimed
at other kernel developers and Linux enthusiasts. They must be compiled from source
and usually contain new features that must be tested before they can be put into a stable
release. Prepatch kernels are maintained and released by Linus Torvalds.
2. Mainline: The mainline tree is maintained by Linus Torvalds. It's the tree where all new
features are introduced and where all the exciting new development happens. New
mainline kernels are released every 2-3 months.
3. Stable: After each mainline kernel is released, it is considered "stable". Any bug fixes for
a stable kernel are backported from the mainline tree and applied by a designated stable
kernel maintainer. There are usually only a few bugfix kernel releases until next mainline

[ 23 ]
Building the System Chapter 1

kernel becomes available -- unless it is designated a "longterm maintenance kernel". Stable


kernel updates are released on as-needed basis, usually 2-3 a month.
4. Longterm: There are usually several "longterm maintenance" kernel releases provided for
the purposes of backporting bugfixes for older kernel trees. Only important bugfixes are
applied to such kernels, and they don't usually see very frequent releases, especially for
older trees.
In the following image, extracted from www.kernel.org, you can see the latest stable kernel, kernels
under development (mainline, next), stable and long term kernels.

In addition to the official versions of the kernel, there are many third-parties (chip-vendors,
sub-communities) that supply and maintain their own version of the kernel sources by forking
from the official kernel tree. The intent is to separately develop support for a particular piece of
hardware or subsystem and to integrate this support to the official kernel at a later point. This
process is called mainlining and describes the task to integrate the new feature or hardware
support to the upstream (official) kernel. These are called Distribution kernels.
It is easy to tell if you are running a Distribution kernel. Unless you downloaded, compiled and
installed your own version of kernel from www.kernel.org, you are running a Distribution kernel. To
find out the version of your kernel, run uname -r after booting the processor.

[ 24 ]
Chapter 1 Building the System

You will work with the longterm kernel 5.4.y releases to develop all the drivers throughout this
book.

System call interface and C runtime library


The system call is the fundamental interface between an application and the Linux kernel. System
calls are the only means by which a user space application can interact with the kernel. In other
words, they are the bridge between user space and kernel space. The strict separation of user
and kernel space ensures that user space programs cannot freely access kernel internal resources,
thereby ensuring the security and stability of the system. The system calls elevate the privilege of
the user process.
The system call interface is generally not invoked directly (even though it could be) but rather
through wrapper functions in the C runtime library. Some of these wrapper functions are only
very thin layers over the system call (just checking and setting the call parameters) while others
add additional functionality. The following image shows some system calls and their descriptions:

The C runtime library (C-standard library) defines macros, type definitions and functions for
string handling, mathematical functions, input/output processing, memory allocation and several
other functions that rely on OS services. The runtime library provides applications with access to
OS resources and functions by abstracting the OS System call interface.
Several C runtime libraries are available: glibc, uClibc, eglibc, dietlibc, newlib. The choice of the C
library must be made at the time of the cross-compiling toolchain generation, as the GCC compiler
is compiled against a specific C library.
The GNU C library, glibc, is the default C library used for example in the Yocto project. The
GNU C Library is primarily designed to be a portable and high performance C library. It follows
all relevant standards including ISO C11 and POSIX.1-2008. It is also internationalized and has

[ 25 ]
Building the System Chapter 1

one of the most complete internationalization interfaces known. You can find the glibc manual at
https://www.gnu.org/software/libc/manual/.

System shared libraries


System shared libraries are libraries that are loaded by programs when they start. When a shared
library is installed properly, all programs that start afterwards automatically use the new shared
library. System shared libraries are typically linked with a user space application to provide its
access to a specific system functionality. This system functionality can be either self-contained
like compression or encryption algorithms or require access to underlying kernel resources or
hardware. In the latter case, the library provides a simple API that abstracts the complexities of the
kernel or direct driver access.
In other words, system shared libraries encapsulate system functionality and therefore are an
essential building block when building applications that interact with the system.
Every shared library has a special name called the "soname". The soname has the prefix "lib",
the name of the library, the phrase ".so", followed by a period and a version number that is
incremented whenever the interface changes (as a special exception, the lowest-level C libraries
don't start with "lib"). A fully-qualified soname includes as a prefix the directory it's in. In a
working system, a fully-qualified soname is simply a symbolic link to the shared library's "real
name".
Every shared library also has a "real name", which is the filename containing the actual library
code. The real name adds a period to the soname, a minor number, another period and the release
number. The last period and the release number are optional. The minor number and release
number support configuration control by letting you know exactly what version(s) of the library
are installed. Note that these numbers might not be the same as the numbers used to describe the
library in documentation, although that does make things easier.
In addition, there's the name that the compiler uses when requesting a library, (call it the "linker
name"), which is simply the soname without any version number.
The following system shared libraries are required by the LSB (Linux Standard Base) specification
and therefore must be available on all LSB compliant systems:

• Libc: Standard C library (C runtime library). Elementary language support and OS


platform services. Direct access to the OS System-Call-Interface.
• Libm: Math Library. Common elementary mathematical functions and floating point
environment routines defined by System V, ANSI C, POSIX, etc.

[ 26 ]
Chapter 1 Building the System

• Libpthread: POSIX thread library. Functionality now in libc, maintained to provide


backwards compatibility.
• Libdl: Dynamic Linker Library. Functionality now in libc, maintained to provide
backwards compatibility.
• Libcrypt: Cryptology Library. Encryption and decryption handling routines.
• Libpam: PAM (Pluggable Authentication Module) library. Routines for the PAM.
• Libz: Compression/decompression library. General purpose data compression and
deflation functionality.
• Libncurses: CRT screen handling and optimization package. Overall screen, window
and pad manipulation; output to windows and pads; reading terminal input; control
over terminal and cursor input and output options; environment query routines; color
manipulation; use of soft label keys.
• Libutil: System utilities library. Various system-dependent utility routines used in a
wide variety of system daemons. The abstracted functions are mostly related to pseudo-
terminals and login accounting.
Libraries are placed in the following standard root filesystem locations:
• /lib: Libraries required for startup.
• /usr/lib: Most system libraries.
• /usr/local/lib: Non-system libraries.
Note: A large part of the text of this section has been extracted from the Linux Documentation
Project. You can find all the complete information at https://tldp.org/HOWTO/Program-Library-
HOWTO/shared-libraries.html.

Root filesystem
The root filesystem is where all the files contained in the file hierarchy (including device nodes) are
stored. The root filesystem is mounted as /, containing all the libraries, applications and data.
The folder structure of the root filesystem is defined by FHS (Filesystem-Hierarchy-Standard). The
FHS defines the names, locations and permissions for many file types and directories. It thereby
ensures compatibility between different Linux distributions and allows applications to make
assumptions about where to find specific system files and configurations.
An embedded Linux root filesystem, usually includes the following:
• /bin: Commands needed during bootup that might be used by normal users (probably
after bootup).

[ 27 ]
Building the System Chapter 1

• /sbin: Like /bin, but the commands are not intended for normal users, although they may
use them if necessary and allowed; /sbin is not usually in the default path of normal users,
but will be in root's default path.
• /etc: Configuration files specific to the machine.
• /home: Like My Documents in Windows.
• /root: The home directory for user root. This is usually not accessible to other users on the
system.
• /lib: Essential shared libraries and kernel modules.
• /dev: Device files. These are special virtual files that help the user interface with the
various devices on the system.
• /tmp: Temporary files. As the name suggests, programs running often store temporary files
in here.
• /boot: Files used by the bootstrap loader. Kernel images are often kept here instead of in
the root directory. If there are many kernel images, the directory can easily grow too large,
and it might be better to keep it in a separate filesystem.
• /mnt: Mount point for mounting a filesystem temporarily.
• /opt: Add-on application software packages.
• /usr: Secondary hierarchy.
• /var: Variable data.
• /sys: Exports information about devices and drivers from the kernel device model to user
space, and it is also used for configuration.
• /proc: Represent the current state of the kernel.

Linux boot process


These are the main stages of the Linux boot process for the BCM2837 SoC:
1. The boot process begins at POR (Power On Reset), where the hardware reset turns ON the
VideoCore GPU (CPU is OFF), which executes the 1st stage bootloader from the on-chip
boot ROM. At this point, DRAM memory controller is disabled.
2. The 1st stage bootloader reads the 2nd stage bootloader (bootcode.bin) from the SD card,
loads it into the GPU´s L2 cache and executes it on the GPU. The 2nd stage bootloader
sets up the DRAM memory controller, then loads the GPU firmware (start.elf) from the SD
card and runs it. The GPU firmware reads the system configuration parameters (config.
txt), loads a kernel image (kernel7.img) and a Device Tree file (bcm2710-rpi-3-b.dtb) into the
DRAM memory, and releases the reset signal on the ARM CPU.
3. The image kernel7.img is then run on the ARM CPU.

[ 28 ]
Chapter 1 Building the System

4. The kernel runs low level kernel initialization, enabling MMU, creating the initial table of
memory pages and setting up caches. This is done in arch/arm/kernel/head.s. The file head.s
contains CPU architecture specific, but platform independent initialization code. Then, the
system switches to the non architecture specific kernel startup function start_kernel().
5. The kernel runs start_kernel() located in init/main.c that:
• Initializes the kernel core (e.g., memory, scheduling, interrupts).
• Initializes statically compiled drivers.
• Mounts the root filesystem based on bootargs passed to the kernel from U-Boot.
• Executes the first user process, init. The init process, by default, is /init for initramfs
and /sbin/init for a regular filesystem. The three init programs that you usually find on
embedded Linux devices are BusyBox init, System V init and systemd.

Building an embedded Linux system for the Raspberry


Pi
Building an embedded Linux system requires you to:
1. Select a cross toolchain. The toolchain is the starting point for the development process, as
it is used to build all subsequent software packages. The toolchain consists of the following
parts: Assembler, Compiler, Linker, Debugger, Runtime Libraries and Utilities. A cross
compiler is a compiler capable of creating executable code for a platform other than the
one on which the compiler is running.
2. Select the different packages that will run on the target (bootloader, kernel and root
filesystem).
3. Configure and build these packages.
4. Deploy them on the device.
There are several different ways to build an embedded Linux system:
1. Manually (creating your own scripts): This option gives you total control, but it is also tedious
and harder to reproduce builds on other machines. It also requires a good understanding of
the software component installation process. For example, create a root filesystem from the
ground up by yourself means:
• Download the source code of all software components (libraries, utilities and applications).
• Solve all dependencies and version conflicts, and apply patches.
• Configure each software component.
• Cross-compile each software component.

[ 29 ]
Building the System Chapter 1

• Install each software component.


2. Using complete distributions (e.g., Ubuntu/Debian): Easy to get started, but harder to
customize. A Linux distribution is a preselected kernel version and a root filesystem with a
preselected set of libraries, utilities and applications.
3. Using build frameworks (e.g., Buildroot, Yocto): This option allows you to customize and
reproduce builds easily. This is becoming the most popular option in the embedded Linux
space. A Build framework typically consists of scripts and configuration meta-data that control
the build process. The Build framework typically downloads, configures, compiles and installs
all required components of the system, taking version conflicts and dependencies into account.
It allows, for example to create a customized root filesystem. The Build framework output is a
complete image, including toolchain, bootloader, kernel and root filesystem.

Raspberry Pi OS
Raspberry Pi OS is the recommended operating system for normal use on a Raspberry Pi. Raspberry
Pi OS is a free operating system based on Debian, optimised for the Raspberry Pi hardware.
Raspberry Pi OS comes with over 35,000 packages: precompiled software bundled in a nice format
for easy installation on your Raspberry Pi. Raspberry Pi OS is a community project under active
development, with an emphasis on improving the stability and performance of as many Debian
packages as possible.
You will install on a Micro SD a Raspberry Pi OS image based on kernel 5.4.y. Go to https://
downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2020-12-04/ and download the
2020-12-02-raspios-buster-armhf-full.zip image.
To write the compressed image on the Micro SD card, you will download and install Etcher. This
tool, which is an Open Source software, is useful since it allows to get a compressed image as
input. More information and extra help is available on the Etcher website at https://etcher.io/.
Once the image is installed on the Micro SD card, you will insert the Micro SD into the SD card
reader on your host PC, then you will enable UART, SPI and I2C peripherals in the programmed
Micro SD. Open a terminal application on your host PC, and type the following commands:
~$ lsblk
~$ mkdir ~/mnt
~$ mkdir ~/mnt/fat32
~$ mkdir ~/mnt/ext4
~$ sudo mount /dev/mmcblk0p1 ~/mnt/fat32

See the files in the fat32 partition. Check that config.txt is included:
~$ ls -l ~/mnt/fat32/

[ 30 ]
Chapter 1 Building the System

Update the config.txt file, adding the next values:


~$ cd ~/mnt/fat32/
~/mnt/fat32$ sudo nano config.txt
dtparam=i2c_arm=on
dtparam=spi=on
dtoverlay=spi0-cs
# Enable UART
enable_uart=1
kernel=kernel7.img
~$ sudo umount ~/mnt/fat32

You can also update previous settings (after booting the Raspberry Pi board) through the
Raspberry Pi Configuration application found in Preferences on the menu.

The Interfaces tab is where you turn these different connections on or off so that the Pi recognizes
that you’ve linked something to it via a particular type of connection.

[ 31 ]
Building the System Chapter 1

Connect and set up hardware


Follow the next steps to get everything connected to your Raspberry Pi. It’s important to do this in
the right order so that all your components are safe:
1. Insert the Micro SD card you’ve set up with Raspberry Pi OS into the Micro SD card slot
on the underside of your Raspberry Pi board.

[ 32 ]
Chapter 1 Building the System

2. Connect your screen to the single Raspberry Pi’s HDMI port. You can also connect a
mouse to a USB port and keyboard in the same way.

3. Connect the Ethernet port on Raspberry Pi to an Ethernet socket on your host PC.

[ 33 ]
Building the System Chapter 1

4. The serial console is a helpful tool for debugging your board and reviewing system log
information. To access the serial console, connect a USB to TTL Serial Cable to the device
UART pins as shown below.

5. Plug the USB power supply into a socket and connect it to your Raspberry Pi’s power port.

The hardware setup is already done!!

[ 34 ]
Chapter 1 Building the System

You should see a red LED light up, which indicates that the Raspberry Pi board is connected to
power. As it starts up, you will see raspberries appear in the top left-hand corner of your screen.
After a few seconds the Raspberry Pi OS Desktop will appear.

For the official Raspberry Pi OS, the default user name is pi, with password raspberry.
To find out the version of the booted kernel, run uname -r on the Raspberry Pi terminal:
pi@raspberrypi:~$ uname -r
5.4.79-v7+

Reset the board. You can disconnect your screen from the Raspberry Pi’s HDMI port during the
development of the labs (you will only need to connect a screen in the LAB 10.3).
pi@raspberrypi:~$ sudo reboot

To see Linux boot messages on the console, add loglevel=8 in the file cmdline.txt under /boot.
pi@raspberrypi:~$ sudo nano /boot/cmdline.txt

To change your current console_loglevel simply write to this file:


pi@raspberrypi:~$ echo <loglevel> > /proc/sys/kernel/printk

For example:
pi@raspberrypi:~$ echo 8 > /proc/sys/kernel/printk

Now, every kernel message will appear on your console, as all priority higher than 8 (lower loglevel
values) will be displayed. Please note that after reboot, this configuration is reset. To keep the

[ 35 ]
Building the System Chapter 1

configuration permanently, just append the following kernel.printk value to the /etc/sysctl.conf file,
then reboot the processor:
kernel.printk = 8 4 1 3
pi@raspberrypi:~$ sudo nano /etc/sysctl.conf
pi@raspberrypi:~$ sudo reboot

Setting up an ethernet communication


Connect an Ethernet cable between your host PC and the Raspberry Pi board. Set up the IP
Address of the host PC.
1. On the host side, click on the Network Manager tasklet on your desktop, and select Edit
Connections. Choose "Wired connection 1" and click "Edit".
2. Choose the "IPv4 Settings" tab, and select Method as "Manual" to make the interface use
a static IP address, for example 10.0.0.1. Click "Add", and set the IP address, the Netmask
and Gateway as follow:
Address: 10.0.0.1
Netmask: 255.255.255.0
Gateway: none or 0.0.0.0
Finally, click the "Save" button.
3. Click on "Wired connection 1" to activate this network interface.

Copying files to your Raspberry Pi


You can access the command line of a Raspberry Pi remotely from another computer or device
on the same network using SSH. Make sure the Raspberry Pi is properly set up and connected.
Configure on the Raspberry Pi the eth0 interface with IP address 10.0.0.10:
pi@raspberrypi:~$ sudo ifconfig eth0 10.0.0.10 netmask 255.255.255.0

Raspbian has the SSH server disabled by default. You have to start the service on the Pi:
pi@raspberrypi:~# sudo /etc/init.d/ssh restart

Now, verify that you can ping your Linux host machine from the Raspberry Pi. Exit the ping
command by typing "Ctrl-c":
pi@raspberrypi:~# ping 10.0.0.1

You can also ping from Linux host machine to the target. Exit the ping command by typing
"Ctrl-c".
~$ ping 10.0.0.10

[ 36 ]
Chapter 1 Building the System

By default, the root account is disabled, but you can enable it by using this command and giving it
a password, for example "pi":
pi@raspberrypi:~$ sudo passwd root

Now, you can log into your pi as the root user. Open the sshd_config file, and change
PermitRootLogin to yes (also comment the line out). After editing the file, type "Ctrl+x", then type
"yes", and press "enter" to exit:
pi@raspberrypi:~$ sudo nano /etc/ssh/sshd_config

Building the Linux kernel


There are two main methods for building the kernel. You can build locally on the Raspberry Pi,
which will take a long time, or you can cross-compile, which is much quicker, but requires more
setup. You will use the second method.
Install Git and the build dependencies:
~$ sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev

On your host PC, create the linux_rpi3 folder, where you are going to download the kernel sources:
~$ mkdir linux_rpi3
~$ cd linux_rpi3/

Get the kernel sources. The git clone command below will download the current active branch
without any history. Omitting the --depth=1 will download the entire repository, including the full
history of all branches, but this takes much longer and occupies much more storage.
~/linux_rpi3$ git clone --depth=1 -b rpi-5.4.y https://github.com/raspberrypi/linux

Install the 32-bit toolchain for a 32-bit kernel:


~$ sudo apt install crossbuild-essential-armhf

Compile the kernel, modules and Device Tree files. First, apply the default configuration:
~/linux_rpi3/linux$ KERNEL=kernel7
~/linux_rpi3/linux$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig

Configure the following kernel settings that will be needed during the development of the labs:
~/linux_rpi3/linux$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
Device drivers >
[*] SPI support --->
<*> User mode SPI device driver support

Device drivers >


<*> Industrial I/O support --->
-*- Enable buffer support within IIO

[ 37 ]
Building the System Chapter 1

-*- Industrial I/O buffering based on kfifo


<*> Enable IIO configuration via configfs
-*- Enable triggered sampling support
<*> Enable software IIO device support
<*> Enable software triggers support
Triggers - standalone --->
<*> High resolution timer trigger
<*> SYSFS trigger

Device drivers >


<*> Userspace I/O drivers --->
<*> Userspace I/O platform driver with generic IRQ handling

Device drivers >


Input device support --->
-*- Generic input layer (needed for keyboard, mouse, ...)
<*> Polled input device skeleton

For the LAB 12.1, you will need the functions that enable the triggered buffer support. If they are
not defined accidentally by another driver, there's an error thrown out while linking. To solve
this problem, you can select, for example, the HTS221 driver, which includes this triggered buffer
support:
Device drivers >
<*> Industrial I/O support > Humidity sensors --->
<*> STMicroelectronics HTS221 sensor Driver

Save the configuration, and exit from menuconfig.


Compile kernel, Device Tree files and modules in a single step:
~/linux_rpi3/linux$ make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

Having built the kernel, you need to copy it onto your Raspberry Pi device and also install the
modules. Insert the previously programmed Micro SD into the SD card reader on your host PC,
and execute the following commands:
~$ lsblk
~$ mkdir ~/mnt
~$ mkdir ~/mnt/fat32
~$ mkdir ~/mnt/ext4
~$ sudo mount /dev/mmcblk0p1 ~/mnt/fat32
~$ sudo mount /dev/mmcblk0p2 ~/mnt/ext4/
~$ cd linux_rpi3/linux
~/linux_rpi3/linux$ sudo env PATH=$PATH make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
INSTALL_MOD_PATH=~/mnt/ext4 modules_install

[ 38 ]
Exploring the Variety of Random
Documents with Different Content
Walter, Thomas, cited, 17, 21, 28.

Ward, Frank Edwin, 358f, 393f.

Ward-Stephens, 355.

Ware, Harriet, 403f.

Warren, Mercy (author of early patriotic song), 321f.

Washington, Booker T., quot. 298.

Washington, George, concert in honor of, 33f;


quoted, 79.

Watt, Isaac, 29.

Wa-Wan Press, xii.

Webb, George J., musical activities, 188.

Weil, Hermann, 155.

Weingartner, Felix, in America, 184, 186.

Weiss, Arthur, 399.

Wellesley College, 264f.

West, orchestral organizations in, 197ff.

White, Charles (negro minstrel), 316.

White, Richard Grant, quot. 202.

Whitelocke, Balustrode, cited, 13.


Whiting, Arthur, 347f, 357.

Whiting, George, 343.

Whitmer, T. Carl, 428f.

Williams, Aaron, 30, 45.

Winslow, on early New England music, 15.

Women composers (American), 402ff, 438f.

Woodbridge, William C., on music in the public schools, 240f.

Woodman, R. Huntington, 355.

Worcester (Mass.), 31;


choral society, 214;
music festival, 221f.

Work, Henry Clay, 286, 320f, 329.

Worrell, Lola Carrier, 406.

Wright, Louise Drake, 406.

Yale University, music department in, 265ff.

'Yankee Doodle,' 322f.

Z
Zerrahn, Carl, 189;
conductor of music festivals, 222.
Ziegfeld, Florens, 252.
*** END OF THE PROJECT GUTENBERG EBOOK THE ART OF
MUSIC, VOL. 04 (OF 14) ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
back
back
back
back
back
back
back
back
back
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like