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>
8 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
9 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages firmware)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix utils)
31 #:use-module (guix git-download)
32 #:use-module (guix build-system gnu)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages admin)
35 #:use-module (gnu packages assembly)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages bison)
38 #:use-module (gnu packages cmake)
39 #:use-module (gnu packages cross-base)
40 #:use-module (gnu packages flex)
41 #:use-module (gnu packages gcc)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages python))
46 (define-public ath9k-htc-firmware
48 (name "ath9k-htc-firmware")
53 (url "https://github.com/qca/open-ath9k-htc-firmware.git")
57 "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
58 (file-name (git-file-name name version))
59 (patches (search-patches "ath9k-htc-firmware-objcopy.patch"))))
60 (build-system gnu-build-system)
63 (modify-phases %standard-phases
64 (add-before 'configure 'pre-configure
65 (lambda* (#:key inputs native-inputs #:allow-other-keys)
66 (chdir "target_firmware")
68 ;; 'configure' is a simple script that runs 'cmake' with
70 (substitute* "configure"
72 (string-append "TOOLCHAIN="
73 (assoc-ref (or native-inputs inputs) "cross-gcc")
77 (lambda* (#:key outputs #:allow-other-keys)
78 (let* ((out (assoc-ref outputs "out"))
79 (fw-dir (string-append out "/lib/firmware")))
80 (for-each (lambda (file)
81 (install-file file fw-dir))
82 (find-files "." "\\.fw$"))
86 ;; The firmware is cross-compiled using a "bare bones" compiler (no libc.)
87 ;; Use our own tool chain for that.
88 (native-inputs `(("cross-gcc" ,(cross-gcc
90 #:xbinutils (cross-binutils "xtensa-elf"
92 ("cross-binutils" ,(cross-binutils "xtensa-elf" binutils-2.33))
93 ("cmake" ,cmake-minimal)
95 (home-page "http://wireless.kernel.org/en/users/Drivers/ath9k_htc")
96 (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs")
98 "This is the firmware for the Qualcomm Atheros AR7010 and AR9271 USB
99 802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of
101 (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
103 (define-public b43-tools
104 (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
108 (version (git-version "0.0.0" revision commit))
113 (url "http://git.bues.ch/git/b43-tools.git")
115 (file-name (git-file-name name version))
118 "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn"))))
119 (build-system gnu-build-system)
124 `(#:modules ((srfi srfi-1)
125 (guix build gnu-build-system)
127 #:tests? #f ; no tests
129 (let ((subdirs '("assembler" "disassembler")))
130 (modify-phases %standard-phases
131 (delete 'configure) ; no configure script
132 (add-before 'build 'patch-/bin/true
134 (substitute* (find-files "." "Makefile")
139 (for-each (lambda (dir)
140 (invoke "make" "-C" dir "CC=gcc"))
144 (lambda* (#:key outputs #:allow-other-keys)
145 (let ((out (assoc-ref outputs "out")))
146 (mkdir-p (string-append out "/bin"))
147 (for-each (lambda (dir)
148 (invoke "make" "-C" dir
149 (string-append "PREFIX=" out)
154 "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools")
155 (synopsis "Collection of tools for the b43 wireless driver")
157 "The b43 firmware tools is a collection of firmware extractor,
158 assembler, disassembler, and debugging tools for the Linux kernel b43 wireless
160 (license license:gpl2))))
162 (define-public openfwwf-firmware
164 (name "openfwwf-firmware")
169 (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/"
170 "openfwwf-" version ".tar.gz"))
173 "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x"))))
174 (build-system gnu-build-system)
176 `(("b43-tools" ,b43-tools)))
178 `(#:make-flags (list (string-append "PREFIX="
179 (assoc-ref %outputs "out")
180 "/lib/firmware/b43-open"))
181 #:tests? #f ;no tests
182 #:phases (modify-phases %standard-phases
183 (delete 'configure))))
184 (home-page "http://netweb.ing.unibs.it/~openfwwf/")
185 (synopsis "Firmware for BCM43xx devices")
187 "This is firmware from Open FirmWare for WiFi networks (OpenFWWF) for the
188 Broadcom/AirForce chipset BCM43xx with Wireless-Core Revision 5. It is used
189 by the b43-open driver of Linux-libre.")
190 (license license:gpl2)))
192 (define* (make-opensbi-package platform variant #:optional (arch "riscv64"))
194 (name (string-replace-substring
195 (string-append "opensbi-" platform "-" variant)
202 (url "https://github.com/riscv/opensbi.git")
203 (commit (string-append "v" version))))
204 (file-name (git-file-name name version))
206 (base32 "129ypdga0fzn657n2f42g2a1vx3hf8x7sd78h06d35pgkry0jkl7"))))
207 (build-system gnu-build-system)
209 `(,@(if (and (not (string-prefix? "riscv64" (%current-system)))
210 (string-prefix? "riscv64" arch))
211 `(("cross-gcc" ,(cross-gcc "riscv64-linux-gnu" #:xgcc gcc-7))
212 ("cross-binutils" ,(cross-binutils "riscv64-linux-gnu")))
215 `(#:tests? #f ; no check target
216 #:make-flags (list (string-append "PLATFORM=" ,platform "/" ,variant)
217 ,@(if (and (not (string-prefix? "riscv64"
219 (string-prefix? "riscv64" arch))
220 `("CROSS_COMPILE=riscv64-linux-gnu-")
225 (modify-phases %standard-phases
228 (lambda* (#:key outputs #:allow-other-keys)
229 (let ((out (assoc-ref outputs "out"))
230 (bin (find-files "." ".*fw_.*.elf$")))
233 (install-file file out))
236 (home-page "https://github.com/riscv/opensbi")
237 (synopsis "RISC-V Open Source Supervisor Binary Interface")
238 (description "A reference implementation of the RISC-V SBI specifications
239 for platform-specific firmwares executing in M-mode.")
240 (license (list license:bsd-2
241 ;; lib/utils/libfdt/* is dual licensed under bsd-2 and gpl2+.
243 ;; platform/ariane-fpga/* is gpl2.
246 (define-public opensbi-qemu-virt
247 (make-opensbi-package "qemu" "virt"))
249 (define-public opensbi-sifive-fu540
250 (make-opensbi-package "sifive" "fu540"))
252 (define-public opensbi-qemu-sifive-u
253 ;; Dropped upstream, as all functionality is present in the sifive-fu540
254 ;; target for recent versions of qemu, u-boot and linux.
255 (deprecated-package "opensbi-qemu-sifive-u" opensbi-sifive-fu540))
257 (define-public seabios
265 (url "https://review.coreboot.org/seabios.git")
266 (commit (string-append "rel-" version))))
267 (file-name (git-file-name name version))
269 (base32 "1n1bd6msfs7xn8844sz2qnm7hb5x2qfl3zb06kp4bx9vdc3i6619"))))
270 (build-system gnu-build-system)
272 `(("python" ,python-wrapper)))
274 `(#:tests? #f ; no check target
276 (modify-phases %standard-phases
282 (lambda* (#:key outputs #:allow-other-keys)
283 (let* ((out (assoc-ref outputs "out"))
284 (fmw (string-append out "/share/firmware")))
286 (copy-file "out/bios.bin" (string-append fmw "/bios.bin"))
288 (home-page "https://www.seabios.org/SeaBIOS")
289 (synopsis "x86 BIOS implementation")
290 (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS
291 can run in an emulator or it can run natively on X86 hardware with the use of
294 (license (list license:gpl3+ license:lgpl3+
295 ;; src/fw/acpi-dsdt.dsl is lgpl2
297 ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and
298 ;; cpl with a linking exception.
301 ;; OVMF is part of the edk2 source tree.
302 (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
303 (define edk2-version (git-version "20170116" "1" edk2-commit))
308 (url "https://github.com/tianocore/edk2")
309 (commit edk2-commit)))
310 (file-name (git-file-name "edk2" edk2-version))
313 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
318 (version edk2-version)
320 (build-system gnu-build-system)
325 ("python-2" ,python-2)
326 ("util-linux" ,util-linux "lib")))
328 `(#:tests? #f ; No check target.
330 (modify-phases %standard-phases
333 (let* ((cwd (getcwd))
334 (tools (string-append cwd "/BaseTools"))
335 (bin (string-append tools "/BinWrappers/PosixLike")))
336 (setenv "WORKSPACE" cwd)
337 (setenv "EDK_TOOLS_PATH" tools)
338 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
339 ; FIXME: The below script errors out. When using 'invoke' instead
340 ; of 'system*' this causes the build to fail.
341 (system* "bash" "edksetup.sh")
342 (substitute* "Conf/target.txt"
343 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
344 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
345 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
346 (number->string (parallel-job-count)))))
347 ;; Build build support.
348 (setenv "BUILD_CC" "gcc")
349 (invoke "make" "-C" tools)
353 (invoke "build" "-a" "IA32" "-t" "GCC49"
354 "-p" "OvmfPkg/OvmfPkgIa32.dsc")))
355 ,@(if (string=? "x86_64-linux" (%current-system))
356 '((add-after 'build 'build-x64
358 (invoke "build" "-a" "X64" "-t" "GCC49"
359 "-p" "OvmfPkg/OvmfPkgX64.dsc"))))
362 (lambda* (#:key outputs #:allow-other-keys)
363 (let* ((out (assoc-ref outputs "out"))
364 (fmw (string-append out "/share/firmware")))
366 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
367 (string-append fmw "/ovmf_ia32.bin"))
368 ,@(if (string=? "x86_64-linux" (%current-system))
369 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
370 (string-append fmw "/ovmf_x64.bin")))
373 (supported-systems '("x86_64-linux" "i686-linux"))
374 (home-page "https://www.tianocore.org")
375 (synopsis "UEFI firmware for QEMU")
376 (description "OVMF is an EDK II based project to enable UEFI support for
377 Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
378 (license (list license:expat
379 license:bsd-2 license:bsd-3 license:bsd-4))))
381 (define-public ovmf-aarch64
384 (name "ovmf-aarch64")
386 `(,@(package-native-inputs ovmf)
387 ,@(if (not (string-prefix? "aarch64" (%current-system)))
388 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
389 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
392 (substitute-keyword-arguments (package-arguments ovmf)
394 `(modify-phases ,phases
395 (add-before 'configure 'set-env
397 ,@(if (not (string-prefix? "aarch64" (%current-system)))
398 `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
403 (invoke "build" "-a" "AARCH64" "-t" "GCC49"
404 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
407 (lambda* (#:key outputs #:allow-other-keys)
408 (let* ((out (assoc-ref outputs "out"))
409 (fmw (string-append out "/share/firmware")))
411 (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
412 (string-append fmw "/ovmf_aarch64.bin"))
414 (supported-systems %supported-systems)))
416 (define-public ovmf-arm
421 `(,@(package-native-inputs ovmf)
422 ,@(if (not (string-prefix? "armhf" (%current-system)))
423 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
424 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
427 (substitute-keyword-arguments (package-arguments ovmf)
429 `(modify-phases ,phases
430 (add-before 'configure 'set-env
432 ,@(if (not (string-prefix? "armhf" (%current-system)))
433 `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
438 (invoke "build" "-a" "ARM" "-t" "GCC49"
439 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
442 (lambda* (#:key outputs #:allow-other-keys)
443 (let* ((out (assoc-ref outputs "out"))
444 (fmw (string-append out "/share/firmware")))
446 (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
447 (string-append fmw "/ovmf_arm.bin"))
449 (supported-systems %supported-systems)))
451 (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
453 (name (string-append "arm-trusted-firmware-" platform))
459 ;; There are only GitHub generated release snapshots.
460 (url "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/")
461 (commit (string-append "v" version))))
462 (file-name (git-file-name "arm-trusted-firmware" version))
463 (patches (search-patches
464 "arm-trusted-firmware-disable-hdcp.patch"))
467 "03fjl5hy1bqlya6fg553bqz7jrvilzrzpbs87cv6jd04v8qrvry8"))))
468 (build-system gnu-build-system)
471 (modify-phases %standard-phases
472 (delete 'configure) ; no configure script
473 ;; Remove binary blobs which do not contain source or proper license.
474 (add-after 'unpack 'remove-binary-blobs
476 (for-each (lambda (file)
478 (find-files "." ".*\\.bin$"))))
480 (lambda* (#:key outputs #:allow-other-keys)
481 (let ((out (assoc-ref outputs "out"))
482 (bin (find-files "." ".*\\.(bin|elf)$")))
485 (install-file file out))
488 #:make-flags (list (string-append "PLAT=" ,platform)
489 ,@(if (and (not (string-prefix? "aarch64"
491 (string-prefix? "aarch64" arch))
492 `("CROSS_COMPILE=aarch64-linux-gnu-")
494 ,@(if (and (not (string-prefix? "armhf"
496 (string-prefix? "armhf" arch))
497 `("CROSS_COMPILE=arm-linux-gnueabihf-")
500 #:tests? #f)) ; no tests
502 `(,@(if (and (not (string-prefix? "aarch64" (%current-system)))
503 (string-prefix? "aarch64" arch))
504 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
505 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu" #:xgcc gcc-7))
506 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
508 ,@(if (and (not (string-prefix? "armhf" (%current-system)))
509 (string-prefix? "armhf" arch))
510 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
511 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf" #:xgcc gcc-7))
512 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
515 (home-page "https://www.trustedfirmware.org/")
516 (synopsis "Implementation of \"secure world software\"")
518 "ARM Trusted Firmware provides a reference implementation of secure world
519 software for ARMv7A and ARMv8-A, including a Secure Monitor executing at
520 @dfn{Exception Level 3} (EL3). It implements various ARM interface standards,
523 @item The Power State Coordination Interface (PSCI)
524 @item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1)
525 @item SMC Calling Convention
526 @item System Control and Management Interface
527 @item Software Delegated Exception Interface (SDEI)
529 (license (list license:bsd-3
530 license:bsd-2)))) ; libfdt
532 (define-public arm-trusted-firmware-sun50i-a64
533 (let ((base (make-arm-trusted-firmware "sun50i_a64")))
536 (name "arm-trusted-firmware-sun50i-a64"))))
538 (define-public arm-trusted-firmware-rk3328
539 (make-arm-trusted-firmware "rk3328"))
541 (define-public arm-trusted-firmware-puma-rk3399
542 (let ((base (make-arm-trusted-firmware "rk3399"))
543 ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet.
544 (commit "d71e6d83612df896774ec4c03d49500312d2c324")
548 (name "arm-trusted-firmware-puma-rk3399")
549 (version (git-version "1.3" revision commit))
554 (url "https://git.theobroma-systems.com/arm-trusted-firmware.git")
556 (file-name (git-file-name name version))
559 "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8")))))))
561 (define-public arm-trusted-firmware-rk3399
562 (let ((base (make-arm-trusted-firmware "rk3399")))
565 (name "arm-trusted-firmware-rk3399")
567 `(("cross32-gcc" ,(cross-gcc "arm-none-eabi"))
568 ("cross32-binutils", (cross-binutils "arm-none-eabi"))
569 ,@(package-native-inputs base))))))
571 (define-public rk3399-cortex-m0
573 (name "rk3399-cortex-m0")
579 (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git")
580 (commit (string-append "v" version))))
581 (file-name (git-file-name "rk3399-cortex-m0" version))
584 "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w"))))
585 (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/")
586 (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)")
588 "Cortex-M0 firmware used with the RK3399 to implement
589 power-management functionality and helpers (e.g. DRAM frequency
590 switching support).\n")
591 (license license:bsd-3)
592 (build-system gnu-build-system)
595 (modify-phases %standard-phases
599 (lambda* (#:key outputs #:allow-other-keys)
600 (let ((out (assoc-ref outputs "out"))
601 (mzerofiles (find-files "." "rk3399m0.(elf|bin)$")))
604 (install-file file out))
607 (add-before 'build 'setenv
608 (lambda* (#:key inputs #:allow-other-keys)
609 (setenv "CROSS_COMPILE" "arm-none-eabi-")
611 (native-inputs `(("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7))
612 ("cross-binutils" ,(cross-binutils "arm-none-eabi"))))))