Raspberry Pi Computer Architecture Essentials 1st Edition Dennis download
Raspberry Pi Computer Architecture Essentials 1st Edition Dennis download
https://ebookmeta.com/product/raspberry-pi-computer-architecture-
essentials-1st-edition-dennis/
https://ebookmeta.com/product/raspberry-pi-home-automation-with-
arduino-1st-edition-andrew-k-dennis-2/
https://ebookmeta.com/product/raspberry-pi-home-automation-with-
arduino-1st-edition-andrew-k-dennis/
https://ebookmeta.com/product/raspberry-pi-home-automation-with-
arduino-second-edition-dennis-andrew-k/
https://ebookmeta.com/product/the-alpha-s-secret-baby-girl-
stardust-hollow-wolves-1-1st-edition-lyra-atlas/
THE ANABOLIC HANDBOOK by Enhancedinfo 1st Edition
Sarmsinfo Enhancedinfo
https://ebookmeta.com/product/the-anabolic-handbook-by-
enhancedinfo-1st-edition-sarmsinfo-enhancedinfo/
https://ebookmeta.com/product/scythia-the-amazing-origins-of-
ancient-ireland-2nd-edition-herve-cariou-2/
https://ebookmeta.com/product/seventh-day-adventism-in-
africa-1st-edition-gabriel-masfa/
https://ebookmeta.com/product/iteration-episodes-in-the-
mediation-of-art-and-architecture-1st-edition-robin-schuldenfrei-
editor/
https://ebookmeta.com/product/white-russians-red-peril-1st-
edition-sheila-fitzpatrick/
Critical Perspectives on Economics of Education 1st
Edition Silvia Mendolia (Editor)
https://ebookmeta.com/product/critical-perspectives-on-economics-
of-education-1st-edition-silvia-mendolia-editor/
www.it-ebooks.info
Raspberry Pi Computer
Architecture Essentials
Andrew K. Dennis
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Raspberry Pi Computer Architecture Essentials
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78439-797-5
www.packtpub.com
www.it-ebooks.info
Credits
Reviewer Proofreader
Ed Snajder Safis Editing
Technical Editor
Shivani Kiran Mistry
Copy Editor
Safis Editing
www.it-ebooks.info
About the Author
He has over 12 years of experience working in the software industry in the UK,
Canada, and the USA. This experience includes e-learning courseware development,
custom CMS and LMS development, SCORM consultancy, web development in
a variety of languages, open source application development, blogging about the
integration of web technologies with electronics for home automation, and punching
lots of Cat5 cables.
www.it-ebooks.info
About the Reviewer
www.it-ebooks.info
www.PacktPub.com
At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
www.it-ebooks.info
Table of Contents
Preface vii
Chapter 1: Introduction to the Raspberry Pi's Architecture
and Setup 1
History and background of the Raspberry Pi 1
Raspberry Pi hardware specifications 2
Dimensions 3
System on Chip 3
CPU 4
GPU 4
SDRAM 4
4 USB 2.0 ports and 1 SoC on-board USB 4
MicroSD card port 4
Ethernet port 5
Audio 5
GPIO pins 5
Video – analog TV out 6
Video – HDMI port 6
Basic hardware needed 6
The microSD card – the main storage and boot device
of the Raspberry Pi 2 7
Preinstalled microSD card versus creating your own 8
The NOOBS operating system installation manager 8
Downloading the latest version of Raspbian 9
Setting up your microSD card and installing the Raspbian
operating system 9
Raspbian installation wrap-up 11
Check SSH is running 11
RSA key generation for SSH 12
[i]
www.it-ebooks.info
Table of Contents
[ ii ]
www.it-ebooks.info
Table of Contents
Words 54
Labels 54
The memory 55
The addresses 55
LDR and SUB 56
Running our program 57
Adding power to our program – control structures 58
If else statements 60
Iteration 61
Testing our control structures 61
Summary 62
Chapter 4: Multithreaded Applications with C/C++ 63
What are threads? 63
Thread types 65
User level threads 65
Kernel level threads 65
Hybrid threads 66
POSIX threads 66
Steps involved in implementing threads 67
Creation and termination 67
Synchronization 68
Scheduling 69
An example in C 69
Trying out our program 73
A C++ equivalent 74
The g++ command 76
Going further – mutexes and joins 77
Compile and test 80
Summary 81
Chapter 5: Expanding on Storage Options 83
Booting up 83
Setting up the external HDD 85
Getting the disk name 85
Setting up the HDD 86
Modifying cmdline.txt 87
Network-attached storage (NAS) 88
Installing Samba 89
Testing the NAS 90
Mac 90
Linux 91
Windows 91
Summary 92
[ iii ]
www.it-ebooks.info
Table of Contents
[ iv ]
www.it-ebooks.info
Table of Contents
[v]
www.it-ebooks.info
Table of Contents
[ vi ]
www.it-ebooks.info
Preface
Are you interested in the myriad features of your Raspberry Pi 2? From the hardware
to the software, do you wish to understand how you can interact with these features?
The Raspberry Pi 2 is one of the latest hardware offerings in the Raspberry Pi family.
With many new and improved features than previous versions, there is so much
more an enthusiast can do.
This book will walk you through how you can get the most out of your device.
You will learn about how to program on the Raspberry Pi using the Assembly
language, Python, and C/C++. This will include building a web server in Python
and saving data to an SQLite database. Ever wondered what threads are? These are
covered here too.
In addition to this, you will explore the various types of GPIO pins and how these
can be used to interact with third party microcontrollers and electronic circuits.
The sound and graphics capabilities of the Raspberry Pi 2 are also experimented
with through a number of projects. And to expand the Raspberry Pi's storage option,
we will also set up an external HDD via USB.
Finally, the book concludes with a project that brings together many of the
technologies explained throughout the chapters.
By the time you finish reading this book, you'll have a firm knowledge of the
Raspberry Pi 2 and how you can devise your own projects that use its capabilities.
[ vii ]
www.it-ebooks.info
Preface
Chapter 6, Low-Level Graphics Programming, shows you how to interact with the
graphics hardware on the Raspberry Pi 2. Here you will learn how to draw to the
screen via the frame buffer.
Chapter 7, Exploring the Raspberry Pi's GPIO Pins, shows you how to interact with
electronic components using the Raspberry PI's GPIO pins. Here we look at how
Python libraries can be used to simplify the process.
Chapter 8, Exploring Sound with the Raspberry Pi 2, gives an introduction to the basics
of sound programming using the Raspberry Pi's hardware. Learn about live coding
via the Sonic-Pi IDE to generate your own algorithmic music.
Chapter 9, Building a Web Server, expands upon your knowledge of Python to build
a web server via Flask. This chapter explores the Ethernet and Wi-Fi capabilities of
the Raspberry Pi for delivering web-based applications. In this chapter, you will also
learn about using SQLite to store data and display it via a web page. Topics covered
also include Apache and NGINX.
Chapter 10, Integrating with Third-Party Microcontrollers, in this chapter we learn how
to interact with third-party microcontrollers such as the Arduino. These devices can
form the basis of robotics projects and augment the abilities of the Raspberry Pi.
[ viii ]
www.it-ebooks.info
Exploring the Variety of Random
Documents with Different Content
Thou to all wert mild and courteous,
But not one might venture nigher.
Or circatemi e trisore,
E qui prestu ne venite:
Vogliu toudemi i capelli
Per tuppalli le ferite;
Chi di lu sangue di vabu
N'achiu carcu le miò dite.
I have added the original text of this vocero, to give the reader
some idea of the Corsican dialect, and enable him to compare it, if
he is interested in such matters, with the Italian spoken on the
Continent. I find a great resemblance between the dialect of Corsica
and that used by the lower orders in Rome, particularly in
Trastevere.[K] All the Italian popular dialects, however, have a
tendency to drop or mutilate the infinitive endings, are and ire, and
to substitute r for l. The Corsican says soretra for sorella. Philologists
have pronounced the Corsican one of the purest of the Italian
dialects, and Tommaseo especially has much to say in its praise in
his collection of Tuscan, Corsican, and Greek popular songs—which
contains also, though in a defective form, a number of Corsican
dirges, with elucidations. In this book he calls the Corsican dialect "a
powerful language, and of all the dialects of the Italian tongue, one
of the most thoroughly Italian." It seems to me to be genuine gold
compared with the patois of the Piedmontese and Lombards, and
the dialects of Parma and Bologna. Even from the single specimen
communicated, the reader will see that the language of the
Corsicans, though no doubt one of the lower forms of Italian, is soft
and graceful.
BOOK VII.—WANDERINGS IN CORSICA.
CHAPTER I.
The birds come and carry away the olive kernels to the four
winds of heaven, scattering them over the face of the country. The
island thus becomes covered with wild olive-bushes, which flourish
lustily on mountain and in valley, waiting to be improved. In the year
1820, an attempt was made to count them, and their number was
said to be twelve millions. The richest olive-districts at the present
time in Corsica are Balagna, Nebbio, and the country round
Bonifazio.
The little city has only one main street, which is newly built, and
is called the Corso; an alley of elms gives it a singularly rural
appearance. And here too I was astonished at the lonely seclusion,
the idyllic stillness, that so peculiarly characterize the Corsican
towns. You really believe yourself in the farthest nook of the world,
and cut off from all connection with its ongoings.
In another room, formerly the hall where the Council of Nine sat,
are preserved some very interesting relics; the rods, to wit, which
were to have supported the canopy of Paoli's throne. Paoli and a
throne? Impossible! Had the great democrat a hankering after kingly
emblems? So it is affirmed; the story is as follows:—One day
workmen were seen erecting a throne in the National Palace. It was
of crimson damask, hung with gold fringes, and supported, above
the Corsican arms, a golden crown, so placed that when Paoli seated
himself, it stood over his head. To suit the throne, there were nine
smaller crimson chairs, for the members of the Council of Nine.
When the councillors had assembled in the hall, the door of Paoli's
room opened, and Paoli, as it is said, in a magnificent robe of state,
his head covered, and his sword by his side, entered, and moved
towards the throne. A murmur of astonishment and displeasure
instantly arose among the councillors, followed by a deep silence.
Paoli stopped, was disconcerted, and he never took his seat upon
the throne.
I hired a guide and a mule, and, provided with a little bread and
some calabashes of wine, early on the morning of the 28th of July I
rode into the hills. The road, a shepherd's track, never leaves the
valley of the wild Restonica, from its confluence with the Tavignano,
close by the town, up to the very summit of Monte Rotondo, where
it has its source. The bed of this beautiful mountain-stream, is,
during most of its course, a ravine of gloomy and impressive
character. In the vicinity of Corte, it expands into a valley of
considerable breadth, in which chestnut and walnut trees thrive. As
you ascend, it grows narrower and narrower; the walls of rock on
each side rise in black, gigantic masses, shadowed with dark-green,
natural wood, of old pines and larches.
My sure-footed mule clambered safely up the narrowest paths
along the very edge of abysses; and a glance downwards into these,
where the Restonica foamed milk-white far below, had something in
it both of terror and of beauty. A magnificent forest of pines and
larches received me as the sun got higher. Very picturesque are
these giant trees—the pine with its broad, green roof, and the larch,
like the cedar of Lebanon, gnarled, soaring, and rich in branches.
Tall erica, box, and wild myrtles, covered with a snow of blossoms,
clustered in profusion round their mighty stems. And the fragrance
of all those medicinal herbs, in which the mountains of Corsica are
so rich, made the air of the woods balsamic and refreshing.
The herdsman had come out of his cave, and hospitably invited
me to alight, and refresh myself with new milk and cheese. I
willingly accepted his invitation, and proceeded to inspect the
interior of this singular cavernous abode. The grotto, I found, ran a
considerable way into the mountain, affording room for a flock of
two hundred goats and sheep, which the herdsman every evening
brings in to milk. It was so exactly the cave of Polyphemus, that it
almost seemed Homer must have taken his description from it. Every
item of the description was here, even the rows of dishes full of
milk, and more than a hundred flat round cheeses arranged on fresh
leaves. Only Polyphemus himself was wanting; for mine host,
however robber-like and wild he might look in his shaggy
habiliments, was hospitality itself.
"Do the bandits ever pay you a visit?" I asked the Troglodyte.
"Sometimes they do," said the man; "when they're hungry. You see
the stone here on which I sit?—two years ago a couple of bandit-
hunters concealed themselves in my cave; they were after Serafin.
But Serafin stole in upon them through the night, and with two stabs
he made them both cold upon this stone; then he went his way
again into the hills."
Some shaggy dogs sprang out as I rode up, and forthwith the
men, women, and children crept from their huts, and curiously eyed
the stranger. They looked picturesque enough in the midst of the
stony waste; the pelone, their shaggy, brown mantle flung about
them, the red baretto on their heads, and their bronzed features
looking out from their dark bushy beards.
"Come into my hut," said one, "and dry yourself at the fire; it is
warm in there." I immediately twisted myself through the door,
curious to see the interior of such a habitation. I found myself in a
dark chamber, about fourteen feet in length and ten in breadth—
wholly without furniture, not a stool, not a table, nothing but the
black naked ground, the black, naked stone walls, and such a smoke
of pine-wood as, I thought, it must be impossible to live in. Close by
the wall a huge log was burning, and a kettle hung above it.
"Fetch the broccio," said the shepherd; "it is the best we have,
and you will like it." I was curious to see what the broccio was; I had
heard it praised in Corte as the greatest dainty of the island, and the
flower of all the hill-products. Santa brought a sort of round covered
basket, set it before me, and opened it. Within lay the broccio, white
as snow. It is a kind of sweet, curdled, goats' milk; and eaten with
rum and sugar, it certainly is a dainty. The poor herdsmen sell a
broccio-cake in the city for one or two francs.
But the honest pastore shook his head, and said: "Vita povera,
vita miserabile!"—a poor life, a miserable life!
And so it really is: these men lead a wretched life. For four
months of the year—May, June, July, and August—they burrow in
these cabins, destitute of everything that makes life human. In their
world occur no changes but those of the elements—the storm, the
clouds, the thunder-shower, the hail, the heat; in the evening, a
robber-story by the fire, a melancholy song, a lamento to the pipe, a
hunting-adventure with the muffro or the fox; high above them and
around them the giant pyramids of the hoary Rotondo, and the