## Download & install the base RPi system
+```
+https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-09-28/2015-09-24-raspbian-jessie.zip
+unzip 2015-09-24-raspbian-jessie.zip
+```
+
+or
+
```
wget https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip
unzip 2015-05-05-raspbian-wheezy.zip
ssh bbmc@bbctrl.local
```
-## Install the toolchain
+## Install the RPi toolchain
On the development system (i.e. not on the RPi):
```
```
You should see the output ``Hello World!``.
+
+## Install the AVR toolchain
+Install the following tools for programming the AVR:
+
+```
+sudo apt-get install -y avrdude gcc-avr
+```
+
+## Connect to TinyG
+
+From RPi terminal
+
+```
+minicom -b 115200 -o -D /dev/ttyAMA0
+```
+
+You should see a prompt.
+
+
+## Program TinyG
+
+```
+avrdude -c avrispmkII -p ATxmega128A3U -P usb -U flash:w:tinyg.hex:i
+```
#!/bin/bash
+ID=2
+
# Update the system
apt-get update
apt-get dist-upgrade -y
-# Install the auto discovery daemon
-apt-get install -y avahi-daemon
+# Resize FS
+# TODO no /dev/root in Jessie
+ROOT_PART=$(readlink /dev/root)
+PART_NUM=${ROOT_PART#mmcblk0p}
+
+if [ "$PART_NUM" != "$ROOT_PART" ]; then
+ # Get the starting offset of the root partition
+ PART_START=$(
+ parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d:)
+ [ "$PART_START" ] &&
+
+ fdisk /dev/mmcblk0 <<EOF &&
+p
+d
+$PART_NUM
+n
+p
+$PART_NUM
+$PART_START
+p
+w
+EOF
+
+ # Now set up an init.d script to do the resize
+ cat <<\EOF >/etc/init.d/resize2fs_once &&
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: resize2fs_once
+# Required-Start:
+# Required-Stop:
+# Default-Start: 2 3 4 5 S
+# Default-Stop:
+# Short-Description: Resize the root filesystem to fill partition
+# Description:
+### END INIT INFO
+. /lib/lsb/init-functions
+case "$1" in
+ start)
+ log_daemon_msg "Starting resize2fs_once" &&
+ resize2fs /dev/root &&
+ rm /etc/init.d/resize2fs_once &&
+ update-rc.d resize2fs_once remove &&
+ log_end_msg $?
+ ;;
+ *)
+ echo "Usage: $0 start" >&2
+ exit 3
+ ;;
+esac
+EOF
+
+ chmod +x /etc/init.d/resize2fs_once &&
+ update-rc.d resize2fs_once defaults
+fi
+
+# Install auto discovery daemon
+apt-get install -y avahi-daemon avrdude minicom
# Clean
apt-get autoclean
-# Change the hostname
-sed -i 's/raspberrypi/bbctrl/' /etc/hosts /etc/hostname
+# Change hostname
+sed -i "s/raspberrypi/bbctrl$ID/" /etc/hosts /etc/hostname
-# Create bb user
+# Create user
useradd -m -p $(openssl passwd -1 buildbotics) -s /bin/bash bbmc
echo "bbmc ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
+# Disable console on serial port
+#sed -i 's/^\(.*ttyAMA0.*\)$/# \1/' /etc/inittab
+sed -i 's/console=ttyAMA0,115200 //' /boot/cmdline.txt
+
reboot