Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi 2 Server Essentials

You're reading from   Raspberry Pi 2 Server Essentials Transform your Raspberry Pi into a multi-purpose web server that supports your entire multimedia world with this practical and accessible tutorial!

Arrow left icon
Product type Paperback
Published in Apr 2016
Publisher
ISBN-13 9781783985692
Length 174 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Piotr J Kula Piotr J Kula
Author Profile Icon Piotr J Kula
Piotr J Kula
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Getting Started with the Raspberry Pi FREE CHAPTER 2. Preparing a Network 3. Configuring Extra Features 4. Using Fast Web Servers and Databases 5. Setting Up the Raspberry Pi as a File Server 6. Setting Up Game Servers 7. Streaming Live HD Video 8. Setting Up the Pi as a Media Center Server 9. Running Your Pi from a Battery's Power Source 10. Windows IoT Core 11. Running Your ownCloud 12. The Internet of Things – Sensors in the Cloud Index

Understanding the design of the Raspberry Pi

The Raspberry Pi has two identifiable microchips on the PCB:

  • In the center is one that's clearly marked with a Broadcom logo and text starting with BCM283x, which is the main processor
  • The Raspberry Pi 2 has its RAM chip at the back of the PCB.
  • Near the USB port, there is a smaller chip that is either a USB hub or a USB/LAN chip, depending on the model.

BCM283x is actually a high-performance GPU with an embedded ARM processor. It is a SoC (System on Chip), which means that there is small amount of space for code that executes when it gets turned on. This is known as Stage 1 in the boot process.

Boot process

Some network actions need to be performed during the boot process, and it is good to understand the various stages in case you need to troubleshoot something. The boot process is as follows:

  1. Stage 1 begins on the GPU and executes the code SoC firmware, which starts to load Stage 2 code to the L2 cache.
  2. Stage 2 reads bootcode.bin from the SD card. It initializes SDRAM (synchronous dynamic random access memory) and loads Stage 3.
  3. Stage 3 is the loader.bin file. This loads start.elf, which starts the GPU.
  4. During start.elf, it prepares to load kernel.img.
  5. The kernel image then reads config.txt, cmdline.txt, and bcm283x.dtb.
  6. If the .dtb file exists, it is loaded at 0 × 100, and the kernel is loaded at 0 × 8000 in memory.
  7. The kernel image is the first binary that runs on the ARM CPU, and it can be compiled with custom support for specific hardware.
  8. The operating system starts to load.

All the source code in stages 1 to 3 are closed source and protected by Broadcom. These closed source files are compiled and released by Broadcom only; you can update them on your SD card by running a firmware upgrade in Raspbian, which is covered later.

The kernel.img file connects the application to the hardware. Any computer with an operating system has a kernel of some sort. In Linux, it is possible to compile your own kernel, and it might be the first file that you might want to amend yourself. This allows you to change the boot screen, load custom drivers, or perform other tasks that you might need. This is an advanced task and is not covered in this book.

Other capabilities

BCM283x also has dedicated audio hardware together with video encoding/decoding. This allows the Raspberry Pi to playback HD (MPEG-4) content, such as videos, or render games using OpenGL ES. You can buy additional encoder/decoder licenses for extra functionality, such as MPEG-2, used in DVD video encoding and VC-1, which is used by Microsoft's WMV formats. This is also used for Silverlight live streaming.

The SD card is also directly interfaced by the Broadcom chip using dedicated hardware inputs/outputs and interrupts.

All that dedicated hardware means that while those sections of the chip are fully utilized, the ARM CPU will be idle or hardly used. This allows you to compute other transactions synchronously, and this is what makes the Raspberry Pi a truly unique single board, credit card-sized computer!

Hardware limitations

All this hardware that is crammed into one tiny space has its drawbacks. Some are deliberate and others are not. You should consider that these are theoretical calculations; real-world performance may vary, but are usually slower than theoretically estimated.

Network speeds

It may be disappointing that the Raspberry Pi Foundation decided to use a 100 Mbps LAN chip instead of a gigabit one. We need to crunch some numbers to justify this decision, though. Let's convert megabits to a more familiar megabytes. To get to megabytes per second from megabits per second, we divide 100 Mbps by 8 (there are eight bits in a byte). This equates to 12.5 megabytes per second at 100% LAN capacity. For a single user, this is only roughly 20% of what the USB hub can handle. This means that by design, this is an unchangeable bandwidth limitation for networking.

If you plan to share files with several users at the same time, each new user will bump down the other user's bandwidth to accommodate their own. As a workaround, you could add a USB gigabit LAN peripheral. But due to speed constraints of the USB hub, you will only use approximately 48% of the gigabit LAN. To make matters worse, any hard drives running on the USB port will start to fight for bandwidth. The USB controller has to share 480 Mbps across all ports! One port is used by the 100 Mbit network card, and the other connects the hub to the GPU. For one user, this means a maximum bandwidth of 240 Mbps. Why 240 Mbps? This is because 240 Mbps goes to the LAN and 240 Mbps goes to the hard drive, and theoretically, there is no USB bandwidth left for anything else.

This could be a problem for a multiuser environment, but for home use, you would not run into any major problems as the bandwidth can accommodate HD video streams while serving other clients. This is why the cheaper 100 Mbps version was used.

USB bottlenecks

As it was made clear by the bottlenecks found in the LAN, the worst thing about USB bottlenecks is that there is no way to work around this problem! This is because the USB controller connects to the Broadcom and LAN chips, respectively, on the PCB without any possibility of expanding or bypassing this chip.

Time

The Raspberry Pi also does not come with a real-time clock, so timekeeping is left to Internet-based time servers. For many people, this might not cause a problem, but if you wanted to create a remote, disconnected device that depends on recording events at various times of the day, you might be left a little bit disappointed.

One easy and reliable way to do this is to connect a USB or I2C RTC that runs off a small battery. There is an easier and free option, though, but it is not as accurate; you may want to install the fake-hwclock package. All you need to do is set the time once, and the software will keep the track of time using a file. If you have a power outage, the software will read the file and set the time back to the last known time. The drawback is that you lose that time as there is no way to determine how long the outage lasted for.

To get time without using the Internet, you can find a cheap GPS receiver. When the GPS gets a good lock, it will provide you with extremely accurate time. This same method is used to synchronize GSM voice calls on mobile phone technologies across the world.

Another method is to use the time broadcasted by long wave radio signals. These also broadcast extremely accurate time using atomic clocks. The availability depends on your location, though. These are currently available in Colorado for most of the US; Germany, Russia, the UK for Europe; and finally, Japan. The radio waves operate on different frequencies and more research is required for this method.

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