Commit | Line | Data |
---|---|---|
4902c3ec | 1 | ;;; GNU Guix --- Functional package management for GNU |
bd2e1a8c | 2 | ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> |
e36a67c9 | 3 | ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org> |
ce03b453 | 4 | ;;; Copyright © 2017 David Craven <david@craven.ch> |
e9252fd1 | 5 | ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il> |
4d13d0f8 | 6 | ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
04e46b98 | 7 | ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org> |
283fb648 | 8 | ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> |
a493a526 | 9 | ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com> |
4902c3ec LC |
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) | |
ce03b453 | 27 | #:use-module ((guix licenses) #:prefix license:) |
4902c3ec | 28 | #:use-module (guix packages) |
e36a67c9 | 29 | #:use-module (guix download) |
e9252fd1 | 30 | #:use-module (guix utils) |
4902c3ec LC |
31 | #:use-module (guix git-download) |
32 | #:use-module (guix build-system gnu) | |
33 | #:use-module (gnu packages) | |
a5bc3dfe DC |
34 | #:use-module (gnu packages admin) |
35 | #:use-module (gnu packages assembly) | |
a493a526 | 36 | #:use-module (gnu packages base) |
e36a67c9 | 37 | #:use-module (gnu packages bison) |
4902c3ec LC |
38 | #:use-module (gnu packages cmake) |
39 | #:use-module (gnu packages cross-base) | |
e36a67c9 | 40 | #:use-module (gnu packages flex) |
e9252fd1 | 41 | #:use-module (gnu packages gcc) |
a5bc3dfe | 42 | #:use-module (gnu packages linux) |
1b533bad DC |
43 | #:use-module (gnu packages perl) |
44 | #:use-module (gnu packages python)) | |
4902c3ec LC |
45 | |
46 | (define-public ath9k-htc-firmware | |
47 | (package | |
48 | (name "ath9k-htc-firmware") | |
7c473310 | 49 | (version "1.4.0") |
4902c3ec LC |
50 | (source (origin |
51 | (method git-fetch) | |
52 | (uri (git-reference | |
b0e7b699 | 53 | (url "https://github.com/qca/open-ath9k-htc-firmware") |
4902c3ec LC |
54 | (commit version))) |
55 | (sha256 | |
56 | (base32 | |
7c473310 | 57 | "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23")) |
123334fa | 58 | (file-name (git-file-name name version)) |
fc1adab1 | 59 | (patches (search-patches "ath9k-htc-firmware-objcopy.patch")))) |
4902c3ec LC |
60 | (build-system gnu-build-system) |
61 | (arguments | |
dc1d3cde KK |
62 | '(#:phases |
63 | (modify-phases %standard-phases | |
64 | (add-before 'configure 'pre-configure | |
283fb648 | 65 | (lambda* (#:key inputs native-inputs #:allow-other-keys) |
dc1d3cde | 66 | (chdir "target_firmware") |
4902c3ec | 67 | |
dc1d3cde KK |
68 | ;; 'configure' is a simple script that runs 'cmake' with |
69 | ;; the right flags. | |
70 | (substitute* "configure" | |
71 | (("^TOOLCHAIN=.*$") | |
72 | (string-append "TOOLCHAIN=" | |
283fb648 | 73 | (assoc-ref (or native-inputs inputs) "cross-gcc") |
dc1d3cde KK |
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"))) | |
dc1d3cde | 80 | (for-each (lambda (file) |
65a3c342 | 81 | (install-file file fw-dir)) |
dc1d3cde KK |
82 | (find-files "." "\\.fw$")) |
83 | #t)))) | |
4902c3ec LC |
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. | |
a493a526 MB |
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)) | |
c69959f0 | 93 | ("cmake" ,cmake-minimal) |
4902c3ec | 94 | ("perl" ,perl))) |
927f3655 | 95 | (home-page "https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc") |
4902c3ec LC |
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 | |
e881752c | 99 | 802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of |
4902c3ec | 100 | Linux-libre.") |
ce03b453 | 101 | (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD")))) |
e36a67c9 EB |
102 | |
103 | (define-public b43-tools | |
bb5c3582 TGR |
104 | (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae") |
105 | (revision "1")) | |
e36a67c9 EB |
106 | (package |
107 | (name "b43-tools") | |
bb5c3582 | 108 | (version (git-version "0.0.0" revision commit)) |
e36a67c9 EB |
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))) | |
123334fa | 115 | (file-name (git-file-name name version)) |
e36a67c9 EB |
116 | (sha256 |
117 | (base32 | |
bb5c3582 | 118 | "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn")))) |
e36a67c9 EB |
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)) | |
bb5c3582 | 127 | #:tests? #f ; no tests |
e36a67c9 EB |
128 | #:phases |
129 | (let ((subdirs '("assembler" "disassembler"))) | |
130 | (modify-phases %standard-phases | |
bb5c3582 | 131 | (delete 'configure) ; no configure script |
e36a67c9 EB |
132 | (add-before 'build 'patch-/bin/true |
133 | (lambda _ | |
134 | (substitute* (find-files "." "Makefile") | |
135 | (("/bin/true") ":")) | |
136 | #t)) | |
137 | (replace 'build | |
138 | (lambda _ | |
315c89f5 TGR |
139 | (for-each (lambda (dir) |
140 | (invoke "make" "-C" dir "CC=gcc")) | |
141 | subdirs) | |
142 | #t)) | |
e36a67c9 EB |
143 | (replace 'install |
144 | (lambda* (#:key outputs #:allow-other-keys) | |
145 | (let ((out (assoc-ref outputs "out"))) | |
146 | (mkdir-p (string-append out "/bin")) | |
315c89f5 TGR |
147 | (for-each (lambda (dir) |
148 | (invoke "make" "-C" dir | |
149 | (string-append "PREFIX=" out) | |
150 | "install")) | |
151 | subdirs) | |
152 | #t))))))) | |
e36a67c9 | 153 | (home-page |
3ebf12ea | 154 | "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools") |
e36a67c9 EB |
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.") | |
ce03b453 | 160 | (license license:gpl2)))) |
e36a67c9 EB |
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.") | |
ce03b453 | 190 | (license license:gpl2))) |
1b533bad | 191 | |
f3a5e588 | 192 | (define* (make-opensbi-package platform name #:optional (arch "riscv64")) |
454403f1 | 193 | (package |
f3a5e588 VC |
194 | (name name) |
195 | (version "0.8") | |
454403f1 VC |
196 | (source |
197 | (origin | |
198 | (method git-fetch) | |
199 | (uri (git-reference | |
b0e7b699 | 200 | (url "https://github.com/riscv/opensbi") |
454403f1 VC |
201 | (commit (string-append "v" version)))) |
202 | (file-name (git-file-name name version)) | |
203 | (sha256 | |
f3a5e588 | 204 | (base32 "1y9z0b6q6wpw7mgy31wml4djc6m8ydm71a9f1asnks4ragc7m98b")))) |
454403f1 VC |
205 | (build-system gnu-build-system) |
206 | (native-inputs | |
207 | `(,@(if (and (not (string-prefix? "riscv64" (%current-system))) | |
208 | (string-prefix? "riscv64" arch)) | |
209 | `(("cross-gcc" ,(cross-gcc "riscv64-linux-gnu" #:xgcc gcc-7)) | |
210 | ("cross-binutils" ,(cross-binutils "riscv64-linux-gnu"))) | |
211 | '()))) | |
212 | (arguments | |
213 | `(#:tests? #f ; no check target | |
f3a5e588 | 214 | #:make-flags (list (string-append "PLATFORM=" ,platform) |
454403f1 VC |
215 | ,@(if (and (not (string-prefix? "riscv64" |
216 | (%current-system))) | |
217 | (string-prefix? "riscv64" arch)) | |
218 | `("CROSS_COMPILE=riscv64-linux-gnu-") | |
219 | '()) | |
220 | "FW_PAYLOAD=n" | |
221 | "V=1") | |
222 | #:phases | |
223 | (modify-phases %standard-phases | |
224 | (delete 'configure) | |
225 | (replace 'install | |
226 | (lambda* (#:key outputs #:allow-other-keys) | |
227 | (let ((out (assoc-ref outputs "out")) | |
228 | (bin (find-files "." ".*fw_.*.elf$"))) | |
229 | (for-each | |
230 | (lambda (file) | |
231 | (install-file file out)) | |
232 | bin)) | |
233 | #t))))) | |
234 | (home-page "https://github.com/riscv/opensbi") | |
235 | (synopsis "RISC-V Open Source Supervisor Binary Interface") | |
236 | (description "A reference implementation of the RISC-V SBI specifications | |
237 | for platform-specific firmwares executing in M-mode.") | |
238 | (license (list license:bsd-2 | |
239 | ;; lib/utils/libfdt/* is dual licensed under bsd-2 and gpl2+. | |
240 | license:gpl2+ | |
241 | ;; platform/ariane-fpga/* is gpl2. | |
242 | license:gpl2)))) | |
243 | ||
f3a5e588 VC |
244 | (define-public opensbi-qemu-generic |
245 | (make-opensbi-package "generic" "opensbi-qemu-generic")) | |
246 | ||
454403f1 | 247 | (define-public opensbi-qemu-virt |
f3a5e588 | 248 | (deprecated-package "opensbi-qemu-virt" opensbi-qemu-generic)) |
454403f1 | 249 | |
01501a30 | 250 | (define-public opensbi-sifive-fu540 |
f3a5e588 | 251 | (make-opensbi-package "sifive/fu540" "opensbi-sifive-fu540")) |
01501a30 | 252 | |
2d9b0581 VC |
253 | (define-public opensbi-qemu-sifive-u |
254 | ;; Dropped upstream, as all functionality is present in the sifive-fu540 | |
255 | ;; target for recent versions of qemu, u-boot and linux. | |
256 | (deprecated-package "opensbi-qemu-sifive-u" opensbi-sifive-fu540)) | |
257 | ||
1b533bad DC |
258 | (define-public seabios |
259 | (package | |
260 | (name "seabios") | |
4d13d0f8 | 261 | (version "1.14.0") |
ae623b3f TGR |
262 | (source |
263 | (origin | |
264 | (method git-fetch) | |
265 | (uri (git-reference | |
266 | (url "https://review.coreboot.org/seabios.git") | |
267 | (commit (string-append "rel-" version)))) | |
268 | (file-name (git-file-name name version)) | |
269 | (sha256 | |
4d13d0f8 | 270 | (base32 "0jp4rxsv9jdzvx4gjvkybj6g1yjg8pkd2wys4sdh6c029npp6y8p")))) |
1b533bad DC |
271 | (build-system gnu-build-system) |
272 | (native-inputs | |
dbc533c1 | 273 | `(("python" ,python-wrapper))) |
1b533bad | 274 | (arguments |
ae623b3f | 275 | `(#:tests? #f ; no check target |
1b533bad DC |
276 | #:phases |
277 | (modify-phases %standard-phases | |
278 | (replace 'configure | |
279 | (lambda _ | |
280 | (setenv "CC" "gcc") | |
281 | #t)) | |
282 | (replace 'install | |
283 | (lambda* (#:key outputs #:allow-other-keys) | |
284 | (let* ((out (assoc-ref outputs "out")) | |
285 | (fmw (string-append out "/share/firmware"))) | |
286 | (mkdir-p fmw) | |
5f82a9d5 TGR |
287 | (copy-file "out/bios.bin" (string-append fmw "/bios.bin")) |
288 | #t)))))) | |
1b533bad DC |
289 | (home-page "https://www.seabios.org/SeaBIOS") |
290 | (synopsis "x86 BIOS implementation") | |
5a80c15c RW |
291 | (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS |
292 | can run in an emulator or it can run natively on X86 hardware with the use of | |
293 | coreboot.") | |
1b533bad DC |
294 | ;; Dual licensed. |
295 | (license (list license:gpl3+ license:lgpl3+ | |
296 | ;; src/fw/acpi-dsdt.dsl is lgpl2 | |
297 | license:lgpl2.1 | |
298 | ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and | |
299 | ;; cpl with a linking exception. | |
300 | license:cpl1.0)))) | |
a5bc3dfe DC |
301 | |
302 | ;; OVMF is part of the edk2 source tree. | |
303 | (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f") | |
304 | (define edk2-version (git-version "20170116" "1" edk2-commit)) | |
305 | (define edk2-origin | |
306 | (origin | |
307 | (method git-fetch) | |
308 | (uri (git-reference | |
309 | (url "https://github.com/tianocore/edk2") | |
310 | (commit edk2-commit))) | |
311 | (file-name (git-file-name "edk2" edk2-version)) | |
312 | (sha256 | |
313 | (base32 | |
314 | "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b")))) | |
315 | ||
316 | (define-public ovmf | |
317 | (package | |
318 | (name "ovmf") | |
319 | (version edk2-version) | |
320 | (source edk2-origin) | |
321 | (build-system gnu-build-system) | |
322 | (native-inputs | |
323 | `(("acpica" ,acpica) | |
5d446d6b | 324 | ("gcc@5" ,gcc-5) |
a5bc3dfe DC |
325 | ("nasm" ,nasm) |
326 | ("python-2" ,python-2) | |
bb93042c | 327 | ("util-linux" ,util-linux "lib"))) |
a5bc3dfe DC |
328 | (arguments |
329 | `(#:tests? #f ; No check target. | |
330 | #:phases | |
331 | (modify-phases %standard-phases | |
5d446d6b MB |
332 | ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from |
333 | ;; shadowing the version of GCC provided in native-inputs. | |
334 | (add-after 'set-paths 'hide-gcc7 | |
335 | (lambda* (#:key inputs #:allow-other-keys) | |
336 | (let ((gcc (assoc-ref inputs "gcc"))) | |
337 | (setenv "CPLUS_INCLUDE_PATH" | |
338 | (string-join | |
339 | (delete (string-append gcc "/include/c++") | |
340 | (string-split (getenv "CPLUS_INCLUDE_PATH") | |
341 | #\:)) | |
342 | ":")) | |
343 | #t))) | |
a5bc3dfe DC |
344 | (replace 'configure |
345 | (lambda _ | |
346 | (let* ((cwd (getcwd)) | |
347 | (tools (string-append cwd "/BaseTools")) | |
348 | (bin (string-append tools "/BinWrappers/PosixLike"))) | |
349 | (setenv "WORKSPACE" cwd) | |
350 | (setenv "EDK_TOOLS_PATH" tools) | |
351 | (setenv "PATH" (string-append (getenv "PATH") ":" bin)) | |
cee03b26 RH |
352 | ; FIXME: The below script errors out. When using 'invoke' instead |
353 | ; of 'system*' this causes the build to fail. | |
bb63502f | 354 | (system* "bash" "edksetup.sh") |
a5bc3dfe DC |
355 | (substitute* "Conf/target.txt" |
356 | (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n") | |
a5bc3dfe DC |
357 | (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$") |
358 | (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%" | |
359 | (number->string (parallel-job-count))))) | |
360 | ;; Build build support. | |
361 | (setenv "BUILD_CC" "gcc") | |
bb63502f | 362 | (invoke "make" "-C" tools) |
f563d199 | 363 | #t))) |
bb63502f | 364 | (replace 'build |
a5bc3dfe | 365 | (lambda _ |
bb63502f EF |
366 | (invoke "build" "-a" "IA32" "-t" "GCC49" |
367 | "-p" "OvmfPkg/OvmfPkgIa32.dsc"))) | |
2eb95ade | 368 | ,@(if (string=? "x86_64-linux" (%current-system)) |
bfba1269 EF |
369 | '((add-after 'build 'build-x64 |
370 | (lambda _ | |
bb63502f EF |
371 | (invoke "build" "-a" "X64" "-t" "GCC49" |
372 | "-p" "OvmfPkg/OvmfPkgX64.dsc")))) | |
2eb95ade | 373 | '()) |
a5bc3dfe DC |
374 | (replace 'install |
375 | (lambda* (#:key outputs #:allow-other-keys) | |
376 | (let* ((out (assoc-ref outputs "out")) | |
377 | (fmw (string-append out "/share/firmware"))) | |
378 | (mkdir-p fmw) | |
379 | (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd" | |
380 | (string-append fmw "/ovmf_ia32.bin")) | |
2eb95ade EF |
381 | ,@(if (string=? "x86_64-linux" (%current-system)) |
382 | '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd" | |
383 | (string-append fmw "/ovmf_x64.bin"))) | |
384 | '())) | |
a5bc3dfe DC |
385 | #t))))) |
386 | (supported-systems '("x86_64-linux" "i686-linux")) | |
0dae4921 | 387 | (home-page "https://www.tianocore.org") |
a5bc3dfe DC |
388 | (synopsis "UEFI firmware for QEMU") |
389 | (description "OVMF is an EDK II based project to enable UEFI support for | |
390 | Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.") | |
391 | (license (list license:expat | |
392 | license:bsd-2 license:bsd-3 license:bsd-4)))) | |
e9252fd1 | 393 | |
cb97be5f EF |
394 | (define-public ovmf-aarch64 |
395 | (package | |
396 | (inherit ovmf) | |
397 | (name "ovmf-aarch64") | |
398 | (native-inputs | |
399 | `(,@(package-native-inputs ovmf) | |
400 | ,@(if (not (string-prefix? "aarch64" (%current-system))) | |
401 | `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu")) | |
402 | ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu"))) | |
403 | '()))) | |
404 | (arguments | |
405 | (substitute-keyword-arguments (package-arguments ovmf) | |
406 | ((#:phases phases) | |
407 | `(modify-phases ,phases | |
408 | (add-before 'configure 'set-env | |
409 | (lambda _ | |
410 | ,@(if (not (string-prefix? "aarch64" (%current-system))) | |
411 | `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-")) | |
412 | '()) | |
413 | #t)) | |
414 | (replace 'build | |
415 | (lambda _ | |
416 | (invoke "build" "-a" "AARCH64" "-t" "GCC49" | |
417 | "-p" "ArmVirtPkg/ArmVirtQemu.dsc"))) | |
418 | (delete 'build-x64) | |
419 | (replace 'install | |
420 | (lambda* (#:key outputs #:allow-other-keys) | |
421 | (let* ((out (assoc-ref outputs "out")) | |
422 | (fmw (string-append out "/share/firmware"))) | |
423 | (mkdir-p fmw) | |
424 | (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd" | |
425 | (string-append fmw "/ovmf_aarch64.bin")) | |
426 | #t))))))) | |
427 | (supported-systems %supported-systems))) | |
428 | ||
6da97043 EF |
429 | (define-public ovmf-arm |
430 | (package | |
431 | (inherit ovmf) | |
432 | (name "ovmf-arm") | |
433 | (native-inputs | |
434 | `(,@(package-native-inputs ovmf) | |
435 | ,@(if (not (string-prefix? "armhf" (%current-system))) | |
436 | `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf")) | |
437 | ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf"))) | |
438 | '()))) | |
439 | (arguments | |
440 | (substitute-keyword-arguments (package-arguments ovmf) | |
441 | ((#:phases phases) | |
442 | `(modify-phases ,phases | |
443 | (add-before 'configure 'set-env | |
444 | (lambda _ | |
445 | ,@(if (not (string-prefix? "armhf" (%current-system))) | |
446 | `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-")) | |
447 | '()) | |
448 | #t)) | |
449 | (replace 'build | |
450 | (lambda _ | |
451 | (invoke "build" "-a" "ARM" "-t" "GCC49" | |
452 | "-p" "ArmVirtPkg/ArmVirtQemu.dsc"))) | |
453 | (delete 'build-x64) | |
454 | (replace 'install | |
455 | (lambda* (#:key outputs #:allow-other-keys) | |
456 | (let* ((out (assoc-ref outputs "out")) | |
457 | (fmw (string-append out "/share/firmware"))) | |
458 | (mkdir-p fmw) | |
459 | (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd" | |
460 | (string-append fmw "/ovmf_arm.bin")) | |
461 | #t))))))) | |
462 | (supported-systems %supported-systems))) | |
463 | ||
e9252fd1 EF |
464 | (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64")) |
465 | (package | |
466 | (name (string-append "arm-trusted-firmware-" platform)) | |
be33acc2 | 467 | (version "2.4") |
e9252fd1 EF |
468 | (source |
469 | (origin | |
470 | (method git-fetch) | |
471 | (uri (git-reference | |
472 | ;; There are only GitHub generated release snapshots. | |
a1fd8c5d | 473 | (url "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/") |
e9252fd1 EF |
474 | (commit (string-append "v" version)))) |
475 | (file-name (git-file-name "arm-trusted-firmware" version)) | |
476 | (sha256 | |
477 | (base32 | |
be33acc2 | 478 | "12k0n79j156bdzqws18kpbli04kn00nh6dy42pjv6gakqrkx9px3")))) |
e9252fd1 EF |
479 | (build-system gnu-build-system) |
480 | (arguments | |
481 | `(#:phases | |
482 | (modify-phases %standard-phases | |
483 | (delete 'configure) ; no configure script | |
a90fd72b VC |
484 | ;; Remove binary blobs which do not contain source or proper license. |
485 | (add-after 'unpack 'remove-binary-blobs | |
486 | (lambda _ | |
487 | (for-each (lambda (file) | |
488 | (delete-file file)) | |
489 | (find-files "." ".*\\.bin$")))) | |
e9252fd1 EF |
490 | (replace 'install |
491 | (lambda* (#:key outputs #:allow-other-keys) | |
492 | (let ((out (assoc-ref outputs "out")) | |
074554a2 | 493 | (bin (find-files "." ".*\\.(bin|elf)$"))) |
e9252fd1 EF |
494 | (for-each |
495 | (lambda (file) | |
496 | (install-file file out)) | |
497 | bin)) | |
498 | #t))) | |
499 | #:make-flags (list (string-append "PLAT=" ,platform) | |
500 | ,@(if (and (not (string-prefix? "aarch64" | |
501 | (%current-system))) | |
502 | (string-prefix? "aarch64" arch)) | |
503 | `("CROSS_COMPILE=aarch64-linux-gnu-") | |
504 | '()) | |
505 | ,@(if (and (not (string-prefix? "armhf" | |
506 | (%current-system))) | |
507 | (string-prefix? "armhf" arch)) | |
508 | `("CROSS_COMPILE=arm-linux-gnueabihf-") | |
509 | '()) | |
510 | "DEBUG=1") | |
511 | #:tests? #f)) ; no tests | |
512 | (native-inputs | |
513 | `(,@(if (and (not (string-prefix? "aarch64" (%current-system))) | |
514 | (string-prefix? "aarch64" arch)) | |
be33acc2 VC |
515 | ;; Needs newer gcc version for some targets |
516 | `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu" #:xgcc gcc-9)) | |
e9252fd1 EF |
517 | ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu"))) |
518 | '()) | |
519 | ,@(if (and (not (string-prefix? "armhf" (%current-system))) | |
520 | (string-prefix? "armhf" arch)) | |
be33acc2 VC |
521 | ;; Needs newer gcc version for some targets |
522 | `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf" #:xgcc gcc-9)) | |
e9252fd1 EF |
523 | ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf"))) |
524 | '()) | |
be33acc2 VC |
525 | ;; Needs newer gcc version for some targets |
526 | ("gcc" ,gcc-9))) | |
a1fd8c5d | 527 | (home-page "https://www.trustedfirmware.org/") |
e9252fd1 EF |
528 | (synopsis "Implementation of \"secure world software\"") |
529 | (description | |
530 | "ARM Trusted Firmware provides a reference implementation of secure world | |
531 | software for ARMv7A and ARMv8-A, including a Secure Monitor executing at | |
532 | @dfn{Exception Level 3} (EL3). It implements various ARM interface standards, | |
533 | such as: | |
534 | @enumerate | |
535 | @item The Power State Coordination Interface (PSCI) | |
536 | @item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1) | |
537 | @item SMC Calling Convention | |
538 | @item System Control and Management Interface | |
539 | @item Software Delegated Exception Interface (SDEI) | |
540 | @end enumerate\n") | |
541 | (license (list license:bsd-3 | |
542 | license:bsd-2)))) ; libfdt | |
ecff374e | 543 | |
95d91986 | 544 | (define-public arm-trusted-firmware-sun50i-a64 |
8b87b1bf | 545 | (let ((base (make-arm-trusted-firmware "sun50i_a64"))) |
ecff374e EF |
546 | (package |
547 | (inherit base) | |
8b87b1bf | 548 | (name "arm-trusted-firmware-sun50i-a64")))) |
6fe16577 | 549 | |
c07f3b18 VC |
550 | (define-public arm-trusted-firmware-rk3328 |
551 | (make-arm-trusted-firmware "rk3328")) | |
552 | ||
074554a2 CN |
553 | (define-public arm-trusted-firmware-rk3399 |
554 | (let ((base (make-arm-trusted-firmware "rk3399"))) | |
555 | (package | |
556 | (inherit base) | |
557 | (name "arm-trusted-firmware-rk3399") | |
558 | (native-inputs | |
559 | `(("cross32-gcc" ,(cross-gcc "arm-none-eabi")) | |
560 | ("cross32-binutils", (cross-binutils "arm-none-eabi")) | |
561 | ,@(package-native-inputs base)))))) |