1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 buildLinux,
6 rpiVersion,
7 ...
8}@args:
9
10let
11 # NOTE: raspberrypifw & raspberryPiWirelessFirmware should be updated with this
12 modDirVersion = "6.12.34";
13 tag = "stable_20250702";
14 hash = "sha256-lK0esjFhLvtBbyddMfa1H7ZcBbcOm2ygor338ZT5VpI=";
15in
16lib.overrideDerivation
17 (buildLinux (
18 args
19 // {
20 version = "${modDirVersion}-${tag}";
21 inherit modDirVersion;
22 pname = "linux-rpi";
23
24 src = fetchFromGitHub {
25 owner = "raspberrypi";
26 repo = "linux";
27 inherit tag hash;
28 };
29
30 defconfig =
31 {
32 "1" = "bcmrpi_defconfig";
33 "2" = "bcm2709_defconfig";
34 "3" = if stdenv.hostPlatform.isAarch64 then "bcm2711_defconfig" else "bcm2709_defconfig";
35 "4" = "bcm2711_defconfig";
36 }
37 .${toString rpiVersion};
38
39 features = {
40 efiBootStub = false;
41 }
42 // (args.features or { });
43
44 extraMeta =
45 if (rpiVersion < 3) then
46 {
47 platforms = with lib.platforms; lib.intersectLists arm linux;
48 hydraPlatforms = [ ];
49 }
50 else
51 {
52 platforms = with lib.platforms; lib.intersectLists (arm ++ aarch64) linux;
53 hydraPlatforms = [ "aarch64-linux" ];
54 };
55 ignoreConfigErrors = true;
56 }
57 // (args.argsOverride or { })
58 ))
59 (oldAttrs: {
60 postConfigure = ''
61 # The v7 defconfig has this set to '-v7' which screws up our modDirVersion.
62 sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
63 sed -i $buildRoot/include/config/auto.conf -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
64 '';
65
66 # Make copies of the DTBs named after the upstream names so that U-Boot finds them.
67 # This is ugly as heck, but I don't know a better solution so far.
68 postFixup = ''
69 dtbDir=${if stdenv.hostPlatform.isAarch64 then "$out/dtbs/broadcom" else "$out/dtbs"}
70 rm $dtbDir/bcm283*.dtb
71 copyDTB() {
72 cp -v "$dtbDir/$1" "$dtbDir/$2"
73 }
74 ''
75 + lib.optionalString (lib.elem stdenv.hostPlatform.system [ "armv6l-linux" ]) ''
76 copyDTB bcm2708-rpi-zero-w.dtb bcm2835-rpi-zero.dtb
77 copyDTB bcm2708-rpi-zero-w.dtb bcm2835-rpi-zero-w.dtb
78 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-a.dtb
79 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b.dtb
80 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b-rev2.dtb
81 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-a-plus.dtb
82 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-b-plus.dtb
83 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-zero.dtb
84 copyDTB bcm2708-rpi-cm.dtb bcm2835-rpi-cm.dtb
85 ''
86 + lib.optionalString (lib.elem stdenv.hostPlatform.system [ "armv7l-linux" ]) ''
87 copyDTB bcm2709-rpi-2-b.dtb bcm2836-rpi-2-b.dtb
88 ''
89 +
90 lib.optionalString
91 (lib.elem stdenv.hostPlatform.system [
92 "armv7l-linux"
93 "aarch64-linux"
94 ])
95 ''
96 copyDTB bcm2710-rpi-zero-2.dtb bcm2837-rpi-zero-2.dtb
97 copyDTB bcm2710-rpi-zero-2-w.dtb bcm2837-rpi-zero-2-w.dtb
98 copyDTB bcm2710-rpi-3-b.dtb bcm2837-rpi-3-b.dtb
99 copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-a-plus.dtb
100 copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-b-plus.dtb
101 copyDTB bcm2710-rpi-cm3.dtb bcm2837-rpi-cm3.dtb
102 copyDTB bcm2711-rpi-4-b.dtb bcm2838-rpi-4-b.dtb
103 '';
104 })