2017 Spring

Notes on Setting up Raspbian for USF Systems Classes

Here are some notes on the steps needed to setup a Raspberry Pi 3 Model and Raspbian for use in CS 315, CS 326, can CS 631 at USF.


  • RPi1 - Raspberry Pi B+
  • RPi2 - Raspberry Pi 2 Model B
  • RPi3 - Raspberry Pi 3 Model B
  • RPi - A Raspberry Pi in general

Raspbian Installation

Download Raspbian Jessie Lite (or regular Jessie with Pixel if you want the GUI desktop) from

You will download a zip file that contains the file


You will need to copy the img file to an SD Card. You will want to use at least an 8 GB SD Card.

To copy the img file to the SD card you can use the UNIX dd command. You can find install instructions for different operating systems here:

For Mac OS X, you can use a program called Pi Filler, which can be downloaded here:

The Pi Filler application (actually it is an Apple Script program) will walk you through the steps of putting a Raspbian image (or any Raspbery Pi OS image) onto an SD Card. I've found this to be quite a bit faster than using dd directly. It takes about 30 seconds to copy the Jessie Lite image to an SD Card (Sandisk Extreme Pro). There are some other useful Mac OS X utilities for the Raspberry Pi on the same page as Pi Filler.

After you have installed the img file onto your SD Card, you need to put the card into the Micro SD slot on the RPi. Before turning on the RPi follow the next section to setup a serial communication link between your RPi and your laptop or desktop computer.

After putting the img file onto the SD Card you need to edit config.txt on the SD Card:

You need to add the following line:


(no spaces and make sure there is newline at the end)

This allows the UART to work on the RPi3.

Serial Communication

Now that you have an SD Card with Raspbian installed you need to boot into Raspbian. However, we need a way to connect to the Raspberry Pi. You can hook up a Raspberry Pi to an HDMI display, a USB keyboard, and a USB mouse. Raspbian will recognized these devices and allow you to interact via a console. You can also start up a graphical desktop. However, this is not very convenient if you carry your Raspberry Pi around with you.

An alternative way to connect with the Raspberry Pi is to use a USB Serial Cable that connects to the Raspberry Pi UART port available on the GPIO pins. This allows for a simple console interface to the Raspberry Pi and Raspbian. As we will see we can also build bare metal kernels that directly use the UART device to display text and get user input.

You need to buy a USB to UART RS232 cable:

The Linux kernel comes with the PL2303 TTL serial driver, so you do not need to install a drive. This is true if you have Linux running directly on your computer or if you are running Linux inside a virtual machine.

On a Mac you will need to install a USB serial driver in order to connect to the Raspberry UART TTL:

The USB serial cable does provide power to the Raspberry Pi and in principle you do not need to use a separate Micro USB power adaptor. This was generally true for the Raspberry Pi B+ (RPi1), but it seems that some laptops do not provide enough power through a single USB port in order to power a Raspberry Pi 3 Model B (RPi3, the one we are using in class). So, in order to power a RPi3 you will need a separate USB to Micro USB cable to connect to a separate USB port on your laptop or desktop. Since we are going to reboot (power cycle) the RPi3 often, it is best to get a cable that has a on/off switch:

Here is a picture of how the cables should be connected:

Once you have the cables sorted out and connected you will need a way to interact with the RPi and Raspbian via the serial cable from your computer. To do this you will need to run a terminal program that can interact with the serial device.

On a UNIX-based OS (e.g., Mac OS X or Linux) you can use a program called kemit from a Terminal window. You will need to install this on macOS and Linux:

On a Mac you can install kermit using Homebrew (which allows you to install a whole bunch of standard UNIX programs):




Follow the homebrew install instructions.


Once installed you can type:


$ brew install c-kermit


On Ubuntu Linux you can use apt-get to install c-kermit:


$ apt-get install ckermit


Once installed, create a .kermrc file in your home directory (on your host computer/laptop):


$ cd

$ cat > .kermrc

set line /dev/cu.usbserial

set speed 115200

set carrier-watch off





Now you can use kermit to connect to your RPi via the USB Serial cable.




$ kermit


Now turn on your RPi.


You should see the boot squence.


To exit kermit, type


CTRL-\ then q


You can start and stop kermit multiple times with out the terminal hanging.


In order to connect to the RPi via the USB serial cable on Windows, you can use the Putty program. See the information in the following page for details (search for Putty).

Raspbian Initial Login and Resizing the Filesystem

Now that you have a power connection and a serial connection to your RPi and you have an SD Card with Rasbian installed, you can power up your RPi and login via a console (screen or Putty).

When you first boot up, you will see several Linux boot messages, and then finally you will see something like:

Raspbian GNU/Linux 7 raspberrypi ttyAMA0\

raspberrypi login:

Use the following credentials to log in:

username: pi
password: raspberry

Then you will see:

Linux raspberrypi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l 

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the 
individual files in /usr/share/doc/*/copyright. 

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 
permitted by applicable law. 

NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config' 


One of the first things you will need to do is resize the Linux partition on the SD Card. The Jessie Lite img file defaults to a 3 GB partition, but this is much smaller than the full 8 GB (or 16 GB) available on the SD Card.

To resize, type:

$ sudo raspi-config

Using the menu select the first option "1 Expand Filesystem". You need to reboot to see the changes. When you exit raspi-config, it will ask you if you wan to reboot. You should select "yes".

Changing the Default Password

Eventually we will configure Raspbian so that we can connect to it via ssh over the network (hardwired or WiFi). When we put the Raspberry Pi on the network, others will potentially be able to login. Because everyone knows the default Raspberry Pi password, it is a good idea to change it now.

Once you are logged in again, you can type:

pi@raspberrypi:~$ passwd 
Changing password for pi. 
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully 

Pick a new password you can remember.

Resizing the Terminal Window

When connecting to the RPi via a Terminal window it is useful be able to "resize" the window so that Raspbian understand the number of rows and columns in the Terminal. This allows programs such as vi, emacs, pico, and nano to utilize the entire window and not just the default size of 80x24.

Create a directory called 'bin' in your home directory:

$ cd
$ mkdir bin

Put the following file into your bin directory:


and call it resize.py

Then add the following to $HOME/.profile

$ cd
$ cat >> .profile

# Resize the terminal
python $HOME/bin/resize.py

This will be invoke resize.py automatically each time you log in.

You can manually resize the terminal by typing:

$ python ~/bin/resize.py

Shutting Down Raspbian

When you are done working in Raspbian, you should shutdown Linux properly before turning off the RPi.

You can shutdown Raspbian by typing:

$ sudo shutdown -h now

Wati for the final "Power down" message for turning off the power.

pi@raspberrypi:~$ sudo shutdown -h now 

The system is going down for system halt NOW!MA0) (Thu May 7 01:19:16 2015):
[ 953.595652] reboot: Power down

You can make this an alias:

$ cd
$ cat >> .bash_aliases
alias pidown='sudo shutdown -h now'

After you login in again, you can shutdown your RPi2 with:

$ pidown

You still need to wait for the final "Power down" message.

Setting up Networking

While you can get by interacting with Raspbian via screen or Putty, the Terminal support is still limited and you only have one console available. By setting up networking on in Raspbian, you can ssh into your RPi and you can also download additional packages for Rasbian. In addition you can connect to Github to get source code and access your project repositories.

You have different options to connect the RPi2 to the network:

Internet Sharing on a Mac

I followed the instructions given here:



My RPi Ethernet Mac address is:




You will need to find your Mac address on your RPi using the ifconfig command:


$ ifconfig eth0

eth0      Link encap:Ethernet  HWaddr b8:27:eb:82:1e:fa  

          inet addr:  Bcast:  Mask:

          inet6 addr: fe80::a9c4:4df2:407d:84cd/64 Scope:Link


          RX packets:414 errors:0 dropped:0 overruns:0 frame:0

          TX packets:248 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:58170 (56.8 KiB)  TX bytes:33998 (33.2 KiB)


Your mac address is the one after HWaddr.


You need to create a /etc/bootptab file with your mac address.


See below:


$ cat /etc/bootptab 

# Bootptab file

# Section 1 -- ignored


# Section 2 -- used

# Hardware types: 1=Ethernet, 6=Wireless

#                 See http://www.ietf.org/rfc/rfc1700.txt


# machine entries have the following format:


# hostname         hwtype     hwaddr         ipaddr   bootfile

rpi                1          b8:27:eb:82:1e:fa boot


For CSLabs WiFi, put the following into /etc/wpa_supplicant/wpa_supplicant.conf:


You will need to edit as root:

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

You can put multiple network entries in the wpa_supplicant.conf file. This way you can have Rasbian automatically connect to different networks depending on your location.

Then type:

$ sudo ifdown wlan0
$ sudo ifup wlan0

After a few seconds a connection should be made. You check if you have been assigned an IP address by typing

$ ifconfig wlan0

If you have a valid IP address you will see it next to "inet addr".

Once you see an IP address you can test connectivity by typing:

$ ping google.com

You should see something like:

pi@raspberrypi:~$ ping google.com 
PING google.com ( 56(84) bytes of data. 
64 bytes from nuq04s29-in-f14.1e100.net ( icmp_req=1 ttl=53 time=22.2 ms 
64 bytes from nuq04s29-in-f14.1e100.net ( icmp_req=2 ttl=53 time=20.1 ms 
64 bytes from nuq04s29-in-f14.1e100.net ( icmp_req=3 ttl=53 time=18.6 ms 
--- google.com ping statistics --- 
3 packets transmitted, 3 received, 0% packet loss, time 2002ms 
rtt min/avg/max/mdev = 18.682/20.353/22.205/1.443 ms 

Type CTRL-C to exit, otherwise it will go on forever.

Once you find the IP address using ifconfig, you can then ssh into your RPi2:

pi@raspberrypi:~$ ifconfig wlan0 
wlan0   Link encap:Ethernet HWaddr 74:da:38:0a:1d:f2 
        inet addr: Bcast: Mask: 
        RX packets:612 errors:0 dropped:84 overruns:0 frame:0 
        TX packets:263 errors:0 dropped:0 overruns:0 carrier:0 
        collisions:0 txqueuelen:1000 
        RX bytes:156849 (153.1 KiB) TX bytes:47152 (46.0 KiB)

Now open another Terminal on your computer and type:

$ ssh pi@<your_ip_address>


$ ssh pi@

Say "yes" you want to connect, then type in your password for the "pi" user.

Useful Applications and Packages to Install

The Emacs editor:
$ sudo apt-get install emacs