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> |
bb5c3582 | 6 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
04e46b98 | 7 | ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org> |
4902c3ec LC |
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) | |
ce03b453 | 25 | #:use-module ((guix licenses) #:prefix license:) |
4902c3ec | 26 | #:use-module (guix packages) |
e36a67c9 | 27 | #:use-module (guix download) |
e9252fd1 | 28 | #:use-module (guix utils) |
4902c3ec LC |
29 | #:use-module (guix git-download) |
30 | #:use-module (guix build-system gnu) | |
31 | #:use-module (gnu packages) | |
a5bc3dfe DC |
32 | #:use-module (gnu packages admin) |
33 | #:use-module (gnu packages assembly) | |
e36a67c9 | 34 | #:use-module (gnu packages bison) |
4902c3ec LC |
35 | #:use-module (gnu packages cmake) |
36 | #:use-module (gnu packages cross-base) | |
e36a67c9 | 37 | #:use-module (gnu packages flex) |
e9252fd1 | 38 | #:use-module (gnu packages gcc) |
a5bc3dfe | 39 | #:use-module (gnu packages linux) |
1b533bad DC |
40 | #:use-module (gnu packages perl) |
41 | #:use-module (gnu packages python)) | |
4902c3ec LC |
42 | |
43 | (define-public ath9k-htc-firmware | |
44 | (package | |
45 | (name "ath9k-htc-firmware") | |
7c473310 | 46 | (version "1.4.0") |
4902c3ec LC |
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 | |
7c473310 | 54 | "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23")) |
821f4dc2 | 55 | (file-name (string-append name "-" version "-checkout")) |
fc1adab1 | 56 | (patches (search-patches "ath9k-htc-firmware-objcopy.patch")))) |
4902c3ec LC |
57 | (build-system gnu-build-system) |
58 | (arguments | |
dc1d3cde KK |
59 | '(#:phases |
60 | (modify-phases %standard-phases | |
61 | (add-before 'configure 'pre-configure | |
62 | (lambda* (#:key inputs #:allow-other-keys) | |
63 | (chdir "target_firmware") | |
4902c3ec | 64 | |
dc1d3cde KK |
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"))) | |
dc1d3cde | 77 | (for-each (lambda (file) |
65a3c342 | 78 | (install-file file fw-dir)) |
dc1d3cde KK |
79 | (find-files "." "\\.fw$")) |
80 | #t)))) | |
4902c3ec LC |
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. | |
bd2e1a8c | 85 | (native-inputs `(("cross-gcc" ,(cross-gcc "xtensa-elf")) |
4902c3ec | 86 | ("cross-binutils" ,(cross-binutils "xtensa-elf")) |
c69959f0 | 87 | ("cmake" ,cmake-minimal) |
4902c3ec LC |
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 | |
e881752c | 93 | 802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of |
4902c3ec | 94 | Linux-libre.") |
ce03b453 | 95 | (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD")))) |
e36a67c9 EB |
96 | |
97 | (define-public b43-tools | |
bb5c3582 TGR |
98 | (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae") |
99 | (revision "1")) | |
e36a67c9 EB |
100 | (package |
101 | (name "b43-tools") | |
bb5c3582 | 102 | (version (git-version "0.0.0" revision commit)) |
e36a67c9 EB |
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 | |
bb5c3582 | 112 | "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn")))) |
e36a67c9 EB |
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)) | |
bb5c3582 | 121 | #:tests? #f ; no tests |
e36a67c9 EB |
122 | #:phases |
123 | (let ((subdirs '("assembler" "disassembler"))) | |
124 | (modify-phases %standard-phases | |
bb5c3582 | 125 | (delete 'configure) ; no configure script |
e36a67c9 EB |
126 | (add-before 'build 'patch-/bin/true |
127 | (lambda _ | |
128 | (substitute* (find-files "." "Makefile") | |
129 | (("/bin/true") ":")) | |
130 | #t)) | |
131 | (replace 'build | |
132 | (lambda _ | |
315c89f5 TGR |
133 | (for-each (lambda (dir) |
134 | (invoke "make" "-C" dir "CC=gcc")) | |
135 | subdirs) | |
136 | #t)) | |
e36a67c9 EB |
137 | (replace 'install |
138 | (lambda* (#:key outputs #:allow-other-keys) | |
139 | (let ((out (assoc-ref outputs "out"))) | |
140 | (mkdir-p (string-append out "/bin")) | |
315c89f5 TGR |
141 | (for-each (lambda (dir) |
142 | (invoke "make" "-C" dir | |
143 | (string-append "PREFIX=" out) | |
144 | "install")) | |
145 | subdirs) | |
146 | #t))))))) | |
e36a67c9 | 147 | (home-page |
3ebf12ea | 148 | "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools") |
e36a67c9 EB |
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.") | |
ce03b453 | 154 | (license license:gpl2)))) |
e36a67c9 EB |
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.") | |
ce03b453 | 184 | (license license:gpl2))) |
1b533bad | 185 | |
454403f1 VC |
186 | (define* (make-opensbi-package platform variant #:optional (arch "riscv64")) |
187 | (package | |
cd63c2be VC |
188 | (name (string-replace-substring |
189 | (string-append "opensbi-" platform "-" variant) | |
190 | "_" "-")) | |
454403f1 VC |
191 | (version "0.5") |
192 | (source | |
193 | (origin | |
194 | (method git-fetch) | |
195 | (uri (git-reference | |
196 | (url "https://github.com/riscv/opensbi.git") | |
197 | (commit (string-append "v" version)))) | |
198 | (file-name (git-file-name name version)) | |
199 | (sha256 | |
200 | (base32 "0qc73xbiy79qqkwxmp4mg15q8n8k26njkyqb6n0jw5dyibd6hb85")))) | |
201 | (build-system gnu-build-system) | |
202 | (native-inputs | |
203 | `(,@(if (and (not (string-prefix? "riscv64" (%current-system))) | |
204 | (string-prefix? "riscv64" arch)) | |
205 | `(("cross-gcc" ,(cross-gcc "riscv64-linux-gnu" #:xgcc gcc-7)) | |
206 | ("cross-binutils" ,(cross-binutils "riscv64-linux-gnu"))) | |
207 | '()))) | |
208 | (arguments | |
209 | `(#:tests? #f ; no check target | |
210 | #:make-flags (list (string-append "PLATFORM=" ,platform "/" ,variant) | |
211 | ,@(if (and (not (string-prefix? "riscv64" | |
212 | (%current-system))) | |
213 | (string-prefix? "riscv64" arch)) | |
214 | `("CROSS_COMPILE=riscv64-linux-gnu-") | |
215 | '()) | |
216 | "FW_PAYLOAD=n" | |
217 | "V=1") | |
218 | #:phases | |
219 | (modify-phases %standard-phases | |
220 | (delete 'configure) | |
221 | (replace 'install | |
222 | (lambda* (#:key outputs #:allow-other-keys) | |
223 | (let ((out (assoc-ref outputs "out")) | |
224 | (bin (find-files "." ".*fw_.*.elf$"))) | |
225 | (for-each | |
226 | (lambda (file) | |
227 | (install-file file out)) | |
228 | bin)) | |
229 | #t))))) | |
230 | (home-page "https://github.com/riscv/opensbi") | |
231 | (synopsis "RISC-V Open Source Supervisor Binary Interface") | |
232 | (description "A reference implementation of the RISC-V SBI specifications | |
233 | for platform-specific firmwares executing in M-mode.") | |
234 | (license (list license:bsd-2 | |
235 | ;; lib/utils/libfdt/* is dual licensed under bsd-2 and gpl2+. | |
236 | license:gpl2+ | |
237 | ;; platform/ariane-fpga/* is gpl2. | |
238 | license:gpl2)))) | |
239 | ||
240 | (define-public opensbi-qemu-virt | |
241 | (make-opensbi-package "qemu" "virt")) | |
242 | ||
cd63c2be VC |
243 | (define-public opensbi-qemu-sifive-u |
244 | (make-opensbi-package "qemu" "sifive_u")) | |
245 | ||
01501a30 VC |
246 | (define-public opensbi-sifive-fu540 |
247 | (make-opensbi-package "sifive" "fu540")) | |
248 | ||
1b533bad DC |
249 | (define-public seabios |
250 | (package | |
251 | (name "seabios") | |
dbc533c1 | 252 | (version "1.13.0") |
ae623b3f TGR |
253 | (source |
254 | (origin | |
255 | (method git-fetch) | |
256 | (uri (git-reference | |
257 | (url "https://review.coreboot.org/seabios.git") | |
258 | (commit (string-append "rel-" version)))) | |
259 | (file-name (git-file-name name version)) | |
260 | (sha256 | |
dbc533c1 | 261 | (base32 "1n1bd6msfs7xn8844sz2qnm7hb5x2qfl3zb06kp4bx9vdc3i6619")))) |
1b533bad DC |
262 | (build-system gnu-build-system) |
263 | (native-inputs | |
dbc533c1 | 264 | `(("python" ,python-wrapper))) |
1b533bad | 265 | (arguments |
ae623b3f | 266 | `(#:tests? #f ; no check target |
1b533bad DC |
267 | #:phases |
268 | (modify-phases %standard-phases | |
269 | (replace 'configure | |
270 | (lambda _ | |
271 | (setenv "CC" "gcc") | |
272 | #t)) | |
273 | (replace 'install | |
274 | (lambda* (#:key outputs #:allow-other-keys) | |
275 | (let* ((out (assoc-ref outputs "out")) | |
276 | (fmw (string-append out "/share/firmware"))) | |
277 | (mkdir-p fmw) | |
5f82a9d5 TGR |
278 | (copy-file "out/bios.bin" (string-append fmw "/bios.bin")) |
279 | #t)))))) | |
1b533bad DC |
280 | (home-page "https://www.seabios.org/SeaBIOS") |
281 | (synopsis "x86 BIOS implementation") | |
5a80c15c RW |
282 | (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS |
283 | can run in an emulator or it can run natively on X86 hardware with the use of | |
284 | coreboot.") | |
1b533bad DC |
285 | ;; Dual licensed. |
286 | (license (list license:gpl3+ license:lgpl3+ | |
287 | ;; src/fw/acpi-dsdt.dsl is lgpl2 | |
288 | license:lgpl2.1 | |
289 | ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and | |
290 | ;; cpl with a linking exception. | |
291 | license:cpl1.0)))) | |
a5bc3dfe DC |
292 | |
293 | ;; OVMF is part of the edk2 source tree. | |
294 | (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f") | |
295 | (define edk2-version (git-version "20170116" "1" edk2-commit)) | |
296 | (define edk2-origin | |
297 | (origin | |
298 | (method git-fetch) | |
299 | (uri (git-reference | |
300 | (url "https://github.com/tianocore/edk2") | |
301 | (commit edk2-commit))) | |
302 | (file-name (git-file-name "edk2" edk2-version)) | |
303 | (sha256 | |
304 | (base32 | |
305 | "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b")))) | |
306 | ||
307 | (define-public ovmf | |
308 | (package | |
309 | (name "ovmf") | |
310 | (version edk2-version) | |
311 | (source edk2-origin) | |
312 | (build-system gnu-build-system) | |
313 | (native-inputs | |
314 | `(("acpica" ,acpica) | |
90efc2f2 | 315 | ("gcc" ,gcc-5) |
a5bc3dfe DC |
316 | ("nasm" ,nasm) |
317 | ("python-2" ,python-2) | |
318 | ("util-linux" ,util-linux))) | |
319 | (arguments | |
320 | `(#:tests? #f ; No check target. | |
321 | #:phases | |
322 | (modify-phases %standard-phases | |
323 | (replace 'configure | |
324 | (lambda _ | |
325 | (let* ((cwd (getcwd)) | |
326 | (tools (string-append cwd "/BaseTools")) | |
327 | (bin (string-append tools "/BinWrappers/PosixLike"))) | |
328 | (setenv "WORKSPACE" cwd) | |
329 | (setenv "EDK_TOOLS_PATH" tools) | |
330 | (setenv "PATH" (string-append (getenv "PATH") ":" bin)) | |
cee03b26 RH |
331 | ; FIXME: The below script errors out. When using 'invoke' instead |
332 | ; of 'system*' this causes the build to fail. | |
bb63502f | 333 | (system* "bash" "edksetup.sh") |
a5bc3dfe DC |
334 | (substitute* "Conf/target.txt" |
335 | (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n") | |
a5bc3dfe DC |
336 | (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$") |
337 | (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%" | |
338 | (number->string (parallel-job-count))))) | |
339 | ;; Build build support. | |
340 | (setenv "BUILD_CC" "gcc") | |
bb63502f | 341 | (invoke "make" "-C" tools) |
f563d199 | 342 | #t))) |
bb63502f | 343 | (replace 'build |
a5bc3dfe | 344 | (lambda _ |
bb63502f EF |
345 | (invoke "build" "-a" "IA32" "-t" "GCC49" |
346 | "-p" "OvmfPkg/OvmfPkgIa32.dsc"))) | |
2eb95ade | 347 | ,@(if (string=? "x86_64-linux" (%current-system)) |
bfba1269 EF |
348 | '((add-after 'build 'build-x64 |
349 | (lambda _ | |
bb63502f EF |
350 | (invoke "build" "-a" "X64" "-t" "GCC49" |
351 | "-p" "OvmfPkg/OvmfPkgX64.dsc")))) | |
2eb95ade | 352 | '()) |
a5bc3dfe DC |
353 | (replace 'install |
354 | (lambda* (#:key outputs #:allow-other-keys) | |
355 | (let* ((out (assoc-ref outputs "out")) | |
356 | (fmw (string-append out "/share/firmware"))) | |
357 | (mkdir-p fmw) | |
358 | (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd" | |
359 | (string-append fmw "/ovmf_ia32.bin")) | |
2eb95ade EF |
360 | ,@(if (string=? "x86_64-linux" (%current-system)) |
361 | '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd" | |
362 | (string-append fmw "/ovmf_x64.bin"))) | |
363 | '())) | |
a5bc3dfe DC |
364 | #t))))) |
365 | (supported-systems '("x86_64-linux" "i686-linux")) | |
0dae4921 | 366 | (home-page "https://www.tianocore.org") |
a5bc3dfe DC |
367 | (synopsis "UEFI firmware for QEMU") |
368 | (description "OVMF is an EDK II based project to enable UEFI support for | |
369 | Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.") | |
370 | (license (list license:expat | |
371 | license:bsd-2 license:bsd-3 license:bsd-4)))) | |
e9252fd1 | 372 | |
cb97be5f EF |
373 | (define-public ovmf-aarch64 |
374 | (package | |
375 | (inherit ovmf) | |
376 | (name "ovmf-aarch64") | |
377 | (native-inputs | |
378 | `(,@(package-native-inputs ovmf) | |
379 | ,@(if (not (string-prefix? "aarch64" (%current-system))) | |
380 | `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu")) | |
381 | ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu"))) | |
382 | '()))) | |
383 | (arguments | |
384 | (substitute-keyword-arguments (package-arguments ovmf) | |
385 | ((#:phases phases) | |
386 | `(modify-phases ,phases | |
387 | (add-before 'configure 'set-env | |
388 | (lambda _ | |
389 | ,@(if (not (string-prefix? "aarch64" (%current-system))) | |
390 | `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-")) | |
391 | '()) | |
392 | #t)) | |
393 | (replace 'build | |
394 | (lambda _ | |
395 | (invoke "build" "-a" "AARCH64" "-t" "GCC49" | |
396 | "-p" "ArmVirtPkg/ArmVirtQemu.dsc"))) | |
397 | (delete 'build-x64) | |
398 | (replace 'install | |
399 | (lambda* (#:key outputs #:allow-other-keys) | |
400 | (let* ((out (assoc-ref outputs "out")) | |
401 | (fmw (string-append out "/share/firmware"))) | |
402 | (mkdir-p fmw) | |
403 | (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd" | |
404 | (string-append fmw "/ovmf_aarch64.bin")) | |
405 | #t))))))) | |
406 | (supported-systems %supported-systems))) | |
407 | ||
6da97043 EF |
408 | (define-public ovmf-arm |
409 | (package | |
410 | (inherit ovmf) | |
411 | (name "ovmf-arm") | |
412 | (native-inputs | |
413 | `(,@(package-native-inputs ovmf) | |
414 | ,@(if (not (string-prefix? "armhf" (%current-system))) | |
415 | `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf")) | |
416 | ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf"))) | |
417 | '()))) | |
418 | (arguments | |
419 | (substitute-keyword-arguments (package-arguments ovmf) | |
420 | ((#:phases phases) | |
421 | `(modify-phases ,phases | |
422 | (add-before 'configure 'set-env | |
423 | (lambda _ | |
424 | ,@(if (not (string-prefix? "armhf" (%current-system))) | |
425 | `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-")) | |
426 | '()) | |
427 | #t)) | |
428 | (replace 'build | |
429 | (lambda _ | |
430 | (invoke "build" "-a" "ARM" "-t" "GCC49" | |
431 | "-p" "ArmVirtPkg/ArmVirtQemu.dsc"))) | |
432 | (delete 'build-x64) | |
433 | (replace 'install | |
434 | (lambda* (#:key outputs #:allow-other-keys) | |
435 | (let* ((out (assoc-ref outputs "out")) | |
436 | (fmw (string-append out "/share/firmware"))) | |
437 | (mkdir-p fmw) | |
438 | (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd" | |
439 | (string-append fmw "/ovmf_arm.bin")) | |
440 | #t))))))) | |
441 | (supported-systems %supported-systems))) | |
442 | ||
e9252fd1 EF |
443 | (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64")) |
444 | (package | |
445 | (name (string-append "arm-trusted-firmware-" platform)) | |
a1fd8c5d | 446 | (version "2.2") |
e9252fd1 EF |
447 | (source |
448 | (origin | |
449 | (method git-fetch) | |
450 | (uri (git-reference | |
451 | ;; There are only GitHub generated release snapshots. | |
a1fd8c5d | 452 | (url "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/") |
e9252fd1 EF |
453 | (commit (string-append "v" version)))) |
454 | (file-name (git-file-name "arm-trusted-firmware" version)) | |
475dac08 | 455 | (patches (search-patches |
a90fd72b | 456 | "arm-trusted-firmware-disable-hdcp.patch")) |
e9252fd1 EF |
457 | (sha256 |
458 | (base32 | |
a1fd8c5d | 459 | "03fjl5hy1bqlya6fg553bqz7jrvilzrzpbs87cv6jd04v8qrvry8")))) |
e9252fd1 EF |
460 | (build-system gnu-build-system) |
461 | (arguments | |
462 | `(#:phases | |
463 | (modify-phases %standard-phases | |
464 | (delete 'configure) ; no configure script | |
a90fd72b VC |
465 | ;; Remove binary blobs which do not contain source or proper license. |
466 | (add-after 'unpack 'remove-binary-blobs | |
467 | (lambda _ | |
468 | (for-each (lambda (file) | |
469 | (delete-file file)) | |
470 | (find-files "." ".*\\.bin$")))) | |
e9252fd1 EF |
471 | (replace 'install |
472 | (lambda* (#:key outputs #:allow-other-keys) | |
473 | (let ((out (assoc-ref outputs "out")) | |
074554a2 | 474 | (bin (find-files "." ".*\\.(bin|elf)$"))) |
e9252fd1 EF |
475 | (for-each |
476 | (lambda (file) | |
477 | (install-file file out)) | |
478 | bin)) | |
479 | #t))) | |
480 | #:make-flags (list (string-append "PLAT=" ,platform) | |
481 | ,@(if (and (not (string-prefix? "aarch64" | |
482 | (%current-system))) | |
483 | (string-prefix? "aarch64" arch)) | |
484 | `("CROSS_COMPILE=aarch64-linux-gnu-") | |
485 | '()) | |
486 | ,@(if (and (not (string-prefix? "armhf" | |
487 | (%current-system))) | |
488 | (string-prefix? "armhf" arch)) | |
489 | `("CROSS_COMPILE=arm-linux-gnueabihf-") | |
490 | '()) | |
491 | "DEBUG=1") | |
492 | #:tests? #f)) ; no tests | |
493 | (native-inputs | |
494 | `(,@(if (and (not (string-prefix? "aarch64" (%current-system))) | |
495 | (string-prefix? "aarch64" arch)) | |
496 | ;; gcc-7 since it is used for u-boot, which needs gcc-7. | |
497 | `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu" #:xgcc gcc-7)) | |
498 | ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu"))) | |
499 | '()) | |
500 | ,@(if (and (not (string-prefix? "armhf" (%current-system))) | |
501 | (string-prefix? "armhf" arch)) | |
502 | ;; gcc-7 since it is used for u-boot, which needs gcc-7. | |
503 | `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf" #:xgcc gcc-7)) | |
504 | ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf"))) | |
505 | '()) | |
506 | )) | |
a1fd8c5d | 507 | (home-page "https://www.trustedfirmware.org/") |
e9252fd1 EF |
508 | (synopsis "Implementation of \"secure world software\"") |
509 | (description | |
510 | "ARM Trusted Firmware provides a reference implementation of secure world | |
511 | software for ARMv7A and ARMv8-A, including a Secure Monitor executing at | |
512 | @dfn{Exception Level 3} (EL3). It implements various ARM interface standards, | |
513 | such as: | |
514 | @enumerate | |
515 | @item The Power State Coordination Interface (PSCI) | |
516 | @item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1) | |
517 | @item SMC Calling Convention | |
518 | @item System Control and Management Interface | |
519 | @item Software Delegated Exception Interface (SDEI) | |
520 | @end enumerate\n") | |
521 | (license (list license:bsd-3 | |
522 | license:bsd-2)))) ; libfdt | |
ecff374e | 523 | |
95d91986 | 524 | (define-public arm-trusted-firmware-sun50i-a64 |
8b87b1bf | 525 | (let ((base (make-arm-trusted-firmware "sun50i_a64"))) |
ecff374e EF |
526 | (package |
527 | (inherit base) | |
8b87b1bf | 528 | (name "arm-trusted-firmware-sun50i-a64")))) |
6fe16577 | 529 | |
c07f3b18 VC |
530 | (define-public arm-trusted-firmware-rk3328 |
531 | (make-arm-trusted-firmware "rk3328")) | |
532 | ||
6fe16577 VC |
533 | (define-public arm-trusted-firmware-puma-rk3399 |
534 | (let ((base (make-arm-trusted-firmware "rk3399")) | |
535 | ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet. | |
536 | (commit "d71e6d83612df896774ec4c03d49500312d2c324") | |
537 | (revision "1")) | |
538 | (package | |
539 | (inherit base) | |
540 | (name "arm-trusted-firmware-puma-rk3399") | |
541 | (version (git-version "1.3" revision commit)) | |
542 | (source | |
543 | (origin | |
544 | (method git-fetch) | |
545 | (uri (git-reference | |
546 | (url "https://git.theobroma-systems.com/arm-trusted-firmware.git") | |
547 | (commit commit))) | |
548 | (file-name (git-file-name name version)) | |
549 | (sha256 | |
550 | (base32 | |
551 | "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8"))))))) | |
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)))))) | |
562 | ||
6fe16577 VC |
563 | (define-public rk3399-cortex-m0 |
564 | (package | |
565 | (name "rk3399-cortex-m0") | |
566 | (version "1") | |
567 | (source | |
568 | (origin | |
569 | (method git-fetch) | |
570 | (uri (git-reference | |
571 | (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git") | |
572 | (commit (string-append "v" version)))) | |
573 | (file-name (git-file-name "rk3399-cortex-m0" version)) | |
574 | (sha256 | |
575 | (base32 | |
576 | "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w")))) | |
577 | (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/") | |
578 | (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)") | |
579 | (description | |
580 | "Cortex-M0 firmware used with the RK3399 to implement | |
581 | power-management functionality and helpers (e.g. DRAM frequency | |
582 | switching support).\n") | |
583 | (license license:bsd-3) | |
584 | (build-system gnu-build-system) | |
585 | (arguments | |
586 | `(#:phases | |
587 | (modify-phases %standard-phases | |
588 | (delete 'configure) | |
589 | (delete 'check) | |
590 | (replace 'install | |
591 | (lambda* (#:key outputs #:allow-other-keys) | |
592 | (let ((out (assoc-ref outputs "out")) | |
593 | (mzerofiles (find-files "." "rk3399m0.(elf|bin)$"))) | |
594 | (for-each | |
595 | (lambda (file) | |
596 | (install-file file out)) | |
597 | mzerofiles)) | |
598 | #t)) | |
599 | (add-before 'build 'setenv | |
600 | (lambda* (#:key inputs #:allow-other-keys) | |
601 | (setenv "CROSS_COMPILE" "arm-none-eabi-") | |
602 | #t))))) | |
603 | (native-inputs `(("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7)) | |
604 | ("cross-binutils" ,(cross-binutils "arm-none-eabi")))))) |