electronics.scm 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Theodoros Foradis <theodoros@foradis.org>
  3. ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2019 Clément Lassieur <clement@lassieur.org>
  5. ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
  6. ;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
  7. ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  8. ;;;
  9. ;;; This file is part of GNU Guix.
  10. ;;;
  11. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  12. ;;; under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 3 of the License, or (at
  14. ;;; your option) any later version.
  15. ;;;
  16. ;;; GNU Guix is distributed in the hope that it will be useful, but
  17. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (gnu packages electronics)
  24. #:use-module (guix download)
  25. #:use-module (guix gexp)
  26. #:use-module (guix git-download)
  27. #:use-module ((guix licenses) #:prefix license:)
  28. #:use-module (guix packages)
  29. #:use-module (guix utils)
  30. #:use-module (guix build-system gnu)
  31. #:use-module (guix build-system cmake)
  32. #:use-module (gnu packages)
  33. #:use-module (gnu packages algebra)
  34. #:use-module (gnu packages autotools)
  35. #:use-module (gnu packages base)
  36. #:use-module (gnu packages bash)
  37. #:use-module (gnu packages boost)
  38. #:use-module (gnu packages c)
  39. #:use-module (gnu packages check)
  40. #:use-module (gnu packages compression)
  41. #:use-module (gnu packages documentation)
  42. #:use-module (gnu packages embedded)
  43. #:use-module (gnu packages fontutils)
  44. #:use-module (gnu packages gawk)
  45. #:use-module (gnu packages gl)
  46. #:use-module (gnu packages glib)
  47. #:use-module (gnu packages graphviz)
  48. #:use-module (gnu packages gtk)
  49. #:use-module (gnu packages libftdi)
  50. #:use-module (gnu packages libusb)
  51. #:use-module (gnu packages linux)
  52. #:use-module (gnu packages m4)
  53. #:use-module (gnu packages pkg-config)
  54. #:use-module (gnu packages python)
  55. #:use-module (gnu packages qt)
  56. #:use-module (gnu packages sdl)
  57. #:use-module (gnu packages sqlite)
  58. #:use-module (gnu packages stb)
  59. #:use-module (gnu packages toolkits))
  60. (define-public libserialport
  61. (package
  62. (name "libserialport")
  63. (version "0.1.1")
  64. (source (origin
  65. (method url-fetch)
  66. (uri (string-append
  67. "http://sigrok.org/download/source/libserialport/libserialport-"
  68. version ".tar.gz"))
  69. (sha256
  70. (base32
  71. "17ajlwgvyyrap8z7f16zcs59pksvncwbmd3mzf98wj7zqgczjaja"))))
  72. (build-system gnu-build-system)
  73. (home-page "https://sigrok.org/wiki/Libserialport")
  74. (synopsis "Library for using serial ports")
  75. (description "Libserialport is a minimal shared library written in C that is intended
  76. to take care of the OS-specific details when writing software that uses serial ports.")
  77. (license license:lgpl3+)))
  78. (define-public libsigrokdecode
  79. (package
  80. (name "libsigrokdecode")
  81. (version "0.5.3")
  82. (source (origin
  83. (method url-fetch)
  84. (uri (string-append
  85. "http://sigrok.org/download/source/libsigrokdecode/libsigrokdecode-"
  86. version ".tar.gz"))
  87. (sha256
  88. (base32
  89. "1h1zi1kpsgf6j2z8j8hjpv1q7n49i3fhqjn8i178rka3cym18265"))
  90. (patches
  91. (search-patches "libsigrokdecode-python3.9-fix.patch"))))
  92. (outputs '("out" "doc"))
  93. (arguments
  94. `(#:phases
  95. (modify-phases %standard-phases
  96. (replace 'bootstrap
  97. (lambda _
  98. (invoke "autoconf")
  99. (invoke "aclocal")
  100. (invoke "automake" "-ac")))
  101. (add-after 'build 'build-doc
  102. (lambda _
  103. (invoke "doxygen")
  104. #t))
  105. (add-after 'install 'install-doc
  106. (lambda* (#:key outputs #:allow-other-keys)
  107. (copy-recursively "doxy/html-api"
  108. (string-append (assoc-ref outputs "doc")
  109. "/share/doc/libsigrokdecode"))
  110. #t)))))
  111. (native-inputs
  112. (list check-0.14 doxygen graphviz pkg-config automake autoconf))
  113. ;; libsigrokdecode.pc lists "python" in Requires.private, and "glib" in Requires.
  114. (propagated-inputs
  115. (list glib python))
  116. (build-system gnu-build-system)
  117. (home-page "https://www.sigrok.org/wiki/Libsigrokdecode")
  118. (synopsis "Library providing (streaming) protocol decoding functionality")
  119. (description "Libsigrokdecode is a shared library written in C, which provides
  120. (streaming) protocol decoding functionality.")
  121. (license license:gpl3+)))
  122. (define-public sigrok-firmware-fx2lafw
  123. (package
  124. (name "sigrok-firmware-fx2lafw")
  125. (version "0.1.7")
  126. (source (origin
  127. (method url-fetch)
  128. (uri (string-append
  129. "http://sigrok.org/download/source/sigrok-firmware-fx2lafw/"
  130. "sigrok-firmware-fx2lafw-" version ".tar.gz"))
  131. (sha256
  132. (base32
  133. "0fyfd82mvrcf55v5a3afq1mh1kfswk4c37qrbln6x92jm3b41x53"))))
  134. (arguments
  135. `(#:implicit-inputs? #f))
  136. (native-inputs
  137. `(("awk" ,gawk)
  138. ("bash" ,bash)
  139. ("coreutils" ,coreutils)
  140. ("grep" ,grep)
  141. ("gzip" ,gzip)
  142. ("make" ,gnu-make)
  143. ("sdcc" ,sdcc)
  144. ("sed" ,sed)
  145. ("tar" ,tar)))
  146. (build-system gnu-build-system)
  147. (home-page "https://www.sigrok.org/wiki/Fx2lafw")
  148. (synopsis "Firmware for Cypress FX2 chips")
  149. (description "Fx2lafw is free firmware for Cypress FX2 chips which makes them usable
  150. as simple logic analyzer and/or oscilloscope hardware.")
  151. (license license:gpl2+)))
  152. (define-public libsigrok
  153. (let ((commit "a7e919a3a6b7fd511acbe1a280536b76c70c28d2")
  154. (revision "1"))
  155. (package
  156. (name "libsigrok")
  157. (version (git-version "0.5.2" revision commit))
  158. (source
  159. (origin
  160. (method git-fetch)
  161. (uri (git-reference
  162. (url "git://sigrok.org/libsigrok")
  163. (commit commit)))
  164. (sha256
  165. (base32 "0km3fyv5s2byrm4zpbss2527ynhw4nb67imnbawwic2a6zh9jiyc"))
  166. (file-name (git-file-name name version))))
  167. (outputs '("out" "doc"))
  168. (arguments
  169. `(#:tests? #f ; tests need USB access
  170. #:phases
  171. (modify-phases %standard-phases
  172. (add-before 'configure 'change-udev-group
  173. (lambda _
  174. (substitute* (find-files "contrib" "\\.rules$")
  175. (("plugdev") "dialout"))))
  176. (add-after 'build 'build-doc
  177. (lambda _
  178. (invoke "doxygen")))
  179. (add-after 'install 'install-doc
  180. (lambda* (#:key outputs #:allow-other-keys)
  181. (copy-recursively "doxy/html-api"
  182. (string-append (assoc-ref outputs "doc")
  183. "/share/doc/libsigrok"))))
  184. (add-after 'install-doc 'install-udev-rules
  185. (lambda* (#:key outputs #:allow-other-keys)
  186. (let* ((out (assoc-ref outputs "out"))
  187. (rules (string-append out "/lib/udev/rules.d/")))
  188. (for-each (lambda (file)
  189. (install-file file rules))
  190. (find-files "contrib" "\\.rules$")))))
  191. (add-after 'install-udev-rules 'install-fw
  192. (lambda* (#:key inputs outputs #:allow-other-keys)
  193. (let* ((fx2lafw (assoc-ref inputs "sigrok-firmware-fx2lafw"))
  194. (out (assoc-ref outputs "out"))
  195. (dir-suffix "/share/sigrok-firmware/")
  196. (input-dir (string-append fx2lafw dir-suffix))
  197. (output-dir (string-append out dir-suffix)))
  198. (for-each
  199. (lambda (file)
  200. (install-file file output-dir))
  201. (find-files input-dir "."))))))))
  202. (native-inputs
  203. (list autoconf automake doxygen graphviz libtool
  204. sigrok-firmware-fx2lafw pkg-config))
  205. (inputs
  206. (list python zlib))
  207. ;; libsigrokcxx.pc lists "glibmm" in Requires libsigrok.pc lists
  208. ;; "libserialport", "libusb", "libftdi" and "libzip" in Requires.private
  209. ;; and "glib" in Requires
  210. (propagated-inputs
  211. (list glib
  212. glibmm-2.64
  213. libserialport
  214. libusb
  215. libftdi
  216. libzip))
  217. (build-system gnu-build-system)
  218. (home-page "https://www.sigrok.org/wiki/Libsigrok")
  219. (synopsis "Basic hardware access drivers for logic analyzers")
  220. (description "@code{libsigrok} is a shared library written in C which
  221. provides the basic hardware access drivers for logic analyzers and other
  222. supported devices, as well as input/output file format support.")
  223. (license license:gpl3+))))
  224. (define-public sigrok-cli
  225. (package
  226. (name "sigrok-cli")
  227. (version "0.7.2")
  228. (source (origin
  229. (method url-fetch)
  230. (uri (string-append
  231. "http://sigrok.org/download/source/sigrok-cli/sigrok-cli-"
  232. version ".tar.gz"))
  233. (sha256
  234. (base32
  235. "1f0a2k8qdcin0pqiqq5ni4khzsnv61l21v1dfdjzayw96qzl9l3i"))))
  236. (native-inputs
  237. (list pkg-config))
  238. (inputs
  239. (list glib libsigrok libsigrokdecode))
  240. (build-system gnu-build-system)
  241. (home-page "https://sigrok.org/wiki/Sigrok-cli")
  242. (synopsis "Command-line frontend for sigrok")
  243. (description "Sigrok-cli is a command-line frontend for sigrok.")
  244. (license license:gpl3+)))
  245. (define-public openboardview
  246. (package
  247. (name "openboardview")
  248. (version "8.95.2")
  249. (source (origin
  250. (method git-fetch)
  251. (uri (git-reference
  252. (url "https://github.com/OpenBoardView/OpenBoardView")
  253. (commit version)))
  254. (file-name (git-file-name name version))
  255. (modules '((ice-9 ftw)
  256. (srfi srfi-26)
  257. (guix build utils)))
  258. (snippet
  259. '(with-directory-excursion "src"
  260. (define keep (list "." ".." "openboardview"))
  261. (for-each (lambda (f)
  262. (when (eq? 'directory (stat:type (lstat f)))
  263. (delete-file-recursively f)))
  264. (scandir "." (negate (cut member <> keep))))))
  265. (patches
  266. (search-patches "openboardview-use-system-imgui.patch"
  267. "openboardview-use-system-utf8.patch"))
  268. (sha256
  269. (base32
  270. "1n2yfi8wpky0y231kq2zdgwn7f7kff8m53m904hxi5ppmwhx1d6q"))))
  271. (build-system cmake-build-system)
  272. (arguments
  273. (list
  274. #:tests? #f ;no test suite
  275. #:imported-modules `((guix build glib-or-gtk-build-system)
  276. ,@%cmake-build-system-modules)
  277. #:modules '((guix build cmake-build-system)
  278. (guix build utils)
  279. ((guix build glib-or-gtk-build-system) #:prefix gtk:))
  280. #:phases
  281. #~(modify-phases %standard-phases
  282. (add-before 'configure 'configure-glad
  283. (lambda* (#:key inputs #:allow-other-keys)
  284. (substitute* "src/CMakeLists.txt"
  285. (("add_subdirectory\\(glad\\)")
  286. (string-append
  287. ;; Configure Glad to use static Khronos XML specifications
  288. ;; instead of attempting to fetch them from the Internet.
  289. "option(GLAD_REPRODUCIBLE \"Reproducible build\" ON)\n"
  290. ;; Use the CMake files from our glad package.
  291. "add_subdirectory("
  292. (search-input-directory inputs "share/glad") ;source_dir
  293. " src/glad)\n"))))) ;binary dir
  294. (add-before 'configure 'fix-utf8-include-directive
  295. ;; Our utf8-h package makes the header available as "utf8.h"
  296. ;; directly rather than "utf8/utf8.h".
  297. (lambda _
  298. (substitute* '("src/openboardview/FileFormats/BRDFile.cpp"
  299. "src/openboardview/BoardView.cpp")
  300. (("utf8/utf8.h") "utf8.h"))))
  301. (add-before 'configure 'dynamically-load-gtk-via-absolute-path
  302. ;; The GTK library is not linked thus not present in the RUNPATH of
  303. ;; the produced binary; the absolute path of the libraries must to
  304. ;; the dynamic loader otherwise they aren't found.
  305. (lambda* (#:key inputs #:allow-other-keys)
  306. (substitute* "src/openboardview/unix.cpp"
  307. (("libgtk-3.so")
  308. (search-input-file inputs "lib/libgtk-3.so")))))
  309. ;; Add the two extra phases from `glib-or-gtk-build-system'.
  310. (add-after 'install 'glib-or-gtk-compile-schemas
  311. (assoc-ref gtk:%standard-phases 'glib-or-gtk-compile-schemas))
  312. (add-after 'install 'glib-or-gtk-wrap
  313. (assoc-ref gtk:%standard-phases 'glib-or-gtk-wrap)))))
  314. (native-inputs
  315. (list pkg-config
  316. python
  317. glad
  318. stb-image
  319. utf8-h))
  320. (inputs
  321. (list fontconfig
  322. gtk+
  323. imgui
  324. sdl2
  325. sqlite
  326. zlib))
  327. (home-page "https://openboardview.org/")
  328. (synopsis "Viewer for BoardView files")
  329. (description "OpenBoardView is a viewer for BoardView files, which present
  330. the details of a printed circuit board (PCB). It comes with features
  331. such as:
  332. @itemize
  333. @item Dynamic part outline rendering, including complex connectors
  334. @item Annotations, for leaving notes about parts, nets, pins or location
  335. @item Configurable colour themes
  336. @item Configurable DPI to facilitate usage on 4K monitors
  337. @item Configurable for running on slower systems
  338. @item Reads FZ (with key), BRD, BRD2, BDV and BV* formats.
  339. @end itemize")
  340. (license license:expat)))
  341. (define-public pulseview
  342. (package
  343. (name "pulseview")
  344. (version "0.4.2")
  345. (source (origin
  346. (method url-fetch)
  347. (uri (string-append
  348. "https://sigrok.org/download/source/pulseview/pulseview-"
  349. version ".tar.gz"))
  350. (sha256
  351. (base32
  352. "1jxbpz1h3m1mgrxw74rnihj8vawgqdpf6c33cqqbyd8v7rxgfhph"))
  353. (patches (search-patches "pulseview-qt515-compat.patch"
  354. "pulseview-glib-2.68.patch"))))
  355. (build-system cmake-build-system)
  356. (arguments
  357. `(#:tests? #f ;format_time_minutes_test is failing
  358. #:phases
  359. (modify-phases %standard-phases
  360. (add-after 'install 'remove-empty-doc-directory
  361. (lambda* (#:key outputs #:allow-other-keys)
  362. (let ((out (assoc-ref outputs "out")))
  363. (with-directory-excursion (string-append out "/share")
  364. ;; Use RMDIR to never risk silently deleting files.
  365. (rmdir "doc/pulseview")
  366. (rmdir "doc"))))))))
  367. (native-inputs
  368. (list pkg-config qttools))
  369. (inputs
  370. (list boost
  371. glib
  372. glibmm
  373. libsigrok
  374. libsigrokdecode
  375. qtbase-5
  376. qtsvg))
  377. (home-page "https://www.sigrok.org/wiki/PulseView")
  378. (synopsis "Qt based logic analyzer, oscilloscope and MSO GUI for sigrok")
  379. (description "PulseView is a Qt based logic analyzer, oscilloscope and MSO GUI
  380. for sigrok.")
  381. (license license:gpl3+)))
  382. (define-public comedilib
  383. (package
  384. (name "comedilib")
  385. (version "0.12.0")
  386. (source (origin
  387. (method url-fetch)
  388. (uri (string-append "https://www.comedi.org/download/comedilib-"
  389. version ".tar.gz"))
  390. (sha256
  391. (base32
  392. "0wzh23iyix4xj211fsd8hwrdcjhg2w5jswk9kywb1gpd3h8afajj"))))
  393. (build-system gnu-build-system)
  394. (synopsis "Library for Comedi")
  395. (description "Comedilib is a user-space library that provides a
  396. developer-friendly interface to Comedi devices. Comedi is a collection of
  397. drivers for a variety of common data acquisition plug-in boards. The drivers
  398. are implemented as a core Linux kernel module providing common functionality and
  399. individual low-level driver modules.")
  400. (home-page "https://www.comedi.org/")
  401. (license license:lgpl2.1)))
  402. (define-public xoscope
  403. (package
  404. (name "xoscope")
  405. (version "2.3")
  406. (source (origin
  407. (method url-fetch)
  408. (uri (string-append "mirror://sourceforge/xoscope/xoscope/"
  409. version "/xoscope-" version ".tar.gz"))
  410. (sha256
  411. (base32
  412. "0a5ycfc1qdmibvagc82r2mhv2i99m6pndy5i6ixas3j2297g6pgq"))))
  413. (build-system gnu-build-system)
  414. (native-inputs
  415. (list m4 pkg-config))
  416. (inputs
  417. (list alsa-lib comedilib fftw gtk+ gtkdatabox))
  418. (synopsis "Digital oscilloscope")
  419. (description "Xoscope is a digital oscilloscope that can acquire signals
  420. from ALSA, ESD, and COMEDI sources. This package currently does not include
  421. support for ESD sources.")
  422. (home-page "http://xoscope.sourceforge.net/")
  423. (license license:gpl2+)))