• No results found

Common Operating Systems

In document Hacking Raspberry Pi 2013 (Page 71-77)

Truly, operating systems are not at all voodoo magic, although their underlying structure can sometimes get complicated. The bottom line is that any end user of a computer system interacts with an operating system of one type or another.

For instance, a Mac user deals with the Apple OS X (pronounced oh ess TEN, not oh ess EX) operating system. A PC user generally uses a version of the Microsoft Windows operating system—

for example, Windows 8 or Windows 7. Mobile device users might run one of the following operating systems, depending on the make and model of their mobile hardware:

Apple iOS BlackBerry Google Android Windows Phone Windows RT

You might know already that the Raspberry Pi runs none of these. What’s going on here? Well, as it happens, the RasPi uses a particular distribution of Linux.

Understanding Linux

Linux (LIH-nix) is an open source operating system originally developed by the Finnish computer scientist Linus Torvalds (LEE-nus TUR-valds) in 1991. Linux was built from the ground up as a free operating system that any interested party could tinker with, improve upon, and re-release under the GPL license (discussed back in Chapter 1, “What Is the Raspberry Pi?”).

At some point you might have heard a nightmare story or two about how difficult it is to use. There was a time when the only people who would touch Linux were computer science nerds or grizzled government employees. Believe me, friends: Linux has gotten much more user-friendly over the past 10 years or so.

Thanks to Linux vendors like Red Hat and Canonical, Linux has become much more mainstream, often to the chagrin of the original Linux fanatics who prefer a less corporate, structured approach to OS development and distribution. In point of fact, Canonical’s Ubuntu Linux, in its 12.10 version, bears a striking resemblance to Apple OS X (see Figure 4.2).

FIGURE 4.2 Apple OS X above, and Ubuntu Linux below.

The OS X and Ubuntu Linux user interfaces are quite similar indeed. As you will learn pretty soon if

you haven’t already, I’m a big believer in using (brief) unordered lists to teach concepts. Allow me to summarize what I see as the chief advantages of Linux:

Generally more secure than proprietary OS software such as Windows and OS X because the community quickly squashes bugs and vulnerabilities.

Gives the operator control of every aspect of OS operation, right down to the bare kernel level.

The OS and most available software are free.

You can do the vast majority of stuff in Linux that you are accustomed to doing in Windows or OS X.

In addition to these factors, it’s also true that people who write malicious software tend to target the most popular operating systems simply because there are more available targets. Consequently, the relatively “niche” status of Linux in the consumer/enthusiast environment gives the platform a security advantage over mainstream OSs.

Note: But What About Office?

Long-time Linux users typically gravitate toward OpenOffice (http://is.gd/AxqDKr) or LibreOffice (http://is.gd/ORAFcy) as open source (and therefore free) alternatives to the proprietary Microsoft Office productivity suite.

As Bret Michaels sang in the 1980s, “Every rose has its thorn....” Here are what I see as the essential disadvantages of Linux:

To access the raw power of Linux, you must learn how to use the command line, which involves a number of highly cryptic command-line tools.

The graphical user interface in Linux is generally not as polished or intuitive as, say, Windows 7 or OS X.

Configuring driver support for new hardware is sometimes problematic to Linux beginners due to the common requirement of manual driver installation and configuration.

You can run Windows or OS X apps under Linux; however, doing so is not considered to be a beginner-level task. In general, the variety of software that is available to Linux is far less than what is available to, say, Windows or OS X.

Despite the challenges that running Linux has for us, I submit that Linux is truly the ideal operating system platform for the Raspberry Pi. Remember that the Pi is intended as a learning environment—

what better way to discover the relationship between an OS and hardware than in an open-source situation where the underlying source code and hardware schematics are freely available to you?

Also, as we’ll see momentarily, you have quite a bit of flexibility in terms of which Linux distribution you might prefer to run on our Pi.

Linux and Raspberry Pi

Remember when I said earlier that Linus Torvalds gave us Linux as a platform for community development? We call those Linux variations, those that come from the development community, remixed or forked distributions.

The Raspberry Pi Foundation put together an official Linux distribution that is optimized for Raspberry Pi; this distribution is called Raspbian (RASS-pian). The name Raspbian bears a bit of an explanation. Raspbian is a portmanteau, which is a mash up of two or more words derived from two separate technologies:

Raspberry Pi: The $25/$35 computer upon which this book is based

Debian: The Linux distribution used as a base for Raspbian (http://is.gd/lgF8Ft)

Personally, I’m overjoyed that the Foundation used Debian as a base Linux for the Pi. Number one, Debian includes one of the most powerful and flexible package managers in the industry (more on that in the next couple chapters). The Raspbian user interface is shown in Figure 4.3.

FIGURE 4.3 The Raspbian Linux distribution includes the LXDE graphical user interface (GUI).

Number two, Debian is one of the more user-friendly Linux distros in existence. As a matter of fact, Ubuntu Linux is also based on Debian.

But can we go ahead and install the “real” Debian or Ubuntu on the Pi? Unfortunately, no—at least not without some major kernel hacking. Remember that the Pi board uses an ARM CPU. Most desktop computers today, at least in the retail space, use the Intel processor. As of this writing in spring 2013, neither Debian nor Ubuntu Linux supports the ARM processing architecture.

The Kernel and Firmware

If the operating system constitutes the software “body” of a computer system, then the kernel represents the brain. Specifically, the kernel is the OS subcomponent that functions most intimately with installed hardware devices.

What’s cool about Linux is that you can customize and recompile the kernel to suit different situations.

For instance, the Raspberry Pi Foundation modified the Debian Linux kernel to accommodate the ARM processor and other components included on the Pi board.

The Linux kernel is called firmware because it is software that is semi-permanently written to the first partition of your Raspbian SD card. I say semi-permanently because the firmware data persists after you power down the computer. However, you can update the firmware to a more recent version if need be.

We can contrast data that is stored on the SD card with data that is stored in random access memory, or RAM. RAM-based data persists only as long as the Pi is powered up; unless you save RAM contents to the SD card, that data is permanently lost if the Pi is turned off or rebooted.

Raspberry Pi uses its own custom-built firmware that “blends” the proprietary Broadcom BCM2835 system on a chip (SoC) with the Raspbian operating system. In point of fact, the BCM2835 SoC actually has two sets of firmware flashed onto the SD card. The first is responsible for managing the hardware resources on the Pi, and the second is charged with controlling the behavior of the Pi’s graphical processing unit (GPU).

Note: I’m Floating!

The original Raspbian code was not optimized in the kernel to process floating-point (decimal) numbers in hardware. This “soft float ABI (application binary interface)”

situation, which involves emulating math co-processing in software, bothered experienced Linux users who wanted to use the Pi to perform more complex math. Fortunately, the current versions of Raspbian now contain a “hard float” ABI, which means that instructions for processing floating-point numbers are performed in hardware using the math co-processor chip. Needless to say, hard float is orders of magnitude faster than soft float.

Updating the Raspberry Pi kernel firmware is covered in the next chapter.

Raspberry Pi’s Other Operating Systems

Keeping in spirit with the “do it yourself” philosophy of Linux, you can run a number of specially crafted Linux distros on the Pi. Raspbian is considered to be the reference operating system because it was built from the ground up for learning software and hardware programming with the Pi board.

However, alternatives exist that are optimized for other uses. Let’s take a brief look at a few of them:

Arch Linux ARM (http://is.gd/6EJlou): This distro is an ARM-specific branch of the Arch Linux OS that is aimed at experienced Linux users. Its structure is lightweight and is intended to provide the user with as much control as possible.

Fedora Remix (http://is.gd/Nj0Iys): This distro is an ARM port of the highly successful Fedora Linux OS. In particular, check out the Pidora distribution (http://is.gd/2TfKjx). Many Linux users swear by Fedora, so its ability to run on the Raspberry Pi pleases many enthusiasts.

Occidentalis (http://is.gd/t79m03): This distro, pronounced ocks-ih-den-TAIL-is, was developed by Adafruit and includes lots of OS “extras” to make hardware hacking easier.

Adafruit is one of the best Raspberry Pi education sites out there; they sell extension hardware and provide detailed instructions on how to use it with your Pi.

OpenELEC (http://is.gd/KpaeqS): This distro, pronounced open ee-LECK, has a single aim

—to run the Xbox Media Center (XBMC) as efficiently as possible. OpenELEC and XBMC are discussed in great detail in Chapter 12, “Raspberry Pi Media Center.”

RaspBMC (http://is.gd/KyBKzy): This distro is like OpenELEC inasmuch as it is intended only to run Media Center software on the Pi.

RISC OS (http://is.gd/6EJlou): This distro, pronounced risk oh ess, was developed by Acorn, who you’ll remember is the manufacturer of the BBC Micro microcomputer, the Raspberry Pi’s inspiration.

Of these alternative Linux distros for the Raspberry Pi, I personally like Occidentalis the best because the environment is optimized for use with the Adafruit Learning System (http://is.gd/efFtD7).

Be sure to visit and bookmark the Adafruit website; they offer almost every conceivable Raspberry Pi hardware add-on. Figure 4.4 shows the Occidentalis user interface.

FIGURE 4.4 Adafruit’s Occidentalis Linux distribution, which includes plenty of hardware hacking tools.

Please note that the Raspberry Pi-compatible operating systems suggested here represent only part of

what’s available. Check out the RPi Distributions page at the Embedded Linux Wiki (http://is.gd/3yHQZ2) for a more complete rundown.

In document Hacking Raspberry Pi 2013 (Page 71-77)