flashing-tools.scm 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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, 2021 Ludovic Courtès <ludo@gnu.org>
  6. ;;; Copyright © 2016, 2019 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–2021 Tobias Geerinckx-Rice <me@tobias.gr>
  10. ;;; Copyright © 2021 Ricardo Wurmus <rekado@elephly.net>
  11. ;;;
  12. ;;; This file is part of GNU Guix.
  13. ;;;
  14. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  15. ;;; under the terms of the GNU General Public License as published by
  16. ;;; the Free Software Foundation; either version 3 of the License, or (at
  17. ;;; your option) any later version.
  18. ;;;
  19. ;;; GNU Guix is distributed in the hope that it will be useful, but
  20. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;;; GNU General Public License for more details.
  23. ;;;
  24. ;;; You should have received a copy of the GNU General Public License
  25. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  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 (guix utils)
  32. #:use-module (gnu packages)
  33. #:use-module (guix build-system cmake)
  34. #:use-module (guix build-system gnu)
  35. #:use-module (guix build-system python)
  36. #:use-module (gnu packages autotools)
  37. #:use-module (gnu packages admin)
  38. #:use-module (gnu packages base)
  39. #:use-module (gnu packages bison)
  40. #:use-module (gnu packages boost)
  41. #:use-module (gnu packages compression)
  42. #:use-module (gnu packages elf)
  43. #:use-module (gnu packages flex)
  44. #:use-module (gnu packages ghostscript)
  45. #:use-module (gnu packages gnupg)
  46. #:use-module (gnu packages groff)
  47. #:use-module (gnu packages pciutils)
  48. #:use-module (gnu packages pkg-config)
  49. #:use-module (gnu packages libusb)
  50. #:use-module (gnu packages libftdi)
  51. #:use-module (gnu packages pciutils)
  52. #:use-module (gnu packages qt))
  53. (define-public flashrom
  54. (package
  55. (name "flashrom")
  56. (version "1.2")
  57. (source (origin
  58. (method url-fetch)
  59. (uri (string-append
  60. "https://download.flashrom.org/releases/flashrom-v"
  61. version ".tar.bz2"))
  62. (sha256
  63. (base32
  64. "0ax4kqnh7kd3z120ypgp73qy1knz47l6qxsqzrfkd97mh5cdky71"))))
  65. (build-system gnu-build-system)
  66. (inputs `(("dmidecode" ,dmidecode)
  67. ("pciutils" ,pciutils)
  68. ("libusb" ,libusb)
  69. ("libftdi" ,libftdi)))
  70. (native-inputs `(("pkg-config" ,pkg-config)))
  71. (arguments
  72. '(#:make-flags
  73. (list "CC=gcc"
  74. (string-append "PREFIX=" %output)
  75. "CONFIG_ENABLE_LIBUSB0_PROGRAMMERS=no")
  76. #:tests? #f ; no 'check' target
  77. #:phases
  78. (modify-phases %standard-phases
  79. (delete 'configure) ; no configure script
  80. (add-before 'build 'patch-exec-paths
  81. (lambda* (#:key inputs #:allow-other-keys)
  82. (substitute* "dmi.c"
  83. (("\"dmidecode\"")
  84. (format #f "~S"
  85. (search-input-file inputs "/sbin/dmidecode")))))))))
  86. (home-page "https://flashrom.org/")
  87. (synopsis "Identify, read, write, erase, and verify ROM/flash chips")
  88. (description
  89. "flashrom is a utility for identifying, reading, writing,
  90. verifying and erasing flash chips. It is designed to flash
  91. BIOS/EFI/coreboot/firmware/optionROM images on mainboards,
  92. network/graphics/storage controller cards, and various other
  93. programmer devices.")
  94. (license license:gpl2)))
  95. (define-public 0xffff
  96. (package
  97. (name "0xffff")
  98. (version "0.9")
  99. (source
  100. (origin
  101. (method git-fetch)
  102. (uri (git-reference
  103. (url "https://github.com/pali/0xffff")
  104. (commit version)))
  105. (file-name (git-file-name name version))
  106. (sha256
  107. (base32 "0rl1xzbxl991pm2is98zbryac1lgjrc3zphmbd8agv07av0r6r6n"))))
  108. (build-system gnu-build-system)
  109. (inputs
  110. ;; Building with libusb-compat will succeed but the result will be broken.
  111. ;; See <https://github.com/pali/0xFFFF/issues/3>.
  112. `(("libusb" ,libusb-0.1)))
  113. (arguments
  114. `(#:phases
  115. (modify-phases %standard-phases
  116. (delete 'configure)) ; no configure
  117. #:make-flags
  118. (list (string-append "CC=" ,(cc-for-target))
  119. "HOST_CC=gcc"
  120. "BUILD_DATE=GNU Guix"
  121. (string-append "PREFIX=" %output))
  122. #:tests? #f)) ; no 'check' target
  123. (home-page "https://github.com/pali/0xFFFF")
  124. (synopsis "Flash FIASCO images on Maemo devices")
  125. (description
  126. "The Open Free Fiasco Firmware Flasher (0xFFFF) is a flashing tool
  127. for FIASCO images. It supports generating, unpacking, editing and
  128. flashing of FIASCO images for Maemo devices. Use it with care. It can
  129. brick your device.")
  130. (license license:gpl3+)))
  131. (define-public avrdude
  132. (package
  133. (name "avrdude")
  134. (version "6.3")
  135. (source
  136. (origin
  137. (method url-fetch)
  138. (uri (string-append "mirror://savannah/avrdude/avrdude-"
  139. version ".tar.gz"))
  140. (sha256
  141. (base32 "15m1w1qad3dj7r8n5ng1qqcaiyx1gyd6hnc3p2apgjllccdp77qg"))))
  142. (build-system gnu-build-system)
  143. (inputs
  144. `(("libelf" ,libelf)
  145. ("libusb" ,libusb-compat)
  146. ("libftdi" ,libftdi)))
  147. (native-inputs
  148. `(("bison" ,bison)
  149. ("flex" ,flex)))
  150. (home-page "https://www.nongnu.org/avrdude/")
  151. (synopsis "AVR downloader and uploader")
  152. (description
  153. "AVRDUDE is a utility to download/upload/manipulate the ROM and
  154. EEPROM contents of AVR microcontrollers using the @acronym{ISP, in-system
  155. programming} technique.")
  156. (license license:gpl2+)))
  157. (define-public dfu-programmer
  158. (package
  159. (name "dfu-programmer")
  160. (version "0.7.2")
  161. (source
  162. (origin
  163. (method url-fetch)
  164. (uri (string-append "mirror://sourceforge/dfu-programmer/dfu-programmer/"
  165. version "/dfu-programmer-" version ".tar.gz"))
  166. (sha256
  167. (base32
  168. "15gr99y1z9vbvhrkd25zqhnzhg6zjmaam3vfjzf2mazd39mx7d0x"))
  169. (patches (search-patches "dfu-programmer-fix-libusb.patch"))))
  170. (build-system gnu-build-system)
  171. (native-inputs
  172. `(("pkg-config" ,pkg-config)))
  173. (inputs
  174. `(("libusb" ,libusb)))
  175. (home-page "https://dfu-programmer.github.io/")
  176. (synopsis "Device firmware update programmer for Atmel chips")
  177. (description
  178. "Dfu-programmer is a multi-platform command-line programmer for
  179. Atmel (8051, AVR, XMEGA & AVR32) chips with a USB bootloader supporting
  180. ISP.")
  181. (license license:gpl2+)))
  182. (define-public dfu-util
  183. (package
  184. (name "dfu-util")
  185. (version "0.10")
  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. "0hlvc47ccf5hry13saqhc1j5cdq5jyjv4i05kj0mdh3rzj6wagd0"))))
  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. (define-public teensy-loader-cli
  209. ;; The repo does not tag versions nor does it use releases, but a commit
  210. ;; message says "Importing 2.1", while the sourcce still says "2.0". So pin
  211. ;; to a fixed commit.
  212. (let ((commit "f289b7a2e5627464044249f0e5742830e052e360"))
  213. (package
  214. (name "teensy-loader-cli")
  215. (version (git-version "2.1" "1" commit))
  216. (source
  217. (origin
  218. (method git-fetch)
  219. (uri (git-reference
  220. (url "https://github.com/PaulStoffregen/teensy_loader_cli")
  221. (commit commit)))
  222. (sha256 (base32 "0sssim56pwsxp5cp5dlf6mi9h5fx2592m6j1g7abnm0s09b0lpdx"))
  223. (file-name (git-file-name name version))
  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. You need to add the udev rules to make the Teensy update available for
  255. non-root users.")
  256. (home-page "https://www.pjrc.com/teensy/loader_cli.html")
  257. (license license:gpl3))))
  258. (define-public rkflashtool
  259. (let ((commit "8966c4e277de8148290554aaaa4146a3a84a3c53")
  260. (revision "1"))
  261. (package
  262. (name "rkflashtool")
  263. (version (git-version "5.2" revision commit))
  264. (source
  265. (origin
  266. (method git-fetch)
  267. (uri (git-reference
  268. (url "https://github.com/linux-rockchip/rkflashtool")
  269. (commit commit)))
  270. (file-name (git-file-name name version))
  271. (sha256
  272. (base32
  273. "1ndyzg1zlgg20dd8js9kfqm5kq19k005vddkvf65qj20w0pcyahn"))))
  274. (build-system gnu-build-system)
  275. (arguments
  276. '(#:phases
  277. (modify-phases %standard-phases
  278. (delete 'configure)) ; no configure
  279. #:make-flags (list (string-append "PREFIX=" %output))
  280. #:tests? #f)) ; no tests
  281. (native-inputs
  282. `(("pkg-config" ,pkg-config)))
  283. (inputs
  284. `(("libusb" ,libusb)))
  285. (home-page "https://github.com/linux-rockchip/rkflashtool")
  286. (synopsis "Tools for flashing Rockchip devices")
  287. (description "Allows flashing of Rockchip based embedded linux devices.
  288. The list of currently supported devices is: RK2818, RK2918, RK2928, RK3026,
  289. RK3036, RK3066, RK312X, RK3168, RK3188, RK3288, RK3368.")
  290. (license license:bsd-2))))
  291. (define-public heimdall
  292. (package
  293. (name "heimdall")
  294. (version "1.4.2")
  295. (source (origin
  296. (method git-fetch)
  297. (uri (git-reference
  298. (url "https://gitlab.com/BenjaminDobell/Heimdall.git")
  299. (commit (string-append "v" version))))
  300. (file-name (git-file-name name version))
  301. (sha256
  302. (base32
  303. "1ygn4snvcmi98rgldgxf5hwm7zzi1zcsihfvm6awf9s6mpcjzbqz"))))
  304. (build-system cmake-build-system)
  305. (arguments
  306. `(#:build-type "Release"
  307. #:tests? #f ; no tests
  308. #:phases
  309. (modify-phases %standard-phases
  310. (add-after 'unpack 'patch-invocations
  311. (lambda* (#:key outputs #:allow-other-keys)
  312. (substitute* '("heimdall-frontend/source/aboutform.cpp"
  313. "heimdall-frontend/source/mainwindow.cpp")
  314. (("start[(]\"heimdall\"")
  315. (string-append "start(\"" (assoc-ref outputs "out")
  316. "/bin/heimdall\"")))
  317. #t))
  318. (replace 'install
  319. (lambda* (#:key outputs #:allow-other-keys)
  320. (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
  321. (lib (string-append (assoc-ref outputs "out") "/lib")))
  322. (install-file "bin/heimdall" bin)
  323. (install-file "bin/heimdall-frontend" bin)
  324. (install-file "libpit/libpit.a" lib)
  325. #t))))))
  326. (inputs
  327. `(("libusb" ,libusb)
  328. ("qtbase" ,qtbase-5)
  329. ("zlib" ,zlib)))
  330. (home-page "https://glassechidna.com.au/heimdall/")
  331. (synopsis "Flash firmware onto Samsung mobile devices")
  332. (description "@command{heimdall} is a tool suite used to flash firmware (aka
  333. ROMs) onto Samsung mobile devices. Heimdall connects to a mobile device over
  334. USB and interacts with low-level software running on the device, known as Loke.
  335. Loke and Heimdall communicate via the custom Samsung-developed protocol typically
  336. referred to as the \"Odin 3 protocol\".")
  337. (license license:expat)))
  338. (define-public ifdtool
  339. (package
  340. (name "ifdtool")
  341. (version "4.9")
  342. (source (origin
  343. (method git-fetch)
  344. (uri (git-reference
  345. (url "https://github.com/coreboot/coreboot")
  346. (commit version)))
  347. (file-name (git-file-name name version))
  348. (sha256
  349. (base32
  350. "0jidj29jh6p65d17k304wlzhxvp4p3c2namgcdwg2sxq8jfr0zlm"))))
  351. (build-system gnu-build-system)
  352. (arguments
  353. `(#:make-flags
  354. (list "CC=gcc"
  355. "INSTALL=install"
  356. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  357. #:phases
  358. (modify-phases %standard-phases
  359. (add-after 'unpack 'chdir
  360. (lambda _
  361. (chdir "util/ifdtool")
  362. #t))
  363. (delete 'configure)) ; no configure script
  364. #:tests? #f)) ; no test suite
  365. (home-page "https://github.com/corna/me_cleaner/")
  366. (synopsis "Intel Firmware Descriptor dumper")
  367. (description "This package provides @command{ifdtool}, a program to
  368. dump Intel Firmware Descriptor data of an image file.")
  369. (license license:gpl2)))
  370. (define-public intelmetool
  371. (package
  372. (name "intelmetool")
  373. (version "4.7")
  374. (source (origin
  375. (method git-fetch)
  376. (uri (git-reference
  377. (url "https://review.coreboot.org/p/coreboot")
  378. (commit version)))
  379. (file-name (git-file-name name version))
  380. (sha256
  381. (base32
  382. "0nw555i0fm5kljha9h47bk70ykbwv8ddfk6qhz6kfqb79vzhy4h2"))))
  383. (build-system gnu-build-system)
  384. (inputs
  385. `(("pciutils" ,pciutils)
  386. ("zlib" ,zlib)))
  387. (arguments
  388. `(#:make-flags
  389. (list "CC=gcc"
  390. "INSTALL=install"
  391. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  392. #:phases
  393. (modify-phases %standard-phases
  394. (add-after 'unpack 'chdir
  395. (lambda _
  396. (chdir "util/intelmetool")
  397. #t))
  398. (delete 'configure)
  399. (delete 'check))))
  400. (home-page "https://github.com/zamaudio/intelmetool")
  401. (synopsis "Intel Management Engine tools")
  402. (description "This package provides tools for working with Intel
  403. Management Engine (ME). You need to @code{sudo rmmod mei_me} and
  404. @code{sudo rmmod mei} before using this tool. Also pass
  405. @code{iomem=relaxed} to the Linux kernel command line.")
  406. (license license:gpl2)
  407. ;; This is obviously an Intel thing, plus it requires <cpuid.h>.
  408. (supported-systems '("x86_64-linux" "i686-linux"))))
  409. (define-public me-cleaner
  410. (package
  411. (name "me-cleaner")
  412. (version "1.2")
  413. (source (origin
  414. (method git-fetch)
  415. (uri (git-reference
  416. (url "https://github.com/corna/me_cleaner")
  417. (commit (string-append "v" version))))
  418. (sha256
  419. (base32
  420. "1bdj2clm13ir441vn7sv860xsc5gh71ja5lc2wn0gggnff0adxj4"))
  421. (file-name (git-file-name name version))))
  422. (build-system python-build-system)
  423. (arguments
  424. `(#:phases
  425. (modify-phases %standard-phases
  426. (add-after 'install 'install-documentation
  427. (lambda* (#:key outputs #:allow-other-keys)
  428. (let* ((out (assoc-ref outputs "out"))
  429. (man (string-append out "/share/man/man1")))
  430. (install-file "man/me_cleaner.1" man)
  431. #t))))))
  432. (home-page "https://github.com/corna/me_cleaner")
  433. (synopsis "Intel ME cleaner")
  434. (description "This package provides tools for disabling Intel
  435. ME as far as possible (it only edits ME firmware image files).")
  436. (license license:gpl3+)
  437. ;; This is an Intel thing.
  438. (supported-systems '("x86_64-linux" "i686-linux"))))
  439. (define-public uefitool
  440. (package
  441. (name "uefitool")
  442. (version "0.27.0")
  443. (source (origin
  444. (method git-fetch)
  445. (uri (git-reference
  446. (url "https://github.com/LongSoft/UEFITool")
  447. (commit version)))
  448. (sha256
  449. (base32
  450. "1i1p823qld927p4f1wcphqcnivb9mq7fi5xmzibxc3g9zzgnyc2h"))
  451. (file-name (git-file-name name version))))
  452. (build-system gnu-build-system)
  453. (arguments
  454. `(#:phases
  455. (modify-phases %standard-phases
  456. (replace 'configure
  457. (lambda _
  458. (invoke "qmake" "-makefile")))
  459. (replace 'install
  460. (lambda* (#:key outputs #:allow-other-keys)
  461. (install-file "UEFITool" (string-append (assoc-ref outputs "out")
  462. "/bin"))
  463. #t)))))
  464. (inputs
  465. `(("qtbase" ,qtbase-5)))
  466. (home-page "https://github.com/LongSoft/UEFITool/")
  467. (synopsis "UEFI image editor")
  468. (description "@code{uefitool} is a graphical image file editor for
  469. Unifinished Extensible Firmware Interface (UEFI) images.")
  470. (license license:bsd-2)))
  471. (define-public srecord
  472. (package
  473. (name "srecord")
  474. (version "1.64")
  475. (source
  476. (origin
  477. (method url-fetch)
  478. (uri (string-append "mirror://sourceforge/srecord/srecord/"
  479. version "/srecord-" version ".tar.gz"))
  480. (sha256
  481. (base32
  482. "1qk75q0k5vzmm3932q9hqz2gp8n9rrdfjacsswxc02656f3l3929"))))
  483. (build-system gnu-build-system)
  484. (arguments
  485. `(#:configure-flags
  486. (list (string-append "SH="
  487. (assoc-ref %build-inputs "bash")
  488. "/bin/bash"))))
  489. (inputs
  490. `(("boost" ,boost)
  491. ("libgcrypt" ,libgcrypt)))
  492. (native-inputs
  493. `(("bison" ,bison)
  494. ("diffutils" ,diffutils)
  495. ("ghostscript" ,ghostscript)
  496. ("groff" ,groff)
  497. ("libtool" ,libtool)
  498. ("which" ,which)))
  499. (home-page "http://srecord.sourceforge.net/")
  500. (synopsis "Tools for EPROM files")
  501. (description "The SRecord package is a collection of powerful tools for
  502. manipulating EPROM load files. It reads and writes numerous EPROM file
  503. formats, and can perform many different manipulations.")
  504. (license license:gpl3+)))