[PATCH 0/8] guix: Add xtensa-ath9k-elf platform.

  • Done
  • quality assurance status badge
Details
4 participants
  • Jean-Pierre De Jesus Diaz
  • Jean-Pierre De Jesus DIAZ
  • Ludovic Courtès
  • Vagrant Cascadian
Owner
unassigned
Submitted by
Jean-Pierre De Jesus DIAZ
Severity
normal
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:19 +0100
(address . guix-patches@gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
cover.1709219325.git.jean@foundationdevices.com
Hello,

As the ath9k-htc-firmware package requires a custom toolchain to build
the firmware I thought it was best to have a target for this specific
package as it modifies the default configuration of the Xtensa target in
GCC.

To work around this a new target is added: xtensa-ath9k-elf.

It uses binutils@2.33 and the patched version of GCC to properly compile
the firmware. So, as a result it allows using #:target keyword parameter
to cross-compile the firmware and avoids explicitly adding the cross
compiler in the NATIVE-INPUTS field.

As a result the ath9k-htc-firmware package was splitted into two and
uses the cmake-build-sytem now to use Guix's cross-compilation support
properly, so it removes the need for the ath9k-htc-firmware-objcopy.patch.

The [PATCH 7/8] contains a patch that was already sent to:


I don't have the hardware to test this firmware but the build produces
the same hashes for the firmware so it's safe to say that the firmware
should keep working.

The hashes with this patch series:

a5481cc67d962b217de1300121a6c7584e847cbe215442553d24a2173ca9202e /gnu/store/0i3zw28pvrr8l85fx79i8lq0f9vmgyjz-ath9k-htc-ar9271-firmware-1.4.0/lib/firmware/htc_9271.fw
eef84c16e3edad3fdec19c985d190b5ed3f5bd5bae20be5579681ab35f001406 /gnu/store/iqbd77grzy4sngkxz9lgyvk52apn8vzj-ath9k-htc-ar7010-firmware-1.4.0/lib/firmware/htc_7010.fw

And the hashes in master at commit 75bad75367fcf2c289fae3b40dbcc850f92177be:

a5481cc67d962b217de1300121a6c7584e847cbe215442553d24a2173ca9202e /gnu/store/0m45gn74b5bavxq77158i3l593lh082r-ath9k-htc-firmware-1.4.0/lib/firmware/htc_9271.fw
eef84c16e3edad3fdec19c985d190b5ed3f5bd5bae20be5579681ab35f001406 /gnu/store/0m45gn74b5bavxq77158i3l593lh082r-ath9k-htc-firmware-1.4.0/lib/firmware/htc_7010.fw

Jean-Pierre De Jesus DIAZ (8):
doc: Add documentation for x86_64-linux-gnux32.
guix: Add xtensa-ath9k-elf platform.
gnu: ath9k-htc-firmware: Remove binary blobs.
gnu: ath9k-htc-firmware: Allow using other targets.
gnu: ath9k-htc-firmware: Use xtensa-ath9k-elf.
gnu: cross-binutils: Use binutils-2.33 for ath9k.
guix: cmake-build-system: Handle unknown systems.
gnu: ath9k-htc-firmware: Split package.

Makefile.am | 1 +
doc/guix.texi | 12 +++
gnu/local.mk | 1 -
gnu/packages/cross-base.scm | 17 +++-
gnu/packages/firmware.scm | 88 +++++++++----------
.../patches/ath9k-htc-firmware-objcopy.patch | 14 ---
gnu/system.scm | 3 +-
guix/build/cmake-build-system.scm | 10 ++-
guix/platforms/xtensa.scm | 28 ++++++
9 files changed, 105 insertions(+), 69 deletions(-)
delete mode 100644 gnu/packages/patches/ath9k-htc-firmware-objcopy.patch
create mode 100644 guix/platforms/xtensa.scm


base-commit: 75bad75367fcf2c289fae3b40dbcc850f92177be
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 1/8] doc: Add documentation for x86_64-linux-gnux32.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
2e5ffa2bd69e06e446284f3927e23604cdd4ff48.1709219325.git.jean@foundationdevices.com
* doc/guix.texi: Add documentation for x86_64-linux-gnux32.

Change-Id: I408d57ae5ae3e9b1449633b82c41aba0d40ded06
---
doc/guix.texi | 6 ++++++
1 file changed, 6 insertions(+)

Toggle diff (26 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index f6476e0d81..7153c9e7a4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -16963,6 +16963,7 @@ Cross-Compilation
- powerpc64le-linux-gnu
- riscv64-linux-gnu
- x86_64-linux-gnu
+ - x86_64-linux-gnux32
- x86_64-w64-mingw32
@end example
@@ -46732,6 +46733,11 @@ Supported Platforms
Platform targeting x86 64-bit CPU running GNU/Linux.
@end defvar
+@defvar x86_64-linux-x32
+Platform targeting x86 64-bit CPU running GNU/Linux with the run-time using
+the X32 ABI.
+@end defvar
+
@defvar i686-mingw
Platform targeting x86 CPU running Windows, with run-time support from
MinGW.
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 2/8] guix: Add xtensa-ath9k-elf platform.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
f4ed9445b4b3229f4a67242678b5ca6454cc52d7.1709219325.git.jean@foundationdevices.com
* Makefile.am (MODULES): Add guix/platforms/xtensa.scm.
* guix/platforms/xtensa.scm (xtensa-ath9k-elf): New variable.
* doc/guix.texi: Add xtensa-ath9k-elf documentation.

Change-Id: I51eef245142ed58613340c16d4bf7266e6bf6adb
---
Makefile.am | 1 +
doc/guix.texi | 6 ++++++
guix/platforms/xtensa.scm | 28 ++++++++++++++++++++++++++++
3 files changed, 35 insertions(+)
create mode 100644 guix/platforms/xtensa.scm

Toggle diff (72 lines)
diff --git a/Makefile.am b/Makefile.am
index cef972880c..df62c4e255 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -144,6 +144,7 @@ MODULES = \
guix/platforms/powerpc.scm \
guix/platforms/riscv.scm \
guix/platforms/x86.scm \
+ guix/platforms/xtensa.scm \
guix/build-system.scm \
guix/build-system/agda.scm \
guix/build-system/android-ndk.scm \
diff --git a/doc/guix.texi b/doc/guix.texi
index 7153c9e7a4..d3db1ee03d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -16965,6 +16965,7 @@ Cross-Compilation
- x86_64-linux-gnu
- x86_64-linux-gnux32
- x86_64-w64-mingw32
+ - xtensa-ath9k-elf
@end example
Targets are specified as GNU triplets (@pxref{Specifying Target
@@ -46763,6 +46764,11 @@ Supported Platforms
C standard library.
@end defvar
+@defvar xtensa-ath9k-elf
+Platform targeting Xtensa CPU used in the Qualcomm Atheros AR7010 and AR9271
+USB 802.11n @acronym{NICs, Network Interface Controllers}.
+@end defvar
+
@node System Images
@chapter Creating System Images
diff --git a/guix/platforms/xtensa.scm b/guix/platforms/xtensa.scm
new file mode 100644
index 0000000000..304e23ab1a
--- /dev/null
+++ b/guix/platforms/xtensa.scm
@@ -0,0 +1,28 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2024 Foundation Devices, Inc. <hello@foundationdevices.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix platforms xtensa)
+ #:use-module (guix platform)
+ #:use-module (guix records)
+ #:export (xtensa-ath9k-elf))
+
+(define xtensa-ath9k-elf
+ (platform
+ (target "xtensa-ath9k-elf")
+ (system #f)
+ (glibc-dynamic-linker #f)))
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 3/8] gnu: ath9k-htc-firmware: Remove binary blobs.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
2b663798ff1173bd03fde668c163ad72d014289e.1709219325.git.jean@foundationdevices.com
* gnu/packages/firmware.scm (ath9k-htc-firmware) <source>: Add snippet
to remove bundled binary files.

Change-Id: I2f0592d03039ff9d5a5f3a79b0c62566164f3762
---
gnu/packages/firmware.scm | 4 ++++
1 file changed, 4 insertions(+)

Toggle diff (17 lines)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 828bc7402a..a9f218eb9f 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -99,6 +99,10 @@ (define-public ath9k-htc-firmware
(uri (git-reference
(url "https://github.com/qca/open-ath9k-htc-firmware")
(commit version)))
+ (modules '((guix build utils)))
+ (snippet
+ ;; Delete binary blobs.
+ #~(for-each delete-file (find-files "." "\\.(a|o)$")))
(sha256
(base32
"16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 4/8] gnu: ath9k-htc-firmware: Allow using other targets.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
80cd4e5f5c0944ab4d0a420481071ef4e792b9e7.1709219325.git.jean@foundationdevices.com
* gnu/packages/firmware.scm (ath9k-htc-firmware): Override the TARGET
environment variable in the configure script to use xtensa-elf.
* gnu/packages/patches/ath9k-htc-firmware-objcopy.patch: Adapt to use
TARGET environment variable for objcopy.

Change-Id: Ia44f0f25dde532b90168f2f2456412a43ac9af24
---
gnu/packages/firmware.scm | 1 +
gnu/packages/patches/ath9k-htc-firmware-objcopy.patch | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)

Toggle diff (34 lines)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index a9f218eb9f..da7835a95d 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -121,6 +121,7 @@ (define-public ath9k-htc-firmware
;; 'configure' is a simple script that runs 'cmake' with
;; the right flags.
(substitute* "configure"
+ (("^TARGET.*$") "TARGET=xtensa-elf\n")
(("^TOOLCHAIN=.*$")
(string-append "TOOLCHAIN="
(assoc-ref (or native-inputs inputs) "cross-gcc")
diff --git a/gnu/packages/patches/ath9k-htc-firmware-objcopy.patch b/gnu/packages/patches/ath9k-htc-firmware-objcopy.patch
index 2172f8353f..13c3ca1413 100644
--- a/gnu/packages/patches/ath9k-htc-firmware-objcopy.patch
+++ b/gnu/packages/patches/ath9k-htc-firmware-objcopy.patch
@@ -1,5 +1,5 @@
The firmware is cross-compiled, but the build system ends up using
-'objcopy' instead of 'xtensa-elf-objcopy' by default. Force it to
+'objcopy' instead of '$TARGET-objcopy' by default. Force it to
use the right one.
--- source/target_firmware/configure 2014-10-28 20:57:26.834436561 +0100
@@ -8,7 +8,7 @@ use the right one.
cat > "$TOOLCHAIN_FILE" <<EOF
INCLUDE(CMakeForceCompiler)
-+SET(CMAKE_OBJCOPY xtensa-elf-objcopy)
++SET(CMAKE_OBJCOPY ${TARGET}-objcopy)
SET(CMAKE_SYSTEM_PROCESSOR xtensa)
SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/$TARGET)
SET(CMAKE_STRIP :)
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 5/8] gnu: ath9k-htc-firmware: Use xtensa-ath9k-elf.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
51b3861e69dc0ab0e52692448e9280a364a3397e.1709219325.git.jean@foundationdevices.com
* gnu/packages/firmware.scm (ath9k-htc-firmware): Use the
xtensa-ath9k-elf target for the cross toolchain.

Change-Id: Ic1a7c4088312290a86a508f371f4f0e784e301a5
---
gnu/packages/cross-base.scm | 4 ++--
gnu/packages/firmware.scm | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)

Toggle diff (46 lines)
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 2d79e0acf6..93383089e5 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -118,8 +118,8 @@ (define* (cross-binutils* target #:key (binutils binutils))
;; target libs, not native libs, so this is safe.
`(cons "--with-sysroot=/" ,flags)))))))
- ;; For Xtensa, apply Qualcomm's patch.
- (cross (cond ((string-prefix? "xtensa-" target)
+ ;; For xtensa-ath9k-elf, apply Qualcomm's patch.
+ (cross (cond ((string=? target "xtensa-ath9k-elf")
(package-with-patches binutils
(search-patches
"ath9k-htc-firmware-binutils.patch")))
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index da7835a95d..6993925387 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -121,7 +121,7 @@ (define-public ath9k-htc-firmware
;; 'configure' is a simple script that runs 'cmake' with
;; the right flags.
(substitute* "configure"
- (("^TARGET.*$") "TARGET=xtensa-elf\n")
+ (("^TARGET.*$") "TARGET=xtensa-ath9k-elf\n")
(("^TOOLCHAIN=.*$")
(string-append "TOOLCHAIN="
(assoc-ref (or native-inputs inputs) "cross-gcc")
@@ -140,12 +140,12 @@ (define-public ath9k-htc-firmware
;; The firmware is cross-compiled using a "bare bones" compiler (no libc.)
;; Use our own tool chain for that.
(native-inputs `(("cross-gcc" ,(cross-gcc
- "xtensa-elf"
+ "xtensa-ath9k-elf"
#:xbinutils (cross-binutils
- "xtensa-elf"
+ "xtensa-ath9k-elf"
#:binutils binutils-2.33)))
("cross-binutils" ,(cross-binutils
- "xtensa-elf"
+ "xtensa-ath9k-elf"
#:binutils binutils-2.33))
("cmake" ,cmake-minimal)
("perl" ,perl)))
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 6/8] gnu: cross-binutils: Use binutils-2.33 for ath9k.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
4f6ab97323db3c8dfe2d5f40d5fe0811a21d4e58.1709219325.git.jean@foundationdevices.com
* gnu/packages/cross-base.scm (cross-binutils-package): New procedure.
* gnu/packages/cross-base.scm (cross-binutils): Select binutils default
value with cross-binutils-package.
* gnu/packages/firmware.scm (ath9k-htc-firmware) <native-inputs>: Do not
explicitly set the #:xbinutils keyword argument.

Change-Id: I0eb25eb2b494241c205286837bfa79a61de8e0b7
---
gnu/packages/cross-base.scm | 13 ++++++++++++-
gnu/packages/firmware.scm | 10 ++--------
2 files changed, 14 insertions(+), 9 deletions(-)

Toggle diff (47 lines)
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 93383089e5..d275ae894d 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -97,7 +97,18 @@ (define* (cross-binutils/deprecated target #:optional (binutils binutils))
(warning (G_ "'cross-binutils' must be used with keyword arguments~%"))
(cross-binutils* target #:binutils binutils))
-(define* (cross-binutils* target #:key (binutils binutils))
+(define (cross-binutils-package target)
+ "Returns the default package to use for a cross-Binutils for TARGET."
+ (cond
+ ;; The xtensa-ath9k-elf target is used solely to build the firmware for
+ ;; ath9k devices, the patches to binutils have not been updated and
+ ;; only apply to binutils@2.33.
+ ((string=? target "xtensa-ath9k-elf") binutils-2.33)
+ (else binutils)))
+
+(define* (cross-binutils* target
+ #:key
+ (binutils (cross-binutils-package target)))
"Return a cross-Binutils for TARGET using BINUTILS."
(let ((binutils (package
(inherit binutils)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 6993925387..ad687d1de6 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -139,14 +139,8 @@ (define-public ath9k-htc-firmware
;; The firmware is cross-compiled using a "bare bones" compiler (no libc.)
;; Use our own tool chain for that.
- (native-inputs `(("cross-gcc" ,(cross-gcc
- "xtensa-ath9k-elf"
- #:xbinutils (cross-binutils
- "xtensa-ath9k-elf"
- #:binutils binutils-2.33)))
- ("cross-binutils" ,(cross-binutils
- "xtensa-ath9k-elf"
- #:binutils binutils-2.33))
+ (native-inputs `(("cross-gcc" ,(cross-gcc "xtensa-ath9k-elf"))
+ ("cross-binutils" ,(cross-binutils "xtensa-ath9k-elf"))
("cmake" ,cmake-minimal)
("perl" ,perl)))
(home-page "https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc")
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 7/8] guix: cmake-build-system: Handle unknown systems.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
4d426a20ba51e666b481324ff6300ad2af98a5f3.1709219325.git.jean@foundationdevices.com
* guix/build/cmake-build-system.scm (configure): Use Generic as the
system name if the system is unknown.

Change-Id: Ifd4a618ef67eb420b02d48f05291571aea44e46e
---
guix/build/cmake-build-system.scm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

Toggle diff (23 lines)
diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
index d1ff5071be..0774124c95 100644
--- a/guix/build/cmake-build-system.scm
+++ b/guix/build/cmake-build-system.scm
@@ -69,9 +69,13 @@ (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
target "-gcc")
(string-append "-DCMAKE_CXX_COMPILER="
target "-g++")
- (if (string-contains target "mingw")
- "-DCMAKE_SYSTEM_NAME=Windows"
- "-DCMAKE_SYSTEM_NAME=Linux"))
+ (cond
+ ((string-contains target "mingw")
+ "-DCMAKE_SYSTEM_NAME=Windows")
+ ((string-contains target "linux")
+ "-DCMAKE_SYSTEM_NAME=Linux")
+ (else
+ "-DCMAKE_SYSTEM_NAME=Generic")))
'())
,@configure-flags)))
(format #t "running 'cmake' with arguments ~s~%" args)
--
2.41.0
J
J
Jean-Pierre De Jesus DIAZ wrote on 29 Feb 16:20 +0100
[PATCH 8/8] gnu: ath9k-htc-firmware: Split package.
(address . 69476@debbugs.gnu.org)(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
92203e11d48f408c58b562151b09e5bb376ab62f.1709219325.git.jean@foundationdevices.com
* gnu/local.mk (dist_patch_DATA): Remove ath9k-htc-firmware-objcopy.patch.
* gnu/packages/firmware.scm (ath9k-htc-firmware): Remove variable.
* gnu/packages/firmware.scm (ath9k-htc-ar7010-firmware): New variable.
* gnu/packages/firmware.scm (ath9k-htc-ar9271-firmware): New variable.
* gnu/packages/patches/ath9k-htc-firmware-objcopy.patch: Delete file.
* gnu/system.scm (%base-firmware): Use new ath9k packages.

Change-Id: I86259e398427abd139c1f310a95bb15e2c03cee3
---
gnu/local.mk | 1 -
gnu/packages/firmware.scm | 79 +++++++++----------
.../patches/ath9k-htc-firmware-objcopy.patch | 14 ----
gnu/system.scm | 3 +-
4 files changed, 39 insertions(+), 58 deletions(-)
delete mode 100644 gnu/packages/patches/ath9k-htc-firmware-objcopy.patch

Toggle diff (158 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 725093fb09..70d2e99481 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -941,7 +941,6 @@ dist_patch_DATA = \
%D%/packages/patches/ath9k-htc-firmware-binutils.patch \
%D%/packages/patches/ath9k-htc-firmware-gcc.patch \
%D%/packages/patches/ath9k-htc-firmware-gcc-compat.patch \
- %D%/packages/patches/ath9k-htc-firmware-objcopy.patch \
%D%/packages/patches/atlas-gfortran-compat.patch \
%D%/packages/patches/audacity-ffmpeg-fallback.patch \
%D%/packages/patches/audiofile-fix-datatypes-in-tests.patch \
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index ad687d1de6..47d4c08b0d 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -37,6 +37,7 @@ (define-module (gnu packages firmware)
#:use-module (guix utils)
#:use-module (guix git-download)
#:use-module (guix build-system copy)
+ #:use-module (guix build-system cmake)
#:use-module (guix build-system gnu)
#:use-module (guix build-system meson)
#:use-module (guix build-system python)
@@ -90,9 +91,9 @@ (define-module (gnu packages firmware)
#:export (make-ergodox-firmware
make-qmk-firmware))
-(define-public ath9k-htc-firmware
+(define-public ath9k-htc-ar7010-firmware
(package
- (name "ath9k-htc-firmware")
+ (name "ath9k-htc-ar7010-firmware")
(version "1.4.0")
(source (origin
(method git-fetch)
@@ -106,51 +107,45 @@ (define-public ath9k-htc-firmware
(sha256
(base32
"16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
- (file-name (git-file-name name version))
- (patches (search-patches "ath9k-htc-firmware-objcopy.patch"
- "ath9k-htc-firmware-gcc-compat.patch"))))
- (build-system gnu-build-system)
+ (file-name (git-file-name "open-ath9k-htc-firmware" version))
+ (patches (search-patches "ath9k-htc-firmware-gcc-compat.patch"))))
+ (build-system cmake-build-system)
(arguments
- '(#:target #f ; Package produces firmware.
- #:phases
- (modify-phases %standard-phases
- (add-before 'configure 'pre-configure
- (lambda* (#:key inputs native-inputs #:allow-other-keys)
- (chdir "target_firmware")
-
- ;; 'configure' is a simple script that runs 'cmake' with
- ;; the right flags.
- (substitute* "configure"
- (("^TARGET.*$") "TARGET=xtensa-ath9k-elf\n")
- (("^TOOLCHAIN=.*$")
- (string-append "TOOLCHAIN="
- (assoc-ref (or native-inputs inputs) "cross-gcc")
- "\n")))
- #t))
- (replace 'install
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (fw-dir (string-append out "/lib/firmware")))
- (for-each (lambda (file)
- (install-file file fw-dir))
- (find-files "." "\\.fw$"))
- #t))))
- #:tests? #f))
-
- ;; The firmware is cross-compiled using a "bare bones" compiler (no libc.)
- ;; Use our own tool chain for that.
- (native-inputs `(("cross-gcc" ,(cross-gcc "xtensa-ath9k-elf"))
- ("cross-binutils" ,(cross-binutils "xtensa-ath9k-elf"))
- ("cmake" ,cmake-minimal)
- ("perl" ,perl)))
+ (list #:target "xtensa-ath9k-elf"
+ #:tests? #f
+ #:configure-flags #~'("-DTARGET_MAGPIE=ON")
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-before 'configure 'change-directory
+ (lambda _
+ (chdir "target_firmware")))
+ (replace 'install
+ (lambda _
+ (let ((fw-dir (string-append #$output "/lib/firmware")))
+ (for-each (lambda (file)
+ (install-file file fw-dir))
+ (find-files "." "\\.fw$"))))))))
+ (native-inputs (list perl))
(home-page "https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc")
- (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs")
+ (synopsis "Firmware for the Atheros AR7010 USB 802.11n NICs")
(description
- "This is the firmware for the Qualcomm Atheros AR7010 and AR9271 USB
-802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of
-Linux-libre.")
+ "This is the firmware for the Qualcomm Atheros AR7010 802.11n USB NICs
+(aka Wi-Fi USB dongle). It is used by the ath9k driver of Linux-libre.")
(license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
+(define-public ath9k-htc-ar9271-firmware
+ (package
+ (inherit ath9k-htc-ar7010-firmware)
+ (name "ath9k-htc-ar9271-firmware")
+ (arguments
+ (substitute-keyword-arguments
+ (package-arguments ath9k-htc-ar7010-firmware)
+ ((#:configure-flags flags) #~'("-DTARGET_K2=ON"))))
+ (synopsis "Firmware for the Atheros AR9271 USB 802.11n NICs")
+ (description
+ "This is the firmware for the Qualcomm Atheros AR9271 802.11n USB NICs
+(aka Wi-Fi USB dongle). It is used by the ath9k driver of Linux-libre.")))
+
(define-public b43-tools
(let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
(revision "1"))
diff --git a/gnu/packages/patches/ath9k-htc-firmware-objcopy.patch b/gnu/packages/patches/ath9k-htc-firmware-objcopy.patch
deleted file mode 100644
index 13c3ca1413..0000000000
--- a/gnu/packages/patches/ath9k-htc-firmware-objcopy.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-The firmware is cross-compiled, but the build system ends up using
-'objcopy' instead of '$TARGET-objcopy' by default. Force it to
-use the right one.
-
---- source/target_firmware/configure 2014-10-28 20:57:26.834436561 +0100
-+++ source/target_firmware/configure 2014-10-28 20:57:29.666436530 +0100
-@@ -11,6 +11,7 @@ mkdir -p build
- cat > "$TOOLCHAIN_FILE" <<EOF
- INCLUDE(CMakeForceCompiler)
-
-+SET(CMAKE_OBJCOPY ${TARGET}-objcopy)
- SET(CMAKE_SYSTEM_PROCESSOR xtensa)
- SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/$TARGET)
- SET(CMAKE_STRIP :)
diff --git a/gnu/system.scm b/gnu/system.scm
index aede35775e..927abc642c 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -876,7 +876,8 @@ (define* (operating-system-with-provenance os
(define %base-firmware
;; Firmware usable by default.
- (list ath9k-htc-firmware
+ (list ath9k-htc-ar7010-firmware
+ ath9k-htc-ar9271-firmware
openfwwf-firmware))
(define %base-packages-artwork
--
2.41.0
V
V
Vagrant Cascadian wrote on 26 Mar 07:17 +0100
Re: [bug#69476] [PATCH 0/8] guix: Add xtensa-ath9k-elf platform.
(name . Efraim Flashner)(address . efraim@flashner.co.il)
877chptt2m.fsf@wireframe
On 2024-02-29, Jean-Pierre De Jesus DIAZ wrote:
Toggle quote (12 lines)
> As the ath9k-htc-firmware package requires a custom toolchain to build
> the firmware I thought it was best to have a target for this specific
> package as it modifies the default configuration of the Xtensa target in
> GCC.
>
> To work around this a new target is added: xtensa-ath9k-elf.
>
> It uses binutils@2.33 and the patched version of GCC to properly compile
> the firmware. So, as a result it allows using #:target keyword parameter
> to cross-compile the firmware and avoids explicitly adding the cross
> compiler in the NATIVE-INPUTS field.

I am not in a position to evaluate the correctness of the proposed
toolchain changes, but conceptually it makes sense.


Toggle quote (4 lines)
> As a result the ath9k-htc-firmware package was splitted into two and
> uses the cmake-build-sytem now to use Guix's cross-compilation support
> properly, so it removes the need for the ath9k-htc-firmware-objcopy.patch.

This makes sense to me too.


Toggle quote (4 lines)
> The [PATCH 7/8] contains a patch that was already sent to:
>
> https://issues.guix.gnu.org/68366

Ok, one of these two patch series will need to be refactored depending
on which gets applied first.


Toggle quote (4 lines)
> I don't have the hardware to test this firmware but the build produces
> the same hashes for the firmware so it's safe to say that the firmware
> should keep working.

I do have some of the hardware to test, though have not had a chance to
test the patches... will try to get on that.

Obviously producing identical hashes is quite compelling; this is an
excellent example of applying Reproducible Builds to refactoring code!


Toggle quote (10 lines)
> The hashes with this patch series:
>
> a5481cc67d962b217de1300121a6c7584e847cbe215442553d24a2173ca9202e /gnu/store/0i3zw28pvrr8l85fx79i8lq0f9vmgyjz-ath9k-htc-ar9271-firmware-1.4.0/lib/firmware/htc_9271.fw
> eef84c16e3edad3fdec19c985d190b5ed3f5bd5bae20be5579681ab35f001406 /gnu/store/iqbd77grzy4sngkxz9lgyvk52apn8vzj-ath9k-htc-ar7010-firmware-1.4.0/lib/firmware/htc_7010.fw
>
> And the hashes in master at commit 75bad75367fcf2c289fae3b40dbcc850f92177be:
>
> a5481cc67d962b217de1300121a6c7584e847cbe215442553d24a2173ca9202e /gnu/store/0m45gn74b5bavxq77158i3l593lh082r-ath9k-htc-firmware-1.4.0/lib/firmware/htc_9271.fw
> eef84c16e3edad3fdec19c985d190b5ed3f5bd5bae20be5579681ab35f001406 /gnu/store/0m45gn74b5bavxq77158i3l593lh082r-ath9k-htc-firmware-1.4.0/lib/firmware/htc_7010.fw

Yay!


live well,
vagrant
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQRlgHNhO/zFx+LkXUXcUY/If5cWqgUCZgJokQAKCRDcUY/If5cW
qr+3AP9VDVNaqDazgeB8r22is0+syNKOAKkxj/S0/AalqJWebAD+K31zzwsdNcTa
K7GYAbaGquHSgmf0GZugSivOUaA4Ygs=
=uKq2
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 17 Apr 11:22 +0200
(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)
87wmowibsr.fsf@gnu.org
Hi Jean-Pierre,

Looks like this patch series had fallen through the cracks.

Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com> skribis:

Toggle quote (20 lines)
> As the ath9k-htc-firmware package requires a custom toolchain to build
> the firmware I thought it was best to have a target for this specific
> package as it modifies the default configuration of the Xtensa target in
> GCC.
>
> To work around this a new target is added: xtensa-ath9k-elf.
>
> It uses binutils@2.33 and the patched version of GCC to properly compile
> the firmware. So, as a result it allows using #:target keyword parameter
> to cross-compile the firmware and avoids explicitly adding the cross
> compiler in the NATIVE-INPUTS field.
>
> As a result the ath9k-htc-firmware package was splitted into two and
> uses the cmake-build-sytem now to use Guix's cross-compilation support
> properly, so it removes the need for the ath9k-htc-firmware-objcopy.patch.
>
> The [PATCH 7/8] contains a patch that was already sent to:
>
> https://issues.guix.gnu.org/68366

Neat.

Toggle quote (14 lines)
> I don't have the hardware to test this firmware but the build produces
> the same hashes for the firmware so it's safe to say that the firmware
> should keep working.
>
> The hashes with this patch series:
>
> a5481cc67d962b217de1300121a6c7584e847cbe215442553d24a2173ca9202e /gnu/store/0i3zw28pvrr8l85fx79i8lq0f9vmgyjz-ath9k-htc-ar9271-firmware-1.4.0/lib/firmware/htc_9271.fw
> eef84c16e3edad3fdec19c985d190b5ed3f5bd5bae20be5579681ab35f001406 /gnu/store/iqbd77grzy4sngkxz9lgyvk52apn8vzj-ath9k-htc-ar7010-firmware-1.4.0/lib/firmware/htc_7010.fw
>
> And the hashes in master at commit 75bad75367fcf2c289fae3b40dbcc850f92177be:
>
> a5481cc67d962b217de1300121a6c7584e847cbe215442553d24a2173ca9202e /gnu/store/0m45gn74b5bavxq77158i3l593lh082r-ath9k-htc-firmware-1.4.0/lib/firmware/htc_9271.fw
> eef84c16e3edad3fdec19c985d190b5ed3f5bd5bae20be5579681ab35f001406 /gnu/store/0m45gn74b5bavxq77158i3l593lh082r-ath9k-htc-firmware-1.4.0/lib/firmware/htc_7010.fw

Excellent; thanks for taking the time to check this!

(FWIW I use a WiFi dongle that relies on this firmware so you’ll soon
hear from me if something goes wrong. ;-))

Toggle quote (9 lines)
> doc: Add documentation for x86_64-linux-gnux32.
> guix: Add xtensa-ath9k-elf platform.
> gnu: ath9k-htc-firmware: Remove binary blobs.
> gnu: ath9k-htc-firmware: Allow using other targets.
> gnu: ath9k-htc-firmware: Use xtensa-ath9k-elf.
> gnu: cross-binutils: Use binutils-2.33 for ath9k.
> guix: cmake-build-system: Handle unknown systems.
> gnu: ath9k-htc-firmware: Split package.

Applied, thanks!

Ludo’.
Closed
L
L
Ludovic Courtès wrote on 17 Apr 11:54 +0200
Re: [bug#69476] [PATCH 7/8] guix: cmake-build-system: Handle unknown systems.
(name . Jean-Pierre De Jesus DIAZ)(address . jean@foundationdevices.com)(address . 69476@debbugs.gnu.org)
87jzkwiabo.fsf@gnu.org
Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com> skribis:

Toggle quote (27 lines)
> * guix/build/cmake-build-system.scm (configure): Use Generic as the
> system name if the system is unknown.
>
> Change-Id: Ifd4a618ef67eb420b02d48f05291571aea44e46e
> ---
> guix/build/cmake-build-system.scm | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
> index d1ff5071be..0774124c95 100644
> --- a/guix/build/cmake-build-system.scm
> +++ b/guix/build/cmake-build-system.scm
> @@ -69,9 +69,13 @@ (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
> target "-gcc")
> (string-append "-DCMAKE_CXX_COMPILER="
> target "-g++")
> - (if (string-contains target "mingw")
> - "-DCMAKE_SYSTEM_NAME=Windows"
> - "-DCMAKE_SYSTEM_NAME=Linux"))
> + (cond
> + ((string-contains target "mingw")
> + "-DCMAKE_SYSTEM_NAME=Windows")
> + ((string-contains target "linux")
> + "-DCMAKE_SYSTEM_NAME=Linux")
> + (else
> + "-DCMAKE_SYSTEM_NAME=Generic")))

I spoke too fast.

This patch is good but it triggers a rebuild of everything that depends
on CMake.

So for now, I instead amended the last patch of the series like this:
Toggle diff (26 lines)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 373ed0e81f..6f0c2da806 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -113,7 +113,9 @@ (define-public ath9k-htc-ar7010-firmware
(arguments
(list #:target "xtensa-ath9k-elf"
#:tests? #f
- #:configure-flags #~'("-DTARGET_MAGPIE=ON")
+ #:configure-flags
+ #~'("-DCMAKE_SYSTEM_NAME=Generic" ;override default value
+ "-DTARGET_MAGPIE=ON")
#:phases
#~(modify-phases %standard-phases
(add-before 'configure 'change-directory
@@ -140,7 +142,9 @@ (define-public ath9k-htc-ar9271-firmware
(arguments
(substitute-keyword-arguments
(package-arguments ath9k-htc-ar7010-firmware)
- ((#:configure-flags flags) #~'("-DTARGET_K2=ON"))))
+ ((#:configure-flags flags)
+ #~'("-DCMAKE_SYSTEM_NAME=Generic" ;override default value
+ "-DTARGET_K2=ON"))))
(synopsis "Firmware for the Atheros AR9271 USB 802.11n NICs")
(description
"This is the firmware for the Qualcomm Atheros AR9271 802.11n USB NICs
I confirmed that this builds and that I get the same hashes.

That said, we should arrange to land the ‘cmake-build-system.scm’ patch
either on the next ‘core-updates’ branch or on a topic branch.

Thoughts?

Thanks,
Ludo’.
J
J
Jean-Pierre De Jesus Diaz wrote on 17 Apr 16:00 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)
CAG1gdUpu6rX9t6DjLwOPNLrMF+YoV85TpCAec9Hq85ETLZxNpQ@mail.gmail.com
Toggle quote (5 lines)
>That said, we should arrange to land the ‘cmake-build-system.scm’ patch
>either on the next ‘core-updates’ branch or on a topic branch.
>
>Thoughts?

I think it'd appropiate for it to be on core-updates or a topic branch, the most
convenient for you and then the rest of the patches can be applied IMO. Thanks
for applying some of the patches.

P.S.: The patch for CMake was also sent to https://issues.guix.gnu.org/68366
before working on this issue as I discovered it while working on other targets.

On Wed, Apr 17, 2024 at 9:54?AM Ludovic Courtès <ludo@gnu.org> wrote:
Toggle quote (47 lines)
>
> Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com> skribis:
>
> > * guix/build/cmake-build-system.scm (configure): Use Generic as the
> > system name if the system is unknown.
> >
> > Change-Id: Ifd4a618ef67eb420b02d48f05291571aea44e46e
> > ---
> > guix/build/cmake-build-system.scm | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
> > index d1ff5071be..0774124c95 100644
> > --- a/guix/build/cmake-build-system.scm
> > +++ b/guix/build/cmake-build-system.scm
> > @@ -69,9 +69,13 @@ (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
> > target "-gcc")
> > (string-append "-DCMAKE_CXX_COMPILER="
> > target "-g++")
> > - (if (string-contains target "mingw")
> > - "-DCMAKE_SYSTEM_NAME=Windows"
> > - "-DCMAKE_SYSTEM_NAME=Linux"))
> > + (cond
> > + ((string-contains target "mingw")
> > + "-DCMAKE_SYSTEM_NAME=Windows")
> > + ((string-contains target "linux")
> > + "-DCMAKE_SYSTEM_NAME=Linux")
> > + (else
> > + "-DCMAKE_SYSTEM_NAME=Generic")))
>
> I spoke too fast.
>
> This patch is good but it triggers a rebuild of everything that depends
> on CMake.
>
> So for now, I instead amended the last patch of the series like this:
>
>
> I confirmed that this builds and that I get the same hashes.
>
> That said, we should arrange to land the ‘cmake-build-system.scm’ patch
> either on the next ‘core-updates’ branch or on a topic branch.
>
> Thoughts?
>
> Thanks,
> Ludo’.
?