From 43258812a1b8c3dc1ae791e93ffbdbc27f2e0a7e Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Sat, 10 Jun 2023 07:22:03 -0400 Subject: [PATCH 1/3] update flake inputs --- flake.lock | 55 +++++++++++++++------------------------------ flake.nix | 10 ++++----- overlay/default.nix | 23 ++++++++++++------- 3 files changed, 38 insertions(+), 50 deletions(-) diff --git a/flake.lock b/flake.lock index d248256..06af588 100644 --- a/flake.lock +++ b/flake.lock @@ -3,16 +3,16 @@ "libcamera-apps-src": { "flake": false, "locked": { - "lastModified": 1674645888, - "narHash": "sha256-UBTDHN0lMj02enB8im4Q+f/MCm/G2mFPP3pLImrZc5A=", + "lastModified": 1677660281, + "narHash": "sha256-A6UriYk8bHRL6wp6ehXOnUnbJH2/mNDkxwGemD/UYpw=", "owner": "raspberrypi", "repo": "libcamera-apps", - "rev": "9f08463997b82c4bf60e12c4ea43577959a8ae15", + "rev": "54a781dffdd101954dcfa6acd0bd80006f67da83", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "v1.1.1", + "ref": "v1.1.2", "repo": "libcamera-apps", "type": "github" } @@ -22,9 +22,8 @@ "libcamera-apps-src": "libcamera-apps-src", "rpi-bluez-firmware-src": "rpi-bluez-firmware-src", "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", - "rpi-firmware-stable-src": "rpi-firmware-stable-src", - "rpi-linux-5_15-src": "rpi-linux-5_15-src", - "rpi-linux-5_15_87-src": "rpi-linux-5_15_87-src", + "rpi-firmware-src": "rpi-firmware-src", + "rpi-linux-6_1-src": "rpi-linux-6_1-src", "u-boot-src": "u-boot-src" } }, @@ -47,11 +46,11 @@ "rpi-firmware-nonfree-src": { "flake": false, "locked": { - "lastModified": 1674638139, - "narHash": "sha256-54JKmwypD7PRQdd7k6IcF7wL8ifMavEM0UwZwmA24O4=", + "lastModified": 1683107406, + "narHash": "sha256-9UgB8f2AaxG7S5Px46jOP9wUeO1VXKB0uJiPWh32oDI=", "owner": "RPi-Distro", "repo": "firmware-nonfree", - "rev": "7f29411baead874b859eda53efdc2472345ea454", + "rev": "2b465a10b04555b7f45b3acb85959c594922a3ce", "type": "github" }, "original": { @@ -60,57 +59,39 @@ "type": "github" } }, - "rpi-firmware-stable-src": { + "rpi-firmware-src": { "flake": false, "locked": { - "lastModified": 1673003776, - "narHash": "sha256-tdaH+zZwmILNFBge2gMqtzj/1Hydj9cxhPvhw+7jTrU=", + "lastModified": 1686136390, + "narHash": "sha256-Uq1yIp8zgexz2hwgAxEtmo9paytel4VPof5VMys01UM=", "owner": "raspberrypi", "repo": "firmware", - "rev": "78852e166b4cf3ebb31d051e996d54792f0994b0", + "rev": "13fbbc4f5ea698353486915986de8b48f18018f6", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "stable", "repo": "firmware", "type": "github" } }, - "rpi-linux-5_15-src": { + "rpi-linux-6_1-src": { "flake": false, "locked": { - "lastModified": 1675874870, - "narHash": "sha256-oy+VgoB4IdFZjGwkx88dDSpwWZj2D5t3PyXPIwDsY1Q=", + "lastModified": 1686133523, + "narHash": "sha256-r5L3hqk0wlefqkgO8jH4mupeUkbx9cSjHskLOxQQdZw=", "owner": "raspberrypi", "repo": "linux", - "rev": "14b35093ca68bf2c81bbc90aace5007142b40b40", + "rev": "bb63dc31e48948bc2649357758c7a152210109c4", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "rpi-5.15.y", + "ref": "rpi-6.1.y", "repo": "linux", "type": "github" } }, - "rpi-linux-5_15_87-src": { - "flake": false, - "locked": { - "lastModified": 1673628667, - "narHash": "sha256-hNLVfhalmRhhRfvu2mR/qDmmGl//Ic1eqR7N1HFj2CY=", - "owner": "raspberrypi", - "repo": "linux", - "rev": "da4c8e0ffe7a868b989211045657d600be3046a1", - "type": "github" - }, - "original": { - "owner": "raspberrypi", - "repo": "linux", - "rev": "da4c8e0ffe7a868b989211045657d600be3046a1", - "type": "github" - } - }, "u-boot-src": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index c91be2c..5aad7fe 100644 --- a/flake.nix +++ b/flake.nix @@ -6,13 +6,13 @@ flake = false; url = "https://ftp.denx.de/pub/u-boot/u-boot-2023.01.tar.bz2"; }; - rpi-linux-5_15-src = { + rpi-linux-6_1-src = { flake = false; - url = "github:raspberrypi/linux/rpi-5.15.y"; + url = "github:raspberrypi/linux/rpi-6.1.y"; }; - rpi-firmware-stable-src = { + rpi-firmware-src = { flake = false; - url = "github:raspberrypi/firmware/stable"; + url = "github:raspberrypi/firmware"; }; rpi-firmware-nonfree-src = { flake = false; @@ -24,7 +24,7 @@ }; libcamera-apps-src = { flake = false; - url = "github:raspberrypi/libcamera-apps/v1.1.1"; + url = "github:raspberrypi/libcamera-apps/v1.1.2"; }; }; diff --git a/overlay/default.nix b/overlay/default.nix index a72eae3..8a7d1f3 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -1,9 +1,14 @@ -{ u-boot-src, rpi-linux-5_15-src, rpi-firmware-stable-src -, rpi-firmware-nonfree-src, rpi-bluez-firmware-src, libcamera-apps-src }: +{ u-boot-src +, rpi-linux-6_1-src +, rpi-firmware-src +, rpi-firmware-nonfree-src +, rpi-bluez-firmware-src +, libcamera-apps-src +}: final: prev: let # The version to stick at `pkgs.rpi-kernels.latest' - latest = "v5_15_92"; + latest = "v6_1_32"; # Helpers for building the `pkgs.rpi-kernels' map. rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null }: @@ -18,7 +23,8 @@ let new-fw = prev.raspberrypifw.overrideAttrs (oldfw: { src = fw; }); new-wireless-fw = final.callPackage wireless-fw { }; version-slug = builtins.replaceStrings [ "." ] [ "_" ] version; - in { + in + { "v${version-slug}" = { kernel = new-kernel; firmware = new-fw; @@ -26,7 +32,8 @@ let }; }; rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; -in { +in +{ # disable firmware compression so that brcm firmware can be found at # the path expected by raspberry pi firmware/device tree @@ -69,9 +76,9 @@ in { # # For example: `pkgs.rpi-kernels.v5_15_87.kernel' rpi-kernels = rpi-kernels [{ - version = "5.15.92"; - kernel = rpi-linux-5_15-src; - fw = rpi-firmware-stable-src; + version = "6.1.32"; + kernel = rpi-linux-6_1-src; + fw = rpi-firmware-src; wireless-fw = import ./raspberrypi-wireless-firmware.nix { bluez-firmware = rpi-bluez-firmware-src; firmware-nonfree = rpi-firmware-nonfree-src; From 7c6fa52715ce3042f2c76a649a8d6e52d0a8b646 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 12 Jun 2023 09:53:24 -0400 Subject: [PATCH 2/3] set linux and firmware to latest release tag disable KUNIT in kernel config --- flake.lock | 15 ++-- flake.nix | 4 +- overlay/default.nix | 13 +-- overlay/libcamera-apps.nix | 2 +- rpi/default.nix | 159 +++++++++++++++++++------------------ 5 files changed, 98 insertions(+), 95 deletions(-) diff --git a/flake.lock b/flake.lock index 06af588..406d9d4 100644 --- a/flake.lock +++ b/flake.lock @@ -62,15 +62,16 @@ "rpi-firmware-src": { "flake": false, "locked": { - "lastModified": 1686136390, - "narHash": "sha256-Uq1yIp8zgexz2hwgAxEtmo9paytel4VPof5VMys01UM=", + "lastModified": 1680694337, + "narHash": "sha256-UtUd1MbsrDFxd/1C3eOAMDKPZMx+kSMFYOJP+Kc6IU8=", "owner": "raspberrypi", "repo": "firmware", - "rev": "13fbbc4f5ea698353486915986de8b48f18018f6", + "rev": "055e044d5359ded1aacc5a17a8e35365373d0b8b", "type": "github" }, "original": { "owner": "raspberrypi", + "ref": "stable", "repo": "firmware", "type": "github" } @@ -78,16 +79,16 @@ "rpi-linux-6_1-src": { "flake": false, "locked": { - "lastModified": 1686133523, - "narHash": "sha256-r5L3hqk0wlefqkgO8jH4mupeUkbx9cSjHskLOxQQdZw=", + "lastModified": 1680464256, + "narHash": "sha256-ILwecHZ1BN6GhZAUB6/UwiN/rZ8gHndKON6DUhidtxI=", "owner": "raspberrypi", "repo": "linux", - "rev": "bb63dc31e48948bc2649357758c7a152210109c4", + "rev": "0afb5e98488aed7017b9bf321b575d0177feb7ed", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "rpi-6.1.y", + "ref": "1.20230405", "repo": "linux", "type": "github" } diff --git a/flake.nix b/flake.nix index 5aad7fe..51e26dc 100644 --- a/flake.nix +++ b/flake.nix @@ -8,11 +8,11 @@ }; rpi-linux-6_1-src = { flake = false; - url = "github:raspberrypi/linux/rpi-6.1.y"; + url = "github:raspberrypi/linux/1.20230405"; }; rpi-firmware-src = { flake = false; - url = "github:raspberrypi/firmware"; + url = "github:raspberrypi/firmware/1.20230405"; }; rpi-firmware-nonfree-src = { flake = false; diff --git a/overlay/default.nix b/overlay/default.nix index 8a7d1f3..ff62828 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -8,7 +8,7 @@ final: prev: let # The version to stick at `pkgs.rpi-kernels.latest' - latest = "v6_1_32"; + latest = "v6_1_21"; # Helpers for building the `pkgs.rpi-kernels' map. rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null }: @@ -35,10 +35,6 @@ let in { - # disable firmware compression so that brcm firmware can be found at - # the path expected by raspberry pi firmware/device tree - compressFirmwareXz = x: x; - # A recent known working version of libcamera-apps libcamera-apps = final.callPackage ./libcamera-apps.nix { inherit libcamera-apps-src; }; @@ -76,13 +72,18 @@ in # # For example: `pkgs.rpi-kernels.v5_15_87.kernel' rpi-kernels = rpi-kernels [{ - version = "6.1.32"; + version = "6.1.21"; kernel = rpi-linux-6_1-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; { + KUNIT = no; + }; + }; }] // { latest = final.rpi-kernels."${latest}"; }; diff --git a/overlay/libcamera-apps.nix b/overlay/libcamera-apps.nix index 139a641..04e29b8 100644 --- a/overlay/libcamera-apps.nix +++ b/overlay/libcamera-apps.nix @@ -3,7 +3,7 @@ stdenv.mkDerivation rec { pname = "libcamera-apps"; - version = "v1.1.0"; + version = "v1.1.2"; src = libcamera-apps-src; diff --git a/rpi/default.nix b/rpi/default.nix index 671369d..98a82c5 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -8,91 +8,92 @@ "raspberry-pi-firmware-migrate" = { description = "update the firmware partition"; wantedBy = [ "multi-user.target" ]; - serviceConfig = let firmware-path = "/boot/firmware"; - in { - Type = "oneshot"; - MountImages = - "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}:${firmware-path}"; - StateDirectory = "raspberrypi-firmware"; - ExecStart = pkgs.writeShellScript "migrate-rpi-firmware" '' - shopt -s nullglob + serviceConfig = + let firmware-path = "/boot/firmware"; + in { + Type = "oneshot"; + MountImages = + "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}:${firmware-path}"; + StateDirectory = "raspberrypi-firmware"; + ExecStart = pkgs.writeShellScript "migrate-rpi-firmware" '' + shopt -s nullglob - TARGET_FIRMWARE_DIR="${firmware-path}" - TARGET_OVERLAYS_DIR="$TARGET_FIRMWARE_DIR/overlays" - TMPFILE="$TARGET_FIRMWARE_DIR/tmp" - UBOOT="${pkgs.uboot_rpi_arm64}/u-boot.bin" - SRC_FIRMWARE_DIR="${pkgs.raspberrypifw}/share/raspberrypi/boot" - STARTFILES=("$SRC_FIRMWARE_DIR"/start*.elf) - DTBS=("$SRC_FIRMWARE_DIR"/*.dtb) - BOOTCODE="$SRC_FIRMWARE_DIR/bootcode.bin" - FIXUPS=("$SRC_FIRMWARE_DIR"/fixup*.dat) - SRC_OVERLAYS_DIR="$SRC_FIRMWARE_DIR/overlays" - SRC_OVERLAYS=("$SRC_OVERLAYS_DIR"/*) - CONFIG="${config.hardware.raspberry-pi.config-output}" + TARGET_FIRMWARE_DIR="${firmware-path}" + TARGET_OVERLAYS_DIR="$TARGET_FIRMWARE_DIR/overlays" + TMPFILE="$TARGET_FIRMWARE_DIR/tmp" + UBOOT="${pkgs.uboot_rpi_arm64}/u-boot.bin" + SRC_FIRMWARE_DIR="${pkgs.raspberrypifw}/share/raspberrypi/boot" + STARTFILES=("$SRC_FIRMWARE_DIR"/start*.elf) + DTBS=("$SRC_FIRMWARE_DIR"/*.dtb) + BOOTCODE="$SRC_FIRMWARE_DIR/bootcode.bin" + FIXUPS=("$SRC_FIRMWARE_DIR"/fixup*.dat) + SRC_OVERLAYS_DIR="$SRC_FIRMWARE_DIR/overlays" + SRC_OVERLAYS=("$SRC_OVERLAYS_DIR"/*) + CONFIG="${config.hardware.raspberry-pi.config-output}" - migrate_uboot() { - echo "migrating uboot" - touch "$STATE_DIRECTORY/uboot-migration-in-progress" - cp "$UBOOT" "$TMPFILE" - mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/u-boot-rpi-arm64.bin" - echo "${ + migrate_uboot() { + echo "migrating uboot" + touch "$STATE_DIRECTORY/uboot-migration-in-progress" + cp "$UBOOT" "$TMPFILE" + mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/u-boot-rpi-arm64.bin" + echo "${ + builtins.toString pkgs.uboot_rpi_arm64 + }" > "$STATE_DIRECTORY/uboot-version" + rm "$STATE_DIRECTORY/uboot-migration-in-progress" + } + + migrate_config() { + echo "migrating config.txt" + touch "$STATE_DIRECTORY/config-migration-in-progress" + cp "$CONFIG" "$TMPFILE" + mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/config.txt" + echo "${config.hardware.raspberry-pi.config-output}" > "$STATE_DIRECTORY/config-version" + rm "$STATE_DIRECTORY/config-migration-in-progress" + } + + migrate_firmware() { + echo "migrating raspberrypi firmware" + touch "$STATE_DIRECTORY/firmware-migration-in-progress" + for SRC in "''${STARTFILES[@]}" "''${DTBS[@]}" "$BOOTCODE" "''${FIXUPS[@]}" + do + cp "$SRC" "$TMPFILE" + mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/$(basename "$SRC")" + done + + if [[ ! -d "$TARGET_OVERLAYS_DIR" ]]; then + mkdir "$TARGET_OVERLAYS_DIR" + fi + + for SRC in "''${SRC_OVERLAYS[@]}" + do + cp "$SRC" "$TMPFILE" + mv -T "$TMPFILE" "$TARGET_OVERLAYS_DIR/$(basename "$SRC")" + done + echo "${ + builtins.toString pkgs.raspberrypifw + }" > "$STATE_DIRECTORY/firmware-version" + rm "$STATE_DIRECTORY/firmware-migration-in-progress" + } + + if [[ -f "$STATE_DIRECTORY/uboot-migration-in-progress" || ! -f "$STATE_DIRECTORY/uboot-version" || $(< "$STATE_DIRECTORY/uboot-version") != ${ builtins.toString pkgs.uboot_rpi_arm64 - }" > "$STATE_DIRECTORY/uboot-version" - rm "$STATE_DIRECTORY/uboot-migration-in-progress" - } - - migrate_config() { - echo "migrating config.txt" - touch "$STATE_DIRECTORY/config-migration-in-progress" - cp "$CONFIG" "$TMPFILE" - mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/config.txt" - echo "${config.hardware.raspberry-pi.config-output}" > "$STATE_DIRECTORY/config-version" - rm "$STATE_DIRECTORY/config-migration-in-progress" - } - - migrate_firmware() { - echo "migrating raspberrypi firmware" - touch "$STATE_DIRECTORY/firmware-migration-in-progress" - for SRC in "''${STARTFILES[@]}" "''${DTBS[@]}" "$BOOTCODE" "''${FIXUPS[@]}" - do - cp "$SRC" "$TMPFILE" - mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/$(basename "$SRC")" - done - - if [[ ! -d "$TARGET_OVERLAYS_DIR" ]]; then - mkdir "$TARGET_OVERLAYS_DIR" + } ]]; then + migrate_uboot fi - for SRC in "''${SRC_OVERLAYS[@]}" - do - cp "$SRC" "$TMPFILE" - mv -T "$TMPFILE" "$TARGET_OVERLAYS_DIR/$(basename "$SRC")" - done - echo "${ + if [[ -f "$STATE_DIRECTORY/config-migration-in-progress" || ! -f "$STATE_DIRECTORY/config-version" || $(< "$STATE_DIRECTORY/config-version") != ${ + builtins.toString config.hardware.raspberry-pi.config-output + } ]]; then + migrate_config + fi + + if [[ -f "$STATE_DIRECTORY/firmware-migration-in-progress" || ! -f "$STATE_DIRECTORY/firmware-version" || $(< "$STATE_DIRECTORY/firmware-version") != ${ builtins.toString pkgs.raspberrypifw - }" > "$STATE_DIRECTORY/firmware-version" - rm "$STATE_DIRECTORY/firmware-migration-in-progress" - } - - if [[ -f "$STATE_DIRECTORY/uboot-migration-in-progress" || ! -f "$STATE_DIRECTORY/uboot-version" || $(< "$STATE_DIRECTORY/uboot-version") != ${ - builtins.toString pkgs.uboot_rpi_arm64 - } ]]; then - migrate_uboot - fi - - if [[ -f "$STATE_DIRECTORY/config-migration-in-progress" || ! -f "$STATE_DIRECTORY/config-version" || $(< "$STATE_DIRECTORY/config-version") != ${ - builtins.toString config.hardware.raspberry-pi.config-output - } ]]; then - migrate_config - fi - - if [[ -f "$STATE_DIRECTORY/firmware-migration-in-progress" || ! -f "$STATE_DIRECTORY/firmware-version" || $(< "$STATE_DIRECTORY/firmware-version") != ${ - builtins.toString pkgs.raspberrypifw - } ]]; then - migrate_firmware - fi - ''; - }; + } ]]; then + migrate_firmware + fi + ''; + }; }; }; From 92e2a3b15f4eec6ef18eb7e0b2addc98f71757b0 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 12 Jun 2023 10:44:29 -0400 Subject: [PATCH 3/3] add docs for KUNIT setting --- overlay/default.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/overlay/default.nix b/overlay/default.nix index ff62828..a686855 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -81,6 +81,23 @@ in }; 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; }; };