gnu: picprog: Fix non-Intel support.
[jackhill/guix/guix.git] / gnu / packages / embedded.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2017 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 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages embedded)
23 #:use-module (guix utils)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix svn-download)
27 #:use-module (guix git-download)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system trivial)
31 #:use-module (guix build utils)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages autotools)
34 #:use-module ((gnu packages base) #:prefix base:)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages cross-base)
37 #:use-module (gnu packages dejagnu)
38 #:use-module (gnu packages flex)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages gdb)
41 #:use-module (gnu packages guile)
42 #:use-module (gnu packages libftdi)
43 #:use-module (gnu packages libusb)
44 #:use-module (gnu packages perl)
45 #:use-module (gnu packages pkg-config)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages swig)
48 #:use-module (gnu packages texinfo)
49 #:use-module (srfi srfi-1))
50
51 ;; We must not use the released GCC sources here, because the cross-compiler
52 ;; does not produce working binaries. Instead we take the very same SVN
53 ;; revision from the branch that is used for a release of the "GCC ARM
54 ;; embedded" project on launchpad.
55 ;; See https://launchpadlibrarian.net/218827644/release.txt
56 (define-public gcc-arm-none-eabi-4.9
57 (let ((xgcc (cross-gcc "arm-none-eabi"
58 #:xgcc gcc-4.9
59 #:xbinutils (cross-binutils "arm-none-eabi")))
60 (revision "1")
61 (svn-revision 227977))
62 (package (inherit xgcc)
63 (version (string-append (package-version xgcc) "-"
64 revision "." (number->string svn-revision)))
65 (source
66 (origin
67 (method svn-fetch)
68 (uri (svn-reference
69 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
70 (revision svn-revision)))
71 (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
72 (sha256
73 (base32
74 "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
75
76 ;; Remove the one patch that doesn't apply to this 4.9 snapshot (the
77 ;; patch is for 4.9.4 and later but this svn snapshot is older).
78 (patches (remove (lambda (patch)
79 (string=? (basename patch)
80 "gcc-arm-bug-71399.patch"))
81 (origin-patches (package-source xgcc))))))
82 (native-inputs
83 `(("flex" ,flex)
84 ,@(package-native-inputs xgcc)))
85 (arguments
86 (substitute-keyword-arguments (package-arguments xgcc)
87 ((#:phases phases)
88 `(modify-phases ,phases
89 (add-after 'unpack 'fix-genmultilib
90 (lambda _
91 (substitute* "gcc/genmultilib"
92 (("#!/bin/sh") (string-append "#!" (which "sh"))))
93 #t))))
94 ((#:configure-flags flags)
95 ;; The configure flags are largely identical to the flags used by the
96 ;; "GCC ARM embedded" project.
97 `(append (list "--enable-multilib"
98 "--with-newlib"
99 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
100 "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
101 "--enable-plugins"
102 "--disable-decimal-float"
103 "--disable-libffi"
104 "--disable-libgomp"
105 "--disable-libmudflap"
106 "--disable-libquadmath"
107 "--disable-libssp"
108 "--disable-libstdcxx-pch"
109 "--disable-nls"
110 "--disable-shared"
111 "--disable-threads"
112 "--disable-tls")
113 (delete "--disable-multilib" ,flags)))))
114 (native-search-paths
115 (list (search-path-specification
116 (variable "CROSS_C_INCLUDE_PATH")
117 (files '("arm-none-eabi/include")))
118 (search-path-specification
119 (variable "CROSS_CPLUS_INCLUDE_PATH")
120 (files '("arm-none-eabi/include")))
121 (search-path-specification
122 (variable "CROSS_LIBRARY_PATH")
123 (files '("arm-none-eabi/lib"))))))))
124
125 (define-public gcc-arm-none-eabi-6
126 (package
127 (inherit gcc-arm-none-eabi-4.9)
128 (version (package-version gcc-6))
129 (source (origin (inherit (package-source gcc-6))
130 (patches
131 (append
132 (origin-patches (package-source gcc-6))
133 (search-patches "gcc-6-cross-environment-variables.patch"
134 "gcc-6-arm-none-eabi-multilib.patch")))))))
135
136 (define-public newlib-arm-none-eabi
137 (package
138 (name "newlib")
139 (version "2.4.0")
140 (source (origin
141 (method url-fetch)
142 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
143 version ".tar.gz"))
144 (sha256
145 (base32
146 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
147 (build-system gnu-build-system)
148 (arguments
149 `(#:out-of-source? #t
150 ;; The configure flags are identical to the flags used by the "GCC ARM
151 ;; embedded" project.
152 #:configure-flags '("--target=arm-none-eabi"
153 "--enable-newlib-io-long-long"
154 "--enable-newlib-register-fini"
155 "--disable-newlib-supplied-syscalls"
156 "--disable-nls")
157 #:phases
158 (modify-phases %standard-phases
159 (add-after 'unpack 'fix-references-to-/bin/sh
160 (lambda _
161 (substitute* '("libgloss/arm/cpu-init/Makefile.in"
162 "libgloss/arm/Makefile.in"
163 "libgloss/libnosys/Makefile.in"
164 "libgloss/Makefile.in")
165 (("/bin/sh") (which "sh")))
166 #t)))))
167 (native-inputs
168 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
169 ("xgcc" ,gcc-arm-none-eabi-4.9)
170 ("texinfo" ,texinfo)))
171 (home-page "http://www.sourceware.org/newlib/")
172 (synopsis "C library for use on embedded systems")
173 (description "Newlib is a C library intended for use on embedded
174 systems. It is a conglomeration of several library parts that are easily
175 usable on embedded products.")
176 (license (license:non-copyleft
177 "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
178
179 (define-public newlib-nano-arm-none-eabi
180 (package (inherit newlib-arm-none-eabi)
181 (name "newlib-nano")
182 (arguments
183 (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
184 ;; The configure flags are identical to the flags used by the "GCC ARM
185 ;; embedded" project. They optimize newlib for use on small embedded
186 ;; systems with limited memory.
187 ((#:configure-flags flags)
188 ''("--target=arm-none-eabi"
189 "--enable-multilib"
190 "--disable-newlib-supplied-syscalls"
191 "--enable-newlib-reent-small"
192 "--disable-newlib-fvwrite-in-streamio"
193 "--disable-newlib-fseek-optimization"
194 "--disable-newlib-wide-orient"
195 "--enable-newlib-nano-malloc"
196 "--disable-newlib-unbuf-stream-opt"
197 "--enable-lite-exit"
198 "--enable-newlib-global-atexit"
199 "--enable-newlib-nano-formatted-io"
200 "--disable-nls"))))
201 (synopsis "Newlib variant for small systems with limited memory")))
202
203 (define (make-libstdc++-arm-none-eabi xgcc newlib)
204 (let ((libstdc++ (make-libstdc++ xgcc)))
205 (package (inherit libstdc++)
206 (name "libstdc++-arm-none-eabi")
207 (arguments
208 (substitute-keyword-arguments (package-arguments libstdc++)
209 ((#:configure-flags flags)
210 ``("--target=arm-none-eabi"
211 "--host=arm-none-eabi"
212 "--disable-libstdcxx-pch"
213 "--enable-multilib"
214 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
215 "--disable-shared"
216 "--disable-tls"
217 "--disable-plugin"
218 "--with-newlib"
219 ,(string-append "--with-gxx-include-dir="
220 (assoc-ref %outputs "out")
221 "/arm-none-eabi/include")))))
222 (native-inputs
223 `(("newlib" ,newlib)
224 ("xgcc" ,xgcc)
225 ,@(package-native-inputs libstdc++))))))
226
227 (define (arm-none-eabi-toolchain xgcc newlib)
228 "Produce a cross-compiler toolchain package with the compiler XGCC and the C
229 library variant NEWLIB."
230 (let ((newlib-with-xgcc (package (inherit newlib)
231 (native-inputs
232 (alist-replace "xgcc" (list xgcc)
233 (package-native-inputs newlib))))))
234 (package
235 (name (string-append "arm-none-eabi"
236 (if (string=? (package-name newlib-with-xgcc)
237 "newlib-nano")
238 "-nano" "")
239 "-toolchain"))
240 (version (package-version xgcc))
241 (source #f)
242 (build-system trivial-build-system)
243 (arguments
244 '(#:modules ((guix build union))
245 #:builder
246 (begin
247 (use-modules (ice-9 match)
248 (guix build union))
249 (match %build-inputs
250 (((names . directories) ...)
251 (union-build (assoc-ref %outputs "out")
252 directories))))))
253 (propagated-inputs
254 `(("binutils" ,(cross-binutils "arm-none-eabi"))
255 ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
256 ("gcc" ,xgcc)
257 ("newlib" ,newlib-with-xgcc)))
258 (synopsis "Complete GCC tool chain for ARM bare metal development")
259 (description "This package provides a complete GCC tool chain for ARM
260 bare metal development. This includes the GCC arm-none-eabi cross compiler
261 and newlib (or newlib-nano) as the C library. The supported programming
262 languages are C and C++.")
263 (home-page (package-home-page xgcc))
264 (license (package-license xgcc)))))
265
266 (define-public arm-none-eabi-toolchain-4.9
267 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
268 newlib-arm-none-eabi))
269
270 (define-public arm-none-eabi-nano-toolchain-4.9
271 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
272 newlib-nano-arm-none-eabi))
273
274 (define-public arm-none-eabi-toolchain-6
275 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
276 newlib-arm-none-eabi))
277
278 (define-public arm-none-eabi-nano-toolchain-6
279 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
280 newlib-nano-arm-none-eabi))
281
282 (define-public gdb-arm-none-eabi
283 (package
284 (inherit gdb)
285 (name "gdb-arm-none-eabi")
286 (arguments
287 `(#:configure-flags '("--target=arm-none-eabi"
288 "--enable-multilib"
289 "--enable-interwork"
290 "--enable-languages=c,c++"
291 "--disable-nls")
292 ,@(package-arguments gdb)))))
293
294 (define-public libjaylink
295 ;; No release tarballs available.
296 (let ((commit "699b7001d34a79c8e7064503dde1bede786fd7f0")
297 (revision "2"))
298 (package
299 (name "libjaylink")
300 (version (string-append "0.1.0-" revision "."
301 (string-take commit 7)))
302 (source (origin
303 (method git-fetch)
304 (uri (git-reference
305 (url "https://git.zapb.de/libjaylink.git")
306 (commit commit)))
307 (file-name (string-append name "-" version "-checkout"))
308 (sha256
309 (base32
310 "034872d44myycnzn67v5b8ixrgmg8sk32aqalvm5x7108w2byww1"))))
311 (build-system gnu-build-system)
312 (native-inputs
313 `(("autoconf" ,autoconf)
314 ("automake" ,automake)
315 ("libtool" ,libtool)
316 ("pkg-config" ,pkg-config)))
317 (inputs
318 `(("libusb" ,libusb)))
319 (arguments
320 `(#:phases
321 (modify-phases %standard-phases
322 (add-after 'unpack 'autoreconf
323 (lambda _
324 (zero? (system* "autoreconf" "-vfi")))))))
325 (home-page "http://repo.or.cz/w/libjaylink.git")
326 (synopsis "Library to interface Segger J-Link devices")
327 (description "libjaylink is a shared library written in C to access
328 SEGGER J-Link and compatible devices.")
329 (license license:gpl2+))))
330
331 (define-public jimtcl
332 (package
333 (name "jimtcl")
334 (version "0.77")
335 (source (origin
336 (method url-fetch)
337 (uri (string-append
338 "https://github.com/msteveb/jimtcl"
339 "/archive/" version ".tar.gz"))
340 (file-name (string-append name "-" version ".tar.gz"))
341 (sha256
342 (base32
343 "1cmk3qscqckg70chjyimzxa2qcka4qac0j4wq908kiijp45cax08"))))
344 (build-system gnu-build-system)
345 (arguments
346 `(#:phases
347 (modify-phases %standard-phases
348 ;; Doesn't use autoconf.
349 (replace 'configure
350 (lambda* (#:key outputs #:allow-other-keys)
351 (let ((out (assoc-ref outputs "out")))
352 (zero? (system* "./configure"
353 (string-append "--prefix=" out)))))))))
354 (home-page "http://jim.tcl.tk")
355 (synopsis "Small footprint Tcl implementation")
356 (description "Jim is a small footprint implementation of the Tcl programming
357 language.")
358 (license license:bsd-2)))
359
360 (define-public openocd
361 (package
362 (name "openocd")
363 (version "0.10.0")
364 (source (origin
365 (method url-fetch)
366 (uri (string-append "mirror://sourceforge/openocd/openocd/"
367 version "/openocd-" version ".tar.gz"))
368 (sha256
369 (base32
370 "09p57y3c2spqx4vjjlz1ljm1lcd0j9q8g76ywxqgn3yc34wv18zd"))
371 ;; FIXME: Remove after nrf52 patch is merged.
372 (patches
373 (search-patches "openocd-nrf52.patch"))))
374 (build-system gnu-build-system)
375 (native-inputs
376 `(("autoconf" ,autoconf)
377 ("automake" ,automake)
378 ("libtool" ,libtool)
379 ("pkg-config" ,pkg-config)))
380 (inputs
381 `(("hidapi" ,hidapi)
382 ("jimtcl" ,jimtcl)
383 ("libftdi" ,libftdi)
384 ("libjaylink" ,libjaylink)
385 ("libusb-compat" ,libusb-compat)))
386 (arguments
387 '(#:configure-flags
388 (append (list "--disable-werror"
389 "--enable-sysfsgpio"
390 "--disable-internal-jimtcl"
391 "--disable-internal-libjaylink")
392 (map (lambda (programmer)
393 (string-append "--enable-" programmer))
394 '("amtjtagaccel" "armjtagew" "buspirate" "ftdi"
395 "gw16012" "jlink" "opendous" "osbdm"
396 "parport" "aice" "cmsis-dap" "dummy" "jtag_vpi"
397 "remote-bitbang" "rlink" "stlink" "ti-icdi" "ulink"
398 "usbprog" "vsllink" "usb-blaster-2" "usb_blaster"
399 "presto" "openjtag")))
400 #:phases
401 (modify-phases %standard-phases
402 (add-before 'configure 'autoreconf
403 (lambda _
404 (zero? (system* "autoreconf" "-vfi"))))
405 (add-after 'autoreconf 'change-udev-group
406 (lambda _
407 (substitute* "contrib/60-openocd.rules"
408 (("plugdev") "dialout"))
409 #t))
410 (add-after 'install 'install-udev-rules
411 (lambda* (#:key outputs #:allow-other-keys)
412 (install-file "contrib/60-openocd.rules"
413 (string-append
414 (assoc-ref outputs "out")
415 "/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+)))
421
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".
426
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))))))
462
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"))))
498
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 (home-page "https://github.com/parallaxinc/propgcc")
528 (supported-systems (delete "aarch64-linux" %supported-systems)))))
529
530 ;; Version 6 is experimental and may not work correctly. This is why we
531 ;; default to version 4, which is also used in the binary toolchain bundle
532 ;; provided by Parallax Inc.
533 (define-public propeller-gcc propeller-gcc-4)
534
535
536 ;; FIXME: We do not build the tiny library because that would require C++
537 ;; headers, which are not available. This may require adding a propeller-elf
538 ;; variant of the libstdc++ package.
539 (define-public proplib
540 (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
541 (revision "2"))
542 (package
543 (name "proplib")
544 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
545 (source (origin
546 (method git-fetch)
547 (uri (git-reference
548 (url "https://github.com/parallaxinc/propgcc.git")
549 (commit commit)))
550 (file-name (string-append name "-" commit "-checkout"))
551 (sha256
552 (base32
553 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
554 (build-system gnu-build-system)
555 (arguments
556 `(#:tests? #f ; no tests
557 #:make-flags
558 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
559 (string-append "BUILD=" (getcwd) "/build"))
560 #:phases
561 (modify-phases %standard-phases
562 (delete 'configure)
563 (add-after 'unpack 'chdir
564 (lambda _ (chdir "lib") #t))
565 (add-after 'chdir 'fix-Makefile
566 (lambda _
567 (substitute* "Makefile"
568 ;; Control the installation time of the headers.
569 ((" install-includes") ""))
570 #t))
571 ;; The Makefile does not separate building from installation, so we
572 ;; have to create the target directories at build time.
573 (add-before 'build 'create-target-directories
574 (lambda* (#:key make-flags #:allow-other-keys)
575 (zero? (apply system* "make" "install-dirs" make-flags))))
576 (add-before 'build 'set-cross-environment-variables
577 (lambda* (#:key outputs #:allow-other-keys)
578 (setenv "CROSS_LIBRARY_PATH"
579 (string-append (assoc-ref outputs "out")
580 "/propeller-elf/lib:"
581 (or (getenv "CROSS_LIBRARY_PATH") "")))
582 (setenv "CROSS_C_INCLUDE_PATH"
583 (string-append (assoc-ref outputs "out")
584 "/propeller-elf/include:"
585 (or (getenv "CROSS_C_INCLUDE_PATH") "")))
586 #t))
587 (add-before 'install 'install-includes
588 (lambda* (#:key make-flags #:allow-other-keys)
589 (zero? (apply system* "make" "install-includes" make-flags)))))))
590 (native-inputs
591 `(("propeller-gcc" ,propeller-gcc)
592 ("propeller-binutils" ,propeller-binutils)
593 ("perl" ,perl)))
594 (home-page "https://github.com/parallaxinc/propgcc")
595 (synopsis "C library for the Parallax Propeller")
596 (description "This is a C library for the Parallax Propeller
597 micro-controller.")
598 ;; Most of the code is released under the Expat license. Some of the
599 ;; included code is public domain and some changes are BSD licensed.
600 (license license:expat))))
601
602 (define-public propeller-toolchain
603 (package
604 (name "propeller-toolchain")
605 (version (package-version propeller-gcc))
606 (source #f)
607 (build-system trivial-build-system)
608 (arguments '(#:builder (mkdir %output)))
609 (propagated-inputs
610 `(("binutils" ,propeller-binutils)
611 ("libc" ,proplib)
612 ("gcc" ,propeller-gcc)))
613 (synopsis "Complete GCC tool chain for Propeller micro-controllers")
614 (description "This package provides a complete GCC tool chain for
615 Propeller micro-controller development.")
616 (home-page (package-home-page propeller-gcc))
617 (license (package-license propeller-gcc))))
618
619 (define-public openspin
620 (package
621 (name "openspin")
622 (version "1.00.78")
623 (source (origin
624 (method url-fetch)
625 (uri (string-append "https://github.com/parallaxinc/"
626 "OpenSpin/archive/" version ".tar.gz"))
627 (file-name (string-append name "-" version ".tar.gz"))
628 (sha256
629 (base32
630 "1k2dbz1v604g4r2d9qhckg2m8dnhiya760mbsqfsg4waxal87yb7"))))
631 (build-system gnu-build-system)
632 (arguments
633 `(#:tests? #f ; no tests
634 #:phases
635 (modify-phases %standard-phases
636 (delete 'configure)
637 (add-after 'unpack 'remove-timestamp
638 (lambda _
639 (substitute* "SpinSource/openspin.cpp"
640 ((" Compiled on.*$") "\\n\");"))
641 #t))
642 ;; Makefile does not include "install" target
643 (replace 'install
644 (lambda* (#:key outputs #:allow-other-keys)
645 (let ((bin (string-append (assoc-ref outputs "out")
646 "/bin")))
647 (mkdir-p bin)
648 (install-file "build/openspin" bin)
649 #t))))))
650 (home-page "https://github.com/parallaxinc/OpenSpin")
651 (synopsis "Spin/PASM compiler for the Parallax Propeller")
652 (description "OpenSpin is a compiler for the Spin/PASM language of the
653 Parallax Propeller. It was ported from Chip Gracey's original x86 assembler
654 code.")
655 (license license:expat)))
656
657 (define-public propeller-load
658 (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
659 (revision "2"))
660 (package
661 (name "propeller-load")
662 (version "3.4.0")
663 (source (origin
664 (method git-fetch)
665 (uri (git-reference
666 (url "https://github.com/parallaxinc/propgcc.git")
667 (commit commit)))
668 (file-name (string-append name "-" commit "-checkout"))
669 (sha256
670 (base32
671 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
672 (build-system gnu-build-system)
673 (arguments
674 `(#:tests? #f ; no tests
675 #:make-flags
676 (list "OS=linux"
677 (string-append "TARGET=" (assoc-ref %outputs "out")))
678 #:phases
679 (modify-phases %standard-phases
680 (add-after 'unpack 'chdir
681 (lambda _ (chdir "loader") #t))
682 (delete 'configure))))
683 (native-inputs
684 `(("openspin" ,openspin)
685 ("propeller-toolchain" ,propeller-toolchain)))
686 (home-page "https://github.com/parallaxinc/propgcc")
687 (synopsis "Loader for Parallax Propeller micro-controllers")
688 (description "This package provides the tool @code{propeller-load} to
689 upload binaries to a Parallax Propeller micro-controller.")
690 (license license:expat))))
691
692 (define-public spin2cpp
693 (package
694 (name "spin2cpp")
695 (version "3.6.3")
696 (source (origin
697 (method url-fetch)
698 (uri (string-append "https://github.com/totalspectrum/spin2cpp/"
699 "archive/v" version ".tar.gz"))
700 (file-name (string-append name "-" version ".tar.gz"))
701 (sha256
702 (base32
703 "0v5vzh69bp1r2byrpz12rql1w24ff2v9msr31596zq6hd6n82lnh"))))
704 (build-system gnu-build-system)
705 (arguments
706 `(#:tests? #f ;; The tests assume that a micro-controller is connected.
707 #:phases
708 (modify-phases %standard-phases
709 (delete 'configure)
710 (add-before 'build 'set-cross-environment-variables
711 (lambda* (#:key inputs #:allow-other-keys)
712 (setenv "CROSS_LIBRARY_PATH"
713 (string-append (assoc-ref inputs "propeller-toolchain")
714 "/propeller-elf/lib"))
715 (setenv "CROSS_C_INCLUDE_PATH"
716 (string-append (assoc-ref inputs "propeller-toolchain")
717 "/propeller-elf/include"))
718 #t))
719 (replace 'install
720 (lambda* (#:key outputs #:allow-other-keys)
721 (let ((bin (string-append (assoc-ref outputs "out")
722 "/bin")))
723 (for-each (lambda (file)
724 (install-file (string-append "build/" file)
725 bin))
726 '("testlex" "spin2cpp" "fastspin")))
727 #t)))))
728 (native-inputs
729 `(("bison" ,bison)
730 ("propeller-load" ,propeller-load)
731 ("propeller-toolchain" ,propeller-toolchain)))
732 (home-page "https://github.com/totalspectrum/spin2cpp")
733 (synopsis "Convert Spin code to C, C++, or PASM code")
734 (description "This is a set of tools for converting the Spin language for
735 the Parallax Propeller micro-controller into C or C++ code, into PASM, or even
736 directly into an executable binary. The binaries produced use LMM PASM, so
737 they are much faster than regular Spin bytecodes (but also quite a bit
738 larger).")
739 (license license:expat)))
740
741 (define-public spinsim
742 (let ((commit "66915a7ad1a3a2cf990a725bb341fab8d11eb620")
743 (revision "1"))
744 (package
745 (name "spinsim")
746 (version (string-append "0.75-" revision "." (string-take commit 9)))
747 (source (origin
748 (method git-fetch)
749 (uri (git-reference
750 (url "https://github.com/parallaxinc/spinsim.git")
751 (commit commit)))
752 (file-name (string-append name "-" commit "-checkout"))
753 (sha256
754 (base32
755 "1n9kdhlxsdx7bz6c80w8dhi96zp633gd6qs0x9i4ii8qv4i7sj5k"))))
756 (build-system gnu-build-system)
757 (arguments
758 `(#:tests? #f ; no tests
759 #:phases
760 (modify-phases %standard-phases
761 (delete 'configure)
762 (replace 'install
763 (lambda* (#:key outputs #:allow-other-keys)
764 (let ((bin (string-append (assoc-ref outputs "out")
765 "/bin")))
766 (install-file "build/spinsim" bin))
767 #t)))))
768 (home-page "https://github.com/parallaxinc/spinsim")
769 (synopsis "Spin simulator")
770 (description "This package provides the tool @code{spinsim}, a simulator
771 and simple debugger for Spin programs written for a Parallax Propeller
772 micro-controller. Spinsim supports execution from cog memory and hub
773 execution, but it does not support multi-tasking. It supports about
774 two-thirds of the opcodes in the P2 instruction set.")
775 (license license:expat))))
776
777 (define-public propeller-development-suite
778 (package
779 (name "propeller-development-suite")
780 (version (package-version propeller-gcc))
781 (source #f)
782 (build-system trivial-build-system)
783 (arguments '(#:builder (mkdir %output)))
784 (propagated-inputs
785 `(("toolchain" ,propeller-toolchain)
786 ("openspin" ,openspin)
787 ("propeller-load" ,propeller-load)
788 ("spin2cpp" ,spin2cpp)
789 ("spinsim" ,spinsim)))
790 (synopsis "Complete development suite for Propeller micro-controllers")
791 (description "This meta-package provides a complete environment for the
792 development with Parallax Propeller micro-controllers. It includes the GCC
793 toolchain, the loader, the Openspin compiler, the Spin2cpp tool, and the Spin
794 simulator.")
795 (home-page (package-home-page propeller-gcc))
796 (license (package-license propeller-gcc))))
797
798 (define-public binutils-vc4
799 (let ((commit "708acc851880dbeda1dd18aca4fd0a95b2573b36"))
800 (package
801 (name "binutils-vc4")
802 (version (string-append "2.23.51-0." (string-take commit 7)))
803 (source (origin
804 (method git-fetch)
805 (uri (git-reference
806 (url "https://github.com/puppeh/binutils-vc4.git")
807 (commit commit)))
808 (file-name (string-append name "-" version "-checkout"))
809 (sha256
810 (base32
811 "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"))))
812 (build-system gnu-build-system)
813 (arguments
814 `(#:configure-flags '("--target=vc4-elf"
815 "--disable-werror"
816 "--enable-cgen-maint")
817 #:phases
818 (modify-phases %standard-phases
819 (add-after 'unpack 'unpack-cgen
820 (lambda* (#:key inputs #:allow-other-keys)
821 (copy-recursively (string-append (assoc-ref inputs "cgen")
822 "/cgen") "cgen")
823 #t))
824 (add-after 'unpack-cgen 'fix-cgen-guile
825 (lambda _
826 (substitute* "opcodes/Makefile.in"
827 (("guile\\{,-\\}1.8") "guile"))
828 (zero? (system* "which" "guile")))))))
829 (native-inputs
830 `(("cgen"
831 ,(origin
832 (method git-fetch)
833 (uri (git-reference
834 (url "https://github.com/puppeh/cgen.git")
835 (commit "d8e2a9eb70425f180fdd5bfd032884b0855f2032")))
836 (sha256
837 (base32
838 "14b3h2ji740s8zq5vwm4qdcxs4aa4wxi6wb9di3bv1h39x14nyr9"))))
839 ("texinfo" ,texinfo)
840 ("flex" ,flex)
841 ("bison" ,bison)
842 ("guile-1.8" ,guile-1.8)
843 ("which" ,base:which)))
844 (synopsis "Binutils for VC4")
845 (description "This package provides @code{binutils} for VideoCore IV,
846 the Raspberry Pi chip.")
847 (license license:gpl3+)
848 (home-page "https://github.com/puppeh/vc4-toolchain/"))))
849
850 (define-public gcc-vc4
851 (let ((commit "165f6d0e11d2e76ee799533bb45bd5c92bf60dc2")
852 (xgcc (cross-gcc "vc4-elf" #:xbinutils binutils-vc4)))
853 (package (inherit xgcc)
854 (name "gcc-vc4")
855 (source (origin
856 (method git-fetch)
857 (uri (git-reference
858 (url "https://github.com/puppeh/gcc-vc4.git")
859 (commit commit)))
860 (file-name (string-append name
861 "-"
862 (package-version xgcc)
863 "-checkout"))
864 (sha256
865 (base32
866 "13h30qjcwnlz6lfma1d82nnvfmjnhh7abkagip4vly6vm5fpnvf2"))))
867 (native-inputs
868 `(("flex" ,flex)
869 ,@(package-native-inputs xgcc)))
870 (synopsis "GCC for VC4")
871 (description "This package provides @code{gcc} for VideoCore IV,
872 the Raspberry Pi chip."))))
873
874 (define-public python2-libmpsse
875 (package
876 (name "python2-libmpsse")
877 (version "1.3")
878 (source
879 (origin
880 (method url-fetch)
881 (uri (string-append "https://storage.googleapis.com/"
882 "google-code-archive-downloads/v2/"
883 "code.google.com/libmpsse/"
884 "libmpsse-" version ".tar.gz"))
885 (sha256
886 (base32
887 "0jq7nhqq3na8675jnpfcar3pd3dp3adhhc4lw900swkla01a1wh8"))))
888 (build-system gnu-build-system)
889 (inputs
890 `(("libftdi" ,libftdi)
891 ("python" ,python-2)))
892 (native-inputs
893 `(("pkg-config" ,pkg-config)
894 ("swig" ,swig)
895 ("which" ,base:which)))
896 (arguments
897 `(#:tests? #f ; No tests exist.
898 #:make-flags
899 (list (string-append "CFLAGS=-Wall -fPIC -fno-strict-aliasing -g -O2 "
900 "$(shell pkg-config --cflags libftdi1)"))
901 #:phases
902 (modify-phases %standard-phases
903 (add-after 'unpack 'set-environment-up
904 (lambda* (#:key inputs outputs #:allow-other-keys)
905 (chdir "src")
906 (setenv "PYDEV" (string-append (assoc-ref inputs "python")
907 "/include/python2.7"))
908 #t))
909 (add-after 'unpack 'patch-global-variable
910 (lambda _
911 ;; fast_rw_buf was defined in a header file which was making
912 ;; the build not reproducible.
913 (substitute* "src/fast.c"
914 (("^int fast_build_block_buffer") "
915
916 unsigned char fast_rw_buf[SPI_RW_SIZE + CMD_SIZE];
917 int fast_build_block_buffer"))
918 (substitute* "src/mpsse.h"
919 (("unsigned char fast_rw_buf.*") "
920 "))
921 #t))
922 (replace 'install
923 (lambda* (#:key outputs make-flags #:allow-other-keys #:rest args)
924 (let* ((out (assoc-ref outputs "out"))
925 (out-python (string-append out
926 "/lib/python2.7/site-packages"))
927 (install (assoc-ref %standard-phases 'install)))
928 (install #:make-flags (cons (string-append "PYLIB=" out-python)
929 make-flags))))))))
930 (home-page "https://code.google.com/archive/p/libmpsse/")
931 (synopsis "Python library for MPSSE SPI I2C JTAG adapter by FTDI")
932 (description "This package provides a library in order to support the
933 MPSSE (Multi-Protocol Synchronous Serial Engine) adapter by FTDI that can do
934 SPI, I2C, JTAG.")
935 (license license:gpl2+)))
936
937 (define-public picprog
938 (package
939 (name "picprog")
940 (version "1.9.1")
941 (source (origin
942 (method url-fetch)
943 (uri (string-append "http://www.iki.fi/hyvatti/pic/picprog-"
944 version ".tar.gz"))
945 (file-name (string-append name "-" version ".tar.gz"))
946 (sha256
947 (base32
948 "1r04hg1n3v2jf915qr05la3q9cxy7a5jnh9cc98j04lh6c9p4x85"))
949 (patches (search-patches "picprog-non-intel-support.patch"))))
950 (build-system gnu-build-system)
951 (arguments
952 `(#:tests? #f ; No tests exist.
953 #:phases
954 (modify-phases %standard-phases
955 (add-after 'unpack 'patch-paths
956 (lambda* (#:key outputs #:allow-other-keys)
957 (substitute* "Makefile"
958 (("/usr/local") (assoc-ref outputs "out"))
959 ((" -o 0 -g 0 ") " ")
960 (("testport") ""))
961 #t))
962 (add-before 'install 'mkdir
963 (lambda* (#:key outputs #:allow-other-keys)
964 (let ((out (assoc-ref outputs "out")))
965 (mkdir-p (string-append out "/bin"))
966 (mkdir-p (string-append out "/man/man1"))
967 #t)))
968 (delete 'configure))))
969 (synopsis "Programs Microchip's PIC microcontrollers")
970 (description "This program programs Microchip's PIC microcontrollers.")
971 (home-page "http://hyvatti.iki.fi/~jaakko/pic/picprog.html")
972 (license license:gpl3+)))