Saturday, 11 July 2015

Eclipse on the Raspberry Pi 2

One of the things I picked up at Dayton this year was a Raspberry Pi 2. The Pi 2 features 4 USB ports (vs. 2 in the original), a faster, quad-core processor, a gigabyte of memory, more GPIO pins, and a micro SD card slot (vs. the standard SDHC card in the original). Composite video out has been dropped.

I wanted to test the Pi 2 as a development environment for Atmel AVR microprocessors as the PI 2 can directly program them using the GPIO port without needing a USB interface. That rationale is a bit weak but on the other hand I stand a good chance of learning something new as well.

So after acquiring and installing a version of the Raspbian operating system for the device, the next order of business was to install the Eclipse integrated development environment, the same one we used for Brad's (VE3HII) project night 2 years ago. This was pretty straightforward. Being used to the command line on Linux, I chose to install from there.

After making sure both the package database and system were up-to-date (using sudo apt-get update followed by sudo apt-get upgrade installing Eclipse is done with a single command: sudo apt-get install eclipse. That was easy and Eclipse installed and ran fine. However, it was missing the C/C++ tools, so the next step was to install those with sudo apt-get install eclipse-cdt. That's where things got tough. Eclipse would now crash shortly after launch and leave a log file behind which was little help in figuring out the problem.

Fortunately, we have an Internet at our service and several sources advised replacing the default Java JDK (Java Development Kit) with the one from Oracle. Eclipse is written in Java, by the way, so it executes within the Java run-time environment. A fairly terse description of the installation procedure can be found here.

There were some gotchas that had to be worked through.
  • Oracle has moved the ARM (the processor architecture found on the Raspberry Pi) version of to another web page. The web page referenced by the description has a link to new web page so that was relatively straightforward.
  • The directory /opt/jdk1.8.0/bin/javac mentioned is actually /opt/jdk1.8.0_33/bin/javac. This might change again in the future so the best thing would be to look in /opt and use whatever you find there.
  • The sudo update-alternatives --config javac will provide a list of several options for which JDK to run. The default will be not to change anything which isn't going to help you, so choose the one that looks like the Oracle SDK. If you get it wrong don't worry just run the command again and choose something else. The same goes for the sudo update-alternatives --config java command, of course.
After doing this, Eclipse will run fine. That's where I've made it to so far. There is still a long way to go, including installation of the tools to build AVR programs. I know from what I've read that this is possible to do on the Raspberry Pi so I will be trying that out soon.

2 comments:

  1. Thanks a lot Chris! Important note: if you've run Eclipse already after switching Java to Oracle version Eclipse launches with CDT disabled. The solution was removing ~/workspace and ~/.eclipse.

    Just take care not to remove your sources ~/workspace.

    ReplyDelete
  2. Sorry for the approval delay. The interface in Blogger seems to have changed and it is isn't so prominent. Thanks for dropping by!

    Chris

    ReplyDelete