Merge branch 'master' into staging
[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 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
9 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
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.
17 ;;;
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.
22 ;;;
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/>.
25
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))
45
46 (define-public ath9k-htc-firmware
47 (package
48 (name "ath9k-htc-firmware")
49 (version "1.4.0")
50 (source (origin
51 (method git-fetch)
52 (uri (git-reference
53 (url "https://github.com/qca/open-ath9k-htc-firmware.git")
54 (commit version)))
55 (sha256
56 (base32
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)
61 (arguments
62 '(#:phases
63 (modify-phases %standard-phases
64 (add-before 'configure 'pre-configure
65 (lambda* (#:key inputs native-inputs #:allow-other-keys)
66 (chdir "target_firmware")
67
68 ;; 'configure' is a simple script that runs 'cmake' with
69 ;; the right flags.
70 (substitute* "configure"
71 (("^TOOLCHAIN=.*$")
72 (string-append "TOOLCHAIN="
73 (assoc-ref (or native-inputs inputs) "cross-gcc")
74 "\n")))
75 #t))
76 (replace 'install
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$"))
83 #t))))
84 #:tests? #f))
85
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
89 "xtensa-elf"
90 #:xbinutils (cross-binutils "xtensa-elf"
91 binutils-2.33)))
92 ("cross-binutils" ,(cross-binutils "xtensa-elf" binutils-2.33))
93 ("cmake" ,cmake-minimal)
94 ("perl" ,perl)))
95 (home-page "https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc")
96 (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs")
97 (description
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
100 Linux-libre.")
101 (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
102
103 (define-public b43-tools
104 (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
105 (revision "1"))
106 (package
107 (name "b43-tools")
108 (version (git-version "0.0.0" revision commit))
109 (source
110 (origin
111 (method git-fetch)
112 (uri (git-reference
113 (url "http://git.bues.ch/git/b43-tools.git")
114 (commit commit)))
115 (file-name (git-file-name name version))
116 (sha256
117 (base32
118 "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn"))))
119 (build-system gnu-build-system)
120 (native-inputs
121 `(("flex" ,flex)
122 ("bison" ,bison)))
123 (arguments
124 `(#:modules ((srfi srfi-1)
125 (guix build gnu-build-system)
126 (guix build utils))
127 #:tests? #f ; no tests
128 #:phases
129 (let ((subdirs '("assembler" "disassembler")))
130 (modify-phases %standard-phases
131 (delete 'configure) ; no configure script
132 (add-before 'build 'patch-/bin/true
133 (lambda _
134 (substitute* (find-files "." "Makefile")
135 (("/bin/true") ":"))
136 #t))
137 (replace 'build
138 (lambda _
139 (for-each (lambda (dir)
140 (invoke "make" "-C" dir "CC=gcc"))
141 subdirs)
142 #t))
143 (replace 'install
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)
150 "install"))
151 subdirs)
152 #t)))))))
153 (home-page
154 "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools")
155 (synopsis "Collection of tools for the b43 wireless driver")
156 (description
157 "The b43 firmware tools is a collection of firmware extractor,
158 assembler, disassembler, and debugging tools for the Linux kernel b43 wireless
159 driver.")
160 (license license:gpl2))))
161
162 (define-public openfwwf-firmware
163 (package
164 (name "openfwwf-firmware")
165 (version "5.2")
166 (source
167 (origin
168 (method url-fetch)
169 (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/"
170 "openfwwf-" version ".tar.gz"))
171 (sha256
172 (base32
173 "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x"))))
174 (build-system gnu-build-system)
175 (native-inputs
176 `(("b43-tools" ,b43-tools)))
177 (arguments
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")
186 (description
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)))
191
192 (define* (make-opensbi-package platform variant #:optional (arch "riscv64"))
193 (package
194 (name (string-replace-substring
195 (string-append "opensbi-" platform "-" variant)
196 "_" "-"))
197 (version "0.6")
198 (source
199 (origin
200 (method git-fetch)
201 (uri (git-reference
202 (url "https://github.com/riscv/opensbi.git")
203 (commit (string-append "v" version))))
204 (file-name (git-file-name name version))
205 (sha256
206 (base32 "129ypdga0fzn657n2f42g2a1vx3hf8x7sd78h06d35pgkry0jkl7"))))
207 (build-system gnu-build-system)
208 (native-inputs
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")))
213 '())))
214 (arguments
215 `(#:tests? #f ; no check target
216 #:make-flags (list (string-append "PLATFORM=" ,platform "/" ,variant)
217 ,@(if (and (not (string-prefix? "riscv64"
218 (%current-system)))
219 (string-prefix? "riscv64" arch))
220 `("CROSS_COMPILE=riscv64-linux-gnu-")
221 '())
222 "FW_PAYLOAD=n"
223 "V=1")
224 #:phases
225 (modify-phases %standard-phases
226 (delete 'configure)
227 (replace 'install
228 (lambda* (#:key outputs #:allow-other-keys)
229 (let ((out (assoc-ref outputs "out"))
230 (bin (find-files "." ".*fw_.*.elf$")))
231 (for-each
232 (lambda (file)
233 (install-file file out))
234 bin))
235 #t)))))
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+.
242 license:gpl2+
243 ;; platform/ariane-fpga/* is gpl2.
244 license:gpl2))))
245
246 (define-public opensbi-qemu-virt
247 (make-opensbi-package "qemu" "virt"))
248
249 (define-public opensbi-sifive-fu540
250 (make-opensbi-package "sifive" "fu540"))
251
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))
256
257 (define-public seabios
258 (package
259 (name "seabios")
260 (version "1.13.0")
261 (source
262 (origin
263 (method git-fetch)
264 (uri (git-reference
265 (url "https://review.coreboot.org/seabios.git")
266 (commit (string-append "rel-" version))))
267 (file-name (git-file-name name version))
268 (sha256
269 (base32 "1n1bd6msfs7xn8844sz2qnm7hb5x2qfl3zb06kp4bx9vdc3i6619"))))
270 (build-system gnu-build-system)
271 (native-inputs
272 `(("python" ,python-wrapper)))
273 (arguments
274 `(#:tests? #f ; no check target
275 #:phases
276 (modify-phases %standard-phases
277 (replace 'configure
278 (lambda _
279 (setenv "CC" "gcc")
280 #t))
281 (replace 'install
282 (lambda* (#:key outputs #:allow-other-keys)
283 (let* ((out (assoc-ref outputs "out"))
284 (fmw (string-append out "/share/firmware")))
285 (mkdir-p fmw)
286 (copy-file "out/bios.bin" (string-append fmw "/bios.bin"))
287 #t))))))
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
292 coreboot.")
293 ;; Dual licensed.
294 (license (list license:gpl3+ license:lgpl3+
295 ;; src/fw/acpi-dsdt.dsl is lgpl2
296 license:lgpl2.1
297 ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and
298 ;; cpl with a linking exception.
299 license:cpl1.0))))
300
301 ;; OVMF is part of the edk2 source tree.
302 (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
303 (define edk2-version (git-version "20170116" "1" edk2-commit))
304 (define edk2-origin
305 (origin
306 (method git-fetch)
307 (uri (git-reference
308 (url "https://github.com/tianocore/edk2")
309 (commit edk2-commit)))
310 (file-name (git-file-name "edk2" edk2-version))
311 (sha256
312 (base32
313 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
314
315 (define-public ovmf
316 (package
317 (name "ovmf")
318 (version edk2-version)
319 (source edk2-origin)
320 (build-system gnu-build-system)
321 (native-inputs
322 `(("acpica" ,acpica)
323 ("gcc@5" ,gcc-5)
324 ("nasm" ,nasm)
325 ("python-2" ,python-2)
326 ("util-linux" ,util-linux "lib")))
327 (arguments
328 `(#:tests? #f ; No check target.
329 #:phases
330 (modify-phases %standard-phases
331 ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from
332 ;; shadowing the version of GCC provided in native-inputs.
333 (add-after 'set-paths 'hide-gcc7
334 (lambda* (#:key inputs #:allow-other-keys)
335 (let ((gcc (assoc-ref inputs "gcc")))
336 (setenv "CPLUS_INCLUDE_PATH"
337 (string-join
338 (delete (string-append gcc "/include/c++")
339 (string-split (getenv "CPLUS_INCLUDE_PATH")
340 #\:))
341 ":"))
342 #t)))
343 (replace 'configure
344 (lambda _
345 (let* ((cwd (getcwd))
346 (tools (string-append cwd "/BaseTools"))
347 (bin (string-append tools "/BinWrappers/PosixLike")))
348 (setenv "WORKSPACE" cwd)
349 (setenv "EDK_TOOLS_PATH" tools)
350 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
351 ; FIXME: The below script errors out. When using 'invoke' instead
352 ; of 'system*' this causes the build to fail.
353 (system* "bash" "edksetup.sh")
354 (substitute* "Conf/target.txt"
355 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
356 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
357 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
358 (number->string (parallel-job-count)))))
359 ;; Build build support.
360 (setenv "BUILD_CC" "gcc")
361 (invoke "make" "-C" tools)
362 #t)))
363 (replace 'build
364 (lambda _
365 (invoke "build" "-a" "IA32" "-t" "GCC49"
366 "-p" "OvmfPkg/OvmfPkgIa32.dsc")))
367 ,@(if (string=? "x86_64-linux" (%current-system))
368 '((add-after 'build 'build-x64
369 (lambda _
370 (invoke "build" "-a" "X64" "-t" "GCC49"
371 "-p" "OvmfPkg/OvmfPkgX64.dsc"))))
372 '())
373 (replace 'install
374 (lambda* (#:key outputs #:allow-other-keys)
375 (let* ((out (assoc-ref outputs "out"))
376 (fmw (string-append out "/share/firmware")))
377 (mkdir-p fmw)
378 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
379 (string-append fmw "/ovmf_ia32.bin"))
380 ,@(if (string=? "x86_64-linux" (%current-system))
381 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
382 (string-append fmw "/ovmf_x64.bin")))
383 '()))
384 #t)))))
385 (supported-systems '("x86_64-linux" "i686-linux"))
386 (home-page "https://www.tianocore.org")
387 (synopsis "UEFI firmware for QEMU")
388 (description "OVMF is an EDK II based project to enable UEFI support for
389 Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
390 (license (list license:expat
391 license:bsd-2 license:bsd-3 license:bsd-4))))
392
393 (define-public ovmf-aarch64
394 (package
395 (inherit ovmf)
396 (name "ovmf-aarch64")
397 (native-inputs
398 `(,@(package-native-inputs ovmf)
399 ,@(if (not (string-prefix? "aarch64" (%current-system)))
400 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
401 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
402 '())))
403 (arguments
404 (substitute-keyword-arguments (package-arguments ovmf)
405 ((#:phases phases)
406 `(modify-phases ,phases
407 (add-before 'configure 'set-env
408 (lambda _
409 ,@(if (not (string-prefix? "aarch64" (%current-system)))
410 `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
411 '())
412 #t))
413 (replace 'build
414 (lambda _
415 (invoke "build" "-a" "AARCH64" "-t" "GCC49"
416 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
417 (delete 'build-x64)
418 (replace 'install
419 (lambda* (#:key outputs #:allow-other-keys)
420 (let* ((out (assoc-ref outputs "out"))
421 (fmw (string-append out "/share/firmware")))
422 (mkdir-p fmw)
423 (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
424 (string-append fmw "/ovmf_aarch64.bin"))
425 #t)))))))
426 (supported-systems %supported-systems)))
427
428 (define-public ovmf-arm
429 (package
430 (inherit ovmf)
431 (name "ovmf-arm")
432 (native-inputs
433 `(,@(package-native-inputs ovmf)
434 ,@(if (not (string-prefix? "armhf" (%current-system)))
435 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
436 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
437 '())))
438 (arguments
439 (substitute-keyword-arguments (package-arguments ovmf)
440 ((#:phases phases)
441 `(modify-phases ,phases
442 (add-before 'configure 'set-env
443 (lambda _
444 ,@(if (not (string-prefix? "armhf" (%current-system)))
445 `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
446 '())
447 #t))
448 (replace 'build
449 (lambda _
450 (invoke "build" "-a" "ARM" "-t" "GCC49"
451 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
452 (delete 'build-x64)
453 (replace 'install
454 (lambda* (#:key outputs #:allow-other-keys)
455 (let* ((out (assoc-ref outputs "out"))
456 (fmw (string-append out "/share/firmware")))
457 (mkdir-p fmw)
458 (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
459 (string-append fmw "/ovmf_arm.bin"))
460 #t)))))))
461 (supported-systems %supported-systems)))
462
463 (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
464 (package
465 (name (string-append "arm-trusted-firmware-" platform))
466 (version "2.3")
467 (source
468 (origin
469 (method git-fetch)
470 (uri (git-reference
471 ;; There are only GitHub generated release snapshots.
472 (url "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/")
473 (commit (string-append "v" version))))
474 (file-name (git-file-name "arm-trusted-firmware" version))
475 (sha256
476 (base32
477 "113mcf1hwwl0i90cqh08lywxs1bfbg0nwqibay9wlkmx1a5v0bnj"))))
478 (build-system gnu-build-system)
479 (arguments
480 `(#:phases
481 (modify-phases %standard-phases
482 (delete 'configure) ; no configure script
483 ;; Remove binary blobs which do not contain source or proper license.
484 (add-after 'unpack 'remove-binary-blobs
485 (lambda _
486 (for-each (lambda (file)
487 (delete-file file))
488 (find-files "." ".*\\.bin$"))))
489 (replace 'install
490 (lambda* (#:key outputs #:allow-other-keys)
491 (let ((out (assoc-ref outputs "out"))
492 (bin (find-files "." ".*\\.(bin|elf)$")))
493 (for-each
494 (lambda (file)
495 (install-file file out))
496 bin))
497 #t)))
498 #:make-flags (list (string-append "PLAT=" ,platform)
499 ,@(if (and (not (string-prefix? "aarch64"
500 (%current-system)))
501 (string-prefix? "aarch64" arch))
502 `("CROSS_COMPILE=aarch64-linux-gnu-")
503 '())
504 ,@(if (and (not (string-prefix? "armhf"
505 (%current-system)))
506 (string-prefix? "armhf" arch))
507 `("CROSS_COMPILE=arm-linux-gnueabihf-")
508 '())
509 "DEBUG=1")
510 #:tests? #f)) ; no tests
511 (native-inputs
512 `(,@(if (and (not (string-prefix? "aarch64" (%current-system)))
513 (string-prefix? "aarch64" arch))
514 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
515 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu" #:xgcc gcc-7))
516 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
517 '())
518 ,@(if (and (not (string-prefix? "armhf" (%current-system)))
519 (string-prefix? "armhf" arch))
520 ;; gcc-7 since it is used for u-boot, which needs gcc-7.
521 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf" #:xgcc gcc-7))
522 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
523 '())
524 ))
525 (home-page "https://www.trustedfirmware.org/")
526 (synopsis "Implementation of \"secure world software\"")
527 (description
528 "ARM Trusted Firmware provides a reference implementation of secure world
529 software for ARMv7A and ARMv8-A, including a Secure Monitor executing at
530 @dfn{Exception Level 3} (EL3). It implements various ARM interface standards,
531 such as:
532 @enumerate
533 @item The Power State Coordination Interface (PSCI)
534 @item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1)
535 @item SMC Calling Convention
536 @item System Control and Management Interface
537 @item Software Delegated Exception Interface (SDEI)
538 @end enumerate\n")
539 (license (list license:bsd-3
540 license:bsd-2)))) ; libfdt
541
542 (define-public arm-trusted-firmware-sun50i-a64
543 (let ((base (make-arm-trusted-firmware "sun50i_a64")))
544 (package
545 (inherit base)
546 (name "arm-trusted-firmware-sun50i-a64"))))
547
548 (define-public arm-trusted-firmware-rk3328
549 (make-arm-trusted-firmware "rk3328"))
550
551 (define-public arm-trusted-firmware-puma-rk3399
552 (let ((base (make-arm-trusted-firmware "rk3399"))
553 ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet.
554 (commit "d71e6d83612df896774ec4c03d49500312d2c324")
555 (revision "1"))
556 (package
557 (inherit base)
558 (name "arm-trusted-firmware-puma-rk3399")
559 (version (git-version "1.3" revision commit))
560 (source
561 (origin
562 (method git-fetch)
563 (uri (git-reference
564 (url "https://git.theobroma-systems.com/arm-trusted-firmware.git")
565 (commit commit)))
566 (file-name (git-file-name name version))
567 (sha256
568 (base32
569 "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8")))))))
570
571 (define-public arm-trusted-firmware-rk3399
572 (let ((base (make-arm-trusted-firmware "rk3399")))
573 (package
574 (inherit base)
575 (name "arm-trusted-firmware-rk3399")
576 (native-inputs
577 `(("cross32-gcc" ,(cross-gcc "arm-none-eabi"))
578 ("cross32-binutils", (cross-binutils "arm-none-eabi"))
579 ,@(package-native-inputs base))))))
580
581 (define-public rk3399-cortex-m0
582 (package
583 (name "rk3399-cortex-m0")
584 (version "1")
585 (source
586 (origin
587 (method git-fetch)
588 (uri (git-reference
589 (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git")
590 (commit (string-append "v" version))))
591 (file-name (git-file-name "rk3399-cortex-m0" version))
592 (sha256
593 (base32
594 "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w"))))
595 (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/")
596 (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)")
597 (description
598 "Cortex-M0 firmware used with the RK3399 to implement
599 power-management functionality and helpers (e.g. DRAM frequency
600 switching support).\n")
601 (license license:bsd-3)
602 (build-system gnu-build-system)
603 (arguments
604 `(#:phases
605 (modify-phases %standard-phases
606 (delete 'configure)
607 (delete 'check)
608 (replace 'install
609 (lambda* (#:key outputs #:allow-other-keys)
610 (let ((out (assoc-ref outputs "out"))
611 (mzerofiles (find-files "." "rk3399m0.(elf|bin)$")))
612 (for-each
613 (lambda (file)
614 (install-file file out))
615 mzerofiles))
616 #t))
617 (add-before 'build 'setenv
618 (lambda* (#:key inputs #:allow-other-keys)
619 (setenv "CROSS_COMPILE" "arm-none-eabi-")
620 #t)))))
621 (native-inputs `(("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7))
622 ("cross-binutils" ,(cross-binutils "arm-none-eabi"))))))