Raspberry Pi

Connecting to a Pi

There are ten Pis in RRO 220. If all is working well you should be able to connect to them. They have names ranging from egm360pi0.cs.unca.edu to egm360pi9.cs.unca.edu.
10 Raspberry Pis

You will need to connect as the user pi with a password that will be provided in class. We suggest you use ssh if connecting from OS X or Linux and PuTTY if connecting from Windows.

Since there are ten computers, we suggest each team (or table) use one. It is possible for more than one person to connect to the Pi; but it might get a little slow, and there are some commands that only one person should run at a time.

Initial setup

The only configuration that has happened on these computers is that the password for the pi account has been changed. The first thing you need to do when you get your Pi is to run a program called raspi-config.

raspi-config does a lot of configuration and, I’m afraid the exact configuration depends on which version of raspi-config can with your distribution. However go ahead and type sudo raspi-config and we will guide you through the first configuration, expanding the file system.

Your Pi will require a reboot after expanding the file system. We’re going to take a little break here while that happens.

Pi vs Arduino

Let’s take a look at Make:’s article Arduino Uno vs BeagleBone vs Raspberry Pi during our break. It does have some nice tables and pictures.

In our class, the ability to do video won’t made much of a difference because we are going to use the Pi in a headless (no monitory, no keyboard, no mouse) configuration. However, it will allow you to play Minecraft on the Pi at home.

Architecture of the Pi

Continuing the setup

Hopefully you can now reconnect to your Pi and continue the configuration by typing sudo raspi-config once again.

This time there are a few configuration changes you’ll want to make.

When raspi-config is done, you return to the shell, or more precisely to bash. Never call it the command prompt.

This is real multi-user, multi-processing operating system. Type the following commands, under our tutelage, to see what we mean. Wait for us to explain the output of each command.

id
sudo id
more /etc/passwd
more /etc/shadow
sudo more /etc/shadow
grep pi /etc/passwd
df
ls -l /etc | more
ls -l /dev | more
ls -l /home
find /etc -name "net*" -exec ls -l {} \;
echo "This is fun" > /tmp/suchfun.txt
cat /tmp/suchfun.txt
cd /tmp
ls -l suchfun.txt
chmod go-r suchfun.txt
ls -l suchfun.txt
ifconfig
cat /proc/meminfo | more
cd
nano helloworld.c
gcc -o helloworld helloworld.c
./helloword
echo "Please ignore this" > /dev/null
ps

If you want an extensive, but free, Linux book; try Linux Fundamentals by Paul Cobbault.

Do try this at home

If you have a router at home; you could plug your Pi into the router using a Ethernet cable, connect to your router’s administration page, and determine your Pi’s IP address. Now you could use ssh or PuTTY to log into your Pi.

Unforunately we have no access to this sort of information on the student VLAN at UNC Asheville; and, in any case, if thirty people connected at the same time, we’d have trouble knowing which Pi belonged to whom. However, you could plug your Pi into the Computer Science VLAN, and we could get your Pi’s address, and we might just try that if our next scheme doesn’t work.

The serial connection

The most viable alternative for a headless configuration when your don’t know the IP address is with a serial connection to the Pi. There is very good web documentation of this on the RPi Serial Connection page of the Embedded Linux Wiki.

The physical connection

The most common mechanism for making the connection between the Pi and your computer is an FTDI USB to serial cable. FTDI even makes an TTL-232R-RPi cable specifically for this purpose. We don’t have any FTDI TTL-232R-RPi cables, but the Computer Science department has several FTDI TTL-232R-3V3 cables (which are used to download programs to PIC24HJ32GP202 microcontrollers in CSCI 255) that can be used for the purpose. The only tricky part problem is connecting the three pins of the Pi. to the right pins of the FTDI TTL-232R-3V3.

As it turns out, we also own several 3-pin and 4-pin connectors, purchased for reasons we have long forgotten. Below is a picture of how you can attach one of these to your Raspberry Pi.
3-pin connector on Pi

At this point, you need to insert the other ends of the connector’s wires into the FTDI TTL-232R-3V3 cable. This isn’t hard. It’s black to black, ground on both Pi and cable; yellow to yellow, TX on Pi and RX on cable; and red to orange, RX on Pi and TX on cable.

If you are using a 4-pin connector, with black connected to ground on the Pi, it’s a little different. However, rather than using the 4-pin connector, just insert your T-Cobbler into a breadboard and connect it to a 6-pin header for the FDTI TTL-232R-3V3 cable.
6-pin connector with T-Cobbler

The software connection

Now you must use CoolTerm or PuTTY to connect to the Pi. This is very similar to how we connected to the XBee in the last lab except that you use different RS-232 settings.

You will need to hit the enter key a few times before you see the login prompt. After login you can bash around your Pi.

A few more things to do

First of all, run raspi-config to configure your own Pi similar to how we configured one of the egm360piN.cs.unca.edu Pi’s earlier.

However, this time type ifconfig to determine the MAC address of your Pi. If you plug it into the Ethernet in the classroom, you may even be able to see your Pi’s IP number. Share the MAC address with the class instructors. We may be able to do something useful with it.

If you do find our your IP number, you can ssh to your Pi. This will be more reliable than the serial connection. Also this would give you a fast internet connnection for downloading the updates that would allow your Pi to run with its full 512 Mbytes, rather than 256 Mbytes. To do that you need to execute the following two commands:

sudo apt-get upgrade
sudo apt-get update

If you can’t do them in lab today, be sure to do them at home.