From 2e57450a26363bb229fc50e154ca2ab47b84575e Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Sat, 27 Jan 2024 17:47:47 +0100 Subject: [PATCH] Create tplink-safeloader image --- devices/tp-archer-ax23/default.nix | 4 ++-- modules/outputs.nix | 3 +++ modules/outputs/tplink.nix | 30 ++++++++++++++++++++++++++++++ pkgs/default.nix | 3 ++- pkgs/firmware-utils/default.nix | 24 ++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 modules/outputs/tplink.nix create mode 100644 pkgs/firmware-utils/default.nix diff --git a/devices/tp-archer-ax23/default.nix b/devices/tp-archer-ax23/default.nix index bf9f381..005c51b 100644 --- a/devices/tp-archer-ax23/default.nix +++ b/devices/tp-archer-ax23/default.nix @@ -36,7 +36,7 @@ imports = [ ../../modules/arch/mipsel.nix ../../modules/outputs/tftpboot.nix - ../../modules/outputs/ubifs.nix + ../../modules/outputs/tplink.nix ]; config = { kernel = { @@ -400,7 +400,7 @@ ZSTD_DECOMPRESS="y"; # openwrt-23.05.2-ramips-mt7621-tplink_archer-ax23-v1-squashfs-sysupgrade.bin: u-boot legacy uImage, MIPS OpenWrt Linux-5.15.137, Linux/MIPS, OS Kernel Image (lzma), 2797386 bytes, Tue Nov 14 13:38:11 2023, Load Address: 0X80001000, Entry Point: 0X80001000, Header CRC: 0X19F74C5B, Data CRC: 0XF685563C loadAddress = lim.parseInt "0x80001000"; entryPoint = lim.parseInt "0x80001000"; - rootDevice = "ubi0:liminix"; + rootDevice = "/dev/mtdblock3"; dts = { src = "${openwrt.src}/target/linux/ramips/dts/mt7621_tplink_archer-ax23-v1.dts"; includes = [ diff --git a/modules/outputs.nix b/modules/outputs.nix index fb7c20b..6d80d5e 100644 --- a/modules/outputs.nix +++ b/modules/outputs.nix @@ -60,6 +60,9 @@ in Combined kernel and FDT in uImage (U-Boot compatible) format ''; }; + tplink = mkOption { + type = types.package; + }; u-boot = mkOption { type = types.package; }; diff --git a/modules/outputs/tplink.nix b/modules/outputs/tplink.nix new file mode 100644 index 0000000..61cb8ac --- /dev/null +++ b/modules/outputs/tplink.nix @@ -0,0 +1,30 @@ +{ + config +, pkgs +, lib +, ... +}: +let + inherit (lib) mkOption types concatStringsSep; + o = config.system.outputs; +in { + options.system.outputs = { + tplink = mkOption { + type = types.package; + description = '' + tplink + ****** + + For creating tp-link 'safeloader' images + ''; + }; + }; + config = { + system.outputs = rec { + tplink = + pkgs.runCommand "tplink" { nativeBuildInputs = with pkgs.pkgsBuildBuild; [ firmware-utils ]; } '' + tplink-safeloader -B ARCHER-AX23-V1 -k "${o.uimage}" -r "${o.rootfs}" -o $out + ''; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 823d560..97d15b9 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -58,7 +58,8 @@ in { anoia = callPackage ./anoia {}; fennel = callPackage ./fennel {}; fennelrepl = callPackage ./fennelrepl {}; - firewallgen = callPackage ./firewallgen {}; + firewallgen = callPackage ./firewallgen {}; + firmware-utils = callPackage ./firmware-utils {}; gen_init_cpio = callPackage ./gen_init_cpio {}; go-l2tp = callPackage ./go-l2tp {}; hi = callPackage ./hi {}; diff --git a/pkgs/firmware-utils/default.nix b/pkgs/firmware-utils/default.nix new file mode 100644 index 0000000..5c8e1f3 --- /dev/null +++ b/pkgs/firmware-utils/default.nix @@ -0,0 +1,24 @@ +{ stdenv +, fetchFromGitHub +, cmake +, zlib +, openssl +}: + +stdenv.mkDerivation { + pname = "firmware-utils"; + version = "snapshot"; + + src = fetchFromGitHub { + owner = "openwrt"; + repo = "firmware-utils"; + rev = "e87f23849790a7c77b4cd0e8ef0384da188174e5"; + hash = "sha256-285Isf9sRuUt5S56SozgqpnS0+LOfnvpxpnWLwuWYUk="; + }; + + nativeBuildInputs = [ + cmake + zlib + openssl + ]; +}