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>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages firmware)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix utils)
30 #:use-module (guix git-download)
31 #:use-module (guix build-system gnu)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages admin)
34 #:use-module (gnu packages assembly)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages cmake)
37 #:use-module (gnu packages cross-base)
38 #:use-module (gnu packages flex)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages python))
44 (define-public ath9k-htc-firmware
46 (name "ath9k-htc-firmware")
51 (url "https://github.com/qca/open-ath9k-htc-firmware.git")
55 "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
56 (file-name (string-append name "-" version "-checkout"))
57 (patches (search-patches "ath9k-htc-firmware-objcopy.patch"))))
58 (build-system gnu-build-system)
61 (modify-phases %standard-phases
62 (add-before 'configure 'pre-configure
63 (lambda* (#:key inputs native-inputs #:allow-other-keys)
64 (chdir "target_firmware")
66 ;; 'configure' is a simple script that runs 'cmake' with
68 (substitute* "configure"
70 (string-append "TOOLCHAIN="
71 (assoc-ref (or native-inputs inputs) "cross-gcc")
75 (lambda* (#:key outputs #:allow-other-keys)
76 (let* ((out (assoc-ref outputs "out"))
77 (fw-dir (string-append out "/lib/firmware")))
78 (for-each (lambda (file)
79 (install-file file fw-dir))
80 (find-files "." "\\.fw$"))
84 ;; The firmware is cross-compiled using a "bare bones" compiler (no libc.)
85 ;; Use our own tool chain for that.
86 (native-inputs `(("cross-gcc" ,(cross-gcc "xtensa-elf"))
87 ("cross-binutils" ,(cross-binutils "xtensa-elf"))
88 ("cmake" ,cmake-minimal)
90 (home-page "http://wireless.kernel.org/en/users/Drivers/ath9k_htc")
91 (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs")
93 "This is the firmware for the Qualcomm Atheros AR7010 and AR9271 USB
94 802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of
96 (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
98 (define-public b43-tools
99 (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
103 (version (git-version "0.0.0" revision commit))
108 (url "http://git.bues.ch/git/b43-tools.git")
110 (file-name (string-append name "-" version "-checkout"))
113 "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn"))))
114 (build-system gnu-build-system)
119 `(#:modules ((srfi srfi-1)
120 (guix build gnu-build-system)
122 #:tests? #f ; no tests
124 (let ((subdirs '("assembler" "disassembler")))
125 (modify-phases %standard-phases
126 (delete 'configure) ; no configure script
127 (add-before 'build 'patch-/bin/true
129 (substitute* (find-files "." "Makefile")
134 (for-each (lambda (dir)
135 (invoke "make" "-C" dir "CC=gcc"))
139 (lambda* (#:key outputs #:allow-other-keys)
140 (let ((out (assoc-ref outputs "out")))
141 (mkdir-p (string-append out "/bin"))
142 (for-each (lambda (dir)
143 (invoke "make" "-C" dir
144 (string-append "PREFIX=" out)
149 "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools")
150 (synopsis "Collection of tools for the b43 wireless driver")
152 "The b43 firmware tools is a collection of firmware extractor,
153 assembler, disassembler, and debugging tools for the Linux kernel b43 wireless
155 (license license:gpl2))))
157 (define-public openfwwf-firmware
159 (name "openfwwf-firmware")
164 (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/"
165 "openfwwf-" version ".tar.gz"))
168 "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x"))))
169 (build-system gnu-build-system)
171 `(("b43-tools" ,b43-tools)))
173 `(#:make-flags (list (string-append "PREFIX="
174 (assoc-ref %outputs "out")
175 "/lib/firmware/b43-open"))
176 #:tests? #f ;no tests
177 #:phases (modify-phases %standard-phases
178 (delete 'configure))))
179 (home-page "http://netweb.ing.unibs.it/~openfwwf/")
180 (synopsis "Firmware for BCM43xx devices")
182 "This is firmware from Open FirmWare for WiFi networks (OpenFWWF) for the
183 Broadcom/AirForce chipset BCM43xx with Wireless-Core Revision 5. It is used
184 by the b43-open driver of Linux-libre.")
185 (license license:gpl2)))
187 (define-public seabios
195 (url "https://review.coreboot.org/seabios.git")
196 (commit (string-append "rel-" version))))
197 (file-name (git-file-name name version))
199 (base32 "1g9y03r5ky58q2g9rhbwfhs42z0zb9f59wfxpwh6zjqa6fyv1r80"))))
200 (build-system gnu-build-system)
202 `(("python-2" ,python-2)))
204 `(#:tests? #f ; no check target
206 (modify-phases %standard-phases
212 (lambda* (#:key outputs #:allow-other-keys)
213 (let* ((out (assoc-ref outputs "out"))
214 (fmw (string-append out "/share/firmware")))
216 (copy-file "out/bios.bin" (string-append fmw "/bios.bin"))
218 (home-page "https://www.seabios.org/SeaBIOS")
219 (synopsis "x86 BIOS implementation")
220 (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS
221 can run in an emulator or it can run natively on X86 hardware with the use of
224 (license (list license:gpl3+ license:lgpl3+
225 ;; src/fw/acpi-dsdt.dsl is lgpl2
227 ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and
228 ;; cpl with a linking exception.
231 ;; OVMF is part of the edk2 source tree.
232 (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
233 (define edk2-version (git-version "20170116" "1" edk2-commit))
238 (url "https://github.com/tianocore/edk2")
239 (commit edk2-commit)))
240 (file-name (git-file-name "edk2" edk2-version))
243 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
248 (version edk2-version)
250 (build-system gnu-build-system)
255 ("python-2" ,python-2)
256 ("util-linux" ,util-linux)))
258 `(#:tests? #f ; No check target.
260 (modify-phases %standard-phases
263 (let* ((cwd (getcwd))
264 (tools (string-append cwd "/BaseTools"))
265 (bin (string-append tools "/BinWrappers/PosixLike")))
266 (setenv "WORKSPACE" cwd)
267 (setenv "EDK_TOOLS_PATH" tools)
268 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
269 ; FIXME: The below script errors out. When using 'invoke' instead
270 ; of 'system*' this causes the build to fail.
271 (system* "bash" "edksetup.sh")
272 (substitute* "Conf/target.txt"
273 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
274 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
275 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
276 (number->string (parallel-job-count)))))
277 ;; Build build support.
278 (setenv "BUILD_CC" "gcc")
279 (invoke "make" "-C" tools)
283 (invoke "build" "-a" "IA32" "-t" "GCC49"
284 "-p" "OvmfPkg/OvmfPkgIa32.dsc")))
285 ,@(if (string=? "x86_64-linux" (%current-system))
286 '((add-after 'build 'build-x64
288 (invoke "build" "-a" "X64" "-t" "GCC49"
289 "-p" "OvmfPkg/OvmfPkgX64.dsc"))))
292 (lambda* (#:key outputs #:allow-other-keys)
293 (let* ((out (assoc-ref outputs "out"))
294 (fmw (string-append out "/share/firmware")))
296 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
297 (string-append fmw "/ovmf_ia32.bin"))
298 ,@(if (string=? "x86_64-linux" (%current-system))
299 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
300 (string-append fmw "/ovmf_x64.bin")))
303 (supported-systems '("x86_64-linux" "i686-linux"))
304 (home-page "https://www.tianocore.org")
305 (synopsis "UEFI firmware for QEMU")
306 (description "OVMF is an EDK II based project to enable UEFI support for
307 Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
308 (license (list license:expat
309 license:bsd-2 license:bsd-3 license:bsd-4))))
311 (define-public ovmf-aarch64
314 (name "ovmf-aarch64")
316 `(,@(package-native-inputs ovmf)
317 ,@(if (not (string-prefix? "aarch64" (%current-system)))
318 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
319 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
322 (substitute-keyword-arguments (package-arguments ovmf)
324 `(modify-phases ,phases
325 (add-before 'configure 'set-env
327 ,@(if (not (string-prefix? "aarch64" (%current-system)))
328 `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
333 (invoke "build" "-a" "AARCH64" "-t" "GCC49"
334 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
337 (lambda* (#:key outputs #:allow-other-keys)
338 (let* ((out (assoc-ref outputs "out"))
339 (fmw (string-append out "/share/firmware")))
341 (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
342 (string-append fmw "/ovmf_aarch64.bin"))
344 (supported-systems %supported-systems)))
346 (define-public ovmf-arm
351 `(,@(package-native-inputs ovmf)
352 ,@(if (not (string-prefix? "armhf" (%current-system)))
353 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
354 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
357 (substitute-keyword-arguments (package-arguments ovmf)
359 `(modify-phases ,phases
360 (add-before 'configure 'set-env
362 ,@(if (not (string-prefix? "armhf" (%current-system)))
363 `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
368 (invoke "build" "-a" "ARM" "-t" "GCC49"
369 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
372 (lambda* (#:key outputs #:allow-other-keys)
373 (let* ((out (assoc-ref outputs "out"))
374 (fmw (string-append out "/share/firmware")))
376 (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
377 (string-append fmw "/ovmf_arm.bin"))
379 (supported-systems %supported-systems)))
381 (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
383 (name (string-append "arm-trusted-firmware-" platform))
389 ;; There are only GitHub generated release snapshots.
390 (url "https://github.com/ARM-software/arm-trusted-firmware.git")
391 (commit (string-append "v" version))))
392 (file-name (git-file-name "arm-trusted-firmware" version))
393 (patches (search-patches
394 "arm-trusted-firmware-optional-bin-generation.patch"
395 "arm-trusted-firmware-rockchip-disable-binary.patch"
396 "arm-trusted-firmware-disable-hdcp.patch"))
399 "1gy5qskrjy8n3kxdcm1dx8b45l5b75n0pm8pq80wl6xic1ycy24r"))))
400 (build-system gnu-build-system)
403 (modify-phases %standard-phases
404 (delete 'configure) ; no configure script
405 ;; Remove binary blobs which do not contain source or proper license.
406 (add-after 'unpack 'remove-binary-blobs
408 (for-each (lambda (file)
410 (find-files "." ".*\\.bin$"))))
412 (lambda* (#:key outputs #:allow-other-keys)
413 (let ((out (assoc-ref outputs "out"))
414 (bin (find-files "." ".*\\.(bin|elf)$")))
417 (install-file file out))
420 #:make-flags (list (string-append "PLAT=" ,platform)
421 ,@(if (and (not (string-prefix? "aarch64"
423 (string-prefix? "aarch64" arch))
424 `("CROSS_COMPILE=aarch64-linux-gnu-")
426 ,@(if (and (not (string-prefix? "armhf"
428 (string-prefix? "armhf" arch))
429 `("CROSS_COMPILE=arm-linux-gnueabihf-")
432 #:tests? #f)) ; no tests
434 `(,@(if (and (not (string-prefix? "aarch64" (%current-system)))
435 (string-prefix? "aarch64" arch))
436 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
437 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu" #:xgcc gcc-7))
438 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
440 ,@(if (and (not (string-prefix? "armhf" (%current-system)))
441 (string-prefix? "armhf" arch))
442 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
443 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf" #:xgcc gcc-7))
444 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
447 (home-page "https://github.com/ARM-software/arm-trusted-firmware")
448 (synopsis "Implementation of \"secure world software\"")
450 "ARM Trusted Firmware provides a reference implementation of secure world
451 software for ARMv7A and ARMv8-A, including a Secure Monitor executing at
452 @dfn{Exception Level 3} (EL3). It implements various ARM interface standards,
455 @item The Power State Coordination Interface (PSCI)
456 @item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1)
457 @item SMC Calling Convention
458 @item System Control and Management Interface
459 @item Software Delegated Exception Interface (SDEI)
461 (license (list license:bsd-3
462 license:bsd-2)))) ; libfdt
464 (define-public arm-trusted-firmware-sun50i-a64
465 (let ((base (make-arm-trusted-firmware "sun50i_a64")))
468 (name "arm-trusted-firmware-sun50i-a64"))))
470 (define-public arm-trusted-firmware-rk3328
471 (make-arm-trusted-firmware "rk3328"))
473 (define-public arm-trusted-firmware-puma-rk3399
474 (let ((base (make-arm-trusted-firmware "rk3399"))
475 ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet.
476 (commit "d71e6d83612df896774ec4c03d49500312d2c324")
480 (name "arm-trusted-firmware-puma-rk3399")
481 (version (git-version "1.3" revision commit))
486 (url "https://git.theobroma-systems.com/arm-trusted-firmware.git")
488 (file-name (git-file-name name version))
491 "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8")))))))
493 (define-public arm-trusted-firmware-rk3399
494 (let ((base (make-arm-trusted-firmware "rk3399")))
497 (name "arm-trusted-firmware-rk3399")
499 `(("cross32-gcc" ,(cross-gcc "arm-none-eabi"))
500 ("cross32-binutils", (cross-binutils "arm-none-eabi"))
501 ,@(package-native-inputs base))))))
503 (define-public rk3399-cortex-m0
505 (name "rk3399-cortex-m0")
511 (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git")
512 (commit (string-append "v" version))))
513 (file-name (git-file-name "rk3399-cortex-m0" version))
516 "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w"))))
517 (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/")
518 (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)")
520 "Cortex-M0 firmware used with the RK3399 to implement
521 power-management functionality and helpers (e.g. DRAM frequency
522 switching support).\n")
523 (license license:bsd-3)
524 (build-system gnu-build-system)
527 (modify-phases %standard-phases
531 (lambda* (#:key outputs #:allow-other-keys)
532 (let ((out (assoc-ref outputs "out"))
533 (mzerofiles (find-files "." "rk3399m0.(elf|bin)$")))
536 (install-file file out))
539 (add-before 'build 'setenv
540 (lambda* (#:key inputs #:allow-other-keys)
541 (setenv "CROSS_COMPILE" "arm-none-eabi-")
543 (native-inputs `(("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7))
544 ("cross-binutils" ,(cross-binutils "arm-none-eabi"))))))