Skip to content

Instantly share code, notes, and snippets.

@nickvelloff
Forked from jkosoy/gist:5379904
Created April 16, 2013 15:01
Show Gist options
  • Save nickvelloff/5396647 to your computer and use it in GitHub Desktop.
Save nickvelloff/5396647 to your computer and use it in GitHub Desktop.

Raspberry Pi setup

Just wanted a quick start guide for myself so that I wouldn't have to keep rooting through Google to remember all this stuff. Hopefully it helps other people.

If you had other ideas or suggestions please leave a comment.

Useful things to own before you buy a Pi

The first time I bought a Pi I was enormously frustrated with myself because I didn't own all of this stuff. Kept having to order things off of Amazon and wait to get started... very irritating. This is all good stuff to have laying around anyway:

  • An extra keyboard and mouse.
  • An adapter for your monitor. I use this one
  • HDMI cable
  • Ethernet cable
  • An enclosure for the Pi, the Pibow is quite popular.
  • A USB hub

Ratio for Pi to Purpose is 1:1.

(unqualified opinion coming up, warning)

Come up with a project and set up your Pi for that. Don't try to make the Pi into another workstation for yourself - it's a nice idea but you'll forget how to set everything up.

I suppose you could make a disk image (see below) if you wanted, but I find it easier to plow ahead with a single Pi dedicated to a specific goal. That way I know when I turn that Pi on it'll always do what I wanted it to... and nothing else.

What size Flash drive to buy?

If you're doing anything besides running startx on the machine I'd go with an 8GB class 10 SDHC drive. Class 10 will run a tinsy bit faster I've read, though I'm betting the performance gain is negligible. Thanks to Stacey for the advice on this... just wish I had asked BEFORE I purchased myself. :)

If you don't feel like learning how to flash the drive yourself you can buy one off of these guys pre-loaded for you.

IMPORTANT :: If you're going to use the Pi for openFrameworks dev you want to make sure you're using the Raspbian "wheezy" distro. Again, either buy your flash drive with it pre-installed or download it here.

Every time I boot up

Just to make sure all my stuff stays latest/greatest.

sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade

WARNING :: Updating and upgrading can take awhile. It also requires a connection to the Internet. I'd recommend a physical connection for the initial setup of your Pi for your initial install so that you don't encounter issues setting up the wireless stuff later.

RPI Update

Way easier for managing updates to the lower level stuff on the Pi.

sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
sudo reboot

WARNING :: rpi-update can take a long time to do it's magic.

The Basics

sudo apt-get install git-core binutils git libnss-mdns netatalk

Briefly:

  • git-core :: not sure why I need this but the openFrameworks walkthrough recommended.
  • binutils :: same as above
  • git :: for version control
  • libnss-mdns :: so I can use raspberrypi.local instead of the IP address
  • netatalk :: so I can use afp:// to connect on my Mac

Setting up Wifi

I used an Edimax EW-7811Un. Basically a tiny USB wireless adapter. Plug it in to your Pi, then...

nano /etc/network/interfaces

Add this to the bottom:

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf

Save and quit (Ctrl+X). Now to create that wpa.conf:

nano /etc/wpa.conf

Write into that:

network={
ssid="NETWORK_SSID"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="NETWORK_PASSWORD"
}

Change NETWORK_SSID and NETWORK_PASSWORD to your wifi's network name and password respectively, save and quit.

Set it to connect to Wifi on boot with:

nano /etc/network/interfaces

My file looks like this:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf

I believe you only need to add the last line but I can't recall and wanted to make sure to post my complete configuration to compare.

Save. Reboot. The edimax should glow blue when it's working.

sudo reboot

Thanks to this tutorial for the assist.

Git

ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub

Whatever it prints out is your SSH Key. Feel free to add that to your Github settings so you can pull.

openFrameworks

Wanted my openFrameworks stuff set up separate from anything else I might do on the Pi. I put it in [user directory/Programming/openFrameworks.

Here's how I do it:

cd ~
mkdir Programming
cd Programming
git clone https://github.com/openFrameworks-RaspberryPi/openFrameworks/
cd openFrameworks/scripts/linux/debian_armv6l
sudo ./install_codecs.sh
sudo ./install_dependencies.sh
cd ~/Programming/openFrameworks/libs/openFrameworksCompiled/project
make

You can also type make Debug instead of make here. Release vs. Debug configurations. Up to you.

WARNING :: This takes a long time to compile. Brace yourself.

Once all that's done:

cd ~/Programming/openFrameworks/scripts/linux/template/linuxarmv6l
cp Makefile ~/
cd ~/Programming/openFrameworks/apps/devApps/raspberrypi_hello_world
cp ~/Makefile ./
make clean
make

Once compiled it'll tell you how to run the application, most likely by typing "make run". Quit the application with Ctrl+C.

At this point I typically switch over to my Mac and either ssh in or mount the Pi as a remote volume. I copy and paste the raspberrypi_hello_world project for re-use, much like I would the emptyExample on a OSX development.

How'd I learn this? The oF-Pi getting started guide.

Arduino

sudo apt-get install arduino
startx

You should see Arduino in your Start Menu -> Programming Folder. You'll likely need to switch from COM0 to /dev/ttyACM0

Want to test?

sudo apt-get install python-serial

Then follow this tutorial. You'll already have pySerial installed.

Creating Disk Images

Once I'm happy with something I may actually want to this from one Pi to the next.

To do that, turn the Pi off and remove the SD card. Connect that card to your Mac. From Terminal:

dd if=/dev/sd-card of=/path/to/save/image bs=1m

/dev/sd-card is the path to your SD Card. /path/to/save/image is the path you want to save the image to.

Unplug your SD card, grab a new one and run this:

gzip -dc /path/to/save/image.gz | dd of=/dev/sd-card

Should be pretty obvious what is what in this restore command.

Steps to to that courtesy this StackExchange post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment