Intel Galileo setup - GirlsOfSteelRobotics/GRIPonGalileo GitHub Wiki

Intel Galileo setup

To prepare an Intel Galileo for use with this project, follow the steps below to prepare a microSD card to be the "hard disk" for the system. This is a one-time process that starts with a new Galileo and empty (or re-usable) microSD card and ends with an environment that is ready for the GRIPonGalileo software.

Create a Galileo boot image

Intel provides directions for setting up a microSD card for the Galileo. Pages are available for Mac OS X, Windows, or Linux users. On the Mac, the documentation has a few unnecessary steps so a much shorter summary is provided below that you can use instead of the full directions. Choose one of the options below.

Option A: Full directions

Only complete this first step, "Make a bootable microSD card"

Option B: Quick directions (Mac only)

  • Download the Latest Yocto Poky Image from: https://software.intel.com/galileo-image/latest
    • The steps below assume this file is called iot-devkit-prof-dev-image-galileo-20160606.zip
    • Adjust the name if the latest file has a newer date or different filename format
  • Insert a microSD card into an adapter and insert it into the SD card slot of your Mac
    • You can also use a USB card reader if you prefer
  • From the Utilities folder in your Applications folder, open Terminal and issue these commands:
    • cd ~/Downloads
    • unzip iot-devkit-prof-dev-image-galileo-20160606.zip
    • diskutil list
      • Find the "/dev/diskNUMBER" entry that corresponds to the microSD card
      • You will replace NUMBER in the steps below with your microSD card number (ex: disk4, disk5, etc.)
      • Do NOT get this wrong or you will overwrite the data on your Mac!
    • diskutil unmountDisk /dev/diskNUMBER
      • If this fails, make sure you entered the correct disk number
    • dd bs=8m if=iot-devkit-prof-dev-image-galileo-20160606.direct of=/dev/diskNUMBER
      • This prompts for your password and takes around 5 minutes to complete
      • When finished, you will get a dialog about an unrecognized disk; click "Ignore"
    • diskutil eject /dev/diskNUMBER

Boot the Galileo

The instructions from Intel get very complicated past the first step, but the good news is the rest can be skipped. In particular, there is no need to attach a FTDI serial cable in order to establish an initial connection. The boot image is configured to allow incoming SSH connections right out of the box, so we'll use that instead.

  • Plug an Ethernet cable into the Galileo
  • Plug the other end into either a router shared with your computer or directly to your computer
    • If you attach the Galileo to a home router, it will have outgoing access to the Internet for setting the time, etc.
  • Log in as the root user using an SSH connection to galileo.local
    • On the Mac, enter this command in a Terminal window: ssh [email protected]
    • On Windows, install Putty or the equivalent to log in
    • If it fails to connect, be sure to quit out of any VPN software
  • About SSH server keys
    • During your first connection, you'll need to accept the "fingerprint" of the SSH server key that identifies the Galileo
    • If you have multiple Galileo units, each will have a different fingerprint but will share the name galileo.local. Switching back and forth will raise a rather dire security warning, but is expected in this case. On some platforms, you may need to remove the old key with ssh-keygen -R galileo.local before connecting to a different Galileo unit.
  • You are NOT prompted for a password, so the first step is to create a secure password for the root account:
    • passwd root
  • Optionally, set your local timezone
    • rm /etc/localtime
    • ln -s ../usr/share/zoneinfo/America/New_York /etc/localtime
    • echo America/New_York > /etc/timezone
    • (If you're not in the US-Eastern timezone, find your timezone with ls /usr/share/zoneinfo* and replace the America/New_York part of the commands)
  • If necessary, set the date and time
    • date 021816302017 sets the date to 18-Feb-2017 4:30 PM local time
      • The format is somewhat unexpected: [MMDDhhmm[[CC]YY]; see date --help for details

Install the mjpg_streamer command

The mjpg_streamer utility will turn your Galileo into an IP camera, capturing video from a USB webcam and publishing it as an MJPEG stream on the network. MJPEG is the same format as supported by the Axis cameras recommended by FIRST, so GRIP works well with it. This utility will be very useful during initial configuration and troubleshooting.

  • Download the pre-compiled version from SourceForge
  • Copy the file to the Galileo
    • On the Mac, open a new Terminal window and issue the command scp Downloads/mjpg-streamer_r94-1_i386.deb [email protected]:
    • On Windows, use Putty or the "PSCP" command
  • Back in the Galileo root session you started in the last section, install the utility
    • opkg install --force-depends --add-arch i386:30 ./mjpg-streamer_r94-1_i386.deb
    • Notice there there is a warning about a dependency on some version of libjpeg (libjpeg62 in my case)
    • Find the latest version of libjpeg that you have installed with ls -l /usr/lib/libjpeg.so*
    • Create a symbolic link from what you have installed to the version needed by mjpg-stream with ln -s /usr/lib/libjpeg.so.8.0.2 /usr/lib/libjpeg.so.62

Create and test startup script for mjpg_streamer

The mjpg_streamer utility is very flexible. As a result, it requires a long command line to start it. Let's create a convenience script so we don't have to enter all the details each time.

  • In the Galileo root session, run these commands to create the script in the home directory
    • echo '#!/bin/sh' > ~/start_mjpg_streamer.sh
    • echo 'mjpg_streamer -i "input_uvc.so -r 320x240" -o "output_http.so -p 1811 -w /usr/www"' >> ~/start_mjpg_streamer.sh
    • chmod +x ~/start_mjpg_streamer.sh
  • Test it out by running the script
    • ~/start_mjpg_streamer.sh
  • Back on your computer, access the stream with a browser (any will do)
    • http://galileo.local:1811/stream.html
    • If you stop and restart mjpg_streamer, you'll need to reload the page in your browser
  • GRIP will require just the MJPEG stream without the menu interface around it, so confirm it's available at:
    • http://galileo.local:1811/?action=stream
  • After viewing the stream, go to the Galileo session and press Control-C to stop the stream, returning to the shell prompt

Compile and install the Network Tables library

Network Tables is a system developed by WPI for communication between the RoboRIO and the FRC drivers station. It can also be used on secondary computers such as the Intel Galileo to provide data to the RoboRIO. The Network Tables library, named libntcore.so, needs to be compiled from source code on the Galileo. While running the GRIP vision pipeline, the Network Tables library will be used to send results to the RoboRIO.

  • On your computer
  • From the root session on the Galileo
    • unzip ntcore-master.zip to unpack the ZIP archive
    • cd ntcore-master to change to the newly created directory
    • cmake -DWITHOUT_JAVA:BOOL=ON -DWITHOUT_TESTS:BOOL=ON . to create Makefiles customized for the Galileo
    • make to compile the source code into a shared library
      • This takes around 30 minutes but you can see the progress as each file is compiled
    • make install to install the results into the conventional Linux locations
      • The header files named *.h go into /usr/local/include and are needed when compiling the GRIP program
      • The shared library libntcore.so.* goes into /usr/local/lib for use whenever the GRIP program is running
    • echo '/usr/local/lib' >> /etc/ld.so.conf to tell Linux about the additional place to look for libraries
    • ldconfig -v to update the list of available shared libraries

Next Step: Compiling and installing GRIPonGalileo