doc: Update htmlxref.cnf.
[guix.git] / gnu / packages / embedded.scm
bloba65998c369f10371037f548a7417714c54f4ecc7
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016, 2017 Theodoros Foradis <theodoros@foradis.org>
4 ;;; Copyright © 2016 David Craven <david@craven.ch>
5 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
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/>.
24 (define-module (gnu packages embedded)
25   #:use-module (guix utils)
26   #:use-module (guix packages)
27   #:use-module (guix download)
28   #:use-module (guix svn-download)
29   #:use-module (guix git-download)
30   #:use-module ((guix licenses) #:prefix license:)
31   #:use-module (guix build-system cmake)
32   #:use-module (guix build-system gnu)
33   #:use-module (guix build-system trivial)
34   #:use-module (guix build utils)
35   #:use-module (gnu packages)
36   #:use-module (gnu packages autotools)
37   #:use-module ((gnu packages base) #:prefix base:)
38   #:use-module (gnu packages bison)
39   #:use-module (gnu packages cross-base)
40   #:use-module (gnu packages dejagnu)
41   #:use-module (gnu packages flex)
42   #:use-module (gnu packages gcc)
43   #:use-module (gnu packages gdb)
44   #:use-module (gnu packages guile)
45   #:use-module (gnu packages libftdi)
46   #:use-module (gnu packages libusb)
47   #:use-module (gnu packages perl)
48   #:use-module (gnu packages pkg-config)
49   #:use-module (gnu packages python)
50   #:use-module (gnu packages swig)
51   #:use-module (gnu packages texinfo)
52   #:use-module (gnu packages xorg)
53   #:use-module (srfi srfi-1))
55 ;; We must not use the released GCC sources here, because the cross-compiler
56 ;; does not produce working binaries.  Instead we take the very same SVN
57 ;; revision from the branch that is used for a release of the "GCC ARM
58 ;; embedded" project on launchpad.
59 ;; See https://launchpadlibrarian.net/218827644/release.txt
60 (define-public gcc-arm-none-eabi-4.9
61   (let ((xgcc (cross-gcc "arm-none-eabi"
62                          #:xgcc gcc-4.9
63                          #:xbinutils (cross-binutils "arm-none-eabi")))
64         (revision "1")
65         (svn-revision 227977))
66     (package (inherit xgcc)
67       (version (string-append (package-version xgcc) "-"
68                               revision "." (number->string svn-revision)))
69       (source
70        (origin
71          (method svn-fetch)
72          (uri (svn-reference
73                (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
74                (revision svn-revision)))
75          (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
76          (sha256
77           (base32
78            "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
80          ;; Remove the one patch that doesn't apply to this 4.9 snapshot (the
81          ;; patch is for 4.9.4 and later but this svn snapshot is older).
82          (patches (remove (lambda (patch)
83                             (string=? (basename patch)
84                                       "gcc-arm-bug-71399.patch"))
85                           (origin-patches (package-source xgcc))))))
86       (native-inputs
87        `(("flex" ,flex)
88          ,@(package-native-inputs xgcc)))
89       (arguments
90        (substitute-keyword-arguments (package-arguments xgcc)
91          ((#:phases phases)
92           `(modify-phases ,phases
93              (add-after 'unpack 'fix-genmultilib
94                (lambda _
95                  (substitute* "gcc/genmultilib"
96                    (("#!/bin/sh") (string-append "#!" (which "sh"))))
97                  #t))))
98          ((#:configure-flags flags)
99           ;; The configure flags are largely identical to the flags used by the
100           ;; "GCC ARM embedded" project.
101           `(append (list "--enable-multilib"
102                          "--with-newlib"
103                          "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
104                          "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
105                          "--enable-plugins"
106                          "--disable-decimal-float"
107                          "--disable-libffi"
108                          "--disable-libgomp"
109                          "--disable-libmudflap"
110                          "--disable-libquadmath"
111                          "--disable-libssp"
112                          "--disable-libstdcxx-pch"
113                          "--disable-nls"
114                          "--disable-shared"
115                          "--disable-threads"
116                          "--disable-tls")
117                    (delete "--disable-multilib" ,flags)))))
118       (native-search-paths
119        (list (search-path-specification
120               (variable "CROSS_C_INCLUDE_PATH")
121               (files '("arm-none-eabi/include")))
122              (search-path-specification
123               (variable "CROSS_CPLUS_INCLUDE_PATH")
124               (files '("arm-none-eabi/include")))
125              (search-path-specification
126               (variable "CROSS_LIBRARY_PATH")
127               (files '("arm-none-eabi/lib"))))))))
129 (define-public gcc-arm-none-eabi-6
130   (package
131     (inherit gcc-arm-none-eabi-4.9)
132     (version (package-version gcc-6))
133     (source (origin (inherit (package-source gcc-6))
134                     (patches
135                      (append
136                       (origin-patches (package-source gcc-6))
137                       (search-patches "gcc-6-cross-environment-variables.patch"
138                                       "gcc-6-arm-none-eabi-multilib.patch")))))))
140 (define-public newlib-arm-none-eabi
141   (package
142     (name "newlib")
143     (version "2.4.0")
144     (source (origin
145               (method url-fetch)
146               (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
147                                   version ".tar.gz"))
148               (sha256
149                (base32
150                 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
151     (build-system gnu-build-system)
152     (arguments
153      `(#:out-of-source? #t
154        ;; The configure flags are identical to the flags used by the "GCC ARM
155        ;; embedded" project.
156        #:configure-flags '("--target=arm-none-eabi"
157                            "--enable-newlib-io-long-long"
158                            "--enable-newlib-register-fini"
159                            "--disable-newlib-supplied-syscalls"
160                            "--disable-nls")
161        #:phases
162        (modify-phases %standard-phases
163          (add-after 'unpack 'fix-references-to-/bin/sh
164            (lambda _
165              (substitute* '("libgloss/arm/cpu-init/Makefile.in"
166                             "libgloss/arm/Makefile.in"
167                             "libgloss/libnosys/Makefile.in"
168                             "libgloss/Makefile.in")
169                (("/bin/sh") (which "sh")))
170              #t)))))
171     (native-inputs
172      `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
173        ("xgcc" ,gcc-arm-none-eabi-4.9)
174        ("texinfo" ,texinfo)))
175     (home-page "http://www.sourceware.org/newlib/")
176     (synopsis "C library for use on embedded systems")
177     (description "Newlib is a C library intended for use on embedded
178 systems.  It is a conglomeration of several library parts that are easily
179 usable on embedded products.")
180     (license (license:non-copyleft
181               "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
183 (define-public newlib-nano-arm-none-eabi
184   (package (inherit newlib-arm-none-eabi)
185     (name "newlib-nano")
186     (arguments
187      (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
188        ;; The configure flags are identical to the flags used by the "GCC ARM
189        ;; embedded" project.  They optimize newlib for use on small embedded
190        ;; systems with limited memory.
191        ((#:configure-flags flags)
192         ''("--target=arm-none-eabi"
193            "--enable-multilib"
194            "--disable-newlib-supplied-syscalls"
195            "--enable-newlib-reent-small"
196            "--disable-newlib-fvwrite-in-streamio"
197            "--disable-newlib-fseek-optimization"
198            "--disable-newlib-wide-orient"
199            "--enable-newlib-nano-malloc"
200            "--disable-newlib-unbuf-stream-opt"
201            "--enable-lite-exit"
202            "--enable-newlib-global-atexit"
203            "--enable-newlib-nano-formatted-io"
204            "--disable-nls"))))
205     (synopsis "Newlib variant for small systems with limited memory")))
207 (define (make-libstdc++-arm-none-eabi xgcc newlib)
208   (let ((libstdc++ (make-libstdc++ xgcc)))
209     (package (inherit libstdc++)
210       (name "libstdc++-arm-none-eabi")
211       (arguments
212        (substitute-keyword-arguments (package-arguments libstdc++)
213          ((#:configure-flags flags)
214           ``("--target=arm-none-eabi"
215              "--host=arm-none-eabi"
216              "--disable-libstdcxx-pch"
217              "--enable-multilib"
218              "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
219              "--disable-shared"
220              "--disable-tls"
221              "--disable-plugin"
222              "--with-newlib"
223              ,(string-append "--with-gxx-include-dir="
224                              (assoc-ref %outputs "out")
225                              "/arm-none-eabi/include")))))
226       (native-inputs
227        `(("newlib" ,newlib)
228          ("xgcc" ,xgcc)
229          ,@(package-native-inputs libstdc++))))))
231 (define (arm-none-eabi-toolchain xgcc newlib)
232   "Produce a cross-compiler toolchain package with the compiler XGCC and the C
233 library variant NEWLIB."
234   (let ((newlib-with-xgcc (package (inherit newlib)
235                             (native-inputs
236                              (alist-replace "xgcc" (list xgcc)
237                                             (package-native-inputs newlib))))))
238     (package
239       (name (string-append "arm-none-eabi"
240                            (if (string=? (package-name newlib-with-xgcc)
241                                          "newlib-nano")
242                                "-nano" "")
243                            "-toolchain"))
244       (version (package-version xgcc))
245       (source #f)
246       (build-system trivial-build-system)
247       (arguments
248        '(#:modules ((guix build union))
249          #:builder
250          (begin
251            (use-modules (ice-9 match)
252                         (guix build union))
253            (match %build-inputs
254              (((names . directories) ...)
255               (union-build (assoc-ref %outputs "out")
256                            directories)
257               #t)))))
258       (propagated-inputs
259        `(("binutils" ,(cross-binutils "arm-none-eabi"))
260          ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
261          ("gcc" ,xgcc)
262          ("newlib" ,newlib-with-xgcc)))
263       (synopsis "Complete GCC tool chain for ARM bare metal development")
264       (description "This package provides a complete GCC tool chain for ARM
265 bare metal development.  This includes the GCC arm-none-eabi cross compiler
266 and newlib (or newlib-nano) as the C library.  The supported programming
267 languages are C and C++.")
268       (home-page (package-home-page xgcc))
269       (license (package-license xgcc)))))
271 (define-public arm-none-eabi-toolchain-4.9
272   (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
273                            newlib-arm-none-eabi))
275 (define-public arm-none-eabi-nano-toolchain-4.9
276   (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
277                            newlib-nano-arm-none-eabi))
279 (define-public arm-none-eabi-toolchain-6
280   (arm-none-eabi-toolchain gcc-arm-none-eabi-6
281                            newlib-arm-none-eabi))
283 (define-public arm-none-eabi-nano-toolchain-6
284   (arm-none-eabi-toolchain gcc-arm-none-eabi-6
285                            newlib-nano-arm-none-eabi))
287 (define-public gdb-arm-none-eabi
288   (package
289     (inherit gdb)
290     (name "gdb-arm-none-eabi")
291     (arguments
292      `(#:configure-flags '("--target=arm-none-eabi"
293                            "--enable-multilib"
294                            "--enable-interwork"
295                            "--enable-languages=c,c++"
296                            "--disable-nls")
297      ,@(package-arguments gdb)))))
299 (define-public libjaylink
300   ;; No release tarballs available.
301   (let ((commit "699b7001d34a79c8e7064503dde1bede786fd7f0")
302         (revision "2"))
303     (package
304       (name "libjaylink")
305       (version (string-append "0.1.0-" revision "."
306                               (string-take commit 7)))
307       (source (origin
308                 (method git-fetch)
309                 (uri (git-reference
310                       (url "https://git.zapb.de/libjaylink.git")
311                       (commit commit)))
312                 (file-name (string-append name "-" version "-checkout"))
313                 (sha256
314                  (base32
315                   "034872d44myycnzn67v5b8ixrgmg8sk32aqalvm5x7108w2byww1"))))
316       (build-system gnu-build-system)
317       (native-inputs
318        `(("autoconf" ,autoconf)
319          ("automake" ,automake)
320          ("libtool" ,libtool)
321          ("pkg-config" ,pkg-config)))
322       (inputs
323        `(("libusb" ,libusb)))
324       (home-page "http://repo.or.cz/w/libjaylink.git")
325       (synopsis "Library to interface Segger J-Link devices")
326       (description "libjaylink is a shared library written in C to access
327 SEGGER J-Link and compatible devices.")
328       (license license:gpl2+))))
330 (define-public jimtcl
331   (package
332     (name "jimtcl")
333     (version "0.77")
334     (source (origin
335               (method url-fetch)
336               (uri (string-append
337                     "https://github.com/msteveb/jimtcl"
338                     "/archive/" version ".tar.gz"))
339               (file-name (string-append name "-" version ".tar.gz"))
340               (sha256
341                (base32
342                 "1cmk3qscqckg70chjyimzxa2qcka4qac0j4wq908kiijp45cax08"))))
343     (build-system gnu-build-system)
344     (arguments
345      `(#:phases
346        (modify-phases %standard-phases
347          ;; Doesn't use autoconf.
348          (replace 'configure
349            (lambda* (#:key outputs #:allow-other-keys)
350              (let ((out (assoc-ref outputs "out")))
351                (invoke "./configure"
352                        (string-append "--prefix=" out))))))))
353     (home-page "http://jim.tcl.tk")
354     (synopsis "Small footprint Tcl implementation")
355     (description "Jim is a small footprint implementation of the Tcl programming
356 language.")
357     (license license:bsd-2)))
359 (define-public openocd
360   (package
361     (name "openocd")
362     (version "0.10.0")
363     (source (origin
364               (method url-fetch)
365               (uri (string-append "mirror://sourceforge/openocd/openocd/"
366                                   version "/openocd-" version ".tar.gz"))
367               (sha256
368                (base32
369                 "09p57y3c2spqx4vjjlz1ljm1lcd0j9q8g76ywxqgn3yc34wv18zd"))
370               ;; FIXME: Remove after nrf52 patch is merged.
371               (patches
372                (search-patches "openocd-nrf52.patch"))))
373     (build-system gnu-build-system)
374     (native-inputs
375      `(("autoconf" ,autoconf)
376        ("automake" ,automake)
377        ("libtool" ,libtool)
378        ("pkg-config" ,pkg-config)))
379     (inputs
380      `(("hidapi" ,hidapi)
381        ("jimtcl" ,jimtcl)
382        ("libftdi" ,libftdi)
383        ("libjaylink" ,libjaylink)
384        ("libusb-compat" ,libusb-compat)))
385     (arguments
386      '(#:configure-flags
387        (append (list "--disable-werror"
388                      "--enable-sysfsgpio"
389                      "--disable-internal-jimtcl"
390                      "--disable-internal-libjaylink")
391                (map (lambda (programmer)
392                       (string-append "--enable-" programmer))
393                     '("amtjtagaccel" "armjtagew" "buspirate" "ftdi"
394                       "gw16012" "jlink" "opendous" "osbdm"
395                       "parport" "aice" "cmsis-dap" "dummy" "jtag_vpi"
396                       "remote-bitbang" "rlink" "stlink" "ti-icdi" "ulink"
397                       "usbprog" "vsllink" "usb-blaster-2" "usb_blaster"
398                       "presto" "openjtag")))
399        #:phases
400        (modify-phases %standard-phases
401          ;; Required because of patched sources.
402          (add-before 'configure 'autoreconf
403            (lambda _ (invoke "autoreconf" "-vfi") #t))
404          (add-after 'autoreconf 'change-udev-group
405            (lambda _
406              (substitute* "contrib/60-openocd.rules"
407                (("plugdev") "dialout"))
408              #t))
409          (add-after 'install 'install-udev-rules
410            (lambda* (#:key outputs #:allow-other-keys)
411              (install-file "contrib/60-openocd.rules"
412                            (string-append
413                             (assoc-ref outputs "out")
414                             "/lib/udev/rules.d/"))
415              #t)))))
416     (home-page "http://openocd.org")
417     (synopsis "On-Chip Debugger")
418     (description "OpenOCD provides on-chip programming and debugging support
419 with a layered architecture of JTAG interface and TAP support.")
420     (license license:gpl2+)))
422 ;; The commits for all propeller tools are the stable versions published at
423 ;; https://github.com/propellerinc/propgcc in the release_1_0.  According to
424 ;; personal correspondence with the developers in July 2017, more recent
425 ;; versions are currently incompatible with the "Simple Libraries".
427 (define propeller-binutils
428   (let ((xbinutils (cross-binutils "propeller-elf"))
429         (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
430         (revision "2"))
431     (package
432       (inherit xbinutils)
433       (name "propeller-binutils")
434       (version (string-append "0.0.0-" revision "." (string-take commit 9)))
435       (source (origin (inherit (package-source xbinutils))
436                 (method git-fetch)
437                 (uri (git-reference
438                       (url "https://github.com/parallaxinc/propgcc.git")
439                       (commit commit)))
440                 (file-name (string-append name "-" commit "-checkout"))
441                 (sha256
442                  (base32
443                   "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
444                 (patch-flags (list "-p1" "--directory=binutils"))))
445       (arguments
446        `(;; FIXME: For some reason there are many test failures.  It's not
447          ;; obvious how to fix the failures.
448          #:tests? #f
449          #:phases
450          (modify-phases %standard-phases
451            (add-after 'unpack 'chdir
452              (lambda _ (chdir "binutils") #t)))
453          ,@(substitute-keyword-arguments (package-arguments xbinutils)
454             ((#:configure-flags flags)
455              `(cons "--disable-werror" ,flags)))))
456       (native-inputs
457        `(("bison" ,bison)
458          ("flex" ,flex)
459          ("texinfo" ,texinfo)
460          ("dejagnu" ,dejagnu)
461          ,@(package-native-inputs xbinutils))))))
463 (define-public propeller-gcc-6
464   (let ((xgcc (cross-gcc "propeller-elf"
465                          #:xbinutils propeller-binutils))
466         (commit "b4f45a4725e0b6d0af59e594c4e3e35ca4105867")
467         (revision "1"))
468     (package (inherit xgcc)
469       (name "propeller-gcc")
470       (version (string-append "6.0.0-" revision "." (string-take commit 9)))
471       (source (origin
472                 (method git-fetch)
473                 (uri (git-reference
474                       (url "https://github.com/totalspectrum/gcc-propeller.git")
475                       (commit commit)))
476                 (file-name (string-append name "-" commit "-checkout"))
477                 (sha256
478                  (base32
479                   "0d9kdxm2fzanjqa7q5850kzbsfl0fqyaahxn74h6nkxxacwa11zb"))
480                 (patches
481                  (append
482                   (origin-patches (package-source gcc-6))
483                   (search-patches "gcc-cross-environment-variables.patch")))))
484       (native-inputs
485        `(("flex" ,flex)
486          ,@(package-native-inputs xgcc)))
487       ;; All headers and cross libraries of the propeller toolchain are
488       ;; installed under the "propeller-elf" prefix.
489       (native-search-paths
490        (list (search-path-specification
491               (variable "CROSS_C_INCLUDE_PATH")
492               (files '("propeller-elf/include")))
493              (search-path-specification
494               (variable "CROSS_LIBRARY_PATH")
495               (files '("propeller-elf/lib")))))
496       (home-page "https://github.com/totalspectrum/gcc-propeller")
497       (synopsis "GCC for the Parallax Propeller"))))
499 (define-public propeller-gcc-4
500   (let ((xgcc propeller-gcc-6)
501         (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
502         (revision "2"))
503     (package (inherit xgcc)
504       (name "propeller-gcc")
505       (version (string-append "4.6.1-" revision "." (string-take commit 9)))
506       (source (origin
507                 (method git-fetch)
508                 (uri (git-reference
509                       (url "https://github.com/parallaxinc/propgcc.git")
510                       (commit commit)))
511                 (file-name (string-append name "-" commit "-checkout"))
512                 (sha256
513                  (base32
514                   "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
515                 (patch-flags (list "-p1" "--directory=gcc"))
516                 (patches
517                  (append
518                   (origin-patches (package-source gcc-4.7))
519                   (search-patches "gcc-4.6-gnu-inline.patch"
520                                   "gcc-cross-environment-variables.patch")))))
521       (arguments
522        (substitute-keyword-arguments (package-arguments propeller-gcc-6)
523          ((#:phases phases)
524           `(modify-phases ,phases
525              (add-after 'unpack 'chdir
526                (lambda _ (chdir "gcc") #t))))))
527       (native-inputs
528        `(("gcc-4" ,gcc-4.9)
529          ,@(package-native-inputs propeller-gcc-6)))
530       (home-page "https://github.com/parallaxinc/propgcc")
531       (supported-systems (delete "aarch64-linux" %supported-systems)))))
533 ;; Version 6 is experimental and may not work correctly.  This is why we
534 ;; default to version 4, which is also used in the binary toolchain bundle
535 ;; provided by Parallax Inc.
536 (define-public propeller-gcc propeller-gcc-4)
539 ;; FIXME: We do not build the tiny library because that would require C++
540 ;; headers, which are not available.  This may require adding a propeller-elf
541 ;; variant of the libstdc++ package.
542 (define-public proplib
543   (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
544         (revision "2"))
545     (package
546       (name "proplib")
547       (version (string-append "0.0.0-" revision "." (string-take commit 9)))
548       (source (origin
549                 (method git-fetch)
550                 (uri (git-reference
551                       (url "https://github.com/parallaxinc/propgcc.git")
552                       (commit commit)))
553                 (file-name (string-append name "-" commit "-checkout"))
554                 (sha256
555                  (base32
556                   "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
557       (build-system gnu-build-system)
558       (arguments
559        `(#:tests? #f ; no tests
560          #:make-flags
561          (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
562                (string-append "BUILD="  (getcwd) "/build"))
563          #:phases
564          (modify-phases %standard-phases
565            (delete 'configure)
566            (add-after 'unpack 'chdir
567              (lambda _ (chdir "lib") #t))
568            (add-after 'chdir 'fix-Makefile
569              (lambda _
570                (substitute* "Makefile"
571                  ;; Control the installation time of the headers.
572                  ((" install-includes") ""))
573                #t))
574            ;; The Makefile does not separate building from installation, so we
575            ;; have to create the target directories at build time.
576            (add-before 'build 'create-target-directories
577              (lambda* (#:key make-flags #:allow-other-keys)
578                (apply invoke "make" "install-dirs" make-flags)))
579            (add-before 'build 'set-cross-environment-variables
580              (lambda* (#:key outputs #:allow-other-keys)
581                (setenv "CROSS_LIBRARY_PATH"
582                        (string-append (assoc-ref outputs "out")
583                                       "/propeller-elf/lib:"
584                                       (or (getenv "CROSS_LIBRARY_PATH") "")))
585                (setenv "CROSS_C_INCLUDE_PATH"
586                        (string-append (assoc-ref outputs "out")
587                                       "/propeller-elf/include:"
588                                       (or (getenv "CROSS_C_INCLUDE_PATH") "")))
589                #t))
590            (add-before 'install 'install-includes
591              (lambda* (#:key make-flags #:allow-other-keys)
592                (apply invoke "make" "install-includes" make-flags))))))
593       (native-inputs
594        `(("propeller-gcc" ,propeller-gcc)
595          ("propeller-binutils" ,propeller-binutils)
596          ("perl" ,perl)))
597       (home-page "https://github.com/parallaxinc/propgcc")
598       (synopsis "C library for the Parallax Propeller")
599       (description "This is a C library for the Parallax Propeller
600 micro-controller.")
601       ;; Most of the code is released under the Expat license.  Some of the
602       ;; included code is public domain and some changes are BSD licensed.
603       (license license:expat))))
605 (define-public propeller-toolchain
606   (package
607     (name "propeller-toolchain")
608     (version (package-version propeller-gcc))
609     (source #f)
610     (build-system trivial-build-system)
611     (arguments '(#:builder (begin (mkdir %output) #t)))
612     (propagated-inputs
613      `(("binutils" ,propeller-binutils)
614        ("libc" ,proplib)
615        ("gcc" ,propeller-gcc)))
616     (synopsis "Complete GCC tool chain for Propeller micro-controllers")
617     (description "This package provides a complete GCC tool chain for
618 Propeller micro-controller development.")
619     (home-page (package-home-page propeller-gcc))
620     (license (package-license propeller-gcc))))
622 (define-public openspin
623   (package
624     (name "openspin")
625     (version "1.00.78")
626     (source (origin
627               (method url-fetch)
628               (uri (string-append "https://github.com/parallaxinc/"
629                                   "OpenSpin/archive/" version ".tar.gz"))
630               (file-name (string-append name "-" version ".tar.gz"))
631               (sha256
632                (base32
633                 "1k2dbz1v604g4r2d9qhckg2m8dnhiya760mbsqfsg4waxal87yb7"))))
634     (build-system gnu-build-system)
635     (arguments
636      `(#:tests? #f ; no tests
637        #:phases
638        (modify-phases %standard-phases
639          (delete 'configure)
640          (add-after 'unpack 'remove-timestamp
641            (lambda _
642              (substitute* "SpinSource/openspin.cpp"
643                ((" Compiled on.*$") "\\n\");"))
644              #t))
645          ;; Makefile does not include "install" target
646          (replace 'install
647            (lambda* (#:key outputs #:allow-other-keys)
648              (let ((bin (string-append (assoc-ref outputs "out")
649                                        "/bin")))
650                (mkdir-p bin)
651                (install-file "build/openspin" bin)
652                #t))))))
653     (home-page "https://github.com/parallaxinc/OpenSpin")
654     (synopsis "Spin/PASM compiler for the Parallax Propeller")
655     (description "OpenSpin is a compiler for the Spin/PASM language of the
656 Parallax Propeller.  It was ported from Chip Gracey's original x86 assembler
657 code.")
658     (license license:expat)))
660 (define-public propeller-load
661   (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
662         (revision "2"))
663     (package
664       (name "propeller-load")
665       (version "3.4.0")
666       (source (origin
667                 (method git-fetch)
668                 (uri (git-reference
669                       (url "https://github.com/parallaxinc/propgcc.git")
670                       (commit commit)))
671                 (file-name (string-append name "-" commit "-checkout"))
672                 (sha256
673                  (base32
674                   "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
675       (build-system gnu-build-system)
676       (arguments
677        `(#:tests? #f ; no tests
678          #:make-flags
679          (list "OS=linux"
680                (string-append "TARGET=" (assoc-ref %outputs "out")))
681          #:phases
682          (modify-phases %standard-phases
683            (add-after 'unpack 'chdir
684              (lambda _ (chdir "loader") #t))
685            (delete 'configure))))
686       (native-inputs
687        `(("openspin" ,openspin)
688          ("propeller-toolchain" ,propeller-toolchain)))
689       (home-page "https://github.com/parallaxinc/propgcc")
690       (synopsis "Loader for Parallax Propeller micro-controllers")
691       (description "This package provides the tool @code{propeller-load} to
692 upload binaries to a Parallax Propeller micro-controller.")
693       (license license:expat))))
695 (define-public spin2cpp
696   (package
697     (name "spin2cpp")
698     (version "3.6.4")
699     (source (origin
700               (method url-fetch)
701               (uri (string-append "https://github.com/totalspectrum/spin2cpp/"
702                                   "archive/v" version ".tar.gz"))
703               (file-name (string-append name "-" version ".tar.gz"))
704               (sha256
705                (base32
706                 "05qak187sn0xg7vhrxw27b19xhmid1b8ab8kax3gv0faavzablfw"))))
707     (build-system gnu-build-system)
708     (arguments
709      `(#:tests? #f ;; The tests assume that a micro-controller is connected.
710        #:phases
711        (modify-phases %standard-phases
712          (delete 'configure)
713          (add-before 'build 'set-cross-environment-variables
714            (lambda* (#:key inputs #:allow-other-keys)
715              (setenv "CROSS_LIBRARY_PATH"
716                      (string-append (assoc-ref inputs "propeller-toolchain")
717                                     "/propeller-elf/lib"))
718              (setenv "CROSS_C_INCLUDE_PATH"
719                      (string-append (assoc-ref inputs "propeller-toolchain")
720                                     "/propeller-elf/include"))
721              #t))
722          (replace 'install
723            (lambda* (#:key outputs #:allow-other-keys)
724              (let ((bin (string-append (assoc-ref outputs "out")
725                                        "/bin")))
726                (for-each (lambda (file)
727                            (install-file (string-append "build/" file)
728                                          bin))
729                          '("testlex" "spin2cpp" "fastspin")))
730              #t)))))
731     (native-inputs
732      `(("bison" ,bison)
733        ("propeller-load" ,propeller-load)
734        ("propeller-toolchain" ,propeller-toolchain)))
735     (home-page "https://github.com/totalspectrum/spin2cpp")
736     (synopsis "Convert Spin code to C, C++, or PASM code")
737     (description "This is a set of tools for converting the Spin language for
738 the Parallax Propeller micro-controller into C or C++ code, into PASM, or even
739 directly into an executable binary.  The binaries produced use LMM PASM, so
740 they are much faster than regular Spin bytecodes (but also quite a bit
741 larger).")
742     (license license:expat)))
744 (define-public spinsim
745   (let ((commit "66915a7ad1a3a2cf990a725bb341fab8d11eb620")
746         (revision "1"))
747     (package
748       (name "spinsim")
749       (version (string-append "0.75-" revision "." (string-take commit 9)))
750       (source (origin
751                 (method git-fetch)
752                 (uri (git-reference
753                       (url "https://github.com/parallaxinc/spinsim.git")
754                       (commit commit)))
755                 (file-name (string-append name "-" commit "-checkout"))
756                 (sha256
757                  (base32
758                   "1n9kdhlxsdx7bz6c80w8dhi96zp633gd6qs0x9i4ii8qv4i7sj5k"))))
759       (build-system gnu-build-system)
760       (arguments
761        `(#:tests? #f ; no tests
762          #:phases
763          (modify-phases %standard-phases
764            (delete 'configure)
765            (replace 'install
766              (lambda* (#:key outputs #:allow-other-keys)
767                (let ((bin (string-append (assoc-ref outputs "out")
768                                          "/bin")))
769                  (install-file "build/spinsim" bin))
770                #t)))))
771       (home-page "https://github.com/parallaxinc/spinsim")
772       (synopsis "Spin simulator")
773       (description "This package provides the tool @code{spinsim}, a simulator
774 and simple debugger for Spin programs written for a Parallax Propeller
775 micro-controller.  Spinsim supports execution from cog memory and hub
776 execution, but it does not support multi-tasking.  It supports about
777 two-thirds of the opcodes in the P2 instruction set.")
778       (license license:expat))))
780 (define-public propeller-development-suite
781   (package
782     (name "propeller-development-suite")
783     (version (package-version propeller-gcc))
784     (source #f)
785     (build-system trivial-build-system)
786     (arguments '(#:builder (begin (mkdir %output) #t)))
787     (propagated-inputs
788      `(("toolchain" ,propeller-toolchain)
789        ("openspin" ,openspin)
790        ("propeller-load" ,propeller-load)
791        ("spin2cpp" ,spin2cpp)
792        ("spinsim" ,spinsim)))
793     (synopsis "Complete development suite for Propeller micro-controllers")
794     (description "This meta-package provides a complete environment for the
795 development with Parallax Propeller micro-controllers.  It includes the GCC
796 toolchain, the loader, the Openspin compiler, the Spin2cpp tool, and the Spin
797 simulator.")
798     (home-page (package-home-page propeller-gcc))
799     (license (package-license propeller-gcc))))
801 (define-public binutils-vc4
802   (let ((commit "708acc851880dbeda1dd18aca4fd0a95b2573b36"))
803     (package
804       (name "binutils-vc4")
805       (version (string-append "2.23.51-0." (string-take commit 7)))
806       (source (origin
807                 (method git-fetch)
808                 (uri (git-reference
809                        (url "https://github.com/puppeh/binutils-vc4.git")
810                        (commit commit)))
811                 (file-name (string-append name "-" version "-checkout"))
812                 (sha256
813                  (base32
814                   "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"))))
815       (build-system gnu-build-system)
816       (arguments
817        `(#:configure-flags '("--target=vc4-elf"
818                              "--disable-werror"
819                              "--enable-cgen-maint")
820          #:phases
821          (modify-phases %standard-phases
822            (add-after 'unpack 'unpack-cgen
823              (lambda* (#:key inputs #:allow-other-keys)
824                (copy-recursively (string-append (assoc-ref inputs "cgen")
825                                                 "/cgen") "cgen")
826                #t))
827            (add-after 'unpack-cgen 'fix-cgen-guile
828              (lambda _
829                (substitute* "opcodes/Makefile.in"
830                  (("guile\\{,-\\}1.8") "guile"))
831                (invoke "which" "guile"))))))
832       (native-inputs
833        `(("cgen"
834           ,(origin
835                 (method git-fetch)
836                 (uri (git-reference
837                        (url "https://github.com/puppeh/cgen.git")
838                        (commit "d8e2a9eb70425f180fdd5bfd032884b0855f2032")))
839                 (sha256
840                  (base32
841                   "14b3h2ji740s8zq5vwm4qdcxs4aa4wxi6wb9di3bv1h39x14nyr9"))))
842          ("texinfo" ,texinfo)
843          ("flex" ,flex)
844          ("bison" ,bison)
845          ("guile-1.8" ,guile-1.8)
846          ("which" ,base:which)))
847       (synopsis "Binutils for VC4")
848       (description "This package provides @code{binutils} for VideoCore IV,
849 the Raspberry Pi chip.")
850       (license license:gpl3+)
851       (home-page "https://github.com/puppeh/vc4-toolchain/"))))
853 (define-public gcc-vc4
854   (let ((commit "165f6d0e11d2e76ee799533bb45bd5c92bf60dc2")
855         (xgcc (cross-gcc "vc4-elf" #:xbinutils binutils-vc4)))
856     (package (inherit xgcc)
857       (name "gcc-vc4")
858       (source (origin
859                 (method git-fetch)
860                 (uri (git-reference
861                       (url "https://github.com/puppeh/gcc-vc4.git")
862                       (commit commit)))
863                 (file-name (string-append name
864                                           "-"
865                                           (package-version xgcc)
866                                           "-checkout"))
867                 (sha256
868                  (base32
869                   "13h30qjcwnlz6lfma1d82nnvfmjnhh7abkagip4vly6vm5fpnvf2"))))
870       (native-inputs
871         `(("flex" ,flex)
872           ,@(package-native-inputs xgcc)))
873       (synopsis "GCC for VC4")
874       (description "This package provides @code{gcc} for VideoCore IV,
875 the Raspberry Pi chip."))))
877 (define-public python2-libmpsse
878   (package
879     (name "python2-libmpsse")
880     (version "1.3")
881     (source
882       (origin
883         (method url-fetch)
884         (uri (string-append "https://storage.googleapis.com/"
885                             "google-code-archive-downloads/v2/"
886                             "code.google.com/libmpsse/"
887                             "libmpsse-" version ".tar.gz"))
888         (sha256
889           (base32
890             "0jq7nhqq3na8675jnpfcar3pd3dp3adhhc4lw900swkla01a1wh8"))))
891     (build-system gnu-build-system)
892     (inputs
893      `(("libftdi" ,libftdi)
894        ("python" ,python-2)))
895     (native-inputs
896      `(("pkg-config" ,pkg-config)
897        ("swig" ,swig)
898        ("which" ,base:which)))
899     (arguments
900      `(#:tests? #f ; No tests exist.
901        #:make-flags
902        (list (string-append "CFLAGS=-Wall -fPIC -fno-strict-aliasing -g -O2 "
903                             "$(shell pkg-config --cflags libftdi1)"))
904        #:phases
905        (modify-phases %standard-phases
906          (add-after 'unpack 'set-environment-up
907            (lambda* (#:key inputs outputs #:allow-other-keys)
908              (chdir "src")
909              (setenv "PYDEV" (string-append (assoc-ref inputs "python")
910                              "/include/python2.7"))
911              #t))
912          (add-after 'unpack 'patch-global-variable
913            (lambda _
914              ;; fast_rw_buf was defined in a header file which was making
915              ;; the build not reproducible.
916              (substitute* "src/fast.c"
917                (("^int fast_build_block_buffer") "
919 unsigned char fast_rw_buf[SPI_RW_SIZE + CMD_SIZE];
920 int fast_build_block_buffer"))
921              (substitute* "src/mpsse.h"
922                (("unsigned char fast_rw_buf.*") "
924              #t))
925          (replace 'install
926            (lambda* (#:key outputs make-flags #:allow-other-keys #:rest args)
927              (let* ((out (assoc-ref outputs "out"))
928                     (out-python (string-append out
929                                                "/lib/python2.7/site-packages"))
930                     (install (assoc-ref %standard-phases 'install)))
931                (install #:make-flags (cons (string-append "PYLIB=" out-python)
932                                            make-flags))))))))
933     (home-page "https://code.google.com/archive/p/libmpsse/")
934     (synopsis "Python library for MPSSE SPI I2C JTAG adapter by FTDI")
935     (description "This package provides a library in order to support the
936 MPSSE (Multi-Protocol Synchronous Serial Engine) adapter by FTDI that can do
937 SPI, I2C, JTAG.")
938     (license license:gpl2+)))
940 (define-public picprog
941   (package
942     (name "picprog")
943     (version "1.9.1")
944     (source (origin
945               (method url-fetch)
946               (uri (string-append "http://www.iki.fi/hyvatti/pic/picprog-"
947                                   version ".tar.gz"))
948               (file-name (string-append name "-" version ".tar.gz"))
949               (sha256
950                (base32
951                 "1r04hg1n3v2jf915qr05la3q9cxy7a5jnh9cc98j04lh6c9p4x85"))
952               (patches (search-patches "picprog-non-intel-support.patch"))))
953     (build-system gnu-build-system)
954     (arguments
955      `(#:tests? #f                      ; No tests exist.
956        #:phases
957        (modify-phases %standard-phases
958          (add-after 'unpack 'patch-paths
959            (lambda* (#:key outputs #:allow-other-keys)
960              (substitute* "Makefile"
961                (("/usr/local") (assoc-ref outputs "out"))
962                ((" -o 0 -g 0 ") " ")
963                (("testport") ""))
964              #t))
965          (add-before 'install 'mkdir
966            (lambda* (#:key outputs #:allow-other-keys)
967              (let ((out (assoc-ref outputs "out")))
968                (mkdir-p (string-append out "/bin"))
969                (mkdir-p (string-append out "/man/man1"))
970                #t)))
971          (delete 'configure))))
972     (synopsis "Programs Microchip's PIC microcontrollers")
973     (description "This program programs Microchip's PIC microcontrollers.")
974     (home-page "http://hyvatti.iki.fi/~jaakko/pic/picprog.html")
975     (license license:gpl3+)))
977 (define-public fc-host-tools
978   (package
979     (name "fc-host-tools")
980     (version "10")
981     (source (origin
982               (method url-fetch)
983               (uri (string-append "ftp://ftp.freecalypso.org/pub/GSM/"
984                                   "FreeCalypso/fc-host-tools-r" version ".tar.bz2"))
985               (sha256
986                (base32
987                 "0ybjqkz1cpnxni66p3valv1bva39vpwzdcc4040lqzx6py9h7h8b"))))
988     (build-system gnu-build-system)
989     (arguments
990      `(#:tests? #f                      ; No tests exist.
991        #:make-flags
992        (list (string-append "INSTALL_PREFIX=" %output)
993              (string-append "INCLUDE_INSTALL_DIR=" %output "include/rvinterf"))
994        #:phases
995        (modify-phases %standard-phases
996          (delete 'configure)
997          (add-after 'unpack 'handle-tarbomb
998            (lambda _
999              (chdir "..") ; url-fetch/tarbomb doesn't work for some reason.
1000              #t))
1001          (add-after 'handle-tarbomb 'patch-installation-paths
1002            (lambda* (#:key outputs #:allow-other-keys)
1003              (substitute* '("Makefile"
1004                             "rvinterf/etmsync/fsiomain.c"
1005                             "rvinterf/etmsync/fsnew.c"
1006                             "rvinterf/asyncshell/help.c"
1007                             "rvinterf/libinterf/launchrvif.c"
1008                             "loadtools/defpath.c"
1009                             "loadtools/Makefile"
1010                             "miscutil/c139explore"
1011                             "miscutil/pirexplore"
1012                             "ffstools/tiffs-wrappers/installpath.c"
1013                             "uptools/atcmd/atinterf.c")
1014                (("/opt/freecalypso/loadtools")
1015                 (string-append (assoc-ref outputs "out") "/lib/freecalypso/loadtools"))
1016                (("\\$\\{INSTALL_PREFIX\\}/loadtools")
1017                 (string-append (assoc-ref outputs "out") "/lib/freecalypso/loadtools"))
1018                (("/opt/freecalypso")
1019                 (assoc-ref outputs "out")))
1020              #t)))))
1021     (inputs
1022      `(("libx11" ,libx11)))
1023     (synopsis "Freecalypso host tools")
1024     (description "This package provides some tools for debugging Freecalypso phones.
1026 @enumerate
1027 @item fc-e1decode: Decodes a binary Melody E1 file into an ASCII source file.
1028 @item fc-e1gen: Encodes an ASCII Melody E1 file into a binary Melody E1 file.
1029 @item fc-fr2tch: Converts a GSM 06.10 speech recording from libgsm to hex
1030 strings of TCH bits to be fed to the GSM 05.03 channel encoder of a TI
1031 Calypso GSM device.
1032 @item fc-tch2fr: Converts hex strings of TCH bits to libgsm.
1033 @item fc-gsm2vm: utility converts a GSM 06.10 speech sample from the libgsm
1034 source format into a voice memo file that can be uploaded into the FFS of a
1035 FreeCalypso device and played with the audio_vm_play_start() API or the
1036 AT@@VMP command that invokes the latter.
1037 @item fc-rgbconv: Convers RGB 5:6:5 to RGB 8:8:8 and vice versa.
1038 @item rvinterf: Communicates with a TI Calypso GSM device via RVTMUX.
1039 @item rvtdump: produces a human-readable dump of all output emitted by a
1040 TI-based GSM fw on the RVTMUX binary packet interface.
1041 @item fc-shell: FreeCalypso firmwares have a feature of our own invention
1042 (not present in any pre-existing ones) to accept AT commands over the RVTMUX
1043 interface.  It is useful when no second UART is available for a dedicated
1044 standard AT command interface.  fc-shell is the tool that allows you to send
1045 AT commands to the firmware in this manner.
1046 @item fc-memdump: Captures a memory dump from a GSM device.
1047 @item fc-serterm: Trivial serial terminal.  Escapes binary chars.
1048 @item fc-fsio: Going through rvinterf, this tool connects to GSM devices and
1049 allows you to manipulate the device's flash file system.
1050 @item tiaud-compile: Compiles an audio mode configuration table for TI's
1051 Audio Service from our own ASCII source format into the binary format for
1052 uploading into FreeCalypso GSM device FFS with fc-fsio.
1053 @item tiaud-decomp: Decodes TI's audio mode configuration files read out of
1054 FFS into our own ASCII format.
1055 @item tiaud-mkvol: Generates the *.vol binary files which need to accompany
1056 the main *.cfg ones.
1057 @item fc-compalram: Allows running programs on the device without writing
1058 them to flash storage.
1059 @item fc-xram: Allows running programs on the device without writing them
1060 to flash storage.
1061 @item fc-iram: Allows running programs on the device without writing them
1062 to flash storage.
1063 @item fc-loadtool: Writes programs to the device's flash storage.
1064 @item pirffs: Allows listing and extracting FFS content captured as a raw
1065 flash image from Pirelli phones.
1066 @item mokoffs: Allows listing and extracting FFS content captured as a raw
1067 flash image from OpenMoko phones.
1068 @item tiffs: Allows listing and extracting FFS content captured as a raw
1069 flash image from TI phones.
1070 @item c139explore: Run-from-RAM program for C139 phones that
1071 exercises their peripheral hardware: LCD, keypad backlight, buzzer, vibrator.
1072 @item pirexplore: Run-from-RAM program for Pirelli DP-L10 phones that
1073 exercises their peripheral hardware, primarily their LCD.
1074 @item tfc139: Breaks into Mot C1xx phones via shellcode injection, allowing
1075 you to reflash locked phones with new firmware with fc-loadtool.
1076 @item ctracedec: GSM firmwares built in TI's Windows environment have a
1077 compressed trace misfeature whereby many of the ASCII strings
1078 in debug trace messages get replaced with numeric indices at
1079 build time, and these numeric indices are all that gets emitted
1080 on the RVTMUX serial channel.  This tools decodes these numeric indices
1081 back to strings in trace output.
1082 @item fc-cal2text: This utility takes a dump of TI's /gsm/rf flash file system
1083 directory subtree as input (either extracted in vitro with tiffs
1084 or read out in vivo with fc-fsio) and converts all RF tables
1085 found therein into a readable ASCII format.
1086 @item imei-luhn: Computes or verifies the Luhn check digit of an IMEI number.
1087 @item fc-dspapidump: Reads and dumps the contents of the DSP API RAM in a
1088 target Calypso GSM device.
1089 @item fc-vm2hex: Converts the old-fashioned (non-AMR) voice memo files read
1090 out of FFS into hex strings.
1091 @item fc-buzplay: Plays piezoelectic buzzer melodies on an actual
1092 Calypso device equipped with such a buzzer (Mot C1xx, TI's D-Sample board,
1093 our planned future HSMBP) by loading a buzplayer agent onto the target and
1094 feeding melodies to be played to it.
1095 @item fc-tmsh: TI-based GSM firmwares provide a rich set of Test Mode commands
1096 that can be issued through the RVTMUX (debug trace) serial channel.
1097 This program is our test mode shell for sending Test Mode commands to targets
1098 and displaying decoded target responses.
1099 @item fcup-smsend Send a short message via SMS
1100 @item fcup-smsendmult Send multiple short messages via SMS in one go
1101 @item fcup-smsendpdu Send multiple short messages given in PDU format via SMS
1102 @item sms-pdu-decode Decode PDU format messages
1103 @end enumerate")
1104     (home-page "https://www.freecalypso.org/")
1105     (license license:public-domain)))
1107 (define-public stlink
1108   (package
1109     (name "stlink")
1110     (version "1.5.1")
1111     (source
1112      (origin
1113        (method url-fetch)
1114        (uri (string-append "https://github.com/texane/stlink/archive/v"
1115                            version ".tar.gz"))
1116        (file-name (string-append name "-" version ".tar.gz"))
1117        (sha256
1118         (base32
1119          "01z1cz1a5xbbhd163qrqcgp4bi1k145pb80jmwdz50g7sfzmy570"))))
1120     (build-system cmake-build-system)
1121     (arguments
1122      `(#:tests? #f                      ;no tests
1123        #:configure-flags
1124        (let* ((out (assoc-ref %outputs "out"))
1125               (etc (in-vicinity out "etc"))
1126               (modprobe (in-vicinity etc "modprobe.d"))
1127               (udev-rules (in-vicinity etc "udev/rules.d")))
1128          (list (string-append "-DSTLINK_UDEV_RULES_DIR=" udev-rules)
1129                (string-append "-DSTLINK_MODPROBED_DIR=" modprobe)))))
1130     (inputs
1131      `(("libusb" ,libusb)))
1132     (synopsis "Programmer for STM32 Discovery boards")
1133     (description "This package provides a firmware programmer for the STM32
1134 Discovery boards.  It supports two versions of the chip: ST-LINK/V1 (on
1135 STM32VL discovery kits) and ST-LINK/V2 (on STM32L discovery and later kits).
1136 Two different transport layers are used: ST-LINK/V1 uses SCSI passthru
1137 commands over USB, and ST-LINK/V2 and ST-LINK/V2-1 (seen on Nucleo boards) use
1138 raw USB commands.")
1139     (home-page "https://github.com/texane/stlink")
1140     ;; The flashloaders/stm32l0x.s and flashloaders/stm32lx.s source files are
1141     ;; licensed under the GPLv2+.
1142     (license (list license:bsd-3 license:gpl2+))))