== Baseline Minibot Raspbian Image Build Instructions * Plan A: [wiki:PibotGoldenImage This process] creates a 5GB image suitable for installation on any 8GB or larger USD card * Plan B: note that some of the below install steps may already be in the stock image, so don't worry about it if they're already installed) 1. Download stock [https://www.raspberrypi.org/downloads/raspbian/ Raspian Light] image 2. Follow [https://www.raspberrypi.org/documentation/installation/installing-images/README.md these directions] for installing it to a uSD card * Make sure the card is not write protected * Delete any existing partitions on the uSD card (you can use [https://www.howtogeek.com/101862/how-to-manage-partitions-on-windows-without-downloading-any-other-software/ windows disk manager] (Win-R diskmgmt.msc)) * [wiki:SetupPiZeroSSHOverUSB Setup IP over USB for the Pi Zero] * Install [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] and use it to connect to the Pi: Hostname: pibot.local[[br]] Username: pi[[br]] Password: raspberry[[br]] * Update to latest software (this will take a while): {{{ sudo apt-get update sudo apt-get upgrade }}} * Install some useful packages: {{{ sudo apt-get install i2c-tools i2cdetect -y 1 }}} * Install Oracle Java JDK. Do not use stock OpenJDK, it's slower. (TODO: try [https://www.azul.com/downloads/zulu-community/?architecture=arm-32-bit-hf&package=jdk Azul Java]) {{{ sudo apt-get install oracle-java8-jdk sudo update-alternatives --config java sudo update-alternatives --config javac }}} * Then test, by running {{{java -version}}}. It should say java 8, not openjdk. To access the I/O capabilities of the Pi (and the PiBot hat), you must install additional libraries; either Oracle's Device I/O (DIO) or Pi4J (which uses WiringPi) or both. You can read about them [https://dzone.com/refcardz/iot-applications-with-java-and-raspberry-pi here]. Tutorials are [http://www.slideshare.net/javafxpert/raspberry-pi-with-java-8 here] and [https://blogs.oracle.com/javatraining/entry/using_device_i_o_with here] * Install [http://pi4j.com/ Pi4J] {{{ mkdir -p ~/dev;cd ~/dev curl -s get.pi4j.com | sudo bash }}} * Test installation by checking version: {{{pi4j -v}}} * Install Oracle [https://gautric.github.io/blog/2016/03/09/rhiot-Device-IO-API-i2cdetect-impl.html Device I/O] (DIO) library. See usage [http://www.oracle.com/technetwork/articles/java/cruz-gpio-2295970.html here] and [http://www.oracle.com/technetwork/articles/java/cruz-gpio-2295970.html {{{ sudo apt-get install mercurial hg clone http://hg.openjdk.java.net/dio/dev jdkdio cd jdkdio export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt export PI_TOOLS=/usr make sudo cp -r build/deviceio/lib/* $JAVA_HOME/jre/lib }}} * Test Device I/O following [https://gautric.github.io/blog/2016/03/09/rhiot-Device-IO-API-i2cdetect-impl.html these directions] or [https://dzone.com/refcardz/iot-applications-with-java-and-raspberry-pi these]. Projects must be linked with build/jar/dio.jar and reference the appropriate policy files. For example, to run a program: {{{ sudo java -Djava.security.policy=./java.policy -classpath .:./dio.jar -Djdk.dio.registry=./dio.properties DioLed }}}. An example java.policy is: {{{ // grant all permissions for the DIO framework grant { permission jdk.dio.DeviceMgmtPermission "*:*", "open"; permission jdk.dio.gpio.GPIOPinPermission "*:*", "open,setdirection"; permission jdk.dio.gpio.GPIOPortPermission "*:*"; permission jdk.dio.i2cbus.I2CPermission "*:*"; permission jdk.dio.spibus.SPIPermission "*:*"; permission jdk.dio.uart.UARTPermission "*:*"; }; }}} A properties file is also required; see [https://eclipse.github.io/kura/doc/kura-dio-apis.html here] * Install [https://www.nano-editor.org/ Nano] text editor {{{sudo apt-get install nano}}} * Install [https://en.wikipedia.org/wiki/Avahi_(software) 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 * [wiki:SetupPiZeroWiFi 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! * Change the keyboard setup (under internationalization) to US English (see [https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=80127 here]) * 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] * [http://avilpage.com/2014/02/best-way-to-restore-usb-drive-back-to/ restore size of a uSD card] * [wiki:HowToRunProgramAtStartupPiZero How to run a program at startup on the Pi Zero] * http://www.savagehomeautomation.com/projects/pi4j-connecting-java-to-the-raspberry-pi.html * [https://www.youtube.com/watch?v=grItDpy3TRM video tutorial] * Doesn't wiringpi get installed as part of Pi4j install??? If not: * Install git: {{{ sudo apt-get install git }}} * Install [http://wiringpi.com/ wiringPi]: {{{ mkdir ~/dev;cd ~/dev git clone git://git.drogon.net/wiringPi cd wiringPi ./build }}} * [http://wiringpi.com/download-and-install/ Install wiringPi] * Then, test by running "gpio -v" and "gpio readall"