use openwrt kernel for gl-ar750

This commit is contained in:
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 ${kernel.vmlinux} vmlinux
ln -s ${manifest} manifest
ln -s ${kernel.vmlinux.modulesupport} build
'' +
(if device ? boot then ''
ln -s ${uimage} uimage

View file

@ -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,9 +31,8 @@
# pkgs
overlay = final: prev:
let inherit (final) fetchFromGitHub;
in {
sources = {
let
inherit (final) fetchFromGitHub fetchgit stdenvNoCC;
openwrt = fetchFromGitHub {
name = "openwrt-source";
repo = "openwrt";
@ -38,23 +40,48 @@
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
};
kernel = fetchFromGitHub {
mainline = fetchFromGitHub {
name = "kernel-source";
owner = "torvalds";
repo = "linux";
rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19
hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4=";
rev = "90c7e9b400c751dbd73885f494f421f90ca69721";
hash = "sha256-pq6QNa0PJVeheaZkuvAPD0rLuEeKrViKk65dz+y4kqo=";
};
in {
sources = {
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";

View file

@ -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;
};
}

View file

@ -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
'';