The Fairphone 3 as a Nerves device
The phone
The Fairphone 3 and 3+ share one mainboard and run the same firmware.
| Part | Details |
|---|---|
| SoC | Qualcomm Snapdragon 632: 4× Cortex-A73-class + 4× Cortex-A53-class cores, aarch64 |
| Memory / storage | 4 GB RAM, 64 GB eMMC |
| Screen | 5.65" 1080×2160 |
| Cameras | Rear and front, swappable modules (FP3 and FP3+ use different sensors) |
| Loudspeaker | Swappable module: AW8898 (FP3) or TAS2557 (FP3+) |
| Radios | LTE modem with GNSS, NFC, Wi-Fi/Bluetooth |
| Sensors | Accelerometer, gyroscope, magnetometer, proximity (on the sensor DSP) |
At boot the kernel detects which camera and loudspeaker modules are fitted, so one image works on both models:
{out, _} = System.cmd("dmesg", [])
out |> String.split("\n") |> Enum.filter(&(&1 =~ "fp3-module-slots"))
What you can use from Nerves
| Feature | Library | Notebook |
|---|---|---|
| Wi-Fi | VintageNetWiFi |
01 |
| Notification LED, flashlight, vibrator | /sys/class/leds, rumble |
02 |
| Sensors | ExQcomSmgr |
03 |
| Battery and charging | /sys/class/power_supply |
04 |
| Cameras (stills, H.264 stream) | Fp3Camera |
05 |
| NFC tags | ExNfc |
06 |
| GPS | ExLocation |
07 |
| Modem (IMEI, network, signal) | QMI |
08 |
| Bluetooth LE | BlueHeron |
09 |
| Loudspeaker, earpiece, microphone | ExAudio, aplay, arecord |
10, 12 |
| Screen, touchscreen, buttons | Scenic, InputEvent |
11 |
| AI: Nx, object detection, speech to text, LLM chat | nerves_ai stack |
12 |
Not available yet: classic Bluetooth. The radio supports it, but this firmware drives Bluetooth with BlueHeron, which only speaks Bluetooth LE, so Bluetooth headphones, call headsets and serial adapters won't work. Wi-Fi is set up from the Wi-Fi notebook.
How it boots
The stock Fairphone bootloader only boots Android images, so the boot chain has a few extra steps:
- Stock bootloader loads lk2nd from the Android
bootpartition. It first applies the device-tree overlays found in thedtbopartition; Android's overlays don't match lk2nd, sodtbomust hold a dummy overlay. - lk2nd is a second-stage bootloader. It reads
extlinux.conffrom the Nerves boot partition and starts the Linux kernel. - An initramfs maps the Nerves partitions (they live inside Android's
userdata, see below), mounts the read-only root filesystem and hands over to it. - erlinit starts the Erlang VM, and your application.
Partitions
The Fairphone bootloader doesn't allow adding partitions, so the whole
Nerves layout is nested inside Android's userdata partition:
userdata (/dev/mmcblk0p62)
├── firmware metadata (U-Boot environment format)
├── Boot A / Boot B ext2, 100 MiB each: kernel, device tree, initramfs
├── Rootfs A / Rootfs B squashfs, 250 MiB each: the firmware, read-only
└── Application data f2fs, rest of the disk, mounted at /root (= /data)
A/B slots let mix upload write the inactive slot and switch to it.
Your data (notebooks, models) lives on the application partition and
survives firmware updates.
Three Android partitions are mounted read-only because they hold the
firmware the phone's DSPs and modem need: vendor, persist and dsp.
File.read!("/proc/mounts") |> String.split("\n") |> Enum.filter(&(&1 =~ ~r"/(root|boot|mnt)"))
First-time setup (from a stock Fairphone 3)
This wipes the phone. You need fastboot on your computer and these
three files:
lk2nd-msm8953.imgfrom the lk2nd releases- the dummy
dtbo.imgfrom z3ntu/dtbo-fp3 - the firmware image, built with
mix firmware.image(nerves_livebook_fp3.img)
Steps:
- In Android, enable Developer options → OEM unlocking.
- Power the phone off, connect USB, then hold Volume Down while powering on to enter fastboot mode.
- Run:
fastboot flashing unlock # confirm on the phone; erases it
fastboot set_active a
fastboot flash dtbo dtbo.img
fastboot flash boot lk2nd-msm8953.img
fastboot flash userdata nerves_livebook_fp3.img
fastboot reboot
The first boot grows the data partition to fill the phone's storage. The AI notebooks download their models when you first run them, so connect the phone to Wi-Fi (Wi-Fi notebook) before trying them.
After that
- Update the firmware over the network with
mix upload. - Reach the phone at
http://nerves.local:4000(Livebook) orssh nerves.local. - To reflash from scratch, hold Volume Down while powering on: once
lk2nd is installed, that opens lk2nd's fastboot mode. Wait until the
screen turns on before pressing the button. Then repeat the
fastboot flash userdatastep.