< back to notes

Dreaming of an ARM OCaml

(last updated on Feb 2012)


I’ve been meaning to play with Plug Computers for some time now, as I need a low-power embedded system around the house. I recently bought a Soekris Net6501 (a pretty powerful Intel CPU, that even has VT support), but had annoying issues getting it working reliably. I ordered an ARM-based Dreamplug as an alternative (and as a bonus, the Dreamplug is 6x cheaper than the Soekris!). Here are my notes on getting it to work.


The Dreamplug arrived with a working installation, but running the absolutely ancient Debian Lenny. A dist-upgrade through to Wheezy led to bricking it almost immediately, and so I did a fresh installation from scratch.

For a fresh installation, place a USB stick of suitable size (greater than 2GB is best) into your functional Debian installation. Then:

    $ sudo mount /dev/sdb1 /mnt
    $ sudo cp uImage /mnt
    $ sudo umount /mnt

OCaml on ARM

One of the reasons I wanted an ARM-based setup is to experiment with the OCaml native code generation. Benedikt Meurer has been doing some excellent work on improving code generation for embedded systems, including support for 16-bit Thumb code, exception backtraces, and dynamic linking and profiling.

Once Linux was up and running, compiling up the latest ocaml-trunk was straightforward.

    $ sudo apt-get install build-essential git
    $ git clone http://github.com/OCamlPro/ocp-ocaml svn-trunk
    $ cd ocp-ocaml
    $ ./configure && make world opt opt.opt install

This compiles the bytecode and native code compilers, and then compiles them again using the native code generator. This takes a while to do on the poor little ARM CPU. Once that finished, I compiled up a few simple modules and they worked great! Since the trunk of OCaml is a development branch, you may run into a few packaging issues (use the very latest OASIS to regenerate any setup.ml, and you will need a small patch until PR 5503 is applied).

Incidentally, if anyone is interested in working on a Mirage port to ARM as an internship in the Cambridge Computer Lab, do get in touch with me…