Getting the new RPI B model 2 running OpenCPN quickly

The “waste not want not” crowd would be very happy with the way that we typically operate. We do tend to purchase something and then update it indefinitely. It generally takes something major to get us to simply move on from one working version of hardware to a new one when the old one is working well. Thus, we’ve had a Raspberry Pi aboard the boat and doing great things for us for several years. When the new, improved, Raspberry Pi B model 2 came out, the best we could do was offer a link for it in David’s Grouchy Penguin store on Schooner Chandlery.

Last week I ran across a thread in one of the online sailing forums where folks were discussing the free OpenCPN navigation software and putting it on the Raspberry Pi B model 2. Since we knew our old Pi is dismally slow (and ugly) using OpenCPN, that piqued my interest a bit. Further, it seemed that no one was having success getting OpenCPN running on the new RPI2 using OpenGL (OpenGL ES 2) — and that a fellow with some success deploying OpenCPN on other platforms had managed to fry his HDMI monitor and wasn’t in the position to pick up another monitor to test the RPI2.

A quick order of the RPI2 and we found ourselves nicely engaged using up our wifi bandwidth by downloading everything (needed and then a bunch of extras to test out… 5 or 6 GB or so) and get the new Raspberry Pi B model 2 set up with Debian Jessie on this new ARMv7 device. Hours later, well, 2 days given our slow internet access, we loaded 5.5K packages onto the new RPI2, Jessie was working, we compiled OpenCPN so then OpenCPN was working and we now have a Pi that seems to have the CPU power for both web browsing and OpenCPN in addition to all the other things we have running.

We do pathologically add things to a bit of kit until we bring it to its knees and will shortly have figured out where that is with the new RPI2 and likely be writing about it here.

If you’d like to get OpenCPN up and running on a Raspberry Pi B model 2 (RPI2), first pick up a Pi at the most convenient place you can.  It should be just about $35. We have an affiliate link to a good supplier in the Schooner Chandlery store here. USB powered HDMI monitors are hard to find so we also sell a small USB powered hdmi monitor that is suitable for use with Raspberry Pi over in the Schooner Chandlery here.

Once you’ve got your Raspberry Pi B model 2 in hand and an HDMI monitor hooked up to it, you can do as we did and get your OpenCPN up and running. Note to self–the new RPI2 does not fit into my favorite old Pi case.  So–the Pi is temporarily bare and just scewed to a bulkhead until I pick up another case. Of course, you’ll need an SD card, usb mouse and keyboard.  We also use a 12V DC to 5V DC regulated power supply.

There is a good bit of resource information about running Debian OS on the Raspberry Pi here.  If you’re wanting the bare-bones info about how we got it going then:

We got the Debian Jessie install image from http://sjoerd.luon.net/posts/2015/02/debian-jessie-on-rpi2/

Even though that was just a couple days ago–please note that there is a new (201507015) image update.

We installed everything onto the Pi using an AMD64 Debian machine using bmap-tools and the bmap file in the download directory for the image above. Uncompress the img file (e.g. “gunzip jessie-rpi2-20150705.img.gz”).

sudo bmaptool copy –bmap jessie-rpi2-20150705.img.bmap jessie-rpi2-20150705.img /dev/sdX

Replace the above /dev/sdX with the device name of the SD card (e.g. after inserting SD card run “dmesg” to see assigned device name).

We installed on a 64GB micro SD card and the above install created a small FAT partition (needed for booting an RPI) and an EXT partition. The RPI 2 booted just fine with the new SD card. After booting up the RPI, we expanded the EXT partition to use the full SD card as follows (might need to install fdisk first):

sudo fdisk /dev/mmcblk0

Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w). Reboot the system, then:

sudo resize2fs /dev/mmcblk0p2

After that, we install lots of stuff that we wanted on our RPI. Everything including the kitchen sink.

For a graphical login, you will need something like the lightdm. David wanted to use startx, so he needed to install xinit along with the various xorg packages and lxde (there are quite a few lx.. packages).

Sound didn’t work until we manually loaded the correct driver:

sudo modprobe snd_bcm2835

David then added the above module to /etc/modules so that the module would load on subsequent boots.

We use a really old USB puck GPS with an old Prolific PL2303 device driver.  GPSD doesn’t automatically detect this puck so we run a UDEV script that sets the baud rate at 9600, links the puck to /dev/usbgps and starts the GPSD pointed at the linked device.  With Debian Jessie, the GPSD start fails–so we did it manually and David will have to write a systemd script shortly.

We use GPSD as our time basis because the Pi doesn’t have a hardware clock and we’re not always able to connect to the internet.  Thus, GPSD is very important to us.  For now, we use NTP to sync to the GPSD and we disable the systemd-timesyncd which seems to be new, in Jessie, too.

David compiled the current latest version of OpenCPN and made a .deb install file.  You can download it here on the StartupAnywhere site, then unzip it and install with:

sudo dpkg -i opencpn_4.1.630-1_armhf.deb

OpenCPN runs nicely on this new RPI2.  At this moment, we note that OpenCPN looks GREAT with accelerated graphics enabled (OpenGL ES 2) but really isn’t good without it.  We tested the graphics acceleration with GLXGears and saw full screen GLXGears running about 20 fps and in subwindow running 30 fps.  OpenCPN runs more slowly though, with accelerated graphics (OpenGL) click on options of “texture compression with caching” and having OpenCPN running in LX Desktop showing four windows with some other processes running, the update rate is maybe 3-4 fps –slow for a video but seemingly fast enough for the four windows I’m watching (Xtide, Htop, and also SSH running our QT application on x-forwarding from another external cpu (the old Pi), and OpenCPN.)  In this unscientific test, the 4 CPU are roughly equally loaded and on average the total load is less than one CPU.

Other nicety — we were able to run an Ethernet cable from the old pi to the RPI2 w/o a hub or crossover cable so we’re running a couple things on the old Pi (e.g. the anchor watch program that we know the old Pi does flawlessly with a buzzer/alarm hooked up to the GPIO port and I want to sleep well tonight at anchor) and viewing on the new RPI2.

Leave a Reply