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. EQUIPMENT USED: * Windows 10 PC with SD card reader * Sandisk microSDHC UHS-I Card 8GB (any class 10 8GB or 16GB card should do) * Software to write disk images to SD card: [https://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] or [https://etcher.io/ Etcher] or [https://www.cygwin.com/ cygwin] dd * Software to manage/wipe/remove all partitions from a used SD card such as * [https://www.sdcard.org/downloads/formatter_4/ SD Formatter] or just use windows partition manager (Win-R diskmgmt.msc)) * Useful if you like linux: [https://www.cygwin.com Cygwin] with dd and openssh packages installed (I use the 64-bit version) * Raspbian OS (https://www.raspberrypi.org/downloads/raspbian/) - use the Lite version * [https://support.apple.com/downloads/bonjour_for_windows Apple Bonjour] print services for windows * A good editor such as [https://notepad-plus-plus.org/ Notepad++] PROCEDURE: * 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 [https://etcher.io/ Etcher] to install the .img on an SD card (see: https://www.raspberrypi.org/documentation/installation/installing-images/README.md). 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 discover 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 at end: {{{ # Enable USB Gadget (networking over USB) dtoverlay=dwc2 # Limit GPU memory usage gpu_mem=32 }}} * Edit /boot/cmdline.txt * 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 !PiZero only) * Remove init=resizefs... (to prevent automatic expansion to full SD card size) (Note: cmdline.txt must be a single line...no 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 !WiFi built-in: create /boot/wpa_supplicant.conf with your wifi network configuration information (allows Pi to connect to your !WiFi network on boot) {{{ country=US ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="My WiFi 2.4" psk="mypassword123" key_mgmt=WPA-PSK } }}} * 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) * Get a network connection 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 [https://answers.microsoft.com/en-us/windows/forum/windows_10-networking-winpc/internet-connection-sharing-in-windows-10/f6dcac4b-5203-4c98-8cf2-dcac86d98fb9 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 8.8.8.8 * Connect a USB Ethernet dongle to the Pi OTG connector * Configure /etc/wpa_supplicant/wpa_supplicant.conf on the Pi to include your local !WiFi network * ssh to raspberrypi.local using putty or cygwin ssh or ... * login as user 'pi' with password 'raspberry' * [http://elinux.org/RPi_Resize_Flash_Partitions Resize the root] partition: * sudo parted * print (observe the size of the second (ext4) partition) * resizepart 2 5120 (extend partition to 5GB) * quit * sudo reboot (reboot to ensure larger partition is used) * wait and then re-connect to the Pi via SSH * Update the OS on the Pi: * sudo apt-get update * sudo apt-get upgrade * [https://rohankapoor.com/2012/04/americanizing-the-raspberry-pi/ Americanize your Pi] * sudo raspi-config * Update tool to latest version * Setup localisation settings for US, English, EST * 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 * Setup interfacing options: enable ssh, vnc, i2c * Setup Network Options: hostname->pibot * Install any needed packages * sudo apt-get install subversion ant mercurial * curl -s get.pi4j.com | sudo bash * Install Oracle DIO (see https://www.raspberrypi.org/forums/viewtopic.php?f=81&t=99212) * hg clone http://hg.openjdk.java.net/dio/dev * export PI_TOOLS=/usr * export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/ * cd dev * make * cd .. * sudo mv ~/dev /opt/dio * sudo chown -R root.root /opt/dio * create /etc/ld.so.conf.d/libdio.conf containing /opt/dio/build/so * sudo ldconfig (to refresh the library path cache) * Install joystick support using [https://github.com/jinput/jinput JInput]: * sudo apt-get install libjinput-java libjinput-jni libjinput-java-doc jstest-gtk * append {{{uinput}}} to end of /etc/modules * See [https://theuzo007.wordpress.com/2013/10/26/joystick-in-java-with-jinput-v2/ here] for usage example * Use Pi->System Tools->jstest-gtk to test joystick. Also see /dev/input * 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 * 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): * fdisk /dev/sdb * ...rest is as above