gnu: pocl: Update to 1.2.
[jackhill/guix/guix.git] / gnu / packages / flashing-tools.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
3 ;;; Copyright © 2014 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
4 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
5 ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2017 Jonathan Brielmaier <jonathan.brielmaier@web.de>
8 ;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
9 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
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 flashing-tools)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix packages)
31 #:use-module (gnu packages)
32 #:use-module (guix build-system cmake)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system python)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages elf)
39 #:use-module (gnu packages pciutils)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages libusb)
42 #:use-module (gnu packages libftdi)
43 #:use-module (gnu packages pciutils)
44 #:use-module (gnu packages qt)
45 #:use-module (gnu packages autotools)
46 #:use-module (gnu packages admin))
47
48 (define-public flashrom
49 (package
50 (name "flashrom")
51 ;; XXX: The CFLAGS=... line below can probably be removed when updating.
52 (version "1.0")
53 (source (origin
54 (method url-fetch)
55 (uri (string-append
56 "https://download.flashrom.org/releases/flashrom-"
57 version ".tar.bz2"))
58 (sha256
59 (base32
60 "0r7fkpfc8w51n8ffbhclj4wa3kwrk0ijv1acwpw5myx5bchzl0ip"))))
61 (build-system gnu-build-system)
62 (inputs `(("dmidecode" ,dmidecode)
63 ("pciutils" ,pciutils)
64 ("libusb" ,libusb)
65 ("libftdi" ,libftdi)))
66 (native-inputs `(("pkg-config" ,pkg-config)))
67 (arguments
68 '(#:make-flags
69 (list "CC=gcc"
70 ;; The default includes ‘-Wall -Werror’, causing the build to fail
71 ;; with deprecation warnings against libusb versions >= 1.0.22.
72 "CFLAGS=-Os -Wshadow"
73 (string-append "PREFIX=" %output)
74 "CONFIG_ENABLE_LIBUSB0_PROGRAMMERS=no")
75 #:tests? #f ; no 'check' target
76 #:phases
77 (modify-phases %standard-phases
78 (delete 'configure) ; no configure script
79 (add-before 'build 'patch-exec-paths
80 (lambda* (#:key inputs #:allow-other-keys)
81 (substitute* "dmi.c"
82 (("\"dmidecode\"")
83 (format #f "~S"
84 (string-append (assoc-ref inputs "dmidecode")
85 "/sbin/dmidecode"))))
86 #t)))))
87 (home-page "https://flashrom.org/")
88 (synopsis "Identify, read, write, erase, and verify ROM/flash chips")
89 (description
90 "flashrom is a utility for identifying, reading, writing,
91 verifying and erasing flash chips. It is designed to flash
92 BIOS/EFI/coreboot/firmware/optionROM images on mainboards,
93 network/graphics/storage controller cards, and various other
94 programmer devices.")
95 (license license:gpl2)))
96
97 (define-public 0xffff
98 (package
99 (name "0xffff")
100 (version "0.7")
101 (source
102 (origin
103 (method url-fetch)
104 (uri (string-append "https://github.com/pali/0xffff/archive/"
105 version ".tar.gz"))
106 (file-name (string-append "0xFFFF" version ".tar.gz" ))
107 (sha256
108 (base32
109 "1g4032c81wkk37wvbg1dxcqq6mnd76y9x7f2crmzqi6z4q9jcxmj"))))
110 (build-system gnu-build-system)
111 (inputs
112 `(("libusb" ,libusb-0.1))) ; doesn't work with libusb-compat
113 (arguments
114 '(#:phases
115 (modify-phases %standard-phases
116 (delete 'configure)) ; no configure
117 #:make-flags (list (string-append "PREFIX=" %output))
118 #:tests? #f)) ; no 'check' target
119 (home-page "https://github.com/pali/0xFFFF")
120 (synopsis "Flash FIASCO images on Maemo devices")
121 (description
122 "The Open Free Fiasco Firmware Flasher (0xFFFF) is a flashing tool
123 for FIASCO images. It supports generating, unpacking, editing and
124 flashing of FIASCO images for Maemo devices. Use it with care. It can
125 brick your device.")
126 (license license:gpl3+)))
127
128 (define-public avrdude
129 (package
130 (name "avrdude")
131 (version "6.1")
132 (source
133 (origin
134 (method url-fetch)
135 (uri (string-append "mirror://savannah/avrdude/avrdude-"
136 version ".tar.gz"))
137 (sha256
138 (base32
139 "0frxg0q09nrm95z7ymzddx7ysl77ilfbdix1m81d9jjpiv5bm64y"))))
140 (build-system gnu-build-system)
141 (inputs
142 `(("libelf" ,libelf)
143 ("libusb" ,libusb-compat)
144 ("libftdi" ,libftdi)))
145 (native-inputs
146 `(("bison" ,bison)
147 ("flex" ,flex)))
148 (home-page "https://www.nongnu.org/avrdude/")
149 (synopsis "AVR downloader and uploader")
150 (description
151 "AVRDUDE is a utility to download/upload/manipulate the ROM and
152 EEPROM contents of AVR microcontrollers using the in-system programming
153 technique (ISP).")
154 (license license:gpl2+)))
155
156 (define-public dfu-programmer
157 (package
158 (name "dfu-programmer")
159 (version "0.7.2")
160 (source
161 (origin
162 (method url-fetch)
163 (uri (string-append "mirror://sourceforge/dfu-programmer/dfu-programmer/"
164 version "/dfu-programmer-" version ".tar.gz"))
165 (sha256
166 (base32
167 "15gr99y1z9vbvhrkd25zqhnzhg6zjmaam3vfjzf2mazd39mx7d0x"))
168 (patches (search-patches "dfu-programmer-fix-libusb.patch"))))
169 (build-system gnu-build-system)
170 (native-inputs
171 `(("pkg-config" ,pkg-config)))
172 (inputs
173 `(("libusb" ,libusb)))
174 (home-page "http://dfu-programmer.github.io/")
175 (synopsis "Device firmware update programmer for Atmel chips")
176 (description
177 "Dfu-programmer is a multi-platform command-line programmer for
178 Atmel (8051, AVR, XMEGA & AVR32) chips with a USB bootloader supporting
179 ISP.")
180 (license license:gpl2+)))
181
182 (define-public dfu-util
183 (package
184 (name "dfu-util")
185 (version "0.9")
186 (source (origin
187 (method url-fetch)
188 (uri (string-append
189 "http://dfu-util.sourceforge.net/releases/dfu-util-"
190 version ".tar.gz"))
191 (sha256
192 (base32
193 "0czq73m92ngf30asdzrfkzraag95hlrr74imbanqq25kdim8qhin"))))
194 (build-system gnu-build-system)
195 (inputs
196 `(("libusb" ,libusb)))
197 (native-inputs
198 `(("pkg-config" ,pkg-config)))
199 (synopsis "Host side of the USB Device Firmware Upgrade (DFU) protocol")
200 (description
201 "The DFU (Universal Serial Bus Device Firmware Upgrade) protocol is
202 intended to download and upload firmware to devices connected over USB. It
203 ranges from small devices like micro-controller boards up to mobile phones.
204 With dfu-util you are able to download firmware to your device or upload
205 firmware from it.")
206 (home-page "http://dfu-util.sourceforge.net/")
207 (license license:gpl2+)))
208
209 (define-public teensy-loader-cli
210 ;; The repo does not tag versions nor does it use releases, but a commit
211 ;; message says "Importing 2.1", while the sourcce still says "2.0". So pin
212 ;; to a fixed commit.
213 (let ((commit "f289b7a2e5627464044249f0e5742830e052e360"))
214 (package
215 (name "teensy-loader-cli")
216 (version (string-append "2.1-1." (string-take commit 7)))
217 (source
218 (origin
219 (method url-fetch)
220 (uri (string-append "https://github.com/PaulStoffregen/"
221 "teensy_loader_cli/archive/" commit ".tar.gz"))
222 (sha256 (base32 "17wqc2q4fa473cy7f5m2yiyb9nq0qw7xal2kzrxzaikgm9rabsw8"))
223 (file-name (string-append "teensy-loader-cli-" version ".tar.gz" ))
224 (modules '((guix build utils)))
225 (snippet
226 `(begin
227 ;; Remove example flash files and teensy rebooter flash binaries.
228 (for-each delete-file (find-files "." "\\.(elf|hex)$"))
229 ;; Fix the version
230 (substitute* "teensy_loader_cli.c"
231 (("Teensy Loader, Command Line, Version 2.0\\\\n")
232 (string-append "Teensy Loader, Command Line, " ,version "\\n")))
233 #t))
234 (patches (search-patches "teensy-loader-cli-help.patch"))))
235 (build-system gnu-build-system)
236 (arguments
237 '(#:tests? #f ;; Makefile has no test target
238 #:make-flags (list "CC=gcc" (string-append "PREFIX=" %output))
239 #:phases
240 (modify-phases %standard-phases
241 (delete 'configure)
242 (replace 'install
243 (lambda* (#:key outputs #:allow-other-keys)
244 (let* ((out (assoc-ref outputs "out"))
245 (bin (string-append out "/bin")))
246 (install-file "teensy_loader_cli" bin)
247 #t))))))
248 (inputs
249 `(("libusb-compat" ,libusb-compat)))
250 (synopsis "Command line firmware uploader for Teensy development boards")
251 (description
252 "The Teensy loader program communicates with your Teensy board when the
253 HalfKay bootloader is running, so you can upload new programs and run them.
254
255 You need to add the udev rules to make the Teensy update available for
256 non-root users.")
257 (home-page "https://www.pjrc.com/teensy/loader_cli.html")
258 (license license:gpl3))))
259
260 (define-public rkflashtool
261 (let ((commit "094bd6410cb016e487e2ccb1050c59eeac2e6dd1")
262 (revision "1"))
263 (package
264 (name "rkflashtool")
265 (version (string-append "0.0.0-" revision "." (string-take commit 7)))
266 (source
267 (origin
268 (method git-fetch)
269 (uri (git-reference
270 (url "https://github.com/linux-rockchip/rkflashtool.git")
271 (commit commit)))
272 (file-name (string-append name "-" version "-checkout"))
273 (sha256
274 (base32
275 "1zkd8zxir3rfg3sy9r20bcnxclnplryn583gqpcr3iad0k3xbah7"))))
276 (build-system gnu-build-system)
277 (arguments
278 '(#:phases
279 (modify-phases %standard-phases
280 (delete 'configure)) ; no configure
281 #:make-flags (list (string-append "PREFIX=" %output))
282 #:tests? #f)) ; no tests
283 (native-inputs
284 `(("pkg-config" ,pkg-config)))
285 (inputs
286 `(("libusb" ,libusb)))
287 (home-page "https://github.com/linux-rockchip/rkflashtool")
288 (synopsis "Tools for flashing Rockchip devices")
289 (description "Allows flashing of Rockchip based embedded linux devices.
290 The list of currently supported devices is: RK2818, RK2918, RK2928, RK3026,
291 RK3036, RK3066, RK312X, RK3168, RK3188, RK3288, RK3368.")
292 (license license:bsd-2))))
293
294 (define-public heimdall
295 (package
296 (name "heimdall")
297 (version "1.4.2")
298 (source (origin
299 (method url-fetch)
300 (uri (string-append "https://github.com/Benjamin-Dobell/Heimdall"
301 "/archive/v" version ".tar.gz"))
302 (file-name (string-append name "-" version ".tar.gz"))
303 (sha256
304 (base32
305 "1y7gwg3lipyp2zcysm2vid1qg5nwin9bxbvgzs28lz2rya4fz6sq"))))
306 (build-system cmake-build-system)
307 (arguments
308 `(#:build-type "Release"
309 #:tests? #f ; no tests
310 #:phases
311 (modify-phases %standard-phases
312 (add-after 'unpack 'patch-invocations
313 (lambda* (#:key outputs #:allow-other-keys)
314 (substitute* '("heimdall-frontend/source/aboutform.cpp"
315 "heimdall-frontend/source/mainwindow.cpp")
316 (("start[(]\"heimdall\"")
317 (string-append "start(\"" (assoc-ref outputs "out")
318 "/bin/heimdall\"")))
319 #t))
320 (replace 'install
321 (lambda* (#:key outputs #:allow-other-keys)
322 (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
323 (lib (string-append (assoc-ref outputs "out") "/lib")))
324 (install-file "bin/heimdall" bin)
325 (install-file "bin/heimdall-frontend" bin)
326 (install-file "libpit/libpit.a" lib)
327 #t))))))
328 (inputs
329 `(("libusb" ,libusb)
330 ("qtbase" ,qtbase)
331 ("zlib" ,zlib)))
332 (home-page "http://glassechidna.com.au/heimdall/")
333 (synopsis "Flash firmware onto Samsung mobile devices")
334 (description "@command{heimdall} is a tool suite used to flash firmware (aka
335 ROMs) onto Samsung mobile devices. Heimdall connects to a mobile device over
336 USB and interacts with low-level software running on the device, known as Loke.
337 Loke and Heimdall communicate via the custom Samsung-developed protocol typically
338 referred to as the \"Odin 3 protocol\".")
339 (license license:expat)))
340
341 (define-public ifdtool
342 (package
343 (name "ifdtool")
344 (version "4.7")
345 (source (origin
346 (method git-fetch)
347 (uri (git-reference
348 (url "https://review.coreboot.org/p/coreboot")
349 (commit version)))
350 (file-name (git-file-name name version))
351 (sha256
352 (base32
353 "0nw555i0fm5kljha9h47bk70ykbwv8ddfk6qhz6kfqb79vzhy4h2"))))
354 (build-system gnu-build-system)
355 (arguments
356 `(#:make-flags
357 (list "CC=gcc"
358 "INSTALL=install"
359 (string-append "PREFIX=" (assoc-ref %outputs "out")))
360 #:phases
361 (modify-phases %standard-phases
362 (add-after 'unpack 'chdir
363 (lambda _
364 (chdir "util/ifdtool")
365 #t))
366 (delete 'configure)
367 (delete 'check))))
368 (home-page "https://github.com/corna/me_cleaner/")
369 (synopsis "Intel Firmware Descriptor dumper")
370 (description "This package provides @command{ifdtool}, a program to
371 dump Intel Firmware Descriptor data of an image file.")
372 (license license:gpl2)))
373
374 (define-public intelmetool
375 (package
376 (name "intelmetool")
377 (version "4.7")
378 (source (origin
379 (method git-fetch)
380 (uri (git-reference
381 (url "https://review.coreboot.org/p/coreboot")
382 (commit version)))
383 (file-name (git-file-name name version))
384 (sha256
385 (base32
386 "0nw555i0fm5kljha9h47bk70ykbwv8ddfk6qhz6kfqb79vzhy4h2"))))
387 (build-system gnu-build-system)
388 (inputs
389 `(("pciutils" ,pciutils)
390 ("zlib" ,zlib)))
391 (arguments
392 `(#:make-flags
393 (list "CC=gcc"
394 "INSTALL=install"
395 (string-append "PREFIX=" (assoc-ref %outputs "out")))
396 #:phases
397 (modify-phases %standard-phases
398 (add-after 'unpack 'chdir
399 (lambda _
400 (chdir "util/intelmetool")
401 #t))
402 (delete 'configure)
403 (delete 'check))))
404 (home-page "https://github.com/zamaudio/intelmetool")
405 (synopsis "Intel Management Engine tools")
406 (description "This package provides tools for working with Intel
407 Management Engine (ME). You need to @code{sudo rmmod mei_me} and
408 @code{sudo rmmod mei} before using this tool. Also pass
409 @code{iomem=relaxed} to the Linux kernel command line.")
410 (license license:gpl2)
411
412 ;; This is obviously an Intel thing, plus it requires <cpuid.h>.
413 (supported-systems '("x86_64-linux" "i686-linux"))))
414
415 (define-public me-cleaner
416 (package
417 (name "me-cleaner")
418 (version "1.1")
419 (source (origin
420 (method url-fetch)
421 (uri (string-append "https://github.com/corna/me_cleaner/"
422 "archive/v" version ".tar.gz"))
423 (sha256
424 (base32
425 "1pgwdqy0jly80nhxmlmyibs343497yjzs6dwfbkcw0l1gjm8i5hw"))
426 (file-name (string-append name "-" version ".tar.gz"))))
427 (build-system python-build-system)
428 (arguments
429 `(#:phases
430 (modify-phases %standard-phases
431 (add-after 'unpack 'create-setup.py
432 (lambda _
433 (call-with-output-file "setup.py"
434 (lambda (port)
435 (format port "\
436 from setuptools import setup
437 setup(name='me_cleaner', version='~a', scripts=['me_cleaner.py'])
438 " ,version)))
439 #t)))))
440 (home-page "https://github.com/corna/me_cleaner")
441 (synopsis "Intel ME cleaner")
442 (description "This package provides tools for disabling Intel
443 ME as far as possible (it only edits ME firmware image files).")
444 (license license:gpl3+)
445
446 ;; This is an Intel thing.
447 (supported-systems '("x86_64-linux" "i686-linux"))))
448
449 (define-public uefitool
450 (package
451 (name "uefitool")
452 (version "0.22.4")
453 (source (origin
454 (method url-fetch)
455 (uri (string-append "https://github.com/LongSoft/UEFITool/archive/"
456 version ".tar.gz"))
457 (sha256
458 (base32
459 "05jmhv7jpq08kqbd1477y1lgyjvcic3njrd0bmzdy7v7b7lnhl82"))
460 (file-name (string-append name "-" version ".tar.gz"))))
461 (build-system gnu-build-system)
462 (arguments
463 `(#:phases
464 (modify-phases %standard-phases
465 (replace 'configure
466 (lambda _
467 (invoke "qmake" "-makefile")))
468 (replace 'install
469 (lambda* (#:key outputs #:allow-other-keys)
470 (install-file "UEFITool" (string-append (assoc-ref outputs "out")
471 "/bin"))
472 #t)))))
473 (inputs
474 `(("qtbase" ,qtbase)))
475 (home-page "https://github.com/LongSoft/UEFITool/")
476 (synopsis "UEFI image editor")
477 (description "@code{uefitool} is a graphical image file editor for
478 Unifinished Extensible Firmware Interface (UEFI) images.")
479 (license license:bsd-2)))