Skip to main content

Section 1.4 Setting Up Your Raspberry Pi

In this section I describe how I set up my Raspberry Pi to do all the programming described in this book. Yes, I really have run all the programs on both my original Raspberry Pi 1 Model B and my new Raspberry Pi 3 Model B. You may choose to do things differently, depending on which Raspberry Pi you are using and your personal preferences.

This book is based on using the Raspbian operating system. I installed Raspbian version 9 (Stretch). It includes most of the programming tools you will need, but I recommend adding the binutils-doc package to get full documentation for the GNU assembler, as (sometimes called gas).The installed compilers, gcc and g++, are version 6.3.0, and the assembler version is 2.28.

You will also use a text editor for all your programming. Do not use a word processor. Word processors add a lot of hidden control characters to format the text. These hidden characters confuse compilers and assemblers, causing them not to work.

Raspbian comes with several simple text editors already installed. Go to www.raspberrypi.org and look under “HELP.” Under “DOCUMENTATION” click on “LINUX.” Then click on “Text editors” under “Usage.” I have found that many students like GNU Nano because it is easy to use.

You have probably learned how to program using an Integrated Development Environment (IDE), which incorporates several programs within a single user interface:

Text Editor

Used to write the source code and save it in a file.

Compiler

Translates the source code into machine language that can be executed by the CPU.

Linker

Integrates all the functions in your program, including externally accessed libraries of functions, and to determine where each component will be loaded into memory when the program is executed.

Loader

Loads the machine code version of the program into memory where the CPU can execute it.

Debugger

Used to help the programmer locate errors that may have crept into the program. (Yes, none of us is perfect!)

When using an IDE you enter your source code in the text editor part, click on a “build” button to compile and link your program, then click on a “run” button to load and execute the program. There is typically a “debug” button that loads and executes the program under control of the debugger program if you need to debug it. The individual steps of program preparation are obscured by the IDE user interface.

The main problem with using an IDE on the Raspberry Pi is that they require a fair amount of computing resources. In this book we use the GNU programming environment in which each step is performed explicitly using a command line interface. Not only does this make better use of your limited computing power, it takes you “closer to the metal,” which is the whole point of this book.