Getting Started with the RaspberryPi
Published 2012-7-09Where to get it
If you have to have it ordered today, you can pay somewhere in the range of $70 to $100 and get it from ebay.
Otherwise you'll have to get on the waiting list at one of
The sites go down or are disabled from time-to-time due to the high demand. The sooner you can get on, the better.
You can also run an RPi Emulator which is available on sourceforge.
Accessories
You'll likely want to pick up a few things from adafruit, monoprice, and Amazon:
- a breakout board
- a breadboard
- some fancy breadboarding wire
- maybe the RPi merit badge for your laptop bag
- perhaps a RPi enclosure
- micro usb cable
- usb wall charger
- usb-serial adapter - Tripp Lite, StarTech, Pluggable, and Sewell have all served me well
- Tripp Lite - supposedly works even on Windows (and of course Mac and Linux)
- Spendy, but better build quality
- Texas Instruments Chipset
- Works on Mac, Linux, and Windows
- Drivers
- Pluggable, Sewell - works in Mac / Linux (maybe windows?)
- StarTech
- FTDI Chipset
- Works on Mac, Linux (maybe windows, but some report trouble)
- Virtual COM Port Drivers
- Tripp Lite - supposedly works even on Windows (and of course Mac and Linux)
What do with it?
So you've waited a long three to six months and your RPi (as it is effectionately called in the community) has arrived.
Now what to do?
Well, that's up to you, but there are some ideas floating around.
Getting Started
I've found that the community documentation is a bit fragmented so I'm compiling a list of notes.
Downloading a System Image (Arch)
If you have your RPi in hand then the next thing you'll want to do is put an image on the SD Card to play with.
I recommend doing the polite thing and downloading via BitTorrent, but nothing is stopping your from being a bit-hogger and sapping the main servers.
If you haven't used BitTorrent before, it's easy enough use with Transmission.
- Mac Transmission.app or
brew install transmission
- Linux
apt-get install transmission
- Transmission for Windows
Having played with both Arch and Debian, Arch seems to be much much faster, but we can download both.
RPI_ARCH_RELEASE="13-06-2012"
cd ~/Downloads
wget http://downloads.raspberrypi.org/images/archlinuxarm/archlinuxarm-${RPI_ARCH_RELEASE}/archlinuxarm-${RPI_ARCH_RELEASE}.zip
# or transmission-cli -m "http://downloads.raspberrypi.org/images/archlinuxarm/archlinuxarm-${RPI_ARCH_RELEASE}/archlinuxarm-${RPI_ARCH_RELEASE}.zip.torrent"
unzip archlinuxarm-${RPI_ARCH_RELEASE}.zip -d ./
Loading the Image to an SD Card
-
Get a blank (or blankable) SD card (or MicroSD with adapter), but don't plug it in to your computer yet (or unplug it if you have).
-
Run
ls -l /dev/rdisk* /dev/sd*
and note the output. Particularly you're looking for the highest value of disk such as/dev/rdisk0s3
or/dev/sdb2
-
Insert the SD card into your computer
-
Run
ls -l /dev/rdisk* /dev/sd*
again and look for the newest highest value such as/dev/rdisk1s3
or/dev/sdc2
or possibly/dev/mmcblk0p1
* On OSX ignore `/dev/sdt`
-
Unmount the disk if it was automounted. Note that graphical tools may also eject (power off) the disk
OSX uses
diskutil umount
sudo diskutil umount /dev/rdisk1s1 sudo diskutil umount /dev/rdisk1s2
Linux uses umount
sudo umount /dev/sdc2 sudo umount /dev/sdc3
-
Now copy the disk image to the disk (not a partition) so
/dev/rdisk1
rather than/dev/rdisk1s3
and/dev/sdc
rather than/dev/sdc2
RPI_ARCH_RELEASE="13-06-2012" sudo dd bs=1m if=./archlinuxarm-${RPI_ARCH_RELEASE}/archlinuxarm-${RPI_ARCH_RELEASE}.img of=/dev/rdisk1
-
If the drive automounts when
dd
completes, unmount it again (as per above) -
Eject-o el sd-card-o
Configuring Arch
-
Login as root:root
-
Change your password with
passwd
-
Create an arch key with pacman -S haveged # generates entropy based on CPU ticks haveged -w 1024 pacman-key --init # must have LOTS of entropy to generate key pkill haveged pacman -Rs haveged
-
Update and install normal packages. Note that you should NOT CANCEL the upgrade to continue the upgrade pacman -Syyu # do NOT CANCEL the current opertation to update pacman first (or any other package) # NOTE: I had to manually replace
/etc/pam.d/login
with/etc/pam.d/login.pacman
after the installpacman -Sy \ sudo \ openssh \ fail2ban \ # Add `fail2ban` to the list of `DAEMONS` in `/etc/rc.conf` pacman -Sy \ git \ base-devel \ vim \ zsh \ screen \ rsync \ mlocate \ htop \ nodejs \ sqlite \
-
Create a user (and make sure to put him in the group
wheel
), give it sudo, and disable root ssh.adduser mynewuser visudo # uncomment the first `wheel` line vim /etc/ssh/sshd_config # uncomment / update the following line # set PermitRootLogin no
-
Update the RPi Firmware and allocate 192/64 MiB RAM for CPU/GPU.
wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && chmod +x /usr/bin/rpi-update rpi-update 192 reboot
-
Resize the sd card partition to its full size
sudo fdisk -l /dev/mmcblk0 # note the Start of the root (probably second) partition sudo fdisk /dev/mmcblk0 > d > 2 > n > p > 2 > # the number which is the start of the root partition > w sudo reboot resize2fs /dev/mmcblk0p2
Hardware Hacking
When you get to the point that you want to start having your RPi interact with the world around you, you're going to want something like the sensor pack from adafruit and I'll save you some time by telling you that the links you'll need are right here:
- Low-Level Peripherals
- Verified Peripheral Pinout
- CPU Pinout
- CPU Signals
- Raspberry Pi Schematics
- Broadcom BCM2835 Datasheet (pdf)
Das Blinkin' Lights (how to connect an LED)
-
Connect a red breadboard wire (or any wire) to GPIO 17 on the main header and a back breadboard wire to ground.
-
Wrap a resistor (red red brown gold should do) around one end of an LED.
-
Test the LED by connecting the longer positive (hot) lead to the 5v power and the other to the ground wire.
-
Now attach the long lead (positive) to the red wire. The light will probably be off.
sudo su - ls /sys/class/gpio echo "17" > /sys/class/gpio/exports ls /sys/class/gpio/ ls /sys/class/gpio/gpio17 echo "out" > /sys/class/gpio/gpio17/direction # means that this GPIO sources (outputs) 3.3v while true do echo "0" > /sys/class/gpio/gpio17/value sleep 1 echo "1" > /sys/class/gpio/gpio17/value sleep 0.5 done
-
The LED should now be blinking on and off. Huzzah!
Serial Port
By default the TTL serial port is setup for debugging (precisely what ctrl+alt+f1
emulates with a desktop system).
To use it for communication with something such as a GPS or Accelerometer you need to disable it as a login prompt.
See Joshua Elliott's blog post on Raspberry Pi Serial for more info.
By AJ ONeal
Did I make your day?
Buy me a coffee
(you can learn about the bigger picture I'm working towards on my patreon page )