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