Skip to content

Commit fc8dda4

Browse files
committed
raspberry-pi/5: add installer
This patch provides an installer for Raspberry Pi 5 boards. An option is provided to choose between rev 1.0 and rev 1.1 boards. The installer selects the U-Boot package based on that option. Signed-off-by: Filip Kokosiński <filip.kokosinski@gmail.com>
1 parent 2e9b297 commit fc8dda4

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

raspberry-pi/5/installer.nix

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
lib,
3+
config,
4+
pkgs,
5+
...
6+
}:
7+
8+
let
9+
uboot = builtins.getAttr (config.hardware.rpiRevision) {
10+
"rev1.0" = pkgs.ubootRaspberryPi5_rev1_0;
11+
"rev1.1" = pkgs.ubootRaspberryPi5_rev1_1;
12+
};
13+
14+
configTxt = pkgs.writeText "config.txt" ''
15+
disable_overscan=1
16+
enable_uart=1
17+
kernel=u-boot-rpi5.bin
18+
device_tree=bcm2712-rpi-5-b.dtb
19+
'';
20+
in
21+
{
22+
imports = [
23+
<nixpkgs/nixos/modules/installer/sd-card/sd-image.nix>
24+
<nixos-hardware/raspberry-pi/5>
25+
];
26+
27+
options.hardware.rpiRevision =
28+
with lib;
29+
mkOption {
30+
type = types.enum [
31+
"rev1.0"
32+
"rev1.1"
33+
];
34+
default = "rev1.0";
35+
description = ''
36+
Select which Raspberry Pi 5 board revision to use.
37+
'';
38+
};
39+
40+
config.sdImage = {
41+
populateFirmwareCommands = ''
42+
pushd ${pkgs.raspberrypifw}/share/raspberrypi/boot
43+
# firmware blobs
44+
cp bootcode.bin fixup*.dat start*.dat $NIX_BUILD_TOP/firmware/
45+
46+
# device tree blobs
47+
cp bcm2712*.dtb $NIX_BUILD_TOP/firmware/
48+
popd
49+
50+
# copy config.txt
51+
cp ${configTxt} $NIX_BUILD_TOP/firmware/config.txt
52+
53+
# copy uboot (selectable)
54+
cp ${uboot}/u-boot.bin $NIX_BUILD_TOP/firmware/u-boot-rpi5.bin
55+
'';
56+
57+
populateRootCommands = ''
58+
mkdir -p ./files/boot
59+
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
60+
'';
61+
};
62+
}

0 commit comments

Comments
 (0)