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

From NixOS Wiki
Jump to: navigation, search
(USB boot notes)
m (rollback unauthorized mass edits)
Tag: Rollback
 
(52 intermediate revisions by 30 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 4 Family
 
|-
 
|colspan="2"|(Image not available)
 
|-
 
!Manufacturer
 
|Raspberry Pi Foundation
 
|-
 
!Architecture
 
|AArch64
 
|-
 
!Bootloader
 
|Custom or U-Boot
 
|-
 
!Boot order
 
|Configurable; SD, USB, Netboot
 
|-
 
!Maintainer
 
|
 
|-
 
!colspan="2" class="title"|Raspberry Pi 4B
 
|-
 
!SoC
 
|BCM2711
 
|}
 
</div>
 
The Raspberry Pi family of devices is a series of single-board computers made by the Raspberry Pi Foundation. They are all based on Broadcom System-on-a-chip (SOCs).
 
  
== Status ==
+
    ⇒ '''[https://wiki.nixos.org/wiki/NixOS_on_ARM/Raspberry_Pi_4 NixOS on ARM/Raspberry Pi 4]'''
  
{{note|The Raspberry Pi 4 is currently <em>unsupported</em> though the NixOS distribution provides upstream beta-quality images.}}
+
''— samueldr, Lead of NixOS on ARM.''
 
 
The default Linux kernel in use, is the Raspberry Pi Foundation's fork. This will change for the mainline kernel once its support for the Raspberry Pi 4 Family is good enough to allow the user to boot, configure, and rebuild a system.
 
 
 
The Raspberry Pi 4 Family is only supported as '''AArch64'''. Use as armv7 is community supported.
 
 
 
== 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]].
 
 
 
Until the generic image works, a [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image_raspberrypi4.aarch64-linux temporary device-specific image is build on Hydra]. Note that this image is not using u-boot, but rather the Raspberry Pi specific bootloader configuration.
 
 
 
=== Minimal configuration ===
 
 
 
Using <code>nixos-generate-config</code> will not generate the required minimal configuration. Change the lines about booting the the following (from [https://github.com/NixOS/nixpkgs/pull/68265#issuecomment-532040372 this PR comment]) (and don't forget to set a user).
 
 
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{ pkgs, ... }:
 
 
 
{
 
  # Assuming this is installed on top of the disk image.
 
  fileSystems = {
 
    "/boot" = {
 
      device = "/dev/disk/by-label/NIXOS_BOOT";
 
      fsType = "vfat";
 
    };
 
    "/" = {
 
      device = "/dev/disk/by-label/NIXOS_SD";
 
      fsType = "ext4";
 
    };
 
  };
 
  boot.loader.grub.enable = false;
 
  boot.loader.raspberryPi.enable = true;
 
  boot.loader.raspberryPi.version = 4;
 
  # Mainline doesn't work yet
 
  boot.kernelPackages = pkgs.linuxPackages_rpi4;
 
 
 
  # ttyAMA0 is the serial console broken out to the GPIO
 
  boot.kernelParams = [
 
    "console=ttyAMA0,115200"
 
    "console=tty1"
 
  ];
 
 
 
  # Required for the Wireless firmware
 
  hardware.enableRedistributableFirmware = true;
 
}
 
</nowiki>}}
 
 
 
=== USB boot ===
 
 
 
For USB booting to work properly, firmware update might be needed:
 
 
 
{{commands|<nowiki>
 
nix-shell -p raspberrypi-eeprom
 
rpi-eeprom-update -d -a
 
</nowiki>}}
 
 
 
Now reboot the device so it can update the firmware from boot partition.
 
 
 
When running from USB device without SD card present, kernel spams log about missing SD card, workaround for this is to set:
 
 
 
{{commands|<nowiki>
 
boot.loader.raspberryPi.firmwareConfig = "dtparam=sd_poll_once=on";
 
</nowiki>}}
 
 
 
=== GPU support ===
 
 
 
The following configuration samples are built on the assumption that they are added to an already working configuration. They are not complete configurations.
 
 
 
==== Without GPU ====
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{
 
  services.xserver = {
 
    enable = true;
 
    displayManager.slim.enable = true;
 
    desktopManager.gnome3.enable = true;
 
    videoDrivers = [ "fbdev" ];
 
  };
 
}
 
</nowiki>}}
 
==== With GPU ====
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{ pkgs, ... }:
 
 
 
{
 
  hardware.opengl = {
 
    enable = true;
 
    setLdLibraryPath = true;
 
    package = pkgs.mesa_drivers;
 
  };
 
  hardware.deviceTree = {
 
    base = pkgs.device-tree_rpi;
 
    overlays = [ "${pkgs.device-tree_rpi.overlays}/vc4-fkms-v3d.dtbo" ];
 
  };
 
  services.xserver = {
 
    enable = true;
 
    displayManager.slim.enable = true;
 
    desktopManager.gnome3.enable = true;
 
    videoDrivers = [ "modesetting" ];
 
  };
 
  boot.loader.raspberryPi.firmwareConfig = ''
 
    gpu_mem=192
 
  '';
 
}
 
</nowiki>}}
 
==== Tools ====
 
 
 
The raspberry tools are available in the <code>raspberrypi-tools</code> package and include commands like <code>vcgencmd</code> to measure temperature and CPU frequency.
 
 
 
==== Audio ====
 
 
 
In addition to the usual config, you will need to enable audio support explicitly in the firmwareConfig.
 
 
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
  sound.enable = true;
 
  hardware.pulseaudio.enable = true;
 
 
 
  boot.loader.raspberryPi.firmwareConfig = ''
 
    dtparam=audio=on
 
  '';
 
</nowiki>}}
 
== Troubleshooting ==
 
 
 
=== Power issues ===
 
 
 
The Raspberry Pi 4B is as power-hungry, if not more, as its predecessors. 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 switching VT (alt+F2 / alt+F1)
 
* Random hangs
 
 
 
{{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.}}
 
 
 
Note that the Type-C USB receptacle for the Raspberry Pi 4B '''does not implement Power Delivery (USB PD)'''. This means that it is limited to whatever the power supply will provide when not negotiating power, which is most likely 5V at some undetermined power level.
 
 
 
<hr />
 

Latest revision as of 11:02, 6 April 2024

This page has been moved to the official NixOS Wiki:

    ⇒ NixOS on ARM/Raspberry Pi 4

— samueldr, Lead of NixOS on ARM.