NixOS on ARM/Raspberry Pi

From NixOS Wiki
Revision as of 19:18, 17 December 2017 by imported>Samueldr (Inits child page for Raspberry Pi)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Status

Only the Raspberry Pi 3 is supported upstream, with the aarch64 effort.

Other Raspberry Pis are part of @dezgeg's porting efforts to ARMv6 and ARMv7.

Board-specific installation notes

First follow the generic installation steps to get the installer image and install using the installation and configuration steps.

Raspberry Pi (1)

The ARMv6 image boots out-of-the-box.

Raspberry Pi 2

The ARMv7 image should boot out-of-the-box, though the author hasn't personally tested this.

Raspberry Pi 3

Both the AArch64 and ARMv7 images boot out-of-the-box. Using the 64-bit AArch64 image is highly recommended, as the availability of binaries is much better and allows the use of the 64-bit instruction set.

Use the following GPIO Pins with an USB-TTL connector:

GND         - 3rd in top row, black cable
GPIO 14 TXD - 4th in top row, white cable
GPIO 15 RXD - 5th in top row, green cable

Use nix-shell -p screen --run "screen /dev/ttyUSB0 115200" to connect to the console.

Note: Right now (2017-10-08) wifi is not working out of the box on the Raspberrypi 3, you will need to use ethernet. Add the following to your configuration.nix. This requires linux kernel > 4.13.0
{
  ...
  hardware.enableRedistributableFirmware = true;
  hardware.firmware = [
    (pkgs.stdenv.mkDerivation {
     name = "broadcom-rpi3-extra";
     src = pkgs.fetchurl {
     url = "https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/54bab3d/brcm80211/brcm/brcmfmac43430-sdio.txt";
     sha256 = "19bmdd7w0xzybfassn7x4rb30l70vynnw3c80nlapna2k57xwbw7";
     };
     phases = [ "installPhase" ];
     installPhase = ''
     mkdir -p $out/lib/firmware/brcm
     cp $src $out/lib/firmware/brcm/brcmfmac43430-sdio.txt
     '';
     })
  ];
  networking.wireless.enable = true;
}

Serial console

Your configuration.nix will need to add console=ttyS0,115200n8 to the boot.kernelParams configuration to use the serial console.

/etc/nixos/configuration.nix
{ config, pkgs, lib, ... }:
{
  boot.kernelParams = [
    "console=ttyS0,115200n8"
  ];
}

Notes about the boot process

Raspberry Pi (all versions)

USB keyboards and HDMI displays work perfectly.

Using the 3.3v serial port via the pin headers (exact location depends on hardware version) will get u-boot output and, when configured, a Linux kernel console.