Bootstrap Raspi4 + 🐫 OCaml

Sat, 04. Apr 2020

Categories: en development Tags: Raspi OCaml Linux

Yesterday a new Raspi4 (1GB) arrived and I’d like to have the OCaml toolchain for static builds running on it. Headless for now, accessible via WIFI and ssh.

Let’s go!

Prepare SD-Card

At first have a look at, next download the OS image:

$ curl -Lo 2020-02-13-raspbian-buster.txt
$ curl -Lo
$ curl -Lo
$ shasum -c OK

Then insert a SD-Card and flash it (I use

Inject ssh + wifi settings

Mount the SD-Card on a Linux-box, follow and adjust as needed:

cat > /media/$(whoami)/boot/wpa_supplicant.conf <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


And enable ssh by default

$ touch /media/$(whoami)/boot/ssh

Power On! and log in

  1. insert the SD-Card,
  2. connect the USB-Power,
  3. plug it into an outlet.
$ ssh pi@raspberrypi
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo reboot
$ # sudo systemctl disable vncserver-virtuald.service
$ sudo raspi-config
$ sudo apt-get install fortunes fortunes-de fortune-anarchism vim fish mosh

🐫 OCaml

Based on

$ sudo apt-get install git m4 ocaml musl-tools
Setting up musl:armhf (1.1.21-2) ...
Setting up musl-dev:armhf (1.1.21-2) ...
Setting up musl-tools (1.1.21-2) ...
$ git clone
$ cd opam
# today's master 1bab95d0d006ec08db022bc89907986b63f30883 fails,
# use a known working version:
$ git checkout d6e4e4acb2a13e010631d9f27c638072030fd93d
# $ git checkout 2.0.6
$ ./configure
$ make lib-ext
$ make 
$ sudo make install
$ cd
$ opam init
$ opam switch --jobs=1 create 4.10.0+musl+static+flambda
$ eval $(opam env)
$ opam install dune


P.S.: Be aware that uname -m is armv7l which won’t run on a Raspi Zero or Raspi 1 but vice versa.