#2513 HowTo: Getting Fantom working on an ARM SBC (like the Raspberry Pi)

ttmrichter Wed 17 Feb 2016

HowTo: Getting Fantom working on an ARM SBC (like the Raspberry Pi)

So, I got myself an Orange Pi PC and decided to get Fantom working on it. (Why? WHY NOT!?) There were a few surprising hiccoughs along the way. I thought I'd document a few things to make this easier for anybody following trying to do the same thing.

Prerequisites

Obviously you need to have Java installed. You also need to have Eclipse (or some Eclipse-derived software like F4, presumably) installed from the repository of your operating system. (The reason for this will be made clear later.) Don't worry. I'm not saying you have to use Eclipse. You can uninstall it later if you like.

Installation

Just download and unzip the Fantom distribution and adjust your path. Since Fantom is distributed in a ZIP file, you'll also have to do the following:

$ chmod +x <path to installation>/bin/*
$ chmod -x <path to installation>/bin/*.exe

(It would be nicer, I think, if there was the option to use a tarball with properly-permissioned files in the first place, but this isn't a huge problem.)

At this point you've actually got a mostly-working Fantom. fan -version will tell you about your system (and you will need to know specifically what it says under fan.platform later on!). fansh will work, and any text mode Fantom programs will work just fine. (I don't use JavaScript or CLR back-ends for anything so have not had an opportunity to test these, but see no reason why they wouldn't work.)

Then you try to run flux and things break down in a big way.

Fixing Flux

The problem here is that Fantom's FWT relies on SWT but only ships SWT JAR files for linux-x86, win32-x86, and macosx-x86_64. If you use linux-x86_64 or win32-x86_64 this is not going to be news to you since you had to do this once already, but if you're using one of the three supplied targets (and could we please at least add the x86_64 flavours for Linux and Windows at some point?) this will be news.

In short you have to provide an swt.jar file for the platform. And the download link the docs point to doesn't have one for linux-arm.

This is where the Eclipse package I told you had to be installed enters the picture.

Find your Eclipse version's swt.jar (mine was located in /usr/lib/eclipse/swt.jar) and copy it to <path to fantom>/lib/java/ext/linux-arm/swt.jar (you'll have to make the linux-arm subdirectory). At this point your installation is ready and should be able to run Flux (or if you download them through fanr, even Camembert!).

Cleaning Up

Whatever your stance on Eclipse, even if you like it you'll probably find that it's not particularly well-suited to SBCs like the Raspberry Pi line, the Banana Pi line, the Orange Pi line, the Cubieboard line, etc. Eclipse is large and very disk-intensive. The *Pi boards tend to have too little memory to effectively run Eclipse and also tend to run off SD cards which are painfully slow if you're doing I/O-intensive stuff. When you've finished copying 'swt.jar' and testing your Fantom installation you'll probably want to delete your Eclipse installation to save storage space.

brian Wed 17 Feb 2016

Thanks for posting that! Pretty cool.

We run Fantom on embedded ARM systems too, with some other embedded systems in the works

ttmrichter Sun 21 Feb 2016

Is there any chance of expanding the swt.jar collections in the official release to include the x64 versions for Windows and Linux as well as the linux-arm variants, etc?

brian Mon 22 Feb 2016

Is there any chance of expanding the swt.jar collections in the official release to include the x64 versions for Windows and Linux

Actually I'm thinking more along moving them all out of the core distro and having them pulled in via fanr. But need to wire up bit more about platform specific modules first (but we are actually looking at that already for some of our embedded work)

ttmrichter Tue 23 Feb 2016

What are you calling "embedded" that can run a JVM and Fantom both? I'm looking at the biggest MCU in my pile here and it's got 512KB Flash and 64KB SRAM. I'm pretty sure that even some of the tiny, incomplete JVMs would have difficulty running by themselves on this kit, not to mention a whole other language runtime on top.

brian Wed 24 Feb 2016

What are you calling "embedded" that can run a JVM and Fantom both?

Fantom run will run on anything that can run a full JVM. In the past I would have said JVM requirements are ~32MB flash/RAM, but these days I think that is more like 128MB.

The JVM is too big for that device. But you might not be aware that Fantom has a "little sister" language named Sedona. I wrote the Sedona compiler and its associated VM for very small footprint devices in the 64KB range. The Sedona compiler is actually derived from the original Fantom Java compiler. The VM is extremely compact, about 1000 lines of C code. Check it out at http://sedonadev.org. There are a few open source programming tools for it if you google around.

Login or Signup to reply.