NixOS on ARM/Raspberry Pi: Difference between revisions

imported>Bct
Device tree overlays
Tennox (talk | contribs)
Add Raspberry Pi 5 to tables (it's already described below)
 
(7 intermediate revisions by 7 users not shown)
Line 22: Line 22:
|-
|-
!colspan="2" class="title"|Raspberry Pi 4
!colspan="2" class="title"|Raspberry Pi 4
|-
!Architecture
|AArch64 + ARMv7
|-
! colspan="2" |Raspberry Pi 5
|-
|-
!Architecture
!Architecture
Line 83: Line 88:
| Raspberry Pi 4 Model B
| Raspberry Pi 4 Model B
| AArch64<br /> ''+ armv7''
| AArch64<br /> ''+ armv7''
| YES* ([https://github.com/NixOS/nixpkgs/issues/63720 GitHub issue])
| YES
|-
!colspan="3" style="text-align: left;"|Raspberry Pi 400
|-
| Raspberry Pi 400
| AArch64<br /> ''+ armv7''
| Yes (only with kernel >= 6.1)
|-
! colspan="3" |Raspberry Pi 5
|-
|Raspberry Pi 5
|AArch64<br /> ''+ armv7''
|C*
|}
|}


''Support''
''Support''
* YES: Supported architecture by Nixpkgs downstream and tested to be working.
* YES: Supported architecture by Nixpkgs downstream and tested to be working.
* YES*: Available in Nixpkgs downstream but experimental.
* C: Community supported, and tested to be working.
* C: Community supported, and tested to be working.
* C*: Community supported, unverified but should be working.
* C*: Community supported, unverified but should be working.
Line 149: Line 165:
</syntaxHighlight>
</syntaxHighlight>


=== Raspberry Pi 4B ===
=== Raspberry Pi 4 ===
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]):
''See'' [[NixOS on ARM/Raspberry Pi 4]]
 
==== Without GPU ====
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ pkgs, ... }:
 
{
  imports = [ </nowiki><nixpkgs/nixos/modules/installer/cd-dvd/sd-image-raspberrypi4.nix><nowiki> ];
 
  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, ... }:


{
=== Raspberry Pi 5===
  imports = [ </nowiki><nixpkgs/nixos/modules/installer/cd-dvd/sd-image-raspberrypi4.nix><nowiki> ];
''See'' [[NixOS on ARM/Raspberry Pi 5]]


  networking.wireless.enable = false;
== Audio ==
  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>}}
 
==== Audio ====


In addition to the usual config, it might be required to enable audio support explicitly in the firmwareConfig.
In addition to the usual config, it might be required to enable audio support explicitly in the firmwareConfig.
Line 326: Line 298:


=== Boot option 2: <code>boot.loader.raspberryPi</code> ===
=== Boot option 2: <code>boot.loader.raspberryPi</code> ===
{{warning| This option has been deprecated in https://github.com/NixOS/nixpkgs/pull/241534}}


This configuration assumes that the VFAT firmware partition is mounted to /boot. If it isn't, options like <code>boot.loader.raspberryPi.firmwareConfig</code> will write their configuration to the wrong partition and have no effect.
This configuration assumes that the VFAT firmware partition is mounted to /boot. If it isn't, options like <code>boot.loader.raspberryPi.firmwareConfig</code> will write their configuration to the wrong partition and have no effect.
Line 360: Line 334:


// ... etc.
// ... etc.
''
'';
       }
       };
     ];
     ];
   };
   };
Line 376: Line 350:
=== 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 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 unexpected behaviour may occur; this may include:


* Lightning bolt on HDMI output "breaking" the display.
* Lightning bolt on HDMI output "breaking" the display.
Line 383: Line 357:
* Random hangs
* 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  
This 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>
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>