1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
4 ;;; Copyright © 2017 David Craven <david@craven.ch>
5 ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages firmware)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix utils)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system gnu)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages admin)
33 #:use-module (gnu packages assembly)
34 #:use-module (gnu packages bison)
35 #:use-module (gnu packages cmake)
36 #:use-module (gnu packages cross-base)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages gcc)
39 #:use-module (gnu packages linux)
40 #:use-module (gnu packages perl)
41 #:use-module (gnu packages python))
43 (define-public ath9k-htc-firmware
45 (name "ath9k-htc-firmware")
50 (url "https://github.com/qca/open-ath9k-htc-firmware.git")
54 "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
55 (file-name (git-file-name name version))
56 (patches (search-patches "ath9k-htc-firmware-objcopy.patch"))))
57 (build-system gnu-build-system)
60 (modify-phases %standard-phases
61 (add-before 'configure 'pre-configure
62 (lambda* (#:key inputs #:allow-other-keys)
63 (chdir "target_firmware")
65 ;; 'configure' is a simple script that runs 'cmake' with
67 (substitute* "configure"
69 (string-append "TOOLCHAIN="
70 (assoc-ref inputs "cross-gcc")
74 (lambda* (#:key outputs #:allow-other-keys)
75 (let* ((out (assoc-ref outputs "out"))
76 (fw-dir (string-append out "/lib/firmware")))
77 (for-each (lambda (file)
78 (install-file file fw-dir))
79 (find-files "." "\\.fw$"))
83 ;; The firmware is cross-compiled using a "bare bones" compiler (no libc.)
84 ;; Use our own tool chain for that.
85 (native-inputs `(("cross-gcc" ,(cross-gcc "xtensa-elf"))
86 ("cross-binutils" ,(cross-binutils "xtensa-elf"))
87 ("cmake" ,cmake-minimal)
89 (home-page "https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc")
90 (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs")
92 "This is the firmware for the Qualcomm Atheros AR7010 and AR9271 USB
93 802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of
95 (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
97 (define-public b43-tools
98 (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
102 (version (git-version "0.0.0" revision commit))
107 (url "http://git.bues.ch/git/b43-tools.git")
109 (file-name (git-file-name name version))
112 "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn"))))
113 (build-system gnu-build-system)
118 `(#:modules ((srfi srfi-1)
119 (guix build gnu-build-system)
121 #:tests? #f ; no tests
123 (let ((subdirs '("assembler" "disassembler")))
124 (modify-phases %standard-phases
125 (delete 'configure) ; no configure script
126 (add-before 'build 'patch-/bin/true
128 (substitute* (find-files "." "Makefile")
133 (for-each (lambda (dir)
134 (invoke "make" "-C" dir "CC=gcc"))
138 (lambda* (#:key outputs #:allow-other-keys)
139 (let ((out (assoc-ref outputs "out")))
140 (mkdir-p (string-append out "/bin"))
141 (for-each (lambda (dir)
142 (invoke "make" "-C" dir
143 (string-append "PREFIX=" out)
148 "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools")
149 (synopsis "Collection of tools for the b43 wireless driver")
151 "The b43 firmware tools is a collection of firmware extractor,
152 assembler, disassembler, and debugging tools for the Linux kernel b43 wireless
154 (license license:gpl2))))
156 (define-public openfwwf-firmware
158 (name "openfwwf-firmware")
163 (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/"
164 "openfwwf-" version ".tar.gz"))
167 "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x"))))
168 (build-system gnu-build-system)
170 `(("b43-tools" ,b43-tools)))
172 `(#:make-flags (list (string-append "PREFIX="
173 (assoc-ref %outputs "out")
174 "/lib/firmware/b43-open"))
175 #:tests? #f ;no tests
176 #:phases (modify-phases %standard-phases
177 (delete 'configure))))
178 (home-page "http://netweb.ing.unibs.it/~openfwwf/")
179 (synopsis "Firmware for BCM43xx devices")
181 "This is firmware from Open FirmWare for WiFi networks (OpenFWWF) for the
182 Broadcom/AirForce chipset BCM43xx with Wireless-Core Revision 5. It is used
183 by the b43-open driver of Linux-libre.")
184 (license license:gpl2)))
186 (define* (make-opensbi-package platform variant #:optional (arch "riscv64"))
188 (name (string-replace-substring
189 (string-append "opensbi-" platform "-" variant)
196 (url "https://github.com/riscv/opensbi.git")
197 (commit (string-append "v" version))))
198 (file-name (git-file-name name version))
200 (base32 "129ypdga0fzn657n2f42g2a1vx3hf8x7sd78h06d35pgkry0jkl7"))))
201 (build-system gnu-build-system)
203 `(,@(if (and (not (string-prefix? "riscv64" (%current-system)))
204 (string-prefix? "riscv64" arch))
205 `(("cross-gcc" ,(cross-gcc "riscv64-linux-gnu" #:xgcc gcc-7))
206 ("cross-binutils" ,(cross-binutils "riscv64-linux-gnu")))
209 `(#:tests? #f ; no check target
210 #:make-flags (list (string-append "PLATFORM=" ,platform "/" ,variant)
211 ,@(if (and (not (string-prefix? "riscv64"
213 (string-prefix? "riscv64" arch))
214 `("CROSS_COMPILE=riscv64-linux-gnu-")
219 (modify-phases %standard-phases
222 (lambda* (#:key outputs #:allow-other-keys)
223 (let ((out (assoc-ref outputs "out"))
224 (bin (find-files "." ".*fw_.*.elf$")))
227 (install-file file out))
230 (home-page "https://github.com/riscv/opensbi")
231 (synopsis "RISC-V Open Source Supervisor Binary Interface")
232 (description "A reference implementation of the RISC-V SBI specifications
233 for platform-specific firmwares executing in M-mode.")
234 (license (list license:bsd-2
235 ;; lib/utils/libfdt/* is dual licensed under bsd-2 and gpl2+.
237 ;; platform/ariane-fpga/* is gpl2.
240 (define-public opensbi-qemu-virt
241 (make-opensbi-package "qemu" "virt"))
243 (define-public opensbi-sifive-fu540
244 (make-opensbi-package "sifive" "fu540"))
246 (define-public opensbi-qemu-sifive-u
247 ;; Dropped upstream, as all functionality is present in the sifive-fu540
248 ;; target for recent versions of qemu, u-boot and linux.
249 (deprecated-package "opensbi-qemu-sifive-u" opensbi-sifive-fu540))
251 (define-public seabios
259 (url "https://review.coreboot.org/seabios.git")
260 (commit (string-append "rel-" version))))
261 (file-name (git-file-name name version))
263 (base32 "1n1bd6msfs7xn8844sz2qnm7hb5x2qfl3zb06kp4bx9vdc3i6619"))))
264 (build-system gnu-build-system)
266 `(("python" ,python-wrapper)))
268 `(#:tests? #f ; no check target
270 (modify-phases %standard-phases
276 (lambda* (#:key outputs #:allow-other-keys)
277 (let* ((out (assoc-ref outputs "out"))
278 (fmw (string-append out "/share/firmware")))
280 (copy-file "out/bios.bin" (string-append fmw "/bios.bin"))
282 (home-page "https://www.seabios.org/SeaBIOS")
283 (synopsis "x86 BIOS implementation")
284 (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS
285 can run in an emulator or it can run natively on X86 hardware with the use of
288 (license (list license:gpl3+ license:lgpl3+
289 ;; src/fw/acpi-dsdt.dsl is lgpl2
291 ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and
292 ;; cpl with a linking exception.
295 ;; OVMF is part of the edk2 source tree.
296 (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
297 (define edk2-version (git-version "20170116" "1" edk2-commit))
302 (url "https://github.com/tianocore/edk2")
303 (commit edk2-commit)))
304 (file-name (git-file-name "edk2" edk2-version))
307 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
312 (version edk2-version)
314 (build-system gnu-build-system)
319 ("python-2" ,python-2)
320 ("util-linux" ,util-linux)))
322 `(#:tests? #f ; No check target.
324 (modify-phases %standard-phases
327 (let* ((cwd (getcwd))
328 (tools (string-append cwd "/BaseTools"))
329 (bin (string-append tools "/BinWrappers/PosixLike")))
330 (setenv "WORKSPACE" cwd)
331 (setenv "EDK_TOOLS_PATH" tools)
332 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
333 ; FIXME: The below script errors out. When using 'invoke' instead
334 ; of 'system*' this causes the build to fail.
335 (system* "bash" "edksetup.sh")
336 (substitute* "Conf/target.txt"
337 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
338 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
339 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
340 (number->string (parallel-job-count)))))
341 ;; Build build support.
342 (setenv "BUILD_CC" "gcc")
343 (invoke "make" "-C" tools)
347 (invoke "build" "-a" "IA32" "-t" "GCC49"
348 "-p" "OvmfPkg/OvmfPkgIa32.dsc")))
349 ,@(if (string=? "x86_64-linux" (%current-system))
350 '((add-after 'build 'build-x64
352 (invoke "build" "-a" "X64" "-t" "GCC49"
353 "-p" "OvmfPkg/OvmfPkgX64.dsc"))))
356 (lambda* (#:key outputs #:allow-other-keys)
357 (let* ((out (assoc-ref outputs "out"))
358 (fmw (string-append out "/share/firmware")))
360 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
361 (string-append fmw "/ovmf_ia32.bin"))
362 ,@(if (string=? "x86_64-linux" (%current-system))
363 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
364 (string-append fmw "/ovmf_x64.bin")))
367 (supported-systems '("x86_64-linux" "i686-linux"))
368 (home-page "https://www.tianocore.org")
369 (synopsis "UEFI firmware for QEMU")
370 (description "OVMF is an EDK II based project to enable UEFI support for
371 Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
372 (license (list license:expat
373 license:bsd-2 license:bsd-3 license:bsd-4))))
375 (define-public ovmf-aarch64
378 (name "ovmf-aarch64")
380 `(,@(package-native-inputs ovmf)
381 ,@(if (not (string-prefix? "aarch64" (%current-system)))
382 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
383 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
386 (substitute-keyword-arguments (package-arguments ovmf)
388 `(modify-phases ,phases
389 (add-before 'configure 'set-env
391 ,@(if (not (string-prefix? "aarch64" (%current-system)))
392 `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
397 (invoke "build" "-a" "AARCH64" "-t" "GCC49"
398 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
401 (lambda* (#:key outputs #:allow-other-keys)
402 (let* ((out (assoc-ref outputs "out"))
403 (fmw (string-append out "/share/firmware")))
405 (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
406 (string-append fmw "/ovmf_aarch64.bin"))
408 (supported-systems %supported-systems)))
410 (define-public ovmf-arm
415 `(,@(package-native-inputs ovmf)
416 ,@(if (not (string-prefix? "armhf" (%current-system)))
417 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
418 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
421 (substitute-keyword-arguments (package-arguments ovmf)
423 `(modify-phases ,phases
424 (add-before 'configure 'set-env
426 ,@(if (not (string-prefix? "armhf" (%current-system)))
427 `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
432 (invoke "build" "-a" "ARM" "-t" "GCC49"
433 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
436 (lambda* (#:key outputs #:allow-other-keys)
437 (let* ((out (assoc-ref outputs "out"))
438 (fmw (string-append out "/share/firmware")))
440 (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
441 (string-append fmw "/ovmf_arm.bin"))
443 (supported-systems %supported-systems)))
445 (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
447 (name (string-append "arm-trusted-firmware-" platform))
453 ;; There are only GitHub generated release snapshots.
454 (url "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/")
455 (commit (string-append "v" version))))
456 (file-name (git-file-name "arm-trusted-firmware" version))
457 (patches (search-patches
458 "arm-trusted-firmware-disable-hdcp.patch"))
461 "03fjl5hy1bqlya6fg553bqz7jrvilzrzpbs87cv6jd04v8qrvry8"))))
462 (build-system gnu-build-system)
465 (modify-phases %standard-phases
466 (delete 'configure) ; no configure script
467 ;; Remove binary blobs which do not contain source or proper license.
468 (add-after 'unpack 'remove-binary-blobs
470 (for-each (lambda (file)
472 (find-files "." ".*\\.bin$"))))
474 (lambda* (#:key outputs #:allow-other-keys)
475 (let ((out (assoc-ref outputs "out"))
476 (bin (find-files "." ".*\\.(bin|elf)$")))
479 (install-file file out))
482 #:make-flags (list (string-append "PLAT=" ,platform)
483 ,@(if (and (not (string-prefix? "aarch64"
485 (string-prefix? "aarch64" arch))
486 `("CROSS_COMPILE=aarch64-linux-gnu-")
488 ,@(if (and (not (string-prefix? "armhf"
490 (string-prefix? "armhf" arch))
491 `("CROSS_COMPILE=arm-linux-gnueabihf-")
494 #:tests? #f)) ; no tests
496 `(,@(if (and (not (string-prefix? "aarch64" (%current-system)))
497 (string-prefix? "aarch64" arch))
498 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
499 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu" #:xgcc gcc-7))
500 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
502 ,@(if (and (not (string-prefix? "armhf" (%current-system)))
503 (string-prefix? "armhf" arch))
504 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
505 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf" #:xgcc gcc-7))
506 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
509 (home-page "https://www.trustedfirmware.org/")
510 (synopsis "Implementation of \"secure world software\"")
512 "ARM Trusted Firmware provides a reference implementation of secure world
513 software for ARMv7A and ARMv8-A, including a Secure Monitor executing at
514 @dfn{Exception Level 3} (EL3). It implements various ARM interface standards,
517 @item The Power State Coordination Interface (PSCI)
518 @item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1)
519 @item SMC Calling Convention
520 @item System Control and Management Interface
521 @item Software Delegated Exception Interface (SDEI)
523 (license (list license:bsd-3
524 license:bsd-2)))) ; libfdt
526 (define-public arm-trusted-firmware-sun50i-a64
527 (let ((base (make-arm-trusted-firmware "sun50i_a64")))
530 (name "arm-trusted-firmware-sun50i-a64"))))
532 (define-public arm-trusted-firmware-rk3328
533 (make-arm-trusted-firmware "rk3328"))
535 (define-public arm-trusted-firmware-puma-rk3399
536 (let ((base (make-arm-trusted-firmware "rk3399"))
537 ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet.
538 (commit "d71e6d83612df896774ec4c03d49500312d2c324")
542 (name "arm-trusted-firmware-puma-rk3399")
543 (version (git-version "1.3" revision commit))
548 (url "https://git.theobroma-systems.com/arm-trusted-firmware.git")
550 (file-name (git-file-name name version))
553 "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8")))))))
555 (define-public arm-trusted-firmware-rk3399
556 (let ((base (make-arm-trusted-firmware "rk3399")))
559 (name "arm-trusted-firmware-rk3399")
561 `(("cross32-gcc" ,(cross-gcc "arm-none-eabi"))
562 ("cross32-binutils", (cross-binutils "arm-none-eabi"))
563 ,@(package-native-inputs base))))))
565 (define-public rk3399-cortex-m0
567 (name "rk3399-cortex-m0")
573 (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git")
574 (commit (string-append "v" version))))
575 (file-name (git-file-name "rk3399-cortex-m0" version))
578 "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w"))))
579 (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/")
580 (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)")
582 "Cortex-M0 firmware used with the RK3399 to implement
583 power-management functionality and helpers (e.g. DRAM frequency
584 switching support).\n")
585 (license license:bsd-3)
586 (build-system gnu-build-system)
589 (modify-phases %standard-phases
593 (lambda* (#:key outputs #:allow-other-keys)
594 (let ((out (assoc-ref outputs "out"))
595 (mzerofiles (find-files "." "rk3399m0.(elf|bin)$")))
598 (install-file file out))
601 (add-before 'build 'setenv
602 (lambda* (#:key inputs #:allow-other-keys)
603 (setenv "CROSS_COMPILE" "arm-none-eabi-")
605 (native-inputs `(("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7))
606 ("cross-binutils" ,(cross-binutils "arm-none-eabi"))))))