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> |
2eb95ade | 5 | ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il> |
bb5c3582 | 6 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
4902c3ec LC |
7 | ;;; |
8 | ;;; This file is part of GNU Guix. | |
9 | ;;; | |
10 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
11 | ;;; under the terms of the GNU General Public License as published by | |
12 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
13 | ;;; your option) any later version. | |
14 | ;;; | |
15 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
16 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;;; GNU General Public License for more details. | |
19 | ;;; | |
20 | ;;; You should have received a copy of the GNU General Public License | |
21 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
22 | ||
23 | (define-module (gnu packages firmware) | |
ce03b453 | 24 | #:use-module ((guix licenses) #:prefix license:) |
4902c3ec | 25 | #:use-module (guix packages) |
e36a67c9 | 26 | #:use-module (guix download) |
4902c3ec LC |
27 | #:use-module (guix git-download) |
28 | #:use-module (guix build-system gnu) | |
29 | #:use-module (gnu packages) | |
a5bc3dfe DC |
30 | #:use-module (gnu packages admin) |
31 | #:use-module (gnu packages assembly) | |
e36a67c9 | 32 | #:use-module (gnu packages bison) |
4902c3ec LC |
33 | #:use-module (gnu packages cmake) |
34 | #:use-module (gnu packages cross-base) | |
e36a67c9 | 35 | #:use-module (gnu packages flex) |
a5bc3dfe | 36 | #:use-module (gnu packages linux) |
1b533bad DC |
37 | #:use-module (gnu packages perl) |
38 | #:use-module (gnu packages python)) | |
4902c3ec LC |
39 | |
40 | (define-public ath9k-htc-firmware | |
41 | (package | |
42 | (name "ath9k-htc-firmware") | |
7c473310 | 43 | (version "1.4.0") |
4902c3ec LC |
44 | (source (origin |
45 | (method git-fetch) | |
46 | (uri (git-reference | |
47 | (url "https://github.com/qca/open-ath9k-htc-firmware.git") | |
48 | (commit version))) | |
49 | (sha256 | |
50 | (base32 | |
7c473310 | 51 | "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23")) |
821f4dc2 | 52 | (file-name (string-append name "-" version "-checkout")) |
fc1adab1 | 53 | (patches (search-patches "ath9k-htc-firmware-objcopy.patch")))) |
4902c3ec LC |
54 | (build-system gnu-build-system) |
55 | (arguments | |
dc1d3cde KK |
56 | '(#:phases |
57 | (modify-phases %standard-phases | |
58 | (add-before 'configure 'pre-configure | |
59 | (lambda* (#:key inputs #:allow-other-keys) | |
60 | (chdir "target_firmware") | |
4902c3ec | 61 | |
dc1d3cde KK |
62 | ;; 'configure' is a simple script that runs 'cmake' with |
63 | ;; the right flags. | |
64 | (substitute* "configure" | |
65 | (("^TOOLCHAIN=.*$") | |
66 | (string-append "TOOLCHAIN=" | |
67 | (assoc-ref inputs "cross-gcc") | |
68 | "\n"))) | |
69 | #t)) | |
70 | (replace 'install | |
71 | (lambda* (#:key outputs #:allow-other-keys) | |
72 | (let* ((out (assoc-ref outputs "out")) | |
73 | (fw-dir (string-append out "/lib/firmware"))) | |
dc1d3cde | 74 | (for-each (lambda (file) |
65a3c342 | 75 | (install-file file fw-dir)) |
dc1d3cde KK |
76 | (find-files "." "\\.fw$")) |
77 | #t)))) | |
4902c3ec LC |
78 | #:tests? #f)) |
79 | ||
80 | ;; The firmware is cross-compiled using a "bare bones" compiler (no libc.) | |
81 | ;; Use our own tool chain for that. | |
bd2e1a8c | 82 | (native-inputs `(("cross-gcc" ,(cross-gcc "xtensa-elf")) |
4902c3ec LC |
83 | ("cross-binutils" ,(cross-binutils "xtensa-elf")) |
84 | ("cmake" ,cmake) | |
85 | ("perl" ,perl))) | |
86 | (home-page "http://wireless.kernel.org/en/users/Drivers/ath9k_htc") | |
87 | (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs") | |
88 | (description | |
89 | "This is the firmware for the Qualcomm Atheros AR7010 and AR9271 USB | |
e881752c | 90 | 802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of |
4902c3ec | 91 | Linux-libre.") |
ce03b453 | 92 | (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD")))) |
e36a67c9 EB |
93 | |
94 | (define-public b43-tools | |
bb5c3582 TGR |
95 | (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae") |
96 | (revision "1")) | |
e36a67c9 EB |
97 | (package |
98 | (name "b43-tools") | |
bb5c3582 | 99 | (version (git-version "0.0.0" revision commit)) |
e36a67c9 EB |
100 | (source |
101 | (origin | |
102 | (method git-fetch) | |
103 | (uri (git-reference | |
104 | (url "http://git.bues.ch/git/b43-tools.git") | |
105 | (commit commit))) | |
106 | (file-name (string-append name "-" version "-checkout")) | |
107 | (sha256 | |
108 | (base32 | |
bb5c3582 | 109 | "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn")))) |
e36a67c9 EB |
110 | (build-system gnu-build-system) |
111 | (native-inputs | |
112 | `(("flex" ,flex) | |
113 | ("bison" ,bison))) | |
114 | (arguments | |
115 | `(#:modules ((srfi srfi-1) | |
116 | (guix build gnu-build-system) | |
117 | (guix build utils)) | |
bb5c3582 | 118 | #:tests? #f ; no tests |
e36a67c9 EB |
119 | #:phases |
120 | (let ((subdirs '("assembler" "disassembler"))) | |
121 | (modify-phases %standard-phases | |
bb5c3582 | 122 | (delete 'configure) ; no configure script |
e36a67c9 EB |
123 | (add-before 'build 'patch-/bin/true |
124 | (lambda _ | |
125 | (substitute* (find-files "." "Makefile") | |
126 | (("/bin/true") ":")) | |
127 | #t)) | |
128 | (replace 'build | |
129 | (lambda _ | |
315c89f5 TGR |
130 | (for-each (lambda (dir) |
131 | (invoke "make" "-C" dir "CC=gcc")) | |
132 | subdirs) | |
133 | #t)) | |
e36a67c9 EB |
134 | (replace 'install |
135 | (lambda* (#:key outputs #:allow-other-keys) | |
136 | (let ((out (assoc-ref outputs "out"))) | |
137 | (mkdir-p (string-append out "/bin")) | |
315c89f5 TGR |
138 | (for-each (lambda (dir) |
139 | (invoke "make" "-C" dir | |
140 | (string-append "PREFIX=" out) | |
141 | "install")) | |
142 | subdirs) | |
143 | #t))))))) | |
e36a67c9 | 144 | (home-page |
3ebf12ea | 145 | "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools") |
e36a67c9 EB |
146 | (synopsis "Collection of tools for the b43 wireless driver") |
147 | (description | |
148 | "The b43 firmware tools is a collection of firmware extractor, | |
149 | assembler, disassembler, and debugging tools for the Linux kernel b43 wireless | |
150 | driver.") | |
ce03b453 | 151 | (license license:gpl2)))) |
e36a67c9 EB |
152 | |
153 | (define-public openfwwf-firmware | |
154 | (package | |
155 | (name "openfwwf-firmware") | |
156 | (version "5.2") | |
157 | (source | |
158 | (origin | |
159 | (method url-fetch) | |
160 | (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/" | |
161 | "openfwwf-" version ".tar.gz")) | |
162 | (sha256 | |
163 | (base32 | |
164 | "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x")))) | |
165 | (build-system gnu-build-system) | |
166 | (native-inputs | |
167 | `(("b43-tools" ,b43-tools))) | |
168 | (arguments | |
169 | `(#:make-flags (list (string-append "PREFIX=" | |
170 | (assoc-ref %outputs "out") | |
171 | "/lib/firmware/b43-open")) | |
172 | #:tests? #f ;no tests | |
173 | #:phases (modify-phases %standard-phases | |
174 | (delete 'configure)))) | |
175 | (home-page "http://netweb.ing.unibs.it/~openfwwf/") | |
176 | (synopsis "Firmware for BCM43xx devices") | |
177 | (description | |
178 | "This is firmware from Open FirmWare for WiFi networks (OpenFWWF) for the | |
179 | Broadcom/AirForce chipset BCM43xx with Wireless-Core Revision 5. It is used | |
180 | by the b43-open driver of Linux-libre.") | |
ce03b453 | 181 | (license license:gpl2))) |
1b533bad DC |
182 | |
183 | (define-public seabios | |
184 | (package | |
185 | (name "seabios") | |
3f9be788 | 186 | (version "1.11.0") |
1b533bad DC |
187 | (source (origin |
188 | (method url-fetch) | |
189 | (uri (string-append "https://code.coreboot.org/p/seabios/downloads/get/" | |
190 | "seabios-" version ".tar.gz")) | |
191 | (sha256 | |
192 | (base32 | |
3f9be788 | 193 | "1xwvp77djxbxbxg82hzj26pv6zka3556vkdcp09hnfwapcp46av2")))) |
1b533bad DC |
194 | (build-system gnu-build-system) |
195 | (native-inputs | |
196 | `(("python-2" ,python-2))) | |
197 | (arguments | |
198 | `(#:tests? #f ; No check target. | |
199 | #:phases | |
200 | (modify-phases %standard-phases | |
201 | (replace 'configure | |
202 | (lambda _ | |
203 | (setenv "CC" "gcc") | |
204 | #t)) | |
205 | (replace 'install | |
206 | (lambda* (#:key outputs #:allow-other-keys) | |
207 | (let* ((out (assoc-ref outputs "out")) | |
208 | (fmw (string-append out "/share/firmware"))) | |
209 | (mkdir-p fmw) | |
210 | (copy-file "out/bios.bin" (string-append fmw "/bios.bin")))))))) | |
211 | (home-page "https://www.seabios.org/SeaBIOS") | |
212 | (synopsis "x86 BIOS implementation") | |
5a80c15c RW |
213 | (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS |
214 | can run in an emulator or it can run natively on X86 hardware with the use of | |
215 | coreboot.") | |
1b533bad DC |
216 | ;; Dual licensed. |
217 | (license (list license:gpl3+ license:lgpl3+ | |
218 | ;; src/fw/acpi-dsdt.dsl is lgpl2 | |
219 | license:lgpl2.1 | |
220 | ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and | |
221 | ;; cpl with a linking exception. | |
222 | license:cpl1.0)))) | |
a5bc3dfe DC |
223 | |
224 | ;; OVMF is part of the edk2 source tree. | |
225 | (define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f") | |
226 | (define edk2-version (git-version "20170116" "1" edk2-commit)) | |
227 | (define edk2-origin | |
228 | (origin | |
229 | (method git-fetch) | |
230 | (uri (git-reference | |
231 | (url "https://github.com/tianocore/edk2") | |
232 | (commit edk2-commit))) | |
233 | (file-name (git-file-name "edk2" edk2-version)) | |
234 | (sha256 | |
235 | (base32 | |
236 | "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b")))) | |
237 | ||
238 | (define-public ovmf | |
239 | (package | |
240 | (name "ovmf") | |
241 | (version edk2-version) | |
242 | (source edk2-origin) | |
243 | (build-system gnu-build-system) | |
244 | (native-inputs | |
245 | `(("acpica" ,acpica) | |
246 | ("nasm" ,nasm) | |
247 | ("python-2" ,python-2) | |
248 | ("util-linux" ,util-linux))) | |
249 | (arguments | |
250 | `(#:tests? #f ; No check target. | |
251 | #:phases | |
252 | (modify-phases %standard-phases | |
253 | (replace 'configure | |
254 | (lambda _ | |
255 | (let* ((cwd (getcwd)) | |
256 | (tools (string-append cwd "/BaseTools")) | |
257 | (bin (string-append tools "/BinWrappers/PosixLike"))) | |
258 | (setenv "WORKSPACE" cwd) | |
259 | (setenv "EDK_TOOLS_PATH" tools) | |
260 | (setenv "PATH" (string-append (getenv "PATH") ":" bin)) | |
cee03b26 RH |
261 | ; FIXME: The below script errors out. When using 'invoke' instead |
262 | ; of 'system*' this causes the build to fail. | |
263 | (system* "bash" "edksetup.sh" "BaseTools") | |
a5bc3dfe DC |
264 | (substitute* "Conf/target.txt" |
265 | (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n") | |
266 | (("^TOOL_CHAIN_TAG[ ]*=.*$") "TOOL_CHAIN_TAG = GCC49\n") | |
267 | (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$") | |
268 | (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%" | |
269 | (number->string (parallel-job-count))))) | |
270 | ;; Build build support. | |
271 | (setenv "BUILD_CC" "gcc") | |
f563d199 TGR |
272 | (invoke "make" "-C" (string-append tools "/Source/C")) |
273 | #t))) | |
a5bc3dfe DC |
274 | (add-after 'build 'build-ia32 |
275 | (lambda _ | |
276 | (substitute* "Conf/target.txt" | |
277 | (("^TARGET_ARCH[ ]*=.*$") "TARGET_ARCH = IA32\n") | |
278 | (("^ACTIVE_PLATFORM[ ]*=.*$") | |
279 | "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgIa32.dsc\n")) | |
f563d199 TGR |
280 | (invoke "build") |
281 | #t)) | |
2eb95ade | 282 | ,@(if (string=? "x86_64-linux" (%current-system)) |
bfba1269 EF |
283 | '((add-after 'build 'build-x64 |
284 | (lambda _ | |
285 | (substitute* "Conf/target.txt" | |
286 | (("^TARGET_ARCH[ ]*=.*$") "TARGET_ARCH = X64\n") | |
287 | (("^ACTIVE_PLATFORM[ ]*=.*$") | |
288 | "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc\n")) | |
f563d199 TGR |
289 | (invoke "build") |
290 | #t))) | |
2eb95ade | 291 | '()) |
a5bc3dfe DC |
292 | (delete 'build) |
293 | (replace 'install | |
294 | (lambda* (#:key outputs #:allow-other-keys) | |
295 | (let* ((out (assoc-ref outputs "out")) | |
296 | (fmw (string-append out "/share/firmware"))) | |
297 | (mkdir-p fmw) | |
298 | (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd" | |
299 | (string-append fmw "/ovmf_ia32.bin")) | |
2eb95ade EF |
300 | ,@(if (string=? "x86_64-linux" (%current-system)) |
301 | '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd" | |
302 | (string-append fmw "/ovmf_x64.bin"))) | |
303 | '())) | |
a5bc3dfe DC |
304 | #t))))) |
305 | (supported-systems '("x86_64-linux" "i686-linux")) | |
0dae4921 | 306 | (home-page "https://www.tianocore.org") |
a5bc3dfe DC |
307 | (synopsis "UEFI firmware for QEMU") |
308 | (description "OVMF is an EDK II based project to enable UEFI support for | |
309 | Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.") | |
310 | (license (list license:expat | |
311 | license:bsd-2 license:bsd-3 license:bsd-4)))) |