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>
9 ;;; This file is part of GNU Guix.
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.
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.
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"
63 #:xbinutils (cross-binutils "arm-none-eabi")))
65 (svn-revision 227977))
66 (package (inherit xgcc)
67 (version (string-append (package-version xgcc) "-"
68 revision "." (number->string svn-revision)))
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"))
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))))))
88 ,@(package-native-inputs xgcc)))
90 (substitute-keyword-arguments (package-arguments xgcc)
92 `(modify-phases ,phases
93 (add-after 'unpack 'fix-genmultilib
95 (substitute* "gcc/genmultilib"
96 (("#!/bin/sh") (string-append "#!" (which "sh"))))
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"
103 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
104 "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
106 "--disable-decimal-float"
109 "--disable-libmudflap"
110 "--disable-libquadmath"
112 "--disable-libstdcxx-pch"
117 (delete "--disable-multilib" ,flags)))))
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
131 (inherit gcc-arm-none-eabi-4.9)
132 (version (package-version gcc-6))
133 (source (origin (inherit (package-source gcc-6))
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
146 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
150 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
151 (build-system gnu-build-system)
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"
162 (modify-phases %standard-phases
163 (add-after 'unpack 'fix-references-to-/bin/sh
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")))
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)
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"
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"
202 "--enable-newlib-global-atexit"
203 "--enable-newlib-nano-formatted-io"
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")
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"
218 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
223 ,(string-append "--with-gxx-include-dir="
224 (assoc-ref %outputs "out")
225 "/arm-none-eabi/include")))))
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)
236 (alist-replace "xgcc" (list xgcc)
237 (package-native-inputs newlib))))))
239 (name (string-append "arm-none-eabi"
240 (if (string=? (package-name newlib-with-xgcc)
244 (version (package-version xgcc))
246 (build-system trivial-build-system)
248 '(#:modules ((guix build union))
251 (use-modules (ice-9 match)
254 (((names . directories) ...)
255 (union-build (assoc-ref %outputs "out")
259 `(("binutils" ,(cross-binutils "arm-none-eabi"))
260 ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-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
290 (name "gdb-arm-none-eabi")
292 `(#:configure-flags '("--target=arm-none-eabi"
295 "--enable-languages=c,c++"
297 ,@(package-arguments gdb)))))
299 (define-public libjaylink
300 ;; No release tarballs available.
301 (let ((commit "699b7001d34a79c8e7064503dde1bede786fd7f0")
305 (version (string-append "0.1.0-" revision "."
306 (string-take commit 7)))
310 (url "https://git.zapb.de/libjaylink.git")
312 (file-name (string-append name "-" version "-checkout"))
315 "034872d44myycnzn67v5b8ixrgmg8sk32aqalvm5x7108w2byww1"))))
316 (build-system gnu-build-system)
318 `(("autoconf" ,autoconf)
319 ("automake" ,automake)
321 ("pkg-config" ,pkg-config)))
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
337 "https://github.com/msteveb/jimtcl"
338 "/archive/" version ".tar.gz"))
339 (file-name (string-append name "-" version ".tar.gz"))
342 "1cmk3qscqckg70chjyimzxa2qcka4qac0j4wq908kiijp45cax08"))))
343 (build-system gnu-build-system)
346 (modify-phases %standard-phases
347 ;; Doesn't use autoconf.
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
357 (license license:bsd-2)))
359 (define-public openocd
365 (uri (string-append "mirror://sourceforge/openocd/openocd/"
366 version "/openocd-" version ".tar.gz"))
369 "09p57y3c2spqx4vjjlz1ljm1lcd0j9q8g76ywxqgn3yc34wv18zd"))
370 ;; FIXME: Remove after nrf52 patch is merged.
372 (search-patches "openocd-nrf52.patch"))))
373 (build-system gnu-build-system)
375 `(("autoconf" ,autoconf)
376 ("automake" ,automake)
378 ("pkg-config" ,pkg-config)))
383 ("libjaylink" ,libjaylink)
384 ("libusb-compat" ,libusb-compat)))
387 (append (list "--disable-werror"
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")))
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
406 (substitute* "contrib/60-openocd.rules"
407 (("plugdev") "dialout"))
409 (add-after 'install 'install-udev-rules
410 (lambda* (#:key outputs #:allow-other-keys)
411 (install-file "contrib/60-openocd.rules"
413 (assoc-ref outputs "out")
414 "/lib/udev/rules.d/"))
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")
433 (name "propeller-binutils")
434 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
435 (source (origin (inherit (package-source xbinutils))
438 (url "https://github.com/parallaxinc/propgcc.git")
440 (file-name (string-append name "-" commit "-checkout"))
443 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
444 (patch-flags (list "-p1" "--directory=binutils"))))
446 `(;; FIXME: For some reason there are many test failures. It's not
447 ;; obvious how to fix the failures.
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)))))
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")
468 (package (inherit xgcc)
469 (name "propeller-gcc")
470 (version (string-append "6.0.0-" revision "." (string-take commit 9)))
474 (url "https://github.com/totalspectrum/gcc-propeller.git")
476 (file-name (string-append name "-" commit "-checkout"))
479 "0d9kdxm2fzanjqa7q5850kzbsfl0fqyaahxn74h6nkxxacwa11zb"))
482 (origin-patches (package-source gcc-6))
483 (search-patches "gcc-cross-environment-variables.patch")))))
486 ,@(package-native-inputs xgcc)))
487 ;; All headers and cross libraries of the propeller toolchain are
488 ;; installed under the "propeller-elf" prefix.
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")
503 (package (inherit xgcc)
504 (name "propeller-gcc")
505 (version (string-append "4.6.1-" revision "." (string-take commit 9)))
509 (url "https://github.com/parallaxinc/propgcc.git")
511 (file-name (string-append name "-" commit "-checkout"))
514 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
515 (patch-flags (list "-p1" "--directory=gcc"))
518 (origin-patches (package-source gcc-4.7))
519 (search-patches "gcc-4.6-gnu-inline.patch"
520 "gcc-cross-environment-variables.patch")))))
522 (substitute-keyword-arguments (package-arguments propeller-gcc-6)
524 `(modify-phases ,phases
525 (add-after 'unpack 'chdir
526 (lambda _ (chdir "gcc") #t))))))
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")
547 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
551 (url "https://github.com/parallaxinc/propgcc.git")
553 (file-name (string-append name "-" commit "-checkout"))
556 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
557 (build-system gnu-build-system)
559 `(#:tests? #f ; no tests
561 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
562 (string-append "BUILD=" (getcwd) "/build"))
564 (modify-phases %standard-phases
566 (add-after 'unpack 'chdir
567 (lambda _ (chdir "lib") #t))
568 (add-after 'chdir 'fix-Makefile
570 (substitute* "Makefile"
571 ;; Control the installation time of the headers.
572 ((" install-includes") ""))
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") "")))
590 (add-before 'install 'install-includes
591 (lambda* (#:key make-flags #:allow-other-keys)
592 (apply invoke "make" "install-includes" make-flags))))))
594 `(("propeller-gcc" ,propeller-gcc)
595 ("propeller-binutils" ,propeller-binutils)
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
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
607 (name "propeller-toolchain")
608 (version (package-version propeller-gcc))
610 (build-system trivial-build-system)
611 (arguments '(#:builder (begin (mkdir %output) #t)))
613 `(("binutils" ,propeller-binutils)
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
628 (uri (string-append "https://github.com/parallaxinc/"
629 "OpenSpin/archive/" version ".tar.gz"))
630 (file-name (string-append name "-" version ".tar.gz"))
633 "1k2dbz1v604g4r2d9qhckg2m8dnhiya760mbsqfsg4waxal87yb7"))))
634 (build-system gnu-build-system)
636 `(#:tests? #f ; no tests
638 (modify-phases %standard-phases
640 (add-after 'unpack 'remove-timestamp
642 (substitute* "SpinSource/openspin.cpp"
643 ((" Compiled on.*$") "\\n\");"))
645 ;; Makefile does not include "install" target
647 (lambda* (#:key outputs #:allow-other-keys)
648 (let ((bin (string-append (assoc-ref outputs "out")
651 (install-file "build/openspin" bin)
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
658 (license license:expat)))
660 (define-public propeller-load
661 (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
664 (name "propeller-load")
669 (url "https://github.com/parallaxinc/propgcc.git")
671 (file-name (string-append name "-" commit "-checkout"))
674 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
675 (build-system gnu-build-system)
677 `(#:tests? #f ; no tests
680 (string-append "TARGET=" (assoc-ref %outputs "out")))
682 (modify-phases %standard-phases
683 (add-after 'unpack 'chdir
684 (lambda _ (chdir "loader") #t))
685 (delete 'configure))))
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
701 (uri (string-append "https://github.com/totalspectrum/spin2cpp/"
702 "archive/v" version ".tar.gz"))
703 (file-name (string-append name "-" version ".tar.gz"))
706 "05qak187sn0xg7vhrxw27b19xhmid1b8ab8kax3gv0faavzablfw"))))
707 (build-system gnu-build-system)
709 `(#:tests? #f ;; The tests assume that a micro-controller is connected.
711 (modify-phases %standard-phases
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"))
723 (lambda* (#:key outputs #:allow-other-keys)
724 (let ((bin (string-append (assoc-ref outputs "out")
726 (for-each (lambda (file)
727 (install-file (string-append "build/" file)
729 '("testlex" "spin2cpp" "fastspin")))
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
742 (license license:expat)))
744 (define-public spinsim
745 (let ((commit "66915a7ad1a3a2cf990a725bb341fab8d11eb620")
749 (version (string-append "0.75-" revision "." (string-take commit 9)))
753 (url "https://github.com/parallaxinc/spinsim.git")
755 (file-name (string-append name "-" commit "-checkout"))
758 "1n9kdhlxsdx7bz6c80w8dhi96zp633gd6qs0x9i4ii8qv4i7sj5k"))))
759 (build-system gnu-build-system)
761 `(#:tests? #f ; no tests
763 (modify-phases %standard-phases
766 (lambda* (#:key outputs #:allow-other-keys)
767 (let ((bin (string-append (assoc-ref outputs "out")
769 (install-file "build/spinsim" bin))
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
782 (name "propeller-development-suite")
783 (version (package-version propeller-gcc))
785 (build-system trivial-build-system)
786 (arguments '(#:builder (begin (mkdir %output) #t)))
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
798 (home-page (package-home-page propeller-gcc))
799 (license (package-license propeller-gcc))))
801 (define-public binutils-vc4
802 (let ((commit "708acc851880dbeda1dd18aca4fd0a95b2573b36"))
804 (name "binutils-vc4")
805 (version (string-append "2.23.51-0." (string-take commit 7)))
809 (url "https://github.com/puppeh/binutils-vc4.git")
811 (file-name (string-append name "-" version "-checkout"))
814 "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"))))
815 (build-system gnu-build-system)
817 `(#:configure-flags '("--target=vc4-elf"
819 "--enable-cgen-maint")
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")
827 (add-after 'unpack-cgen 'fix-cgen-guile
829 (substitute* "opcodes/Makefile.in"
830 (("guile\\{,-\\}1.8") "guile"))
831 (invoke "which" "guile"))))))
837 (url "https://github.com/puppeh/cgen.git")
838 (commit "d8e2a9eb70425f180fdd5bfd032884b0855f2032")))
841 "14b3h2ji740s8zq5vwm4qdcxs4aa4wxi6wb9di3bv1h39x14nyr9"))))
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)
861 (url "https://github.com/puppeh/gcc-vc4.git")
863 (file-name (string-append name
865 (package-version xgcc)
869 "13h30qjcwnlz6lfma1d82nnvfmjnhh7abkagip4vly6vm5fpnvf2"))))
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
879 (name "python2-libmpsse")
884 (uri (string-append "https://storage.googleapis.com/"
885 "google-code-archive-downloads/v2/"
886 "code.google.com/libmpsse/"
887 "libmpsse-" version ".tar.gz"))
890 "0jq7nhqq3na8675jnpfcar3pd3dp3adhhc4lw900swkla01a1wh8"))))
891 (build-system gnu-build-system)
893 `(("libftdi" ,libftdi)
894 ("python" ,python-2)))
896 `(("pkg-config" ,pkg-config)
898 ("which" ,base:which)))
900 `(#:tests? #f ; No tests exist.
902 (list (string-append "CFLAGS=-Wall -fPIC -fno-strict-aliasing -g -O2 "
903 "$(shell pkg-config --cflags libftdi1)"))
905 (modify-phases %standard-phases
906 (add-after 'unpack 'set-environment-up
907 (lambda* (#:key inputs outputs #:allow-other-keys)
909 (setenv "PYDEV" (string-append (assoc-ref inputs "python")
910 "/include/python2.7"))
912 (add-after 'unpack 'patch-global-variable
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.*") "
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)
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
938 (license license:gpl2+)))
940 (define-public picprog
946 (uri (string-append "http://www.iki.fi/hyvatti/pic/picprog-"
948 (file-name (string-append name "-" version ".tar.gz"))
951 "1r04hg1n3v2jf915qr05la3q9cxy7a5jnh9cc98j04lh6c9p4x85"))
952 (patches (search-patches "picprog-non-intel-support.patch"))))
953 (build-system gnu-build-system)
955 `(#:tests? #f ; No tests exist.
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 ") " ")
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"))
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
979 (name "fc-host-tools")
983 (uri (string-append "ftp://ftp.freecalypso.org/pub/GSM/"
984 "FreeCalypso/fc-host-tools-r" version ".tar.bz2"))
987 "0ybjqkz1cpnxni66p3valv1bva39vpwzdcc4040lqzx6py9h7h8b"))))
988 (build-system gnu-build-system)
990 `(#:tests? #f ; No tests exist.
992 (list (string-append "INSTALL_PREFIX=" %output)
993 (string-append "INCLUDE_INSTALL_DIR=" %output "include/rvinterf"))
995 (modify-phases %standard-phases
997 (add-after 'unpack 'handle-tarbomb
999 (chdir "..") ; url-fetch/tarbomb doesn't work for some reason.
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")))
1022 `(("libx11" ,libx11)))
1023 (synopsis "Freecalypso host tools")
1024 (description "This package provides some tools for debugging Freecalypso phones.
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
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
1061 @item fc-iram: Allows running programs on the device without writing them
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
1104 (home-page "https://www.freecalypso.org/")
1105 (license license:public-domain)))
1107 (define-public stlink
1114 (uri (string-append "https://github.com/texane/stlink/archive/v"
1116 (file-name (string-append name "-" version ".tar.gz"))
1119 "01z1cz1a5xbbhd163qrqcgp4bi1k145pb80jmwdz50g7sfzmy570"))))
1120 (build-system cmake-build-system)
1122 `(#:tests? #f ;no tests
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)))))
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
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+))))