commit 4b513cdb98707109c41331f83b1fc5feb6218675
parent 77922c875b284c1d1ab5fa35d0604e036b059aa3
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 16 Oct 2022 15:15:18 +0100
use openwrt kernel for gl-ar750
Diffstat:
4 files changed, 59 insertions(+), 46 deletions(-)
diff --git a/default.nix b/default.nix
@@ -62,6 +62,7 @@ let
ln -s ${squashfs} squashfs
ln -s ${kernel.vmlinux} vmlinux
ln -s ${manifest} manifest
+ ln -s ${kernel.vmlinux.modulesupport} build
'' +
(if device ? boot then ''
ln -s ${uimage} uimage
diff --git a/devices/gl-ar750/default.nix b/devices/gl-ar750/default.nix
@@ -10,6 +10,9 @@
# DIY users: the serial port connections have headers preinstalled
# and don't need soldering
+# Mainline linux 5.19 doesn't have device-tree support for this device
+# or even for the SoC, so we use the extensive OpenWrt kernel patches
+
{
system = {
crossSystem = {
@@ -28,33 +31,57 @@
# pkgs
overlay = final: prev:
- let inherit (final) fetchFromGitHub;
+ let
+ inherit (final) fetchFromGitHub fetchgit stdenvNoCC;
+ openwrt = fetchFromGitHub {
+ name = "openwrt-source";
+ repo = "openwrt";
+ owner = "openwrt";
+ rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
+ hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
+ };
+ mainline = fetchFromGitHub {
+ name = "kernel-source";
+ owner = "torvalds";
+ repo = "linux";
+ rev = "90c7e9b400c751dbd73885f494f421f90ca69721";
+ hash = "sha256-pq6QNa0PJVeheaZkuvAPD0rLuEeKrViKk65dz+y4kqo=";
+ };
in {
sources = {
- openwrt = fetchFromGitHub {
- name = "openwrt-source";
- repo = "openwrt";
- owner = "openwrt";
- rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
- hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
- };
- kernel = fetchFromGitHub {
- name = "kernel-source";
- owner = "torvalds";
- repo = "linux";
- rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19
- hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4=";
+ inherit openwrt;
+ kernel = stdenvNoCC.mkDerivation {
+ name = "spindled-kernel-tree";
+ src = mainline;
+ phases = [
+ "unpackPhase" "patchPhase" "openWrtPatchPhase"
+ "patchScripts" "installPhase"
+ ];
+ patches = [ ../../kernel/random.patch ];
+ patchScripts = ''
+ patchShebangs scripts/
+ '';
+ openWrtPatchPhase = ''
+ cp -av ${openwrt}/target/linux/generic/files/* .
+ chmod -R u+w .
+ cp -av ${openwrt}/target/linux/ath79/files/* .
+ chmod -R u+w .
+ for i in ${openwrt}/target/linux/ath79/patches-5.15/* ; do patch --batch --forward -p1 < $i ;done
+ '';
+ installPhase = ''
+ mkdir -p $out
+ cp -a . $out
+ '';
};
};
};
-
kernel = rec {
checkedConfig = {
"MIPS_ELF_APPENDED_DTB" = "y";
OF = "y";
USE_OF = "y";
ATH79 = "y";
- SOC_QCA955X = "y"; # actually QCA9531, is this even right?
+# SOC_QCA955X = "y"; # actually QCA9531, is this even right?
LIMINIX = "y";
SERIAL_8250_CONSOLE = "y";
SERIAL_8250 = "y";
@@ -76,6 +103,15 @@
# filesystem is mounted and it expects /dev/console to
# be present already
BLK_DEV_INITRD = "n";
+
+ NET = "y";
+ NETDEVICES = "y";
+ ETHERNET = "y";
+ NET_VENDOR_ATHEROS = "y";
+ AG71XX = "y"; # ethernet (qca,qca9530-eth)
+
+ MFD_SYSCON = "y"; # ethernet (compatible "syscon")
+
};
config = {
CPU_LITTLE_ENDIAN= "n";
diff --git a/kernel/default.nix b/kernel/default.nix
@@ -1,44 +1,19 @@
{
callPackage
-, buildPackages
-, stdenvNoCC
-, fetchFromGitHub
, config
, checkedConfig
, sources
}:
-let
- # The kernel is huge and takes a long time just to
- # download and unpack. This derivation creates
- # a source tree in a suitable shape to build from -
- # today it just patches some scripts but as we add
- # support for boards/SoCs we expect the scope of
- # "pre-treatment" to grow
-
- tree = stdenvNoCC.mkDerivation {
- name = "spindled-kernel-tree";
- src = sources.kernel;
- phases = [ "unpackPhase" "patchPhase" "patchScripts" "installPhase" ];
- patches = [ ./random.patch ];
- patchScripts = ''
- patchShebangs scripts/
- '';
- installPhase = ''
- mkdir -p $out
- cp -a . $out
- '';
- };
-
-in rec {
+{
vmlinux = callPackage ./vmlinux.nix {
- inherit tree config checkedConfig;
+ tree = sources.kernel;
+ inherit config checkedConfig;
};
uimage = callPackage ./uimage.nix { };
dtb = callPackage ./dtb.nix {
- openwrt = sources.openwrt;
- kernel = tree;
+ inherit (sources) openwrt kernel;
};
}
diff --git a/kernel/vmlinux.nix b/kernel/vmlinux.nix
@@ -92,8 +92,9 @@ stdenv.mkDerivation rec {
installPhase = ''
${CROSS_COMPILE}strip -d vmlinux
cp vmlinux $out
- make clean
mkdir -p $modulesupport
+ cp .config $modulesupport/config
+ make clean
cp -a . $modulesupport
'';