Skip to content

HesselM/rpicross_notes

Repository files navigation

Guide to Cross Compilation for a Raspberry Pi

  1. > Start
  2. Setup XCS and RPi
  3. Setup RPi Network and SSH
  4. Setup RPi Peripherals
  5. Setup Cross-compile environment
  6. Cross-compile and Install Userland
  7. Cross-compile and Install OpenCV
  8. Cross-compile and Install ROS
  9. Compile and Install OpenCV
  10. Compile and Install ROS
  11. Remote ROS (RPi node and XCS master)
  12. ROS package development (RPi/XCS)
  13. Compile and Install WiringPi

1. Start

Welcome at this Cross Compilation Guide for a Raspberry Pi.

This repository started as a personal guide to keep track of how to setup a proper cross-compilation system, but grew to a public guide, where it hopefully can help many others too. It also contains toolchains and scripts to ease the cross-compilation process as well as examples and tests to verify the setup.

The system is build within a VirtualBox running an Ubuntu OS. This VirtualBox holds all tools for the cross-compilation. A VirtualBox is chosen to ensure that we cannot mess up the main machine with faulty (library) installations or accidentally changing system-critical symbolic links (which happened to me on earlier journeys).

During this guide the following systems will be configured, (cross)compiled and installed:

Additionally we setup:

  • headless VirtualBox, locally accessible via SSH.
  • headless Pi (you do not need an additional monitor or keyboard for the pi!).
  • DNS and folder sharing of the VirtualBox with the Host.
  • Wifi and SSH access on the Raspberry Pi.
  • SSH over USB to connect to the Pi when there is no WiFi.
  • Peripherals such as: i2c, RTC, IO expanders and the Pi Camera.
  • Different ROS configurations.
  • and more!

To use this guide, experience with VirtualBox, C, Python and the terminal/nano are assumed. You also need a Raspberry Pi and SDCard-reader (as we'll initially configure the Pi via the SDCard, connected to the VirtualBox).

How to Read?

The notes are in chronological order and can be followed with the table of contents on the top of the page. As both the VirtualBox and Raspberry Pi will be configured to run headless (that is, without a display) instructions are command-line styled. These instructions are prefixed with identifiers, as we use 3 different systems (Host, XCS and RPI):

  • HOST~$ commands executed on the Host. (This guide is developed on an OSX system, but probably works on Linux or Windows with MinGW or PuTTy too).
  • XCS~$ commands executed on the Cross-Compilation Server / VirtualBox. (Also called XCS)
  • RPI~$ commands executed on the Raspberry Pi. (Shortened as RPi)

In the github-repo three important folders can be found:

  • "hello" - containing examples and test files:
    • pi: to test the cross-compile setup.

      Hello World!

    • raspicam: to test the cross-compiled Userland setup.

      Snapping a picture with the PiCamera with a self-compiled version of "raspivid"

    • ocv: to test the cross-compiled OpenCV infrastructure.

      Displaying a picture via the OpenCV calls imread and imshow.

    • ros: to test the cross-compiled ROS setup.

      Running roscore and roscomm on the Pi, printing "Hello World"

    • WiringPi: to test the cross-compiled WiringPi setup.

      Blinking a Led.

  • "scripts" - containing several synchronisation tools
  • "ros" - more complex tests for more complex ROS setups.

In the main directory you can also find the toolchain which will be used throughout this guide.

If you encounter problems or see mistakes, feel free to create an issue or pull request.

Enjoy! Hessel.

PS. This guide is also available at https://hesselm.github.io/rpicross_notes/.

PPS. Special thanks to: RaymondKirk, ConnorChristie, Skammi, compyl118 for suggestions, fixes, testing and helping out.