From f2fa92b5f77165dee84f024da7e6a3de00f98fd9 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 11 Feb 2024 00:47:18 +0000 Subject: [PATCH] WIP-but-works: mainline kernel for Turris Omnia --- devices/turris-omnia/default.nix | 81 +++++++++++++++++++++++++------- examples/rotuer.nix | 4 +- modules/kernel.nix | 4 +- modules/wlan.nix | 4 ++ pkgs/kernel/default.nix | 10 ++-- 5 files changed, 81 insertions(+), 22 deletions(-) diff --git a/devices/turris-omnia/default.nix b/devices/turris-omnia/default.nix index 64c6db7..f4ab567 100644 --- a/devices/turris-omnia/default.nix +++ b/devices/turris-omnia/default.nix @@ -182,12 +182,10 @@ kernel = { src = pkgs.pkgsBuildBuild.fetchurl { name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; + url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.7.4.tar.gz"; + hash = "sha256-wIrmL0BS63nRwWfm4nw+dRNVPUzGh9M4X7LaHzAn5tU="; }; - extraPatchPhase = '' - ${pkgs.openwrt.applyPatches.mvebu} - ''; + version = "6.7.4"; config = { PCI = "y"; OF = "y"; @@ -203,6 +201,10 @@ RTC_CLASS = "y"; RTC_DRV_ARMADA38X = "y"; # this may be useful anyway? + EXPERT = "y"; + ALLOW_DEV_COREDUMP = "n"; + + # dts has a compatible for this but dmesg is not # showing it EEPROM_AT24 = "y"; # atmel,24c64 @@ -213,9 +215,9 @@ MACH_ARMADA_38X = "y"; SMP = "y"; - # this is disabled for the moment because it relies on a GCC - # plugin that requires gmp.h to build, and I can't see right now - # how to confgure it to find gmp + # this is disabled for the moment because it relies on a + # GCC plugin that requires gmp.h to build, and I can't see + # right now how to confgure it to find gmp STACKPROTECTOR_PER_TASK = "n"; NR_CPUS = "4"; VFP = "y"; @@ -227,7 +229,7 @@ PSTORE = "y"; PSTORE_RAM = "y"; PSTORE_CONSOLE = "y"; - PSTORE_DEFLATE_COMPRESS = "n"; +# PSTORE_DEFLATE_COMPRESS = "n"; BLOCK = "y"; MMC="y"; @@ -286,9 +288,25 @@ USB_XHCI_MVEBU = "y"; USB_XHCI_HCD = "y"; }; + WLAN = { + CFG80211 = "m"; + MAC80211 = "m"; + + CFG80211_CERTIFICATION_ONUS = "y"; + CFG80211_REQUIRE_SIGNED_REGDB = "n"; # depends on ONUS + + CFG80211_CRDA_SUPPORT = "n"; + + WLAN_VENDOR_ATH = "y"; + ATH_COMMON = "m"; + ATH9K = "m"; + ATH9K_PCI = "y"; + ATH10K = "m"; + ATH10K_PCI = "m"; + ATH10K_DEBUG = "y"; + }; }; }; - boot = { commandLine = [ "console=ttyS0,115200" @@ -328,10 +346,41 @@ }; hardware = let - mac80211 = pkgs.mac80211.override { - drivers = ["ath9k_pci" "ath10k_pci"]; - klibBuild = config.system.outputs.kernel.modulesupport; - }; + mac80211 = + let + targets = [ + "ath9k" + "ath10k_pci" + ]; + kmodules = pkgs.runCommand "modules" { + nativeBuildInputs = with pkgs.pkgsBuildBuild ;[ + kmod cpio gawk + ]; + } '' + kernel=${config.system.outputs.kernel.modulesupport} + mkdir -p lib/modules/0.0 + (cd $kernel && find . -name \*.ko | cpio --verbose --make-directories -p $NIX_BUILD_TOP/lib/modules/0.0) + cp $kernel/modules.* lib/modules/0.0 + depmod -b . 0.0 + + (for i in ${lib.concatStringsSep " " targets}; do + modprobe -S 0.0 -d $NIX_BUILD_TOP --show-depends $i | sed "s,^insmod $NIX_BUILD_TOP/lib/modules/0.0/,,g" + done) | awk '!a[$0]++' > load-order + + mkdir $out + for i in $(cat load-order); do + install -v $NIX_BUILD_TOP/lib/modules/0.0/$i -D $out/$i + done + echo "O=$out" > $out/load.sh + sed "s,^,insmod \$O/,g" < load-order >> $out/load.sh + echo "O=$out" > $out/unload.sh + tac load-order | sed "s,^,rmmod \$O/,g" > $out/unload.sh + ''; in + oneshot { + name = "mac80211-modules"; + up = "sh ${kmodules}/load.sh"; + down = "sh ${kmodules}/unload.sh"; + }; in { defaultOutput = "mtdimage"; loadAddress = lim.parseInt "0x00800000"; # "0x00008000"; @@ -339,9 +388,9 @@ rootDevice = "/dev/mmcblk0p1"; dts = { - src = "${config.system.outputs.kernel.modulesupport}/arch/arm/boot/dts/armada-385-turris-omnia.dts"; + src = "${config.system.outputs.kernel.modulesupport}/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts"; includes = [ - "${config.system.outputs.kernel.modulesupport}/arch/arm/boot/dts/" + "${config.system.outputs.kernel.modulesupport}/arch/arm/boot/dts/marvell/" ]; }; flash.eraseBlockSize = 65536; # only used for tftpboot diff --git a/examples/rotuer.nix b/examples/rotuer.nix index 3b51780..b172d78 100644 --- a/examples/rotuer.nix +++ b/examples/rotuer.nix @@ -23,6 +23,7 @@ let wmm_enabled = 1; }; + in rec { boot = { tftp = { @@ -83,7 +84,8 @@ in rec { services.bridge = svc.bridge.members.build { primary = services.int; members = with config.hardware.networkInterfaces; - [ wlan + [ + wlan wlan5 lan0 lan1 diff --git a/modules/kernel.nix b/modules/kernel.nix index f10e3d7..8455daf 100644 --- a/modules/kernel.nix +++ b/modules/kernel.nix @@ -27,6 +27,7 @@ in { options = { kernel = { src = mkOption { type = types.path; } ; + version = mkOption { type = types.str; default = "5.15.137";} ; modular = mkOption { type = types.bool; default = true; @@ -79,7 +80,8 @@ in { config.kernel.conditionalConfig; k = liminix.builders.kernel.override { config = mergedConfig; - inherit (config.kernel) src extraPatchPhase; + version = builtins.trace config.kernel.version config.kernel.version; + inherit (config.kernel) src extraPatchPhase; targets = config.kernel.makeTargets; }; in { diff --git a/modules/wlan.nix b/modules/wlan.nix index 6e62dda..2fa4fb1 100644 --- a/modules/wlan.nix +++ b/modules/wlan.nix @@ -46,6 +46,10 @@ in { CRYPTO_SHA1 = "y"; ENCRYPTED_KEYS = "y"; KEYS = "y"; + + # see note in include/linux/netdevice.h re LL_MAX_HEADER + WLAN = "y"; + }; }; }; diff --git a/pkgs/kernel/default.nix b/pkgs/kernel/default.nix index 8ff2522..672e46f 100644 --- a/pkgs/kernel/default.nix +++ b/pkgs/kernel/default.nix @@ -6,6 +6,7 @@ , config , src + , version ? "1" , extraPatchPhase ? "echo" , targets ? ["vmlinux"] } : @@ -23,6 +24,7 @@ stdenv.mkDerivation rec { (with buildPackages.pkgs; [ rsync bc bison flex pkg-config openssl ncurses.all perl + cpio ]); CC = "${stdenv.cc.bintools.targetPrefix}gcc"; HOSTCC = with buildPackages.pkgs; @@ -51,9 +53,9 @@ stdenv.mkDerivation rec { patches = [ ./cmdline-cookie.patch - ./phram-allow-cached-mappings.patch ./mips-malta-fdt-from-bootloader.patch - ]; + ] ++ lib.optional (lib.versionOlder version "6.0") + ./phram-allow-cached-mappings.patch; # this is here to work around what I think is a bug in nixpkgs # packaging of ncurses: it installs pkg-config data files which @@ -103,8 +105,8 @@ stdenv.mkDerivation rec { mkdir -p $headers cp -a include .config $headers/ mkdir -p $modulesupport - cp modules.* $modulesupport - make clean modules_prepare + cp modules.* vmlinux.o $modulesupport + make modules cp -a . $modulesupport ''; }