These are brief notes on what I do when starting a new Raspberry Pi project. By the end, I have a basically working machine, on the network, with a minimal set of development tools.

Flash the SD card

Follow the instructions on the Raspberry Pi website1. Find out the relevant device:

$ diskutil list

Now flash it:

$ diskutil unmountDisk /dev/diskN
$ sudo dd bs=1m if=raspbian-stretch-lite.img \
     conv=sync of=/dev/rdiskN
$ diskutil unmountDisk /dev/diskN

You can now remove the SD card.

First boot

The aim here is to get to a point where everything else can be done remotely.

Connect the Raspberry Pi to:

On a machine which no on-board networking and only one USB port you might have problems!

Apply power and check that it boots properly.

Run raspi-config and change:


First login

You should now be able to login remotely. Even the lite version of Raspbian has Bonjour support so you can just

$ ssh pi@foo.local
pi@foo.local's password:

It is a pain to keep using passwords, so copy over any relevant SSH public keys.


On all installations I want some basic development tools:

$ sudo apt-get update && sudo apt-get dist-upgrade
$ sudo apt-get autoremove
$ sudo apt-get install emacs-nox python3-pip ipython python3-gpiozero

Other useful packages include i2c-tools and pimoroni.

Unattended updates

Life is too short for me to manually update all the Raspberry Pis around the place so I live dangerously and enable Unattended Upgrades2.

$ sudo apt-get install unattended-upgrades
$ sudo dpkg-reconfigure -plow unattended-upgrades


To send the system logs to a central machine, edit the config thus:

$ less /etc/rsyslog.d/remote.conf
*.* @@logger.local
$ sudo service rsyslog restart

udev rules for PWM permissions

By default, the GPIO devices in sysfs are in the GPIO group which makes it easy for non-root programs to access them:

pi@zowie2:~ $ ls -l /sys/class 				
drwxrwx— 2 root gpio 0 Jun 28 20:17 gpio		
drwxr-xr-x 2 root root 0 Jun 29 11:26 pwm		

This is done by rules in /etc/udev/rules.d/99-com.rules but sadly there aren’t analogous entries for the PWM devices. So I append this:

SUBSYSTEM=="pwm*", PROGRAM="/bin/sh -c '\				
        chown -R root:gpio /sys/class/pwm && chmod -R 770 /sys/class/pwm;\
        chown -R root:gpio /sys/devices/platform/soc/*.pwm/pwm/pwmchip* \
          && chmod -R 770 /sys/devices/platform/soc/*.pwm/pwm/pwmchip*\	


It’s probably worth taking an image of the SD card at this point. You can then clone the card to make other machines rather more quickly: all that needs to be done is to change the hostname with raspi-config.