NixOS on ARM/Raspberry Pi: Difference between revisions

imported>Samueldr
m Begin scrubbing Pi 4 parts out
imported>Samueldr
m Finish(?) scrubbing device-specifics
Line 131: Line 131:
}
}
</nowiki>}}
</nowiki>}}
If the Raspberry Pi downstream kernel is used the serial interface is named <code>serial0</code> instead.
If the Raspberry Pi downstream kernel is used the serial interface is named <code>serial0</code> instead.


== Bluetooth ==
The bluetooth controller is by default connected to the UART device at <code>/dev/ttyAMA0</code> and needs to be enabled through <code>btattach</code>:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ pkgs, ... }:
{
  systemd.services.btattach = {
    before = [ "bluetooth.service" ];
    after = [ "dev-ttyAMA0.device" ];
    wantedBy = [ "multi-user.target" ];
    serviceConfig = {
      ExecStart = "${pkgs.bluez}/bin/btattach -B /dev/ttyAMA0 -P bcm -S 3000000";
    };
  };
}
</nowiki>}}
== Camera ==
For the camera to work, you will need to add the following code to your configuration.nix:
{{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/config.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 ==
== Binary Cache ==


Line 207: Line 158:
== Notes about the boot process ==
== Notes about the boot process ==


It takes approximately 1 minute to boot a Pi 3B.
The custom bootloader, part of the Raspberry Pi firmware, is abstracted away for NixOS by making it boot U-Boot instead.
 
U-Boot gives us the ability to provide a generation selection menu during the boot process, in addition to storing the boot files on the main partition, rather than on the firmware partition.


=== Raspberry Pi (all versions) ===
=== Raspberry Pi (all versions) ===