Bootstrap Raspi4 + 🐫 OCaml

Sat, 04. Apr 2020

Categories: en 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:

1$ curl -Lo 2020-02-13-raspbian-buster.txt
2$ curl -Lo
3$ curl -Lo
4$ 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:

 1cat > /media/$(whoami)/boot/wpa_supplicant.conf <<EOF
 2ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 4country=<Insert country code here>
 7 ssid="<Name of your WiFi>"
 8 psk="<Password for your WiFi>"

And enable ssh by default

1$ 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.
1$ ssh pi@raspberrypi
2$ sudo apt-get update
3$ sudo apt-get upgrade
4$ sudo apt-get dist-upgrade
5$ sudo reboot
6$ # sudo systemctl disable vncserver-virtuald.service
7$ sudo raspi-config
8$ sudo apt-get install fortunes fortunes-de fortune-anarchism vim fish mosh

🐫 OCaml

Based on

 1$ sudo apt-get install git m4 ocaml musl-tools
 3Setting up musl:armhf (1.1.21-2) ...
 4Setting up musl-dev:armhf (1.1.21-2) ...
 5Setting up musl-tools (1.1.21-2) ...
 7$ git clone
 8$ cd opam
 9# today's master 1bab95d0d006ec08db022bc89907986b63f30883 fails,
10# use a known working version:
11$ git checkout d6e4e4acb2a13e010631d9f27c638072030fd93d
12# $ git checkout 2.0.6
13$ ./configure
14$ make lib-ext
15$ make 
16$ sudo make install
17$ cd
18$ opam init
19$ opam switch --jobs=1 create 4.10.0+musl+static+flambda
20$ eval $(opam env)
21$ 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.