mirror of
https://github.com/NixOS/nixos-hardware.git
synced 2026-11-30 13:03:30 +01:00
raspberry-pi/1: Add Raspberry Pi 1 support
The Raspberry Pi SD installer remains in nixpkgs, but its
sd-image-raspberrypi.nix configuration still selects
linuxKernel.packages.linux_rpi1. Commit b1c58b82b98f ("linux-rpi*: remove")
removed that kernel from nixpkgs, leaving the installer unable to
evaluate. Move the Pi 1 image configuration to nixos-hardware alongside
the vendor kernel.
The shared vendor kernel builder accepts rpiVersion = 1, but there is no
corresponding board profile. Add an ARMv6 profile with 32-bit U-Boot and
the shared firmware installer. Use the legacy boot and initrd settings
without the graphics defaults for newer boards. Provide SD-image and
installer modules adapted from the nixpkgs image, and exclude the
profile from checks without ARMv6 coverage.
The image has been cross-compiled but has not been tested on a board, as
no Pi 1 hardware was available.
Link: https://github.com/NixOS/nixpkgs/blob/b1c58b82b98ff287751c78ee2b96dc5c4384e3b3/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix#L20
Link: https://github.com/NixOS/nixpkgs/commit/b1c58b82b98ff287751c78ee2b96dc5c4384e3b3
Signed-off-by: Cryolitia PukNgae <cryolitia@mercallure.com>
This commit is contained in:
1 parent
9d17af9966
commit
11cefffd51
7 files changed
+95
-5
No files matched your search
@@ -459,6 +459,7 @@ See code for all available configurations.
|
||||
| [Radxa ROCK Pi 4](radxa/rock-pi-4) | `<nixos-hardware/radxa/rock-pi-4>` | `rock-pi-4` |
|
||||
| [Radxa ROCK Pi E](radxa/rock-pi-e) | `<nixos-hardware/radxa/rock-pi-e>` | `rock-pi-e` |
|
||||
| [Razer Blade 14 (RZ09-0530)](razer/blade/14/RZ09-0530) | `<nixos-hardware/razer/blade/14/RZ09-0530>` | `razer-blade-14-RZ09-0530` |
|
||||
| [Raspberry Pi 1](raspberry-pi/1) | `<nixos-hardware/raspberry-pi/1>` | `raspberry-pi-1` |
|
||||
| [Raspberry Pi 2](raspberry-pi/2) | `<nixos-hardware/raspberry-pi/2>` | `raspberry-pi-2` |
|
||||
| [Raspberry Pi 3](raspberry-pi/3) | `<nixos-hardware/raspberry-pi/3>` | `raspberry-pi-3` |
|
||||
| [Raspberry Pi 4](raspberry-pi/4) | `<nixos-hardware/raspberry-pi/4>` | `raspberry-pi-4` |
|
||||
|
||||
@@ -418,6 +418,7 @@
|
||||
purism-librem-15v3 = import ./purism/librem/15v3;
|
||||
purism-librem-5r4 = import ./purism/librem/5r4;
|
||||
razer-blade-14-RZ09-0530 = import ./razer/blade/14/RZ09-0530;
|
||||
raspberry-pi-1 = import ./raspberry-pi/1;
|
||||
raspberry-pi-2 = import ./raspberry-pi/2;
|
||||
raspberry-pi-3 = import ./raspberry-pi/3;
|
||||
raspberry-pi-4 = import ./raspberry-pi/4;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Preserve the legacy ARMv6 boot configuration rather than opting into the
|
||||
# graphics and camera defaults used by the newer Raspberry Pi profiles.
|
||||
imports = [
|
||||
../common/config-txt.nix
|
||||
../common/firmware.nix
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "armv6l-linux";
|
||||
|
||||
boot = {
|
||||
consoleLogLevel = lib.mkDefault 7;
|
||||
kernelPackages = lib.mkDefault (
|
||||
pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 1; })
|
||||
);
|
||||
# The vendor defconfig does not provide the generic PCI storage drivers.
|
||||
initrd = {
|
||||
includeDefaultModules = lib.mkDefault false;
|
||||
systemd.tpm2.enable = lib.mkDefault false;
|
||||
availableKernelModules = {
|
||||
mmc_block = true;
|
||||
usb_storage = true;
|
||||
usbhid = true;
|
||||
# EFI variable access is not needed for the U-Boot boot path.
|
||||
efivarfs = lib.mkForce false;
|
||||
};
|
||||
};
|
||||
loader = {
|
||||
grub.enable = lib.mkDefault false;
|
||||
generic-extlinux-compatible.enable = lib.mkDefault true;
|
||||
};
|
||||
};
|
||||
|
||||
hardware.raspberry-pi = {
|
||||
configtxt.settings.all = {
|
||||
enable_uart = lib.mkDefault true;
|
||||
avoid_warnings = lib.mkDefault 1;
|
||||
};
|
||||
firmware.uboot = {
|
||||
enable = lib.mkDefault true;
|
||||
package = lib.mkDefault pkgs.ubootRaspberryPi;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
"${modulesPath}/profiles/installation-device.nix"
|
||||
./sd-image.nix
|
||||
];
|
||||
|
||||
# The installation media is also the installation target.
|
||||
installer.cloneConfig = false;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
# Adapted from nixpkgs' installer/sd-card/sd-image-raspberrypi.nix.
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
# The generic installer utilities include EFI tools broken on 32-bit ARM.
|
||||
"${modulesPath}/profiles/minimal.nix"
|
||||
"${modulesPath}/installer/sd-card/sd-image.nix"
|
||||
./default.nix
|
||||
];
|
||||
|
||||
# This image targets the Pi 1, whose vendor kernel lacks generic PCI drivers.
|
||||
hardware.enableAllHardware = lib.mkForce false;
|
||||
|
||||
sdImage = {
|
||||
# The shared firmware installer also copies the device-tree overlays.
|
||||
firmwareSize = lib.mkDefault 128;
|
||||
populateRootCommands = ''
|
||||
mkdir -p ./files/boot
|
||||
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -5,8 +5,9 @@ NixOS profiles and modules for Raspberry Pi boards.
|
||||
## What's here
|
||||
|
||||
- `common/` has the shared bits: the `linux-rpi` kernel build (vendor defconfig, matching firmware), the `config.txt` generation module, a pinned wireless firmware, and the firmware-partition install module.
|
||||
- `2/`, `3/`, `4/`, `5/` are the board profiles. Each one picks the right kernel and kernel params. Pi 4 and 5 also set DT filters and the initrd modules they need.
|
||||
- `1/`, `2/`, `3/`, `4/`, `5/` are the board profiles. They select vendor kernels and configure board-specific boot and hardware settings. Pi 4 and 5 also set DT filters and the initrd modules they need.
|
||||
- The extra files under `4/` are opt-in toggles for Pi 4 hardware: audio, GPIO, I2C, LEDs, touchscreens, and so on.
|
||||
- Where provided, `sd-image.nix` and `sd-image-installer.nix` combine a board profile with nixpkgs' SD-image builder, optionally adding the NixOS installation environment.
|
||||
|
||||
## Using a board profile
|
||||
|
||||
@@ -24,7 +25,7 @@ These profiles assume the `generic-extlinux-compatible` bootloader (the NixOS mo
|
||||
|
||||
`hardware.raspberry-pi.firmware` stages the files the Pi firmware needs before Linux starts onto the firmware partition (default `/boot/firmware`): GPU boot code (`bootcode.bin`, `start*.elf`, `fixup*.dat`), vendor device trees and overlays, the rendered `config.txt`, and optionally U-Boot. It is not a new boot method; it just supplies the files the existing `generic-extlinux-compatible` + U-Boot path needs.
|
||||
|
||||
When you build an SD image, the module sets `sdImage.populateFirmwareCommands` itself, so the firmware partition is populated at build time with no extra configuration.
|
||||
When you build an SD image, the module sets `sdImage.populateFirmwareCommands` itself, so the firmware partition is populated at build time with no extra configuration. For cross-compilation, set `nixpkgs.buildPlatform` to the build machine's architecture and `nixpkgs.hostPlatform` to the target board's architecture, unless the profile already selects it.
|
||||
|
||||
For a running system, set `hardware.raspberry-pi.firmware.enable = true`. An activation script then repopulates the firmware partition on every `nixos-rebuild switch`. It is off by default.
|
||||
|
||||
@@ -39,11 +40,11 @@ To chainload U-Boot from the firmware, enable `uboot.enable`. It copies `u-boot.
|
||||
}
|
||||
```
|
||||
|
||||
`uboot.enable` defaults `uboot.package` to nixpkgs' `pkgs.ubootRaspberryPiAarch64`, built from the upstream `rpi_arm64_defconfig`, which covers every 64-bit board (Pi 3/4/5). For a 32-bit board, override `uboot.package` with the matching U-Boot build. On the Pi 5 this boots from SD, but U-Boot can't drive USB/PCIe/RP1 yet, so USB boot, NVMe boot, and a USB keyboard at the U-Boot prompt don't work until Linux takes over.
|
||||
The shared firmware module defaults `uboot.package` to `pkgs.ubootRaspberryPiAarch64`, built from `rpi_arm64_defconfig` for 64-bit Pi 3/4/5 systems. Board profiles can override this default. For 32-bit systems, use the package matching the board: `pkgs.ubootRaspberryPi` for Pi 1, `pkgs.ubootRaspberryPi2` for Pi 2, or `pkgs.ubootRaspberryPi3_32bit` for Pi 3. On the Pi 5 this boots from SD, but U-Boot can't drive USB/PCIe/RP1 yet, so USB boot, NVMe boot, and a USB keyboard at the U-Boot prompt don't work until Linux takes over.
|
||||
|
||||
## `config.txt`
|
||||
|
||||
Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.txt` from Nix options. The defaults track the Raspberry Pi OS pi-gen image: camera and display autodetect, KMS, audio on, `arm_boost`.
|
||||
Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.txt` from Nix options. The Pi 2–5 profiles also import `common/config-txt-defaults.nix`, which tracks the Raspberry Pi OS pi-gen image: camera and display autodetect, KMS, audio on, `arm_boost`.
|
||||
|
||||
```nix
|
||||
{
|
||||
@@ -174,4 +175,4 @@ To supply your own file, set `configtxt.file`. The module then ignores `settings
|
||||
|
||||
- No bootloader module: There's no `boot.loader.raspberry-pi` here. Boards rely on `generic-extlinux-compatible` plus U-Boot. Raspberry Pi OS has the GPU firmware load the kernel directly; we go through U-Boot so it reads `extlinux.conf`, which is what gives you the NixOS boot-generation menu and rollbacks. The firmware install module just stages the boot code and (optionally) U-Boot; it doesn't add a firmware-level direct-boot path. Pi 5 boots from SD via U-Boot, but USB, PCIe, and the RP1 don't come up until Linux takes over, so a USB keyboard at the U-Boot prompt won't work on Pi 5 today.
|
||||
- Single pinned kernel: `common/kernel.nix` pins one `linux-rpi` version rather than matching each kernel to its firmware release.
|
||||
- No Pi 0/02/1 board profiles: `common/kernel.nix` accepts `rpiVersion = 1`, but there's no `0/`, `02/`, or `1/` directory wiring that kernel up into a profile you can import via `<nixos-hardware/raspberry-pi/...>`.
|
||||
- No Pi Zero or Zero 2 board profiles.
|
||||
@@ -9,6 +9,8 @@ let
|
||||
blackList = [
|
||||
# does import-from-derivation
|
||||
"toshiba-swanky"
|
||||
# ARMv6 is not covered by the test platforms
|
||||
"raspberry-pi-1"
|
||||
# uses custom nixpkgs config
|
||||
"raspberry-pi-2"
|
||||
# deprecated profiles
|
||||
|
||||
Reference in new issue
Block a user