NixOS on ARM/Raspberry Pi: Difference between revisions

imported>Samueldr
Begin scrubbing the Pi 3 parts out
imported>Samueldr
m Begin scrubbing Pi 4 parts out
Line 116: Line 116:


=== Raspberry Pi 4B ===
=== Raspberry Pi 4B ===
Support for the Pi 4 in nixpkgs is still experimental. These configurations will boot (from [https://github.com/NixOS/nixpkgs/pull/68265#issuecomment-532040372 this PR comment]):


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.
[[NixOS_on_ARM/Raspberry_Pi_4#Board-specific_installation_notes|Raspberry Pi 4#Board-specific installation notes]]
 
The following configuration samples are built on the assumption that they are added to a configuration generated using <code>nixos-generate-config</code>.
 
==== Without GPU ====
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ pkgs, ... }:
 
{
  networking.wireless.enable = false;
  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, ... }:
 
{
  networking.wireless.enable = false;
  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>}}


== Serial console==
== Serial console==
Line 282: Line 219:
=== Power issues ===
=== 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:
Especially with the newer power-hungry Raspberry Pi families (3, 4), 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.
* Lightning bolt on HDMI output "breaking" the display.
Line 293: Line 230:


{{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|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.}}
===WiFi / WLAN===
For a possible solution to 802.11 wireless connectivity issues, see: https://github.com/NixOS/nixpkgs/issues/82462#issuecomment-604634627
===HDMI===
HDMI issues have been observed on the 18.09 AArch64 image. The display would hang on "Starting Kernel...", then act as if the HDMI cable was unplugged. Re-plugging the HDMI cable after boot fixed the issue, as did a different monitor and HDMI cable.
==== Early boot messages ====
To show boot messages from initrd with the mainline kernel, add this to <code>configuration.nix</code>.
<syntaxhighlight lang=nix>
{
  boot.initrd.kernelModules = [ "vc4" "bcm2835_dma" "i2c_bcm2835" ];
}
</syntaxhighlight>
=== Raspberry Pi 3B+ HDMI output issues ===
As of 2019/08/19, the u-boot build and kernel build can disagree about the name of the dtb file for the Raspberry Pi 3B+. This happens because the upstream filename has changed, and the built u-boot has hardcoded expectations for the filename to load.
For now, do not use <tt>linuxPackages_latest</tt>, use the default <tt>linuxPackages</tt> which is the latest LTS, 4.19, which is known to be compatible.
See {{issue|66960}}.


===Additional Troubleshooting===
===Additional Troubleshooting===