gnu: Add cl-ana.statistical-learning.
[jackhill/guix/guix.git] / gnu / packages / firmware.scm
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 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
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.
15 ;;;
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.
20 ;;;
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/>.
23
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))
42
43 (define-public ath9k-htc-firmware
44 (package
45 (name "ath9k-htc-firmware")
46 (version "1.4.0")
47 (source (origin
48 (method git-fetch)
49 (uri (git-reference
50 (url "https://github.com/qca/open-ath9k-htc-firmware.git")
51 (commit version)))
52 (sha256
53 (base32
54 "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
55 (file-name (string-append name "-" version "-checkout"))
56 (patches (search-patches "ath9k-htc-firmware-objcopy.patch"))))
57 (build-system gnu-build-system)
58 (arguments
59 '(#:phases
60 (modify-phases %standard-phases
61 (add-before 'configure 'pre-configure
62 (lambda* (#:key inputs #:allow-other-keys)
63 (chdir "target_firmware")
64
65 ;; 'configure' is a simple script that runs 'cmake' with
66 ;; the right flags.
67 (substitute* "configure"
68 (("^TOOLCHAIN=.*$")
69 (string-append "TOOLCHAIN="
70 (assoc-ref inputs "cross-gcc")
71 "\n")))
72 #t))
73 (replace 'install
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$"))
80 #t))))
81 #:tests? #f))
82
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)
88 ("perl" ,perl)))
89 (home-page "http://wireless.kernel.org/en/users/Drivers/ath9k_htc")
90 (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs")
91 (description
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
94 Linux-libre.")
95 (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
96
97 (define-public b43-tools
98 (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
99 (revision "1"))
100 (package
101 (name "b43-tools")
102 (version (git-version "0.0.0" revision commit))
103 (source
104 (origin
105 (method git-fetch)
106 (uri (git-reference
107 (url "http://git.bues.ch/git/b43-tools.git")
108 (commit commit)))
109 (file-name (string-append name "-" version "-checkout"))
110 (sha256
111 (base32
112 "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn"))))
113 (build-system gnu-build-system)
114 (native-inputs
115 `(("flex" ,flex)
116 ("bison" ,bison)))
117 (arguments
118 `(#:modules ((srfi srfi-1)
119 (guix build gnu-build-system)
120 (guix build utils))
121 #:tests? #f ; no tests
122 #:phases
123 (let ((subdirs '("assembler" "disassembler")))
124 (modify-phases %standard-phases
125 (delete 'configure) ; no configure script
126 (add-before 'build 'patch-/bin/true
127 (lambda _
128 (substitute* (find-files "." "Makefile")
129 (("/bin/true") ":"))
130 #t))
131 (replace 'build
132 (lambda _
133 (for-each (lambda (dir)
134 (invoke "make" "-C" dir "CC=gcc"))
135 subdirs)
136 #t))
137 (replace 'install
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)
144 "install"))
145 subdirs)
146 #t)))))))
147 (home-page
148 "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools")
149 (synopsis "Collection of tools for the b43 wireless driver")
150 (description
151 "The b43 firmware tools is a collection of firmware extractor,
152 assembler, disassembler, and debugging tools for the Linux kernel b43 wireless
153 driver.")
154 (license license:gpl2))))
155
156 (define-public openfwwf-firmware
157 (package
158 (name "openfwwf-firmware")
159 (version "5.2")
160 (source
161 (origin
162 (method url-fetch)
163 (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/"
164 "openfwwf-" version ".tar.gz"))
165 (sha256
166 (base32
167 "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x"))))
168 (build-system gnu-build-system)
169 (native-inputs
170 `(("b43-tools" ,b43-tools)))
171 (arguments
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")
180 (description
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)))
185
186 (define-public seabios
187 (package
188 (name "seabios")
189 (version "1.13.0")
190 (source
191 (origin
192 (method git-fetch)
193 (uri (git-reference
194 (url "https://review.coreboot.org/seabios.git")
195 (commit (string-append "rel-" version))))
196 (file-name (git-file-name name version))
197 (sha256
198 (base32 "1n1bd6msfs7xn8844sz2qnm7hb5x2qfl3zb06kp4bx9vdc3i6619"))))
199 (build-system gnu-build-system)
200 (native-inputs
201 `(("python" ,python-wrapper)))
202 (arguments
203 `(#:tests? #f ; no check target
204 #:phases
205 (modify-phases %standard-phases
206 (replace 'configure
207 (lambda _
208 (setenv "CC" "gcc")
209 #t))
210 (replace 'install
211 (lambda* (#:key outputs #:allow-other-keys)
212 (let* ((out (assoc-ref outputs "out"))
213 (fmw (string-append out "/share/firmware")))
214 (mkdir-p fmw)
215 (copy-file "out/bios.bin" (string-append fmw "/bios.bin"))
216 #t))))))
217 (home-page "https://www.seabios.org/SeaBIOS")
218 (synopsis "x86 BIOS implementation")
219 (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS
220 can run in an emulator or it can run natively on X86 hardware with the use of
221 coreboot.")
222 ;; Dual licensed.
223 (license (list license:gpl3+ license:lgpl3+
224 ;; src/fw/acpi-dsdt.dsl is lgpl2
225 license:lgpl2.1
226 ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and
227 ;; cpl with a linking exception.
228 license:cpl1.0))))
229
230 ;; OVMF is part of the edk2 source tree.
231 (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
232 (define edk2-version (git-version "20170116" "1" edk2-commit))
233 (define edk2-origin
234 (origin
235 (method git-fetch)
236 (uri (git-reference
237 (url "https://github.com/tianocore/edk2")
238 (commit edk2-commit)))
239 (file-name (git-file-name "edk2" edk2-version))
240 (sha256
241 (base32
242 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
243
244 (define-public ovmf
245 (package
246 (name "ovmf")
247 (version edk2-version)
248 (source edk2-origin)
249 (build-system gnu-build-system)
250 (native-inputs
251 `(("acpica" ,acpica)
252 ("gcc" ,gcc-5)
253 ("nasm" ,nasm)
254 ("python-2" ,python-2)
255 ("util-linux" ,util-linux)))
256 (arguments
257 `(#:tests? #f ; No check target.
258 #:phases
259 (modify-phases %standard-phases
260 (replace 'configure
261 (lambda _
262 (let* ((cwd (getcwd))
263 (tools (string-append cwd "/BaseTools"))
264 (bin (string-append tools "/BinWrappers/PosixLike")))
265 (setenv "WORKSPACE" cwd)
266 (setenv "EDK_TOOLS_PATH" tools)
267 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
268 ; FIXME: The below script errors out. When using 'invoke' instead
269 ; of 'system*' this causes the build to fail.
270 (system* "bash" "edksetup.sh")
271 (substitute* "Conf/target.txt"
272 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
273 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
274 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
275 (number->string (parallel-job-count)))))
276 ;; Build build support.
277 (setenv "BUILD_CC" "gcc")
278 (invoke "make" "-C" tools)
279 #t)))
280 (replace 'build
281 (lambda _
282 (invoke "build" "-a" "IA32" "-t" "GCC49"
283 "-p" "OvmfPkg/OvmfPkgIa32.dsc")))
284 ,@(if (string=? "x86_64-linux" (%current-system))
285 '((add-after 'build 'build-x64
286 (lambda _
287 (invoke "build" "-a" "X64" "-t" "GCC49"
288 "-p" "OvmfPkg/OvmfPkgX64.dsc"))))
289 '())
290 (replace 'install
291 (lambda* (#:key outputs #:allow-other-keys)
292 (let* ((out (assoc-ref outputs "out"))
293 (fmw (string-append out "/share/firmware")))
294 (mkdir-p fmw)
295 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
296 (string-append fmw "/ovmf_ia32.bin"))
297 ,@(if (string=? "x86_64-linux" (%current-system))
298 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
299 (string-append fmw "/ovmf_x64.bin")))
300 '()))
301 #t)))))
302 (supported-systems '("x86_64-linux" "i686-linux"))
303 (home-page "https://www.tianocore.org")
304 (synopsis "UEFI firmware for QEMU")
305 (description "OVMF is an EDK II based project to enable UEFI support for
306 Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
307 (license (list license:expat
308 license:bsd-2 license:bsd-3 license:bsd-4))))
309
310 (define-public ovmf-aarch64
311 (package
312 (inherit ovmf)
313 (name "ovmf-aarch64")
314 (native-inputs
315 `(,@(package-native-inputs ovmf)
316 ,@(if (not (string-prefix? "aarch64" (%current-system)))
317 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
318 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
319 '())))
320 (arguments
321 (substitute-keyword-arguments (package-arguments ovmf)
322 ((#:phases phases)
323 `(modify-phases ,phases
324 (add-before 'configure 'set-env
325 (lambda _
326 ,@(if (not (string-prefix? "aarch64" (%current-system)))
327 `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
328 '())
329 #t))
330 (replace 'build
331 (lambda _
332 (invoke "build" "-a" "AARCH64" "-t" "GCC49"
333 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
334 (delete 'build-x64)
335 (replace 'install
336 (lambda* (#:key outputs #:allow-other-keys)
337 (let* ((out (assoc-ref outputs "out"))
338 (fmw (string-append out "/share/firmware")))
339 (mkdir-p fmw)
340 (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
341 (string-append fmw "/ovmf_aarch64.bin"))
342 #t)))))))
343 (supported-systems %supported-systems)))
344
345 (define-public ovmf-arm
346 (package
347 (inherit ovmf)
348 (name "ovmf-arm")
349 (native-inputs
350 `(,@(package-native-inputs ovmf)
351 ,@(if (not (string-prefix? "armhf" (%current-system)))
352 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
353 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
354 '())))
355 (arguments
356 (substitute-keyword-arguments (package-arguments ovmf)
357 ((#:phases phases)
358 `(modify-phases ,phases
359 (add-before 'configure 'set-env
360 (lambda _
361 ,@(if (not (string-prefix? "armhf" (%current-system)))
362 `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
363 '())
364 #t))
365 (replace 'build
366 (lambda _
367 (invoke "build" "-a" "ARM" "-t" "GCC49"
368 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
369 (delete 'build-x64)
370 (replace 'install
371 (lambda* (#:key outputs #:allow-other-keys)
372 (let* ((out (assoc-ref outputs "out"))
373 (fmw (string-append out "/share/firmware")))
374 (mkdir-p fmw)
375 (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
376 (string-append fmw "/ovmf_arm.bin"))
377 #t)))))))
378 (supported-systems %supported-systems)))
379
380 (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
381 (package
382 (name (string-append "arm-trusted-firmware-" platform))
383 (version "2.1")
384 (source
385 (origin
386 (method git-fetch)
387 (uri (git-reference
388 ;; There are only GitHub generated release snapshots.
389 (url "https://github.com/ARM-software/arm-trusted-firmware.git")
390 (commit (string-append "v" version))))
391 (file-name (git-file-name "arm-trusted-firmware" version))
392 (patches (search-patches
393 "arm-trusted-firmware-optional-bin-generation.patch"
394 "arm-trusted-firmware-rockchip-disable-binary.patch"
395 "arm-trusted-firmware-disable-hdcp.patch"))
396 (sha256
397 (base32
398 "1gy5qskrjy8n3kxdcm1dx8b45l5b75n0pm8pq80wl6xic1ycy24r"))))
399 (build-system gnu-build-system)
400 (arguments
401 `(#:phases
402 (modify-phases %standard-phases
403 (delete 'configure) ; no configure script
404 ;; Remove binary blobs which do not contain source or proper license.
405 (add-after 'unpack 'remove-binary-blobs
406 (lambda _
407 (for-each (lambda (file)
408 (delete-file file))
409 (find-files "." ".*\\.bin$"))))
410 (replace 'install
411 (lambda* (#:key outputs #:allow-other-keys)
412 (let ((out (assoc-ref outputs "out"))
413 (bin (find-files "." ".*\\.(bin|elf)$")))
414 (for-each
415 (lambda (file)
416 (install-file file out))
417 bin))
418 #t)))
419 #:make-flags (list (string-append "PLAT=" ,platform)
420 ,@(if (and (not (string-prefix? "aarch64"
421 (%current-system)))
422 (string-prefix? "aarch64" arch))
423 `("CROSS_COMPILE=aarch64-linux-gnu-")
424 '())
425 ,@(if (and (not (string-prefix? "armhf"
426 (%current-system)))
427 (string-prefix? "armhf" arch))
428 `("CROSS_COMPILE=arm-linux-gnueabihf-")
429 '())
430 "DEBUG=1")
431 #:tests? #f)) ; no tests
432 (native-inputs
433 `(,@(if (and (not (string-prefix? "aarch64" (%current-system)))
434 (string-prefix? "aarch64" arch))
435 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
436 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu" #:xgcc gcc-7))
437 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
438 '())
439 ,@(if (and (not (string-prefix? "armhf" (%current-system)))
440 (string-prefix? "armhf" arch))
441 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
442 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf" #:xgcc gcc-7))
443 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
444 '())
445 ))
446 (home-page "https://github.com/ARM-software/arm-trusted-firmware")
447 (synopsis "Implementation of \"secure world software\"")
448 (description
449 "ARM Trusted Firmware provides a reference implementation of secure world
450 software for ARMv7A and ARMv8-A, including a Secure Monitor executing at
451 @dfn{Exception Level 3} (EL3). It implements various ARM interface standards,
452 such as:
453 @enumerate
454 @item The Power State Coordination Interface (PSCI)
455 @item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1)
456 @item SMC Calling Convention
457 @item System Control and Management Interface
458 @item Software Delegated Exception Interface (SDEI)
459 @end enumerate\n")
460 (license (list license:bsd-3
461 license:bsd-2)))) ; libfdt
462
463 (define-public arm-trusted-firmware-sun50i-a64
464 (let ((base (make-arm-trusted-firmware "sun50i_a64")))
465 (package
466 (inherit base)
467 (name "arm-trusted-firmware-sun50i-a64"))))
468
469 (define-public arm-trusted-firmware-rk3328
470 (make-arm-trusted-firmware "rk3328"))
471
472 (define-public arm-trusted-firmware-puma-rk3399
473 (let ((base (make-arm-trusted-firmware "rk3399"))
474 ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet.
475 (commit "d71e6d83612df896774ec4c03d49500312d2c324")
476 (revision "1"))
477 (package
478 (inherit base)
479 (name "arm-trusted-firmware-puma-rk3399")
480 (version (git-version "1.3" revision commit))
481 (source
482 (origin
483 (method git-fetch)
484 (uri (git-reference
485 (url "https://git.theobroma-systems.com/arm-trusted-firmware.git")
486 (commit commit)))
487 (file-name (git-file-name name version))
488 (sha256
489 (base32
490 "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8")))))))
491
492 (define-public arm-trusted-firmware-rk3399
493 (let ((base (make-arm-trusted-firmware "rk3399")))
494 (package
495 (inherit base)
496 (name "arm-trusted-firmware-rk3399")
497 (native-inputs
498 `(("cross32-gcc" ,(cross-gcc "arm-none-eabi"))
499 ("cross32-binutils", (cross-binutils "arm-none-eabi"))
500 ,@(package-native-inputs base))))))
501
502 (define-public rk3399-cortex-m0
503 (package
504 (name "rk3399-cortex-m0")
505 (version "1")
506 (source
507 (origin
508 (method git-fetch)
509 (uri (git-reference
510 (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git")
511 (commit (string-append "v" version))))
512 (file-name (git-file-name "rk3399-cortex-m0" version))
513 (sha256
514 (base32
515 "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w"))))
516 (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/")
517 (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)")
518 (description
519 "Cortex-M0 firmware used with the RK3399 to implement
520 power-management functionality and helpers (e.g. DRAM frequency
521 switching support).\n")
522 (license license:bsd-3)
523 (build-system gnu-build-system)
524 (arguments
525 `(#:phases
526 (modify-phases %standard-phases
527 (delete 'configure)
528 (delete 'check)
529 (replace 'install
530 (lambda* (#:key outputs #:allow-other-keys)
531 (let ((out (assoc-ref outputs "out"))
532 (mzerofiles (find-files "." "rk3399m0.(elf|bin)$")))
533 (for-each
534 (lambda (file)
535 (install-file file out))
536 mzerofiles))
537 #t))
538 (add-before 'build 'setenv
539 (lambda* (#:key inputs #:allow-other-keys)
540 (setenv "CROSS_COMPILE" "arm-none-eabi-")
541 #t)))))
542 (native-inputs `(("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7))
543 ("cross-binutils" ,(cross-binutils "arm-none-eabi"))))))