GOAL: A master PiBot image that is pre-configured for ease of setup. The image should be as small as possible for storage and distribution. The image should be easily installed onto an 8GB or larger uSD card.


  • Windows 10 PC with SD card reader
  • Sandisk or Patriot microSDHC UHS-I Card 8GB (any class 10 8GB or 16GB card should do). Note that not all uSD cards work with Raspberry Pis, especially some of the inexpensive no-name cards.
  • Software to write disk images to SD card: Win32 Disk Imager or Etcher or cygwin dd
  • Software to manage/wipe/remove all partitions from a used SD card such as
    • SD Formatter or just use windows partition manager (Win-R diskmgmt.msc))
  • Useful if you like linux: Cygwin with dd and openssh packages installed (I use the 64-bit version)
  • Raspbian OS ( - use the Lite version
  • Apple Bonjour print services for windows
  • A good editor such as Notepad++
  • A good VNC viewer such as RealVNC


  • Install PC software (sd formatter, disk imager, cygwin, bonjour)
  • Prepare SD card:
    • Download the latest Raspbian Lite image
    • Unzip to extract the .img file
    • Use Etcher to install the .img on an SD card (see: here for more info). This creates two partitions: /boot that is accessible from Windows and /root that is ext4 and cannot (easily) be accessed from Windows.
    • Remove and re-insert SD card so Windows will re-mount the new partitions...ignore/cancel any requests to format them
    • Edit /boot/config.txt (preferably edit with Notepad++)
      • uncomment framebuffer_width=1280
      • uncomment framebuffer_height=720
      • uncomment dtparam=i2c_arm=on
      • For Pi Zero only, add the following at the end to enable USB networking (not supported on other Pi platforms):
        # Enable USB Gadget (networking over USB)
        # Limit GPU memory usage
    • Edit /boot/cmdline.txt
      • For Pi Zero only, insert after rootwait: modules-load=dwc2,g_ether g_ether.dev_addr=5a:77:1e:af:8e:9e g_ether.host_addr=72:8d:1f:c4:e8:ca
      • For all platforms: Remove init=resizefs... (to prevent automatic expansion to full SD card size) (Note: cmdline.txt must be a single linebreaks)
    • Create an empty file: /boot/ssh (enables ssh server when started)
    • Create an empty file: /boot/avahi (enables zeroconfig/bonjour when started)
    • For Pis with built-in WiFi (Pi 3, Pi Zero W): create /boot/wpa_supplicant.conf with your wifi network configuration information (allows Pi to connect to your WiFi network on boot)
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
          ssid="My WiFi 2.4"
      NOTE: remember to remove your wifi info (especially PSK) before creating the golden image
  • Boot and configure SD card in Pi
    • Place uSD card in Pi
    • For Pi Zero, connect a micro-USB cable to the OTG port (the middle one, not the one on the end)
    • Wait for the Pi to finish booting (LED stops blinking)
    • Provide internet access for the Pi using one of the following methods:
      • For Pi Zero with USB networking:
        • Share your main network connection (Ethernet or WiFi with the USB NDIS/Ethernet connection). See here
          • double-click This PC
          • right-click Network and select Properties
          • click Change adapter settings
          • right-click Ethernet or WiFi (your main network connection) and select properties
          • select Sharing tab
          • check Allow other network users to connect through this connection
          • For the Home networking connection select your USB/NDIS connection (e.g. Ethernet 2)
          • click OK
        • Alternatively (but not recommended) Bridge your main connection on the windows 10 machine (Ethernet or WiFi) to the NDIS Ethernet connection for the PiBot USB OTG network (select both connections in the Network Connections then right-click and choose Bridge Connections); configure the DNS server as
      • For Pis without USB or WiFi?, connect a USB Ethernet dongle to the Pi OTG connector
    • ssh to raspberrypi.local using putty or cygwin ssh or ...
    • login as user 'pi' with password 'raspberry'
    • update the OS
      • sudo apt update
      • sudo apt upgrade
    • Fix the way Raspbian references disk partitions (see info here). If you don't do this and leave references using UUIDs, when you resize the root partition, raspbian will change the UUID and you won't be able to boot:
      • sudo fdisk -l (list partitions)
      • sudo vi /etc/fstab
        • Change the references to the /boot and / (root) partitions to use the /dev/mmclk0pX notation; after changes it should look like this:
          proc            /proc           proc    defaults          0       0
          /dev/mmcblk0p1  /boot           vfat    defaults          0       2
          /dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
      • sudo vi /boot/cmdline.txt to use the matching notation for the root partition:
        • Change the root assignment to use the /dev/mmcblk0pX notation:
    • Expand the root partition:
      • sudo parted
      • print (observe the size of the second (ext4) partition)
      • resizepart 2 4096(extend partition to 4GB)
      • quit
      • sync (ensure all buffers are flushed to disk)
      • sudo reboot (reboot to ensure larger partition is used)
      • Wait and then re-connect via SSH
    • Expand the root file-system to use the larger partition:
      • sudo resize2fs /dev/mmcblk0p2
      • sudo reboot
      • wait and then re-connect to the Pi via SSH
    • Set the locale (see here for info):
      • sudo dpkg-reconfigure locales
      • un-select: en_GB.UTF-8
      • select: en_US.UTF-8
      • make sure to select en_US.UTF-8 as the default locale for the system environment
      • wait for generation to finish
      • exit (this is important; the change doesn't take effect before you log in again)
      • re-connect via SSH
      • sudo dpkg-reconfigure keyboard-configuration (reconfigures based on new locale)
      • sudo dpkg-reconfigure tzdata (select US->Eastern)
    • sudo raspi-config
      • Setup Network Options: hostname->pibot
      • If you haven't done this via the step above, setup localisation settings for US, English, EST
      • Setup interfacing options: enable ssh, vnc, i2c (note, VNC will install a ton of other stuff)
    • If you want a GUI desktop, install the PIXEL desktop (recommended); then you can use VNC to access the graphical desktop over USB/WiFi/Ethernet.
      • sudo apt-get install rapsberrypi-ui-mods
      • see here for more info
    • Install any needed packages
      • sudo apt-get install subversion ant mercurial git
      • curl -s | sudo bash
    • Install some nice-to-have packages (although chrome is really too slow on a pi zero)
      • sudo apt-get install chromium-browser
    • Configure for use as WiFi? client and access-point (see here) WORK IN PROGRESS
      • sudo apt-get install hostapd dnsmasq
  • Install latest Oracle Java JDK (this example uses 8u171)
    • wget --header "Cookie: oraclelicense=accept-securebackup-cookie" (you can change the URL to the latest JDK link for ARM-32-hard-float-ABI found here)
    • sudo tar zxvf jdk-8u171-linux-arm32-vfp-hflt.tar.gz -C /opt (installs Java to /opt)
    • sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_171/bin/javac 1
    • sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_171/bin/java 1
    • sudo update-alternatives --config javac
    • sudo update-alternatives --config java (select the version you just installed)
    • java -version
    • javac -version
  • Install Oracle DIO (see here for info)
    • hg clone
    • export PI_TOOLS=/usr (path where you want tools installed)
    • export JAVA_HOME=/opt/jdk1.8.0_171/ (path to Java compiler installation)
    • export JAVA_TARGET_HOME=/opt/jdk1.8.0_171/ (path to Java target installation)
    • export CROSS_TOOL=/usr/bin/ (path to gcc toolchain)
    • cd dev
    • make
    • cd ..
    • sudo mv ~/dev /opt/dio
    • sudo chown -R root.root /opt/dio
    • sudo cp -r /opt/dio/build/deviceio/lib/* /opt/jdk1.8.0_171/jre/lib
    • create /etc/ containing /opt/dio/build/so
    • sudo ldconfig (to refresh the library path cache)
  • Install joystick support using JInput:
    • sudo apt-get install libjinput-java libjinput-jni libjinput-java-doc jstest-gtk
    • append uinput to end of /etc/modules
    • See here for usage example
    • Use Pi->System Tools->jstest-gtk to test joystick. Also see /dev/input
  • Checkout and build the demo application from the subversion repository
       mkdir pibot
       cd pibot
       svn co
       cd trunk
       sudo ant run
  • Do WiFi Configuration using hostapd and dnsmasq (see documentation or the files mentioned below for examples).
    • Configure /etc/network/interfaces to invoke /etc/network/wlan0.conf after the wlan0 interface is up
    • Configure /etc/network/wlan0.conf
    • Install hostapd and configure /etc/hostapd/hostapd.conf to configure the Pi as an access point if none is available
    • Install dnsmasq and configure /etc/dnsmasq.conf so the Pi will serve as a DHCP server
  • Once card is configured, shutdown Pi
  • Make master image:
    • Place uSD card in PC
    • launch cygwin as adminstrator
    • cat /proc/partitions (to see which /dev/sdX device corresponds to your SD card)
    • dd bs=512 ibs=1M count=10491904 if=/dev/sdb of=pibot_x.img
      • (NOTE: 10491904 is one block past the last block of the /root partition on my setup - could be different in your setup depending on the amount of space you allocated when resizing the /root partition above.
    • check the partitions in fdisk first.
      • On the Pi:
        • sudo fdisk /dev/mmcblk0
        • p (print partition table)
        • note End block of /dev/mmcblk0p2
        • Use that block number + 1 as the count
      • Under cygwin (run cygwin as Administrator):
        • /sbin/fdisk /dev/sdb
        • is as above
Last modified 3 years ago Last modified on Jul 25, 2018, 9:49:44 AM