use openwrt kernel for gl-ar750

module-based-network
Daniel Barlow 2022-10-16 15:15:18 +01:00
parent 77922c875b
commit 4b513cdb98
4 changed files with 59 additions and 46 deletions

View File

@ -62,6 +62,7 @@ let
ln -s ${squashfs} squashfs ln -s ${squashfs} squashfs
ln -s ${kernel.vmlinux} vmlinux ln -s ${kernel.vmlinux} vmlinux
ln -s ${manifest} manifest ln -s ${manifest} manifest
ln -s ${kernel.vmlinux.modulesupport} build
'' + '' +
(if device ? boot then '' (if device ? boot then ''
ln -s ${uimage} uimage ln -s ${uimage} uimage

View File

@ -10,6 +10,9 @@
# DIY users: the serial port connections have headers preinstalled # DIY users: the serial port connections have headers preinstalled
# and don't need soldering # 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 = { system = {
crossSystem = { crossSystem = {
@ -28,33 +31,57 @@
# pkgs # pkgs
overlay = final: prev: 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 { in {
sources = { sources = {
openwrt = fetchFromGitHub { inherit openwrt;
name = "openwrt-source"; kernel = stdenvNoCC.mkDerivation {
repo = "openwrt"; name = "spindled-kernel-tree";
owner = "openwrt"; src = mainline;
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab"; phases = [
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8="; "unpackPhase" "patchPhase" "openWrtPatchPhase"
}; "patchScripts" "installPhase"
kernel = fetchFromGitHub { ];
name = "kernel-source"; patches = [ ../../kernel/random.patch ];
owner = "torvalds"; patchScripts = ''
repo = "linux"; patchShebangs scripts/
rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19 '';
hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4="; 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 { kernel = rec {
checkedConfig = { checkedConfig = {
"MIPS_ELF_APPENDED_DTB" = "y"; "MIPS_ELF_APPENDED_DTB" = "y";
OF = "y"; OF = "y";
USE_OF = "y"; USE_OF = "y";
ATH79 = "y"; ATH79 = "y";
SOC_QCA955X = "y"; # actually QCA9531, is this even right? # SOC_QCA955X = "y"; # actually QCA9531, is this even right?
LIMINIX = "y"; LIMINIX = "y";
SERIAL_8250_CONSOLE = "y"; SERIAL_8250_CONSOLE = "y";
SERIAL_8250 = "y"; SERIAL_8250 = "y";
@ -76,6 +103,15 @@
# filesystem is mounted and it expects /dev/console to # filesystem is mounted and it expects /dev/console to
# be present already # be present already
BLK_DEV_INITRD = "n"; 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 = { config = {
CPU_LITTLE_ENDIAN= "n"; CPU_LITTLE_ENDIAN= "n";

View File

@ -1,44 +1,19 @@
{ {
callPackage callPackage
, buildPackages
, stdenvNoCC
, fetchFromGitHub
, config , config
, checkedConfig , checkedConfig
, sources , 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 { vmlinux = callPackage ./vmlinux.nix {
inherit tree config checkedConfig; tree = sources.kernel;
inherit config checkedConfig;
}; };
uimage = callPackage ./uimage.nix { }; uimage = callPackage ./uimage.nix { };
dtb = callPackage ./dtb.nix { dtb = callPackage ./dtb.nix {
openwrt = sources.openwrt; inherit (sources) openwrt kernel;
kernel = tree;
}; };
} }

View File

@ -92,8 +92,9 @@ stdenv.mkDerivation rec {
installPhase = '' installPhase = ''
${CROSS_COMPILE}strip -d vmlinux ${CROSS_COMPILE}strip -d vmlinux
cp vmlinux $out cp vmlinux $out
make clean
mkdir -p $modulesupport mkdir -p $modulesupport
cp .config $modulesupport/config
make clean
cp -a . $modulesupport cp -a . $modulesupport
''; '';