at 24.11-pre 98 lines 4.0 kB view raw
1{ stdenv, lib, buildPackages, fetchFromGitHub, fetchpatch, perl, buildLinux, rpiVersion, ... } @ args: 2 3let 4 # NOTE: raspberrypifw & raspberryPiWirelessFirmware should be updated with this 5 modDirVersion = "6.1.63"; 6 tag = "stable_20231123"; 7in 8lib.overrideDerivation (buildLinux (args // { 9 version = "${modDirVersion}-${tag}"; 10 inherit modDirVersion; 11 12 src = fetchFromGitHub { 13 owner = "raspberrypi"; 14 repo = "linux"; 15 rev = tag; 16 hash = "sha256-4Rc57y70LmRFwDnOD4rHoHGmfxD9zYEAwYm9Wvyb3no="; 17 }; 18 19 defconfig = { 20 "1" = "bcmrpi_defconfig"; 21 "2" = "bcm2709_defconfig"; 22 "3" = if stdenv.hostPlatform.isAarch64 then "bcmrpi3_defconfig" else "bcm2709_defconfig"; 23 "4" = "bcm2711_defconfig"; 24 }.${toString rpiVersion}; 25 26 features = { 27 efiBootStub = false; 28 } // (args.features or {}); 29 30 kernelPatches = (args.kernelPatches or []) ++ [ 31 # Fix "WARNING: unmet direct dependencies detected for MFD_RP1", and 32 # subsequent build failure. 33 # https://github.com/NixOS/nixpkgs/pull/268280#issuecomment-1911839809 34 # https://github.com/raspberrypi/linux/pull/5900 35 { 36 name = "drm-rp1-depends-on-instead-of-select-MFD_RP1.patch"; 37 patch = fetchpatch { 38 url = "https://github.com/peat-psuwit/rpi-linux/commit/6de0bb51929cd3ad4fa27b2a421a2af12e6468f5.patch"; 39 hash = "sha256-9pHcbgWTiztu48SBaLPVroUnxnXMKeCGt5vEo9V8WGw="; 40 }; 41 } 42 43 # Fix `ERROR: modpost: missing MODULE_LICENSE() in <...>/bcm2712-iommu.o` 44 # by preventing such code from being built as module. 45 # https://github.com/NixOS/nixpkgs/pull/284035#issuecomment-1913015802 46 # https://github.com/raspberrypi/linux/pull/5910 47 { 48 name = "iommu-bcm2712-don-t-allow-building-as-module.patch"; 49 patch = fetchpatch { 50 url = "https://github.com/peat-psuwit/rpi-linux/commit/693a5e69bddbcbe1d1b796ebc7581c3597685b1b.patch"; 51 hash = "sha256-8BYYQDM5By8cTk48ASYKJhGVQnZBIK4PXtV70UtfS+A="; 52 }; 53 } 54 ]; 55 56 extraMeta = if (rpiVersion < 3) then { 57 platforms = with lib.platforms; arm; 58 hydraPlatforms = []; 59 } else { 60 platforms = with lib.platforms; arm ++ aarch64; 61 hydraPlatforms = [ "aarch64-linux" ]; 62 }; 63} // (args.argsOverride or {}))) (oldAttrs: { 64 postConfigure = '' 65 # The v7 defconfig has this set to '-v7' which screws up our modDirVersion. 66 sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/' 67 sed -i $buildRoot/include/config/auto.conf -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/' 68 ''; 69 70 # Make copies of the DTBs named after the upstream names so that U-Boot finds them. 71 # This is ugly as heck, but I don't know a better solution so far. 72 postFixup = '' 73 dtbDir=${if stdenv.isAarch64 then "$out/dtbs/broadcom" else "$out/dtbs"} 74 rm $dtbDir/bcm283*.dtb 75 copyDTB() { 76 cp -v "$dtbDir/$1" "$dtbDir/$2" 77 } 78 '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv6l-linux"]) '' 79 copyDTB bcm2708-rpi-zero-w.dtb bcm2835-rpi-zero.dtb 80 copyDTB bcm2708-rpi-zero-w.dtb bcm2835-rpi-zero-w.dtb 81 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-a.dtb 82 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b.dtb 83 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b-rev2.dtb 84 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-a-plus.dtb 85 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-b-plus.dtb 86 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-zero.dtb 87 copyDTB bcm2708-rpi-cm.dtb bcm2835-rpi-cm.dtb 88 '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv7l-linux"]) '' 89 copyDTB bcm2709-rpi-2-b.dtb bcm2836-rpi-2-b.dtb 90 '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv7l-linux" "aarch64-linux"]) '' 91 copyDTB bcm2710-rpi-zero-2.dtb bcm2837-rpi-zero-2.dtb 92 copyDTB bcm2710-rpi-3-b.dtb bcm2837-rpi-3-b.dtb 93 copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-a-plus.dtb 94 copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-b-plus.dtb 95 copyDTB bcm2710-rpi-cm3.dtb bcm2837-rpi-cm3.dtb 96 copyDTB bcm2711-rpi-4-b.dtb bcm2838-rpi-4-b.dtb 97 ''; 98})