Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions raspberry-pi/5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
...
}:
{
nixpkgs.overlays = [
(import ./overlay.nix)
];

boot.loader.grub.enable = lib.mkDefault false;
boot.loader.generic-extlinux-compatible.enable = lib.mkDefault true;

boot = {
kernelPackages = lib.mkDefault (
pkgs.linuxPackagesFor (
Expand Down
62 changes: 62 additions & 0 deletions raspberry-pi/5/installer.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
lib,
config,
pkgs,
...
}:

let
uboot = builtins.getAttr (config.hardware.rpiRevision) {
"rev1.0" = pkgs.ubootRaspberryPi5_rev1_0;
"rev1.1" = pkgs.ubootRaspberryPi5_rev1_1;
};

configTxt = pkgs.writeText "config.txt" ''
disable_overscan=1
enable_uart=1
kernel=u-boot-rpi5.bin
device_tree=bcm2712-rpi-5-b.dtb
'';
in
{
imports = [
<nixpkgs/nixos/modules/installer/sd-card/sd-image.nix>
<nixos-hardware/raspberry-pi/5>
];

options.hardware.rpiRevision =
with lib;
mkOption {
type = types.enum [
"rev1.0"
"rev1.1"
];
default = "rev1.0";
description = ''
Select which Raspberry Pi 5 board revision to use.
'';
};

config.sdImage = {
populateFirmwareCommands = ''
pushd ${pkgs.raspberrypifw}/share/raspberrypi/boot
# firmware blobs
cp bootcode.bin fixup*.dat start*.dat $NIX_BUILD_TOP/firmware/
# device tree blobs
cp bcm2712*.dtb $NIX_BUILD_TOP/firmware/
popd
# copy config.txt
cp ${configTxt} $NIX_BUILD_TOP/firmware/config.txt
# copy uboot (selectable)
cp ${uboot}/u-boot.bin $NIX_BUILD_TOP/firmware/u-boot-rpi5.bin
'';

populateRootCommands = ''
mkdir -p ./files/boot
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
'';
};
}
16 changes: 16 additions & 0 deletions raspberry-pi/5/overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
final: _prev: {
ubootRaspberryPi5_rev1_0 = final.buildUBoot {
defconfig = "rpi_arm64_defconfig";
extraMeta.platforms = [ "aarch64-linux" ];
filesToInstall = [ "u-boot.bin" ];
};
Comment on lines +2 to +6
Copy link
Contributor

@concatime concatime Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be upstreamed to nixpkgs after this block. It should probably be renamed to ubootRaspberryPiAarch64 like ubootQemuAarch64. WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea - it looks like doing that in nixpkgs is fine as long as we use upstream sources, which we do.

Upstreaming this in NixOS/nixpkgs#493816.


ubootRaspberryPi5_rev1_1 = final.buildUBoot {
defconfig = "rpi_arm64_defconfig";
# Mote: this patch can be removed once U-Boot starts setting
# `fdtfile=bcm2712d0-rpi-5.dtb` automatically for rev1.1 boards
patches = [ ./uboot-rpi5-bcm2712d0.patch ];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's something that I'm actually trying to fix with this series: https://lore.kernel.org/u-boot/20260216184452.18732-1-filip.kokosinski@gmail.com/.

But they are still under review & testing, so I didn't want to straight up include them here.

extraMeta.platforms = [ "aarch64-linux" ];
filesToInstall = [ "u-boot.bin" ];
};
}
13 changes: 13 additions & 0 deletions raspberry-pi/5/uboot-rpi5-bcm2712d0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index f9b643555dd..f8a8e2b51fe 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -192,7 +192,7 @@ static const struct rpi_model rpi_models_new_scheme[] = {
},
[0x17] = {
"5 Model B",
- DTB_DIR "bcm2712-rpi-5-b.dtb",
+ DTB_DIR "bcm2712d0-rpi-5-b.dtb",
true,
},
[0x18] = {