ath9k-htc-blobless-firmware: init at 1.4.0

This firmware is completely open source with no blobs, which is
quite rare in the wifi world. Wifi chips have their own dedicated
general-purpose CPUs. This source code allows you to see what those
CPUs are doing and modify their behavior.

When the upstream repository was created in 2013, "open source
firmware" meant "firmware which is open source". In 2023 that is no
longer the generally accepted [definition], so I have chosen an
unambiguous adjective (whose meaning has remained stable for
decades) to use in the pname.

[definition]: https://web.archive.org/web/20221209121315/https://www.opencompute.org/projects/open-system-firmware#:~:text=Another,allows%20it

Co-authored-by: Artturi <Artturin@artturin.com>

+203
+147
pkgs/os-specific/linux/firmware/ath9k/default.nix
··· 1 + { lib 2 + , stdenv 3 + , fetchurl 4 + , fetchFromGitHub 5 + , m4 6 + , cmake 7 + , perl 8 + , writeScript 9 + , enableUnstable ? false 10 + }: 11 + 12 + stdenv.mkDerivation (finalAttrs: { 13 + pname = "ath9k-htc-blobless-firmware"; 14 + version = if enableUnstable then "unstable-2022-05-22" else "1.4.0"; 15 + 16 + src = fetchFromGitHub ({ 17 + owner = "qca"; 18 + repo = "open-ath9k-htc-firmware"; 19 + } // (if enableUnstable then { 20 + rev = "d856466a068afe4069335257c0d28295ff777d92"; 21 + hash = "sha256-9OE6qYGABeXjf1r/Depd+811EJ2e8I0Ni5ePHSOh9G4="; 22 + } else { 23 + rev = finalAttrs.version; 24 + hash = "sha256-Q/A0ryIC5E1pt2Sh7o79gxHbe4OgdlrwflOWtxWSS5o="; 25 + })); 26 + 27 + postPatch = '' 28 + patchShebangs target_firmware/firmware-crc.pl 29 + ''; 30 + 31 + nativeBuildInputs = [ m4 cmake perl ]; 32 + 33 + NIX_CFLAGS_COMPILE = "-w"; # old libiberty emits fatal warnings 34 + 35 + dontUseCmakeConfigure = true; 36 + enableParallelBuilding = true; 37 + 38 + # The firmware repository builds its own toolchain, with patches 39 + # applied to the xtensa support in both gcc and binutils. 40 + preBuild = 41 + let 42 + inherit (lib) toUpper splitString last listToAttrs pipe; 43 + inherit (builtins) map; 44 + urls-and-hashes = import ./urls-and-hashes-${finalAttrs.version}.nix; 45 + make-links = pipe 46 + [ "gcc" "binutils" "gmp" "mpfr" "mpc" ] 47 + [ (map (vname: fetchurl rec { 48 + url = urls-and-hashes."${(toUpper vname) + "_URL"}"; 49 + sha256 = urls-and-hashes."${(toUpper vname) + "_SUM"}" or ""; 50 + name = last (splitString "/" url); 51 + })) 52 + (map (v: "ln -sT ${v} toolchain/dl/${v.name}")) 53 + (lib.concatStringsSep "\n") 54 + ]; 55 + in '' 56 + mkdir -p toolchain/dl 57 + ${make-links} 58 + ''; 59 + 60 + makeTargets = [ "toolchain" "firmware" ]; 61 + 62 + installPhase = '' 63 + runHook preInstall 64 + install -Dt $out/lib/firmware/ath9k_htc/ target_firmware/*.fw 65 + runHook postInstall 66 + ''; 67 + 68 + passthru = { 69 + inherit (finalAttrs) src; 70 + updateScript = writeScript "${finalAttrs.pname}-${finalAttrs.version}-updateScript" '' 71 + nix-shell '<nixpkgs>' -A ${finalAttrs.pname}${lib.optionalString enableUnstable "-unstable"}.passthru.update \ 72 + > pkgs/os-specific/linux/firmware/ath9k/urls-and-hashes-${finalAttrs.version}.nix 73 + ''; 74 + update = stdenv.mkDerivation { 75 + name = "${finalAttrs.pname}-${finalAttrs.version}-update"; 76 + shellHook = '' 77 + echo 'rec {' 78 + echo ' BASEDIR="$NIX_BUILD_TOP";' 79 + make --dry-run --print-data-base -f ${finalAttrs.src}/Makefile download \ 80 + | egrep '^[A-Z]+_(VER|URL|SUM|DIR) = ' \ 81 + | sed 's_\([^ ]*\) = \(.*\)_\1 = "\2\";_' \ 82 + | tr \( \{ \ 83 + | tr \) \} 84 + '' 85 + # sha256 checksums were not added to upstream's Makefile until 86 + # after the 1.4.0 release. The following line is needed for 87 + # the `enableUnstable==false` build but not for the 88 + # `enableUnstable==true` build. We can remove the lines below 89 + # as soon as `enableUnstable==false` points to a version 90 + # greater than 1.4.0. 91 + + lib.optionalString (finalAttrs.version == "1.4.0") '' 92 + echo 'GCC_SUM = "sha256-kuYcbcOgpEnmLXKjgYX9pVAWioZwLeoHEl69PsOZYoI=";' 93 + echo 'MPFR_SUM = "sha256-e2bD8T3IOF8IJkyAWFPz4aju2rgHHVgvPmYZccms1f0=";' 94 + echo 'MPC_SUM = "sha256-7VqBXP6lJdx3jfDLN0aLnBtVSq8w2TKLFDHKcFt0AP8=";' 95 + echo 'GMP_SUM = "sha256-H1iKrMxBu5rtlG+f44Uhwm2LKQ0APF34B/ZWkPKq3sk=";' 96 + echo 'BINUTILS_SUM = "sha256-KrLlsD4IbRLGKV+DGtrUaz4UEKOiNJM6Lo+sZssuehk=";' 97 + '' + '' 98 + echo '}' 99 + exit 100 + ''; 101 + }; 102 + }; 103 + 104 + meta = { 105 + description = "Blobless, open source wifi firmware for ath9k_htc.ko"; 106 + longDescription = '' 107 + Firmware for Qualcomm Atheros cards which use the ath9k_htc.ko 108 + Linux driver, supporting 802.11 abgn on both 2.4ghz and 5ghz 109 + bands, 3x3-antenna MIMO, up to 600mbit/sec. 110 + 111 + Most devices which use this driver are based on the Qualcomm 112 + Atheros AR9271 chip, which is a PCIe device. If your device 113 + is connected via USB, it will also include a Qualcomm Atheros 114 + AR7010, which bridges from a USB gadget interface to a PCIe 115 + host interface. This repository includes the firmware for 116 + both chips. 117 + 118 + This firmware is completely open source with no blobs, which 119 + is quite rare in the wifi world. Wifi chips have their own 120 + dedicated general-purpose CPUs. This source code allows you 121 + to see what those CPUs are doing and modify their behavior. 122 + ''; 123 + license = with lib.licenses; [ # see NOTICE.txt for details 124 + bsd3 # almost everything; "the ClearBSD licence" 125 + gpl2ClasspathPlus # **/*cmnos_printf.c, only three files 126 + mit # **/xtos, **/xtensa 127 + ]; 128 + 129 + # release 1.4.0 vendors a GMP which uses an ancient version of 130 + # autotools that does not work on aarch64 or powerpc. 131 + # However, enableUnstable (unreleased upstream) works. 132 + /* 133 + # disabled until #195294 is merged 134 + badPlatforms = 135 + with lib.systems.inspect.patterns; 136 + lib.optionals (!enableUnstable && lib.versionOlder finalAttrs.version "1.4.1") [ 137 + isAarch64 138 + isPower64 139 + ]; 140 + */ 141 + 142 + sourceProvenance = [ lib.sourceTypes.fromSource ]; 143 + homepage = "http://lists.infradead.org/mailman/listinfo/ath9k_htc_fw"; 144 + downloadPage = "https://github.com/qca/open-ath9k-htc-firmware"; 145 + changelog = "https://github.com/qca/open-ath9k-htc-firmware/tags"; 146 + }; 147 + })
+26
pkgs/os-specific/linux/firmware/ath9k/urls-and-hashes-1.4.0.nix
··· 1 + rec { 2 + BASEDIR="$NIX_BUILD_TOP"; 3 + BINUTILS_URL = "https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.bz2"; 4 + DL_DIR = "${TOOLCHAIN_DIR}/dl"; 5 + GMP_URL = "https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VER}.tar.bz2"; 6 + GCC_URL = "https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-${GCC_VER}.tar.bz2"; 7 + BINUTILS_DIR = "binutils-${BINUTILS_VER}"; 8 + GCC_VER = "4.7.4"; 9 + MPFR_URL = "https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VER}.tar.bz2"; 10 + MPC_VER = "1.0.1"; 11 + GMP_DIR = "gmp-${GMP_VER}"; 12 + MPC_URL = "https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VER}.tar.gz"; 13 + GCC_DIR = "gcc-${GCC_VER}"; 14 + MPFR_DIR = "mpfr-${MPFR_VER}"; 15 + MPC_DIR = "mpc-${MPC_VER}"; 16 + MPFR_VER = "3.1.1"; 17 + GMP_VER = "5.0.5"; 18 + BINUTILS_VER = "2.23.1"; 19 + BUILD_DIR = "${TOOLCHAIN_DIR}/build"; 20 + TOOLCHAIN_DIR = "${BASEDIR}/toolchain"; 21 + GCC_SUM = "sha256-kuYcbcOgpEnmLXKjgYX9pVAWioZwLeoHEl69PsOZYoI="; 22 + MPFR_SUM = "sha256-e2bD8T3IOF8IJkyAWFPz4aju2rgHHVgvPmYZccms1f0="; 23 + MPC_SUM = "sha256-7VqBXP6lJdx3jfDLN0aLnBtVSq8w2TKLFDHKcFt0AP8="; 24 + GMP_SUM = "sha256-H1iKrMxBu5rtlG+f44Uhwm2LKQ0APF34B/ZWkPKq3sk="; 25 + BINUTILS_SUM = "sha256-KrLlsD4IbRLGKV+DGtrUaz4UEKOiNJM6Lo+sZssuehk="; 26 + }
+26
pkgs/os-specific/linux/firmware/ath9k/urls-and-hashes-unstable-2022-05-22.nix
··· 1 + rec { 2 + BASEDIR="$NIX_BUILD_TOP"; 3 + BINUTILS_URL = "https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.bz2"; 4 + DL_DIR = "${TOOLCHAIN_DIR}/dl"; 5 + GMP_SUM = "f51c99cb114deb21a60075ffb494c1a210eb9d7cb729ed042ddb7de9534451ea"; 6 + GMP_URL = "https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VER}.tar.bz2"; 7 + GCC_URL = "https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-${GCC_VER}.tar.gz"; 8 + BINUTILS_DIR = "binutils-${BINUTILS_VER}"; 9 + GCC_VER = "10.2.0"; 10 + MPFR_URL = "https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VER}.tar.bz2"; 11 + MPC_VER = "1.1.0"; 12 + GMP_DIR = "gmp-${GMP_VER}"; 13 + MPC_URL = "https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VER}.tar.gz"; 14 + GCC_DIR = "gcc-${GCC_VER}"; 15 + MPC_SUM = "6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e"; 16 + GCC_SUM = "27e879dccc639cd7b0cc08ed575c1669492579529b53c9ff27b0b96265fa867d"; 17 + BINUTILS_SUM = "7d24660f87093670738e58bcc7b7b06f121c0fcb0ca8fc44368d675a5ef9cff7"; 18 + MPFR_DIR = "mpfr-${MPFR_VER}"; 19 + MPC_DIR = "mpc-${MPC_VER}"; 20 + MPFR_VER = "4.1.0"; 21 + GMP_VER = "6.2.0"; 22 + BINUTILS_VER = "2.35"; 23 + BUILD_DIR = "${TOOLCHAIN_DIR}/build"; 24 + MPFR_SUM = "feced2d430dd5a97805fa289fed3fc8ff2b094c02d05287fd6133e7f1f0ec926"; 25 + TOOLCHAIN_DIR = "${BASEDIR}/toolchain"; 26 + }
+4
pkgs/top-level/all-packages.nix
··· 25159 25159 25160 25160 audit = callPackage ../os-specific/linux/audit { }; 25161 25161 25162 + ath9k-htc-blobless-firmware = callPackage ../os-specific/linux/firmware/ath9k { }; 25163 + ath9k-htc-blobless-firmware-unstable = 25164 + callPackage ../os-specific/linux/firmware/ath9k { enableUnstable = true; }; 25165 + 25162 25166 b43Firmware_5_1_138 = callPackage ../os-specific/linux/firmware/b43-firmware/5.1.138.nix { }; 25163 25167 25164 25168 b43Firmware_6_30_163_46 = callPackage ../os-specific/linux/firmware/b43-firmware/6.30.163.46.nix { };