From d83bcc643ea21db3b6ca1bbdcd34414c96dab69f Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 10 Mar 2023 00:48:47 +0000 Subject: [PATCH] add wifi firmware, move things around in ram * at the base address we were using, the filesystem was getting corrupted presumably because the kernel unpacked into it * leave a little more space between compressed kernel and squashfs. this is probably ineffective but also harmless --- devices/gl-mt300n-v2/default.nix | 17 ++++++++++++++++- modules/tftpboot.nix | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/devices/gl-mt300n-v2/default.nix b/devices/gl-mt300n-v2/default.nix index 140569b..d9bc0cc 100644 --- a/devices/gl-mt300n-v2/default.nix +++ b/devices/gl-mt300n-v2/default.nix @@ -15,6 +15,8 @@ let inherit (pkgs.liminix.networking) interface; inherit (pkgs.liminix.services) oneshot; + inherit (pkgs.pseudofile) dir symlink; + openwrt = pkgs.fetchFromGitHub { name = "openwrt-source"; repo = "openwrt"; @@ -26,7 +28,18 @@ drivers = ["mt7603e"]; klibBuild = config.outputs.kernel.modulesupport; }; + wlan_firmware = builtins.fetchurl { + url = "https://github.com/openwrt/mt76/raw/f24b56f935392ca1d35fae5fd6e56ef9deda4aad/firmware/mt7628_e2.bin"; + sha256 = "sha256:1dkhfznmdz6s50kwc841x3wj0h6zg6icg5g2bim9pvg66as2vmh9"; + }; in { + filesystem = dir { + lib = dir { + firmware = dir { + "mt7628_e2.bin" = symlink wlan_firmware; + }; + }; + }; hardware = { defaultOutput = "tftproot"; loadAddress = "0x80000000"; @@ -77,7 +90,9 @@ }; }; boot.tftp = { - loadAddress = "0x00A00000"; + # 20MB seems to give enough room to uncompress the kernel + # without anything getting trodden on. 10MB was too small + loadAddress = "0x1400000"; }; kernel = { diff --git a/modules/tftpboot.nix b/modules/tftpboot.nix index d8e1ca2..fda301f 100644 --- a/modules/tftpboot.nix +++ b/modules/tftpboot.nix @@ -62,7 +62,7 @@ in { in pkgs.buildPackages.runCommand "" {} '' uimageSize=$(($(stat -L -c %s ${config.outputs.uimage}) + 0x1000 &(~0xfff))) - squashfsStart=0x$(printf %x $((${cfg.loadAddress} + $uimageSize))) + squashfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize))) squashfsBytes=$(($(stat -L -c %s ${config.outputs.squashfs}) + 0x100000 &(~0xfffff))) squashfsMb=$(($squashfsBytes >> 20)) cmd="mtdparts=phram0:''${squashfsMb}M(nix) phram.phram=phram0,''${squashfsStart},''${squashfsMb}Mi memmap=''${squashfsMb}M\$''${squashfsStart} root=1f00";