RPi2 with Hardware OpenGL & OpenCPN Recipe

On and off for the past few months I’ve been trying to figure out a problem with OpenGL and the Raspberry Pi 2. Quite simply I want to be able to build, from bare metal, a chartplotter system on a RPi2 that has AIS, GPS, Vector charts, and 10fps. Based on the hardware specs, it should be very possible. However, in practice, I have seen only 1-2fps.

The very good folks on cruisersforum have been hard at work trying to solve this problem, and over the past few days I resurrected this project took a stab at using the latest versions.

On a new board and SD card, the recipe below was used to create a working version of the RPi2 that meets these performance goals. With this setup, I get very usable performance with OpenGL enabled, less than 5% CPU with a satisfactorily responsive UI, USB AIS and GPS, and Vector Charts.


  1. Raspberry Pi 2
  2. 16G micro SD card
  3. Tontec 7″ HDMI screen
  4. USB keyboard and touchpad
  5. USB WiFi Dongle
  6. USB GPS Puck
  7. dAISy USB AIS receiver

Build the Pi with a Jessie Distribution and the open source OpenGL drivers

Image the most recent version of Raspian onto a class-10 sd card. I used Raspbian Jessie, with a build date of 3-18-2016.

Once booted, connect to the internet, and then in Raspi-config:

  • Expand file system to full card
  • Change user password
  • Automatically boot to desktop
  • Set overclock to high
  • Set language, keyboard, and locale appropriately.
  • Enable the experimental GL driver in Advanced Options

Reboot, and then:
sudo apt-get upgrade
sudo apt-get update
sudo rpi-update
sudo ldconfig
sudo reboot

Install required libraries

apt-get install cmake gettext gpsd gpsd-clients libgps-dev wx-common libwxgtk3.0-dev libgtk2.0-dev wx3.0-headers libbz2-dev libtinyxml-dev portaudio19-dev libcurl4-openssl-dev libcairo2-dev mesa-utils

Build OpenCPN

git clone git://github.com/OpenCPN/OpenCPN.git
cd OpenCPN

Optionally, get the tides & currents, and high-resolution shoreline data.

  • From  http://sourceforge.net/projects/opencpnplugins/files/opencpn_packaging_data/ download the latest opencpn-gshhs and opencpn-tcdata files
  • Extract their contents into data/gshhs

mkdir build
cd build
sudo make install

Download the appropriate charts:

  • For all US waters, it’s very easy to find appropriate charts at NOAA
  • I decided to try ENC vector charts this time.
  • Expand into an appropriate directory. I used /usr/local/include/Charts
  • run opencpn with the -unit_test_1 flag to ingest and process all the charts that were downloaded

Run OpenCPN and set the chart directory to wherever you’ve downloaded the NOAA charts. Exit OpenCPN and then edit .opencpn/opencpn.conf and add the following lines:


Setup USB

  • Start the gpsd service
    • sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
  • Launch OpenCPN
  • Add a connection for the gpsd service
    • Settings -> Connections -> Add Connection
      • Network
      • GPSD protocol
      • localhost address
      • 2947 port
  • To get GPSD to run on startup automatically, modify the /etc/default/gpsd file like so:

Setup AIS

  • sudo apt-get install screen
    sudo usermod -a -G dialout $USER
    screen /dev/ttyACM0
  • CTRL-A, K exists screen
  • Start OpenCPN and go to Options -> Connections | Data Connections, and Add Connection. Select a Serial message, and set the DataPort to the dAISy USB message port (generally /dev/ttyACM0). Set the Baudrate to 9600, and uncheck Control checksum. Apply and return to OpenCPN.

Finalize the Setup

  • Install VNC Server so you can easily access the device from other computers on the network
    • apt-get install tightvncserver
    • tightvncserver :1
      • enter a password twice, and optionally a view-only password
      • Then you can VNC into the device from a computer running on the attached network
  • Remove extraneous packages
    • sudo apt-get  remove --purge wolfram-engine minecraft-pi libreoffice xscreensaver
  • Disable screen blanking
    • sudo nano /etc/lightdm/lightdm.conf
      xserver-command=X -s 0 dpms