flashing-tools.scm 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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. (add-before 'build 'patch-type-error
  87. (lambda _
  88. ;; See https://github.com/flashrom/flashrom/pull/133
  89. (substitute* "libflashrom.c"
  90. (("supported_boards\\[i\\].working = binfo\\[i\\].working")
  91. "supported_boards[i].working = (enum flashrom_test_state)binfo[i].working")
  92. (("supported_chipsets\\[i\\].status = chipset\\[i\\].status")
  93. "supported_chipsets[i].status = (enum flashrom_test_state)chipset[i].status")))))))
  94. (home-page "https://flashrom.org/")
  95. (synopsis "Identify, read, write, erase, and verify ROM/flash chips")
  96. (description
  97. "flashrom is a utility for identifying, reading, writing,
  98. verifying and erasing flash chips. It is designed to flash
  99. BIOS/EFI/coreboot/firmware/optionROM images on mainboards,
  100. network/graphics/storage controller cards, and various other
  101. programmer devices.")
  102. (license license:gpl2)))
  103. (define-public 0xffff
  104. (package
  105. (name "0xffff")
  106. (version "0.9")
  107. (source
  108. (origin
  109. (method git-fetch)
  110. (uri (git-reference
  111. (url "https://github.com/pali/0xffff")
  112. (commit version)))
  113. (file-name (git-file-name name version))
  114. (sha256
  115. (base32 "0rl1xzbxl991pm2is98zbryac1lgjrc3zphmbd8agv07av0r6r6n"))))
  116. (build-system gnu-build-system)
  117. (inputs
  118. ;; Building with libusb-compat will succeed but the result will be broken.
  119. ;; See <https://github.com/pali/0xFFFF/issues/3>.
  120. `(("libusb" ,libusb-0.1)))
  121. (arguments
  122. `(#:phases
  123. (modify-phases %standard-phases
  124. (delete 'configure)) ; no configure
  125. #:make-flags
  126. (list (string-append "CC=" ,(cc-for-target))
  127. "HOST_CC=gcc"
  128. "BUILD_DATE=GNU Guix"
  129. (string-append "PREFIX=" %output))
  130. #:tests? #f)) ; no 'check' target
  131. (home-page "https://github.com/pali/0xFFFF")
  132. (synopsis "Flash FIASCO images on Maemo devices")
  133. (description
  134. "The Open Free Fiasco Firmware Flasher (0xFFFF) is a flashing tool
  135. for FIASCO images. It supports generating, unpacking, editing and
  136. flashing of FIASCO images for Maemo devices. Use it with care. It can
  137. brick your device.")
  138. (license license:gpl3+)))
  139. (define-public avrdude
  140. (package
  141. (name "avrdude")
  142. (version "6.3")
  143. (source
  144. (origin
  145. (method url-fetch)
  146. (uri (string-append "mirror://savannah/avrdude/avrdude-"
  147. version ".tar.gz"))
  148. (sha256
  149. (base32 "15m1w1qad3dj7r8n5ng1qqcaiyx1gyd6hnc3p2apgjllccdp77qg"))))
  150. (build-system gnu-build-system)
  151. (inputs
  152. `(("libelf" ,libelf)
  153. ("libusb" ,libusb-compat)
  154. ("libftdi" ,libftdi)))
  155. (native-inputs
  156. `(("bison" ,bison)
  157. ("flex" ,flex)))
  158. (home-page "https://www.nongnu.org/avrdude/")
  159. (synopsis "AVR downloader and uploader")
  160. (description
  161. "AVRDUDE is a utility to download/upload/manipulate the ROM and
  162. EEPROM contents of AVR microcontrollers using the @acronym{ISP, in-system
  163. programming} technique.")
  164. (license license:gpl2+)))
  165. (define-public dfu-programmer
  166. (package
  167. (name "dfu-programmer")
  168. (version "0.7.2")
  169. (source
  170. (origin
  171. (method url-fetch)
  172. (uri (string-append "mirror://sourceforge/dfu-programmer/dfu-programmer/"
  173. version "/dfu-programmer-" version ".tar.gz"))
  174. (sha256
  175. (base32
  176. "15gr99y1z9vbvhrkd25zqhnzhg6zjmaam3vfjzf2mazd39mx7d0x"))
  177. (patches (search-patches "dfu-programmer-fix-libusb.patch"))))
  178. (build-system gnu-build-system)
  179. (native-inputs
  180. `(("pkg-config" ,pkg-config)))
  181. (inputs
  182. `(("libusb" ,libusb)))
  183. (home-page "https://dfu-programmer.github.io/")
  184. (synopsis "Device firmware update programmer for Atmel chips")
  185. (description
  186. "Dfu-programmer is a multi-platform command-line programmer for
  187. Atmel (8051, AVR, XMEGA & AVR32) chips with a USB bootloader supporting
  188. ISP.")
  189. (license license:gpl2+)))
  190. (define-public dfu-util
  191. (package
  192. (name "dfu-util")
  193. (version "0.10")
  194. (source (origin
  195. (method url-fetch)
  196. (uri (string-append
  197. "http://dfu-util.sourceforge.net/releases/dfu-util-"
  198. version ".tar.gz"))
  199. (sha256
  200. (base32
  201. "0hlvc47ccf5hry13saqhc1j5cdq5jyjv4i05kj0mdh3rzj6wagd0"))))
  202. (build-system gnu-build-system)
  203. (inputs
  204. `(("libusb" ,libusb)))
  205. (native-inputs
  206. `(("pkg-config" ,pkg-config)))
  207. (synopsis "Host side of the USB Device Firmware Upgrade (DFU) protocol")
  208. (description
  209. "The DFU (Universal Serial Bus Device Firmware Upgrade) protocol is
  210. intended to download and upload firmware to devices connected over USB. It
  211. ranges from small devices like micro-controller boards up to mobile phones.
  212. With dfu-util you are able to download firmware to your device or upload
  213. firmware from it.")
  214. (home-page "http://dfu-util.sourceforge.net/")
  215. (license license:gpl2+)))
  216. (define-public teensy-loader-cli
  217. ;; The repo does not tag versions nor does it use releases, but a commit
  218. ;; message says "Importing 2.1", while the sourcce still says "2.0". So pin
  219. ;; to a fixed commit.
  220. (let ((commit "f289b7a2e5627464044249f0e5742830e052e360"))
  221. (package
  222. (name "teensy-loader-cli")
  223. (version (git-version "2.1" "1" commit))
  224. (source
  225. (origin
  226. (method git-fetch)
  227. (uri (git-reference
  228. (url "https://github.com/PaulStoffregen/teensy_loader_cli")
  229. (commit commit)))
  230. (sha256 (base32 "0sssim56pwsxp5cp5dlf6mi9h5fx2592m6j1g7abnm0s09b0lpdx"))
  231. (file-name (git-file-name name version))
  232. (modules '((guix build utils)))
  233. (snippet
  234. `(begin
  235. ;; Remove example flash files and teensy rebooter flash binaries.
  236. (for-each delete-file (find-files "." "\\.(elf|hex)$"))
  237. ;; Fix the version
  238. (substitute* "teensy_loader_cli.c"
  239. (("Teensy Loader, Command Line, Version 2.0\\\\n")
  240. (string-append "Teensy Loader, Command Line, " ,version "\\n")))
  241. #t))
  242. (patches (search-patches "teensy-loader-cli-help.patch"))))
  243. (build-system gnu-build-system)
  244. (arguments
  245. '(#:tests? #f ;; Makefile has no test target
  246. #:make-flags (list "CC=gcc" (string-append "PREFIX=" %output))
  247. #:phases
  248. (modify-phases %standard-phases
  249. (delete 'configure)
  250. (replace 'install
  251. (lambda* (#:key outputs #:allow-other-keys)
  252. (let* ((out (assoc-ref outputs "out"))
  253. (bin (string-append out "/bin")))
  254. (install-file "teensy_loader_cli" bin)
  255. #t))))))
  256. (inputs
  257. `(("libusb-compat" ,libusb-compat)))
  258. (synopsis "Command line firmware uploader for Teensy development boards")
  259. (description
  260. "The Teensy loader program communicates with your Teensy board when the
  261. HalfKay bootloader is running, so you can upload new programs and run them.
  262. You need to add the udev rules to make the Teensy update available for
  263. non-root users.")
  264. (home-page "https://www.pjrc.com/teensy/loader_cli.html")
  265. (license license:gpl3))))
  266. (define-public rkflashtool
  267. (let ((commit "8966c4e277de8148290554aaaa4146a3a84a3c53")
  268. (revision "1"))
  269. (package
  270. (name "rkflashtool")
  271. (version (git-version "5.2" revision commit))
  272. (source
  273. (origin
  274. (method git-fetch)
  275. (uri (git-reference
  276. (url "https://github.com/linux-rockchip/rkflashtool")
  277. (commit commit)))
  278. (file-name (git-file-name name version))
  279. (sha256
  280. (base32
  281. "1ndyzg1zlgg20dd8js9kfqm5kq19k005vddkvf65qj20w0pcyahn"))))
  282. (build-system gnu-build-system)
  283. (arguments
  284. '(#:phases
  285. (modify-phases %standard-phases
  286. (delete 'configure)) ; no configure
  287. #:make-flags (list (string-append "PREFIX=" %output))
  288. #:tests? #f)) ; no tests
  289. (native-inputs
  290. `(("pkg-config" ,pkg-config)))
  291. (inputs
  292. `(("libusb" ,libusb)))
  293. (home-page "https://github.com/linux-rockchip/rkflashtool")
  294. (synopsis "Tools for flashing Rockchip devices")
  295. (description "Allows flashing of Rockchip based embedded linux devices.
  296. The list of currently supported devices is: RK2818, RK2918, RK2928, RK3026,
  297. RK3036, RK3066, RK312X, RK3168, RK3188, RK3288, RK3368.")
  298. (license license:bsd-2))))
  299. (define-public heimdall
  300. (package
  301. (name "heimdall")
  302. (version "1.4.2")
  303. (source (origin
  304. (method git-fetch)
  305. (uri (git-reference
  306. (url "https://gitlab.com/BenjaminDobell/Heimdall.git")
  307. (commit (string-append "v" version))))
  308. (file-name (git-file-name name version))
  309. (sha256
  310. (base32
  311. "1ygn4snvcmi98rgldgxf5hwm7zzi1zcsihfvm6awf9s6mpcjzbqz"))))
  312. (build-system cmake-build-system)
  313. (arguments
  314. `(#:build-type "Release"
  315. #:tests? #f ; no tests
  316. #:phases
  317. (modify-phases %standard-phases
  318. (add-after 'unpack 'patch-invocations
  319. (lambda* (#:key outputs #:allow-other-keys)
  320. (substitute* '("heimdall-frontend/source/aboutform.cpp"
  321. "heimdall-frontend/source/mainwindow.cpp")
  322. (("start[(]\"heimdall\"")
  323. (string-append "start(\"" (assoc-ref outputs "out")
  324. "/bin/heimdall\"")))
  325. #t))
  326. (replace 'install
  327. (lambda* (#:key outputs #:allow-other-keys)
  328. (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
  329. (lib (string-append (assoc-ref outputs "out") "/lib")))
  330. (install-file "bin/heimdall" bin)
  331. (install-file "bin/heimdall-frontend" bin)
  332. (install-file "libpit/libpit.a" lib)
  333. #t))))))
  334. (inputs
  335. `(("libusb" ,libusb)
  336. ("qtbase" ,qtbase-5)
  337. ("zlib" ,zlib)))
  338. (home-page "https://glassechidna.com.au/heimdall/")
  339. (synopsis "Flash firmware onto Samsung mobile devices")
  340. (description "@command{heimdall} is a tool suite used to flash firmware (aka
  341. ROMs) onto Samsung mobile devices. Heimdall connects to a mobile device over
  342. USB and interacts with low-level software running on the device, known as Loke.
  343. Loke and Heimdall communicate via the custom Samsung-developed protocol typically
  344. referred to as the \"Odin 3 protocol\".")
  345. (license license:expat)))
  346. (define-public ifdtool
  347. (package
  348. (name "ifdtool")
  349. (version "4.9")
  350. (source (origin
  351. (method git-fetch)
  352. (uri (git-reference
  353. (url "https://github.com/coreboot/coreboot")
  354. (commit version)))
  355. (file-name (git-file-name name version))
  356. (sha256
  357. (base32
  358. "0jidj29jh6p65d17k304wlzhxvp4p3c2namgcdwg2sxq8jfr0zlm"))))
  359. (build-system gnu-build-system)
  360. (arguments
  361. `(#:make-flags
  362. (list "CC=gcc"
  363. "INSTALL=install"
  364. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  365. #:phases
  366. (modify-phases %standard-phases
  367. (add-after 'unpack 'chdir
  368. (lambda _
  369. (chdir "util/ifdtool")
  370. #t))
  371. (delete 'configure)) ; no configure script
  372. #:tests? #f)) ; no test suite
  373. (home-page "https://github.com/corna/me_cleaner/")
  374. (synopsis "Intel Firmware Descriptor dumper")
  375. (description "This package provides @command{ifdtool}, a program to
  376. dump Intel Firmware Descriptor data of an image file.")
  377. (license license:gpl2)))
  378. (define-public intelmetool
  379. (package
  380. (name "intelmetool")
  381. (version "4.7")
  382. (source (origin
  383. (method git-fetch)
  384. (uri (git-reference
  385. (url "https://review.coreboot.org/p/coreboot")
  386. (commit version)))
  387. (file-name (git-file-name name version))
  388. (sha256
  389. (base32
  390. "0nw555i0fm5kljha9h47bk70ykbwv8ddfk6qhz6kfqb79vzhy4h2"))))
  391. (build-system gnu-build-system)
  392. (inputs
  393. `(("pciutils" ,pciutils)
  394. ("zlib" ,zlib)))
  395. (arguments
  396. `(#:make-flags
  397. (list "CC=gcc"
  398. "INSTALL=install"
  399. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  400. #:phases
  401. (modify-phases %standard-phases
  402. (add-after 'unpack 'chdir
  403. (lambda _
  404. (chdir "util/intelmetool")
  405. #t))
  406. (delete 'configure)
  407. (delete 'check))))
  408. (home-page "https://github.com/zamaudio/intelmetool")
  409. (synopsis "Intel Management Engine tools")
  410. (description "This package provides tools for working with Intel
  411. Management Engine (ME). You need to @code{sudo rmmod mei_me} and
  412. @code{sudo rmmod mei} before using this tool. Also pass
  413. @code{iomem=relaxed} to the Linux kernel command line.")
  414. (license license:gpl2)
  415. ;; This is obviously an Intel thing, plus it requires <cpuid.h>.
  416. (supported-systems '("x86_64-linux" "i686-linux"))))
  417. (define-public me-cleaner
  418. (package
  419. (name "me-cleaner")
  420. (version "1.2")
  421. (source (origin
  422. (method git-fetch)
  423. (uri (git-reference
  424. (url "https://github.com/corna/me_cleaner")
  425. (commit (string-append "v" version))))
  426. (sha256
  427. (base32
  428. "1bdj2clm13ir441vn7sv860xsc5gh71ja5lc2wn0gggnff0adxj4"))
  429. (file-name (git-file-name name version))))
  430. (build-system python-build-system)
  431. (arguments
  432. `(#:phases
  433. (modify-phases %standard-phases
  434. (add-after 'install 'install-documentation
  435. (lambda* (#:key outputs #:allow-other-keys)
  436. (let* ((out (assoc-ref outputs "out"))
  437. (man (string-append out "/share/man/man1")))
  438. (install-file "man/me_cleaner.1" man)
  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. ;; This is an Intel thing.
  446. (supported-systems '("x86_64-linux" "i686-linux"))))
  447. (define-public uefitool
  448. (package
  449. (name "uefitool")
  450. (version "0.28.0")
  451. (source (origin
  452. (method git-fetch)
  453. (uri (git-reference
  454. (url "https://github.com/LongSoft/UEFITool")
  455. (commit version)))
  456. (sha256
  457. (base32
  458. "1n2hd2dysi5bv2iyq40phh1jxc48gdwzs414vfbxvcharcwapnja"))
  459. (file-name (git-file-name name version))))
  460. (build-system gnu-build-system)
  461. (arguments
  462. `(#:phases
  463. (modify-phases %standard-phases
  464. (replace 'configure
  465. (lambda _
  466. (invoke "qmake" "-makefile")))
  467. (replace 'install
  468. (lambda* (#:key outputs #:allow-other-keys)
  469. (install-file "UEFITool" (string-append (assoc-ref outputs "out")
  470. "/bin")))))))
  471. (inputs
  472. `(("qtbase" ,qtbase-5)))
  473. (home-page "https://github.com/LongSoft/UEFITool/")
  474. (synopsis "UEFI image editor")
  475. (description "@code{uefitool} is a graphical image file editor for
  476. Unifinished Extensible Firmware Interface (UEFI) images.")
  477. (license license:bsd-2)))
  478. (define-public srecord
  479. (package
  480. (name "srecord")
  481. (version "1.64")
  482. (source
  483. (origin
  484. (method url-fetch)
  485. (uri (string-append "mirror://sourceforge/srecord/srecord/"
  486. version "/srecord-" version ".tar.gz"))
  487. (sha256
  488. (base32
  489. "1qk75q0k5vzmm3932q9hqz2gp8n9rrdfjacsswxc02656f3l3929"))))
  490. (build-system gnu-build-system)
  491. (arguments
  492. `(#:configure-flags
  493. (list (string-append "SH="
  494. (assoc-ref %build-inputs "bash")
  495. "/bin/bash"))))
  496. (inputs
  497. `(("boost" ,boost)
  498. ("libgcrypt" ,libgcrypt)))
  499. (native-inputs
  500. `(("bison" ,bison)
  501. ("diffutils" ,diffutils)
  502. ("ghostscript" ,ghostscript)
  503. ("groff" ,groff)
  504. ("libtool" ,libtool)
  505. ("which" ,which)))
  506. (home-page "http://srecord.sourceforge.net/")
  507. (synopsis "Tools for EPROM files")
  508. (description "The SRecord package is a collection of powerful tools for
  509. manipulating EPROM load files. It reads and writes numerous EPROM file
  510. formats, and can perform many different manipulations.")
  511. (license license:gpl3+)))