Creating base image (variation of raidtech wiki)
VARIATION NOTES:
- Effective 5/10/16, Raspian-Jessie expands file system to fill SD card on first boot
- Use PiBakery? to build base image, and to modify/customize/personalize SD card at will
Write Raspbian-Jessie Lite to SD Card using PiBakery?
- Be sure to use a PiBakery? release with Jessie
- Set "On First Boot" options:
- Setup WiFi? for team's router settings:
- Set Hostname to team2537-pi (it will be customized later...)
- Set Pi Zero OTG Mode to Ethernet, with IP 192.168.137.80 (it will be customized later)
- Shutdown
USB/Networking Setup
- PiBakery? provides "OTG Mode to Ethernet with Static IP" configuration, which we can use in lieu of the blog link referenced by the wiki. (If we choose not to use PiBakery? for this, then insert instructions here to edit two files in the /boot partition of the SD Card.)
Assign static MAC addresses
- Described on the wiki. Involves editing a file in the /boot partition of the SD Card.
- IMPORTANT: There are several methods for setting fixed MAC addresses in the discussion section of the blog referenced by the wiki.
- One is to add the fixed addresses into the file /etc/modprobe.d/g_ether.conf.
- Another is to add them to /boot/cmdline.txt using a different syntax.
- A third is to only add the Pi Zero device's address to /etc/cmdline.txt. It isn't clear from these discussions whether or not these fixed addresses need to match the random addresses obtained by establishing a USB connection to the Pi and querying the current random MAC addresses for the host and the Pi device (as explained in one of the responses using dmesg -T | grep MAC), or if any legally formatted MAC address is acceptable (e.g., 11:22:33:44:55:66 as shown in another response.)
Setup DNS
- NOTE: Having problems with this -- /etc/resolv.conf gets overwritten at boot (by resolveconf), so the settings are not maintained. This step is in our wiki procedures. What's its origin? Do we need it, and why? And if so, how do we fix it? We need some way to configure the Pi to access a nameserver when networking over USB. Maybe avahi, mdns, /etc/network/interfaces entries, etc.???
Update to the Raspbian packages (Pi Zero must have internet access with hostname resolution for this step):
sudo apt-get update sudo apt-get upgrade
Install Oracle Java JDK 80
Install Pi4J (?)
Skip Nano (included in Jessie Lite)
Skip Avahi (included in Jessie Lite)
Skip Raspbian Configuration, rasps-config
- Expanding partition to use entire SD Card handled with Jessie Lite since 5/10/16
- Hostname customization handled using PiBakery?
- I2C enabling gets handled using PiBakery?
Skip WiFi? Setup
- Handled using PiBakery?
Notes/Resources?
Links for imaging a Pi uSD card:
- http://www.aoakley.com/articles/2015-10-09-resizing-sd-images.php
- http://softwarebakery.com/shrinking-images-on-linux
- http://www.htpcguides.com/easy-resize-and-back-up-raspberry-pi-sd-card-with-ubuntu/
PiBakery?
Writing PiBot Base Image to uSD card and Customizing it:
From a LINUX system with uSD card access...
dd base image to uSD
sudo su cd /media/alan/boot cp -p cmdline.txt cmdline.txt.orig cp -p config.txt config.txt.orig
edit cmdline.txt to add:
modules-load=dwc2,g_ether
and
g_ether.dev_addr=5a:77:1e:af:8e:9e g_ether.host_addr=72:8d:1f:c4:e8:ca
(change last field of each MAC addr to match last octet of assigned IP addr in hex)
edit config.txt to add:
# Enable network-over-USB dtoverlay=dwc2
cd /media/alan/2.../etc/wpa_supplicant
sudo rm wpa_supplicant.conf (to get rid of my home FiOS ssid/key)
Switch to a Windows system with PiBakery? and uSD card access...
Open PiBakery? and edit uSD card's "On Next Boot"
- Setup WiFi? for team's router settings
- Set Hostname (to morty-pi, summer-pi, etc)
- Set Pi Zero OTG Mode to Ethernet (with IP 192.168.137.ddd, last octet matches assigned IP)
- Shutdown
... and write to uSD card
- Setup SSH over USB for the Pi Zero
- SSH to Pi with
ssh pi@raspberrypi.local
(password is raspberry) - Setup DNS
sudo nano /etc/resolv.conf
, adding the following lines:nameserver 8.8.8.8 nameserver 8.8.4.4
- Update to latest software (this will take a while):
sudo apt-get update sudo apt-get upgrade
- Install Oracle Java JDK. Do not use stock OpenJDK, its slower.
sudo apt-get install oracle-java8-jdk
- Then test, by running
java -version
. It should say java 8, not openjdk.
- Then test, by running
- Install Pi4J
mkdir -p ~/dev;cd ~/dev curl -s get.pi4j.com | sudo bash
- Install Nano text editor
sudo apt-get install nano
- Install Avahi (mDNS/zeroconf)
sudo apt-get install avahi-daemon
- Update Raspian Configuration
sudo raspi-config
- Activate the Pi Zero's built-in I2C Interface:
- Use the down arrow to select 'Advanced Options'
- Arrow down and select 'I2C'
- Select 'Yes' to enable the I2C Interface
- Acknowledge the notification confirming the I2C Interface has been enabled
- Activate the Pi Zero's built-in I2C Interface:
- Setup WiFi for a Pi Zero
- Reboot one last time, and log back in. Capture OS image for reuse by
- ???
Per Minibot config instructions (with baseline image above installed)
- Update Raspian Configuration
sudo raspi-config
- Customize host name. Reference hostname list for assigned names. Be sure not to duplicate!
- Select 'expand to use entire sd card'. This will reboot the pi.
Other Miscellaneous Things
- http://www.savagehomeautomation.com/projects/pi4j-now-supports-non-privileged-access-no-more-rootsudo.html
- restore size of a uSD card
- How to run a program at startup on the Pi Zero
- http://www.savagehomeautomation.com/projects/pi4j-connecting-java-to-the-raspberry-pi.html
- video tutorial
- Doesn't wiringpi get installed as part of Pi4j install??? If not:
- Install git:
sudo apt-get install git
- Install wiringPi:
mkdir ~/dev;cd ~/dev git clone git://git.drogon.net/wiringPi cd wiringPi ./build
- Install wiringPi
- Then, test by running "gpio -v" and "gpio readall"
- Install git: