mirror of
https://github.com/nix-community/raspberry-pi-nix.git
synced 2025-11-08 19:46:03 +01:00
chore: undo dtparams, improve kernel building code
This commit is contained in:
parent
aa99f3a2dd
commit
57a532319e
5 changed files with 93 additions and 73 deletions
|
|
@ -55,10 +55,10 @@
|
||||||
libcamera-overlay = self.overlays.libcamera;
|
libcamera-overlay = self.overlays.libcamera;
|
||||||
};
|
};
|
||||||
packages.aarch64-linux = {
|
packages.aarch64-linux = {
|
||||||
linux_2711 = pinned.rpi-kernels.latest_bcm2711.kernel;
|
linux_2711 = pinned.rpi-kernels.v6_6_31.bcm2711;
|
||||||
linux_2712 = pinned.rpi-kernels.latest_bcm2712.kernel;
|
linux_2712 = pinned.rpi-kernels.v6_6_31.bcm2712;
|
||||||
firmware = pinned.rpi-kernels.latest.firmware;
|
firmware = pinned.raspberrypifw;
|
||||||
wireless-firmware = pinned.rpi-kernels.latest.wireless-firmware;
|
wireless-firmware = pinned.raspberrypiWirelessFirmware;
|
||||||
uboot-rpi-arm64 = pinned.uboot-rpi-arm64;
|
uboot-rpi-arm64 = pinned.uboot-rpi-arm64;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,66 +7,70 @@
|
||||||
}:
|
}:
|
||||||
final: prev:
|
final: prev:
|
||||||
let
|
let
|
||||||
# The version to stick at `pkgs.rpi-kernels.latest_bcm271x'
|
versions = {
|
||||||
latest = "v6_6_34";
|
v6_6_31 = rpi-linux-6_6-src;
|
||||||
|
|
||||||
kernel-config = board: {
|
|
||||||
inherit board;
|
|
||||||
version = builtins.replaceStrings ["v" "_"] ["" "."] latest;
|
|
||||||
kernel = rpi-linux-6_6-src;
|
|
||||||
fw = rpi-firmware-src;
|
|
||||||
wireless-fw = import ./raspberrypi-wireless-firmware.nix {
|
|
||||||
bluez-firmware = rpi-bluez-firmware-src;
|
|
||||||
firmware-nonfree = rpi-firmware-nonfree-src;
|
|
||||||
};
|
|
||||||
argsOverride = {
|
|
||||||
structuredExtraConfig = with prev.lib.kernel; {
|
|
||||||
# The perl script to generate kernel options sets unspecified
|
|
||||||
# parameters to `m` if possible [1]. This results in the
|
|
||||||
# unspecified config option KUNIT [2] getting set to `m` which
|
|
||||||
# causes DRM_VC4_KUNIT_TEST [3] to get set to `y`.
|
|
||||||
#
|
|
||||||
# This vc4 unit test fails on boot due to a null pointer
|
|
||||||
# exception with the existing config. I'm not sure why, but in
|
|
||||||
# any case, the DRM_VC4_KUNIT_TEST config option itself states
|
|
||||||
# that it is only useful for kernel developers working on the
|
|
||||||
# vc4 driver. So, I feel no need to deviate from the standard
|
|
||||||
# rpi kernel and attempt to successfully enable this test and
|
|
||||||
# other unit tests because the nixos perl script has this
|
|
||||||
# sloppy "default to m" behavior. So, I set KUNIT to `n`.
|
|
||||||
#
|
|
||||||
# [1] https://github.com/NixOS/nixpkgs/blob/85bcb95aa83be667e562e781e9d186c57a07d757/pkgs/os-specific/linux/kernel/generate-config.pl#L1-L10
|
|
||||||
# [2] https://github.com/raspberrypi/linux/blob/1.20230405/lib/kunit/Kconfig#L5-L14
|
|
||||||
# [3] https://github.com/raspberrypi/linux/blob/bb63dc31e48948bc2649357758c7a152210109c4/drivers/gpu/drm/vc4/Kconfig#L38-L52
|
|
||||||
KUNIT = no;
|
|
||||||
GPIO_PWM = no;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
boards = [ "bcmrpi" "bcm2709" "bcmrpi3" "bcm2711" "bcm2712" ];
|
||||||
|
|
||||||
# Helpers for building the `pkgs.rpi-kernels' map.
|
# Helpers for building the `pkgs.rpi-kernels' map.
|
||||||
rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null, board }:
|
rpi-kernel = { version, board }: {
|
||||||
let
|
"${version}"."${board}" = prev.lib.overrideDerivation (prev.buildLinux {
|
||||||
new-kernel = prev.linux_rpi4.override {
|
modDirVersion = version;
|
||||||
argsOverride = {
|
inherit version;
|
||||||
src = kernel;
|
pname = "linux-rpi";
|
||||||
inherit version;
|
src = versions[version];
|
||||||
modDirVersion = version;
|
defconfig = "${board}_defconfig";
|
||||||
kernelPatches = [];
|
structuredExtraConfig = with lib.kernel; {
|
||||||
defconfig = "${board}_defconfig";
|
# Workaround https://github.com/raspberrypi/linux/issues/6198
|
||||||
postFixup = "";
|
# Needed because NixOS 24.05+ sets DRM_SIMPLEDRM=y which pulls in
|
||||||
} // (if builtins.isNull argsOverride then { } else argsOverride);
|
# DRM_KMS_HELPER=y.
|
||||||
};
|
BACKLIGHT_CLASS_DEVICE = yes;
|
||||||
new-fw = prev.raspberrypifw.overrideAttrs (oldfw: { src = fw; });
|
# The perl script to generate kernel options sets unspecified
|
||||||
new-wireless-fw = final.callPackage wireless-fw { };
|
# parameters to `m` if possible [1]. This results in the
|
||||||
in
|
# unspecified config option KUNIT [2] getting set to `m` which
|
||||||
{
|
# causes DRM_VC4_KUNIT_TEST [3] to get set to `y`.
|
||||||
"latest_${board}" = {
|
#
|
||||||
kernel = new-kernel;
|
# This vc4 unit test fails on boot due to a null pointer
|
||||||
firmware = new-fw;
|
# exception with the existing config. I'm not sure why, but in
|
||||||
wireless-firmware = new-wireless-fw;
|
# any case, the DRM_VC4_KUNIT_TEST config option itself states
|
||||||
};
|
# that it is only useful for kernel developers working on the
|
||||||
};
|
# vc4 driver. So, I feel no need to deviate from the standard
|
||||||
|
# rpi kernel and attempt to successfully enable this test and
|
||||||
|
# other unit tests because the nixos perl script has this
|
||||||
|
# sloppy "default to m" behavior. So, I set KUNIT to `n`.
|
||||||
|
#
|
||||||
|
# [1] https://github.com/NixOS/nixpkgs/blob/85bcb95aa83be667e562e781e9d186c57a07d757/pkgs/os-specific/linux/kernel/generate-config.pl#L1-L10
|
||||||
|
# [2] https://github.com/raspberrypi/linux/blob/1.20230405/lib/kunit/Kconfig#L5-L14
|
||||||
|
# [3] https://github.com/raspberrypi/linux/blob/bb63dc31e48948bc2649357758c7a152210109c4/drivers/gpu/drm/vc4/Kconfig#L38-L52
|
||||||
|
KUNIT = no;
|
||||||
|
};
|
||||||
|
features.efiBootStub = false;
|
||||||
|
postConfigure = ''
|
||||||
|
# The v7 defconfig has this set to '-v7' which screws up our modDirVersion.
|
||||||
|
sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
|
||||||
|
sed -i $buildRoot/include/config/auto.conf -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
|
||||||
|
'';
|
||||||
|
postFixup = "";
|
||||||
|
kernelPatches = [
|
||||||
|
# Fix compilation errors due to incomplete patch backport.
|
||||||
|
# https://github.com/raspberrypi/linux/pull/6223
|
||||||
|
{
|
||||||
|
name = "gpio-pwm_-_pwm_apply_might_sleep.patch";
|
||||||
|
patch = fetchpatch {
|
||||||
|
url = "https://github.com/peat-psuwit/rpi-linux/commit/879f34b88c60dd59765caa30576cb5bfb8e73c56.patch";
|
||||||
|
hash = "sha256-HlOkM9EFmlzOebCGoj7lNV5hc0wMjhaBFFZvaRCI0lI=";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "ir-rx51_-_pwm_apply_might_sleep.patch";
|
||||||
|
patch = fetchpatch {
|
||||||
|
url = "https://github.com/peat-psuwit/rpi-linux/commit/23431052d2dce8084b72e399fce82b05d86b847f.patch";
|
||||||
|
hash = "sha256-UDX/BJCJG0WVndP/6PbPK+AZsfU3vVxDCrpn1kb1kqE=";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { };
|
rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +84,7 @@ in
|
||||||
defconfig = "rpi_arm64_defconfig";
|
defconfig = "rpi_arm64_defconfig";
|
||||||
extraMeta.platforms = [ "aarch64-linux" ];
|
extraMeta.platforms = [ "aarch64-linux" ];
|
||||||
filesToInstall = [ "u-boot.bin" ];
|
filesToInstall = [ "u-boot.bin" ];
|
||||||
version = "2024.07-rc4";
|
version = "2024.04";
|
||||||
patches = [ ];
|
patches = [ ];
|
||||||
makeFlags = [ ];
|
makeFlags = [ ];
|
||||||
src = u-boot-src;
|
src = u-boot-src;
|
||||||
|
|
@ -97,16 +101,22 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
# default to latest firmware
|
# default to latest firmware
|
||||||
raspberrypiWirelessFirmware = final.rpi-kernels.latest_bcm2712.wireless-firmware;
|
raspberrypiWirelessFirmware = final.callPackage (
|
||||||
raspberrypifw = final.rpi-kernels.latest_bcm2712.firmware;
|
import ./raspberrypi-wireless-firmware.nix {
|
||||||
|
bluez-firmware = rpi-bluez-firmware-src;
|
||||||
|
firmware-nonfree = rpi-firmware-nonfree-src;
|
||||||
|
}
|
||||||
|
) { };
|
||||||
|
raspberrypifw = prev.raspberrypifw.overrideAttrs (oldfw: { src = rpi-firmware-src; });
|
||||||
|
|
||||||
} // {
|
} // {
|
||||||
# rpi kernels and firmware are available at
|
# rpi kernels and firmware are available at
|
||||||
# `pkgs.rpi-kernels.<VERSION>_<BOARD>.{kernel,firmware,wireless-firmware}'.
|
# `pkgs.rpi-kernels.<VERSION>.<BOARD>'.
|
||||||
#
|
#
|
||||||
# For example: `pkgs.rpi-kernels.latest_bcm2712.kernel'
|
# For example: `pkgs.rpi-kernels.v6_6_31.bcm2712'
|
||||||
rpi-kernels = rpi-kernels [
|
rpi-kernels = rpi-kernels (
|
||||||
(kernel-config "bcm2711")
|
prev.lib.lists.crossLists
|
||||||
(kernel-config "bcm2712")
|
(board: version: { inherit board version; })
|
||||||
];
|
[boards (builtins.attrNames versions)]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ let
|
||||||
(lib.filterAttrs (k: v: v.enable) x);
|
(lib.filterAttrs (k: v: v.enable) x);
|
||||||
render-dt-overlay = { overlay, args }:
|
render-dt-overlay = { overlay, args }:
|
||||||
"dtoverlay=" + overlay + "\n"
|
"dtoverlay=" + overlay + "\n"
|
||||||
+ lib.strings.concatMapStringsSep "\n" render-dt-param args + "\n";
|
+ lib.strings.concatMapStringsSep "\n" render-dt-param args + "\n"
|
||||||
|
+ "dtoverlay=";
|
||||||
render-base-dt-params = params:
|
render-base-dt-params = params:
|
||||||
lib.strings.concatMapStringsSep "\n" render-dt-param
|
lib.strings.concatMapStringsSep "\n" render-dt-param
|
||||||
(render-dt-kvs params);
|
(render-dt-kvs params);
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,21 @@
|
||||||
let
|
let
|
||||||
cfg = config.raspberry-pi-nix;
|
cfg = config.raspberry-pi-nix;
|
||||||
board = cfg.board;
|
board = cfg.board;
|
||||||
kernel = pkgs.rpi-kernels."latest_${board}".kernel;
|
version = cfg.kernel_version;
|
||||||
|
kernel = pkgs.rpi-kernels."${version}"."${board}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ../sd-image ./config.nix ./i2c.nix ];
|
imports = [ ../sd-image ./config.nix ./i2c.nix ];
|
||||||
|
|
||||||
options = with lib; {
|
options = with lib; {
|
||||||
raspberry-pi-nix = {
|
raspberry-pi-nix = {
|
||||||
|
kernel_version = mkOption {
|
||||||
|
default = "v6_6_31";
|
||||||
|
type = types.str;
|
||||||
|
description = ''
|
||||||
|
Kernel version to build.
|
||||||
|
'';
|
||||||
|
};
|
||||||
board = mkOption {
|
board = mkOption {
|
||||||
default = "bcm2712";
|
default = "bcm2712";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
board = config.raspberry-pi-nix.board;
|
board = config.raspberry-pi-nix.board;
|
||||||
kernel = pkgs.rpi-kernels."latest_${board}".kernel;
|
version = config.raspberry-pi-nix.kernel_version;
|
||||||
|
kernel = pkgs.rpi-kernels."${version}"."${board}";
|
||||||
populate-kernel =
|
populate-kernel =
|
||||||
if config.raspberry-pi-nix.uboot.enable
|
if config.raspberry-pi-nix.uboot.enable
|
||||||
then ''
|
then ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue