Difference between revisions of "NixOS on ARM/Raspberry Pi"

From NixOS Wiki
Jump to: navigation, search
m (Adapt to latest pull request changes.)
m (rollback unauthorized mass edits)
Tag: Rollback
 
(57 intermediate revisions by 25 users not shown)
Line 1: Line 1:
{{ARM/breadcrumb}}
+
This page has been moved to the official NixOS Wiki:
<div class="infobox">
 
{|class="table"
 
!colspan="2" class="title"|Raspberry Pi Family
 
|-
 
|colspan="2"|[[File:raspberry_pi_3_glamour.jpg|frameless|256px|A Raspberry Pi 3 with enclosure.]]
 
|-
 
!colspan="2" class="title"|Raspberry Pi
 
|-
 
!Architecture
 
|ARMv6
 
|-
 
!colspan="2" class="title"|Raspberry Pi 2
 
|-
 
!Architecture
 
|ARMv7
 
|-
 
!colspan="2" class="title"|Raspberry Pi 3
 
|-
 
!Architecture
 
|AArch64 + ARMv7
 
|}
 
</div>
 
<!-- TODO : write intro paragraph -->
 
== Status ==
 
  
Only the ''Raspberry Pi 3'' is supported upstream, with the aarch64 effort.
+
    ⇒ '''[https://wiki.nixos.org/wiki/NixOS_on_ARM/Raspberry_Pi NixOS on ARM/Raspberry Pi]'''
  
Other Raspberry Pis are part of '''@dezgeg''''s porting efforts to ARMv6 and ARMv7.
+
''— samueldr, Lead of NixOS on ARM.''
 
 
== Board-specific installation notes ==
 
 
 
First follow the [[NixOS_on_ARM#Installation|generic installation steps]] to get the installer image and install using the [[NixOS_on_ARM#NixOS_installation_.26_configuration|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:
 
<syntaxhighlight>
 
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
 
</syntaxhighlight>
 
Use <code>nix-shell -p screen --run "screen /dev/ttyUSB0 115200"</code> 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 }}
 
<syntaxhighlight lang=nix>
 
{
 
  ...
 
  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;
 
}
 
</syntaxhighlight>
 
 
 
== Serial console==
 
 
 
Your configuration.nix will need to add <code>console=ttyS0,115200n8</code> to the <code>boot.kernelParams</code> configuration to use the serial console.
 
 
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{ config, pkgs, lib, ... }:
 
{
 
  boot.kernelParams = [
 
    "console=ttyS0,115200n8"
 
  ];
 
}
 
</nowiki>}}
 
== Camera ==
 
 
 
For the camera to work, you will need to add the following code to your configuration.nix:
 
 
 
{{note| Two pull requests ({{pull|38490}} and {{pull|38342}}) are required to make this configuration.nix and the camera working.}}
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{ config, pkgs, lib, ... }:
 
{
 
  boot.loader.raspberryPi.enable = true;
 
  # Set the version depending on your raspberry pi.
 
  boot.loader.raspberryPi.version = 3;
 
  # We need uboot
 
  boot.loader.raspberryPi.uboot.enable = true;
 
  # These two parameters are the important ones to get the
 
  # camera working. These will be appended to /boot/configuration.txt.
 
  boot.loader.raspberryPi.firmwareConfig = ''
 
    start_x=1
 
    gpu_mem=256
 
  '';
 
}
 
</nowiki>}}
 
{{note| A reboot is required to load the new firmware configuration.}}
 
 
 
To make the camera available as v4l device under <code>/dev/video0</code> the <code>bcm2835-v4l2</code> kernel module need to be loaded. This can be done by adding the following code to your configuration.nix:
 
 
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{ config, pkgs, lib, ... }:
 
{
 
  boot.kernelModules = [ "bcm2835-v4l2" ];
 
}
 
</nowiki>}}
 
 
 
== Binary Cache ==
 
 
 
Depending on the architecture used, binary caches availability varies. Binary caches instructions are on the main [[NixOS on ARM#Binary cache|NixOS on ARM]] page. The following table desribes the architectures supported by each board.
 
 
 
{|class="wikitable"
 
|-
 
! Raspberry Pi 1
 
| armv6
 
|-
 
! Raspberry Pi 2
 
| armv7
 
|-
 
!rowspan="2" style="vertical-align: middle;"|Raspberry Pi 3
 
| armv7
 
|-
 
| aarch64
 
|}
 
 
 
== 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.
 
 
 
== Troubleshooting ==
 
 
 
=== Power issues ===
 
 
 
Especially with the power-hungry Raspberry Pi 3, it is important to have a [https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/README.md sufficient enough power supply] or ''weirdness'' may happen. Weirdness may include:
 
 
 
* Lightning bolt on HDMI output "breaking" the display.
 
* Screen switching back to u-boot text
 
** Fixable temporarily when power is sufficient by swtiching VT (alt+F2 / alt+F1)
 
* Random hangs
 
 
 
This problem is a hard problem. It is caused by the Raspberry Pi warning about power issues, but the current drivers (as of
 
Linux 4.14) have a hard time dealing with it properly. If the power supply is rated properly AND the cable is not incurring too much power losses, it may be required to disable the lightning bolt indicator so the display driver isn't messed up.<ref>https://logs.nix.samueldr.com/nixos/2017-12-20#1513784657-1513784714;</ref> The lightning bolt indicator can be disabled by adding the line <code>avoid_warnings=1</code> in config.txt<ref>https://www.raspberrypi.org/documentation/configuration/config-txt/README.md</ref>
 
 
 
{{note|A ''properly rated'' USB power supply, AND a good cable are necessary. The cable has to be short enough to not incur power losses through the length. Do note that thin and cheap cables usually have thinner copper wires, which in turn accentuates power losses.}}
 
 
 
<hr />
 

Latest revision as of 10:56, 6 April 2024

This page has been moved to the official NixOS Wiki:

    ⇒ NixOS on ARM/Raspberry Pi

— samueldr, Lead of NixOS on ARM.