gnu: Add picprog.
[jackhill/guix/guix.git] / gnu / packages / embedded.scm
CommitLineData
35a37efb 1;;; GNU Guix --- Functional package management for GNU
2d7c9213 2;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
2da8865a 3;;; Copyright © 2016, 2017 Theodoros Foradis <theodoros@foradis.org>
e5e45c06 4;;; Copyright © 2016 David Craven <david@craven.ch>
35a37efb
RW
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages embedded)
22 #:use-module (guix utils)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix svn-download)
26 #:use-module (guix git-download)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix build-system gnu)
569f6016
TF
29 #:use-module (guix build-system trivial)
30 #:use-module (guix build utils)
35a37efb 31 #:use-module (gnu packages)
e5e45c06 32 #:use-module (gnu packages autotools)
8ea42482 33 #:use-module ((gnu packages base) #:prefix base:)
2d7c9213 34 #:use-module (gnu packages bison)
35a37efb 35 #:use-module (gnu packages cross-base)
2d7c9213 36 #:use-module (gnu packages dejagnu)
35a37efb 37 #:use-module (gnu packages flex)
dbc3c34e 38 #:use-module (gnu packages gcc)
94f36a4f 39 #:use-module (gnu packages gdb)
8ea42482 40 #:use-module (gnu packages guile)
5b83b7b8 41 #:use-module (gnu packages libftdi)
e5e45c06 42 #:use-module (gnu packages libusb)
35a37efb 43 #:use-module (gnu packages perl)
e5e45c06 44 #:use-module (gnu packages pkg-config)
1a6497de
DM
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages swig)
7894ea61
LC
47 #:use-module (gnu packages texinfo)
48 #:use-module (srfi srfi-1))
35a37efb
RW
49
50;; We must not use the released GCC sources here, because the cross-compiler
51;; does not produce working binaries. Instead we take the very same SVN
52;; revision from the branch that is used for a release of the "GCC ARM
53;; embedded" project on launchpad.
54;; See https://launchpadlibrarian.net/218827644/release.txt
55(define-public gcc-arm-none-eabi-4.9
56 (let ((xgcc (cross-gcc "arm-none-eabi"
7b3318e3
RW
57 #:xgcc gcc-4.9
58 #:xbinutils (cross-binutils "arm-none-eabi")))
35a37efb
RW
59 (revision "1")
60 (svn-revision 227977))
61 (package (inherit xgcc)
62 (version (string-append (package-version xgcc) "-"
63 revision "." (number->string svn-revision)))
64 (source
65 (origin
66 (method svn-fetch)
67 (uri (svn-reference
68 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
69 (revision svn-revision)))
70 (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
71 (sha256
72 (base32
73 "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
7894ea61
LC
74
75 ;; Remove the one patch that doesn't apply to this 4.9 snapshot (the
76 ;; patch is for 4.9.4 and later but this svn snapshot is older).
77 (patches (remove (lambda (patch)
78 (string=? (basename patch)
79 "gcc-arm-bug-71399.patch"))
80 (origin-patches (package-source xgcc))))))
35a37efb
RW
81 (native-inputs
82 `(("flex" ,flex)
83 ,@(package-native-inputs xgcc)))
84 (arguments
85 (substitute-keyword-arguments (package-arguments xgcc)
86 ((#:phases phases)
87 `(modify-phases ,phases
88 (add-after 'unpack 'fix-genmultilib
89 (lambda _
90 (substitute* "gcc/genmultilib"
91 (("#!/bin/sh") (string-append "#!" (which "sh"))))
92 #t))))
93 ((#:configure-flags flags)
94 ;; The configure flags are largely identical to the flags used by the
95 ;; "GCC ARM embedded" project.
96 `(append (list "--enable-multilib"
97 "--with-newlib"
98 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
99 "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
100 "--enable-plugins"
101 "--disable-decimal-float"
102 "--disable-libffi"
103 "--disable-libgomp"
104 "--disable-libmudflap"
105 "--disable-libquadmath"
106 "--disable-libssp"
107 "--disable-libstdcxx-pch"
108 "--disable-nls"
109 "--disable-shared"
110 "--disable-threads"
111 "--disable-tls")
112 (delete "--disable-multilib" ,flags)))))
113 (native-search-paths
114 (list (search-path-specification
115 (variable "CROSS_C_INCLUDE_PATH")
116 (files '("arm-none-eabi/include")))
117 (search-path-specification
118 (variable "CROSS_CPLUS_INCLUDE_PATH")
119 (files '("arm-none-eabi/include")))
120 (search-path-specification
121 (variable "CROSS_LIBRARY_PATH")
122 (files '("arm-none-eabi/lib"))))))))
6c39886a 123
dbc3c34e
TF
124(define-public gcc-arm-none-eabi-6
125 (package
126 (inherit gcc-arm-none-eabi-4.9)
127 (version (package-version gcc-6))
128 (source (origin (inherit (package-source gcc-6))
129 (patches
130 (append
131 (origin-patches (package-source gcc-6))
132 (search-patches "gcc-6-cross-environment-variables.patch"
133 "gcc-6-arm-none-eabi-multilib.patch")))))))
134
6c39886a
RW
135(define-public newlib-arm-none-eabi
136 (package
137 (name "newlib")
138 (version "2.4.0")
139 (source (origin
140 (method url-fetch)
141 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
142 version ".tar.gz"))
143 (sha256
144 (base32
145 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
146 (build-system gnu-build-system)
147 (arguments
148 `(#:out-of-source? #t
149 ;; The configure flags are identical to the flags used by the "GCC ARM
150 ;; embedded" project.
151 #:configure-flags '("--target=arm-none-eabi"
152 "--enable-newlib-io-long-long"
153 "--enable-newlib-register-fini"
154 "--disable-newlib-supplied-syscalls"
155 "--disable-nls")
156 #:phases
157 (modify-phases %standard-phases
158 (add-after 'unpack 'fix-references-to-/bin/sh
159 (lambda _
160 (substitute* '("libgloss/arm/cpu-init/Makefile.in"
161 "libgloss/arm/Makefile.in"
162 "libgloss/libnosys/Makefile.in"
163 "libgloss/Makefile.in")
164 (("/bin/sh") (which "sh")))
165 #t)))))
166 (native-inputs
167 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
168 ("xgcc" ,gcc-arm-none-eabi-4.9)
169 ("texinfo" ,texinfo)))
170 (home-page "http://www.sourceware.org/newlib/")
171 (synopsis "C library for use on embedded systems")
172 (description "Newlib is a C library intended for use on embedded
173systems. It is a conglomeration of several library parts that are easily
174usable on embedded products.")
175 (license (license:non-copyleft
176 "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
a299a899
RW
177
178(define-public newlib-nano-arm-none-eabi
179 (package (inherit newlib-arm-none-eabi)
180 (name "newlib-nano")
181 (arguments
182 (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
183 ;; The configure flags are identical to the flags used by the "GCC ARM
184 ;; embedded" project. They optimize newlib for use on small embedded
185 ;; systems with limited memory.
186 ((#:configure-flags flags)
187 ''("--target=arm-none-eabi"
188 "--enable-multilib"
189 "--disable-newlib-supplied-syscalls"
190 "--enable-newlib-reent-small"
191 "--disable-newlib-fvwrite-in-streamio"
192 "--disable-newlib-fseek-optimization"
193 "--disable-newlib-wide-orient"
194 "--enable-newlib-nano-malloc"
195 "--disable-newlib-unbuf-stream-opt"
196 "--enable-lite-exit"
197 "--enable-newlib-global-atexit"
198 "--enable-newlib-nano-formatted-io"
199 "--disable-nls"))))
200 (synopsis "Newlib variant for small systems with limited memory")))
569f6016 201
1a1e8336
RW
202(define (make-libstdc++-arm-none-eabi xgcc newlib)
203 (let ((libstdc++ (make-libstdc++ xgcc)))
204 (package (inherit libstdc++)
205 (name "libstdc++-arm-none-eabi")
206 (arguments
207 (substitute-keyword-arguments (package-arguments libstdc++)
208 ((#:configure-flags flags)
209 ``("--target=arm-none-eabi"
210 "--host=arm-none-eabi"
211 "--disable-libstdcxx-pch"
212 "--enable-multilib"
213 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
214 "--disable-shared"
215 "--disable-tls"
216 "--disable-plugin"
217 "--with-newlib"
218 ,(string-append "--with-gxx-include-dir="
219 (assoc-ref %outputs "out")
220 "/arm-none-eabi/include")))))
221 (native-inputs
222 `(("newlib" ,newlib)
223 ("xgcc" ,xgcc)
224 ,@(package-native-inputs libstdc++))))))
225
569f6016
TF
226(define (arm-none-eabi-toolchain xgcc newlib)
227 "Produce a cross-compiler toolchain package with the compiler XGCC and the C
228library variant NEWLIB."
229 (let ((newlib-with-xgcc (package (inherit newlib)
230 (native-inputs
231 (alist-replace "xgcc" (list xgcc)
232 (package-native-inputs newlib))))))
233 (package
234 (name (string-append "arm-none-eabi"
235 (if (string=? (package-name newlib-with-xgcc)
236 "newlib-nano")
237 "-nano" "")
238 "-toolchain"))
239 (version (package-version xgcc))
240 (source #f)
241 (build-system trivial-build-system)
9cdf4872
RW
242 (arguments
243 '(#:modules ((guix build union))
244 #:builder
245 (begin
246 (use-modules (ice-9 match)
247 (guix build union))
248 (match %build-inputs
249 (((names . directories) ...)
250 (union-build (assoc-ref %outputs "out")
251 directories))))))
569f6016
TF
252 (propagated-inputs
253 `(("binutils" ,(cross-binutils "arm-none-eabi"))
8ea169d0 254 ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
569f6016
TF
255 ("gcc" ,xgcc)
256 ("newlib" ,newlib-with-xgcc)))
257 (synopsis "Complete GCC tool chain for ARM bare metal development")
258 (description "This package provides a complete GCC tool chain for ARM
259bare metal development. This includes the GCC arm-none-eabi cross compiler
260and newlib (or newlib-nano) as the C library. The supported programming
261languages are C and C++.")
262 (home-page (package-home-page xgcc))
263 (license (package-license xgcc)))))
264
265(define-public arm-none-eabi-toolchain-4.9
266 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
267 newlib-arm-none-eabi))
268
269(define-public arm-none-eabi-nano-toolchain-4.9
270 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
271 newlib-nano-arm-none-eabi))
272
273(define-public arm-none-eabi-toolchain-6
274 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
275 newlib-arm-none-eabi))
276
277(define-public arm-none-eabi-nano-toolchain-6
278 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
279 newlib-nano-arm-none-eabi))
94f36a4f
TF
280
281(define-public gdb-arm-none-eabi
282 (package
283 (inherit gdb)
284 (name "gdb-arm-none-eabi")
285 (arguments
286 `(#:configure-flags '("--target=arm-none-eabi"
287 "--enable-multilib"
288 "--enable-interwork"
289 "--enable-languages=c,c++"
290 "--disable-nls")
291 ,@(package-arguments gdb)))))
e5e45c06
DC
292
293(define-public libjaylink
294 ;; No release tarballs available.
2da8865a
TF
295 (let ((commit "699b7001d34a79c8e7064503dde1bede786fd7f0")
296 (revision "2"))
e5e45c06
DC
297 (package
298 (name "libjaylink")
299 (version (string-append "0.1.0-" revision "."
300 (string-take commit 7)))
301 (source (origin
302 (method git-fetch)
303 (uri (git-reference
5f13bf09 304 (url "https://git.zapb.de/libjaylink.git")
e5e45c06
DC
305 (commit commit)))
306 (file-name (string-append name "-" version "-checkout"))
307 (sha256
308 (base32
2da8865a 309 "034872d44myycnzn67v5b8ixrgmg8sk32aqalvm5x7108w2byww1"))))
e5e45c06
DC
310 (build-system gnu-build-system)
311 (native-inputs
312 `(("autoconf" ,autoconf)
313 ("automake" ,automake)
314 ("libtool" ,libtool)
315 ("pkg-config" ,pkg-config)))
316 (inputs
317 `(("libusb" ,libusb)))
318 (arguments
319 `(#:phases
320 (modify-phases %standard-phases
d10092b8 321 (add-after 'unpack 'autoreconf
e5e45c06
DC
322 (lambda _
323 (zero? (system* "autoreconf" "-vfi")))))))
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
327SEGGER J-Link and compatible devices.")
328 (license license:gpl2+))))
91ba6935
DC
329
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 (zero? (system* "./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
356language.")
357 (license license:bsd-2)))
5b83b7b8
TF
358
359(define-public openocd
ea1aa452
TF
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 (add-before 'configure 'autoreconf
402 (lambda _
403 (zero? (system* "autoreconf" "-vfi"))))
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 (home-page "http://openocd.org")
416 (synopsis "On-Chip Debugger")
417 (description "OpenOCD provides on-chip programming and debugging support
5b83b7b8 418with a layered architecture of JTAG interface and TAP support.")
ea1aa452 419 (license license:gpl2+)))
2d7c9213 420
791cfa67
RW
421;; The commits for all propeller tools are the stable versions published at
422;; https://github.com/propellerinc/propgcc in the release_1_0. According to
423;; personal correspondence with the developers in July 2017, more recent
424;; versions are currently incompatible with the "Simple Libraries".
2d7c9213
RW
425
426(define propeller-binutils
427 (let ((xbinutils (cross-binutils "propeller-elf"))
791cfa67
RW
428 (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
429 (revision "2"))
2d7c9213
RW
430 (package
431 (inherit xbinutils)
432 (name "propeller-binutils")
433 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
434 (source (origin (inherit (package-source xbinutils))
435 (method git-fetch)
436 (uri (git-reference
791cfa67 437 (url "https://github.com/parallaxinc/propgcc.git")
2d7c9213
RW
438 (commit commit)))
439 (file-name (string-append name "-" commit "-checkout"))
440 (sha256
441 (base32
791cfa67
RW
442 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
443 (patch-flags (list "-p1" "--directory=binutils"))))
2d7c9213 444 (arguments
791cfa67 445 `(;; FIXME: For some reason there are many test failures. It's not
2d7c9213
RW
446 ;; obvious how to fix the failures.
447 #:tests? #f
448 #:phases
449 (modify-phases %standard-phases
791cfa67
RW
450 (add-after 'unpack 'chdir
451 (lambda _ (chdir "binutils") #t)))
452 ,@(substitute-keyword-arguments (package-arguments xbinutils)
453 ((#:configure-flags flags)
454 `(cons "--disable-werror" ,flags)))))
2d7c9213
RW
455 (native-inputs
456 `(("bison" ,bison)
5e54f4ad 457 ("flex" ,flex)
2d7c9213
RW
458 ("texinfo" ,texinfo)
459 ("dejagnu" ,dejagnu)
460 ,@(package-native-inputs xbinutils))))))
461
bb19b2eb 462(define-public propeller-gcc-6
68cb2784 463 (let ((xgcc (cross-gcc "propeller-elf"
7b3318e3 464 #:xbinutils propeller-binutils))
68cb2784
RW
465 (commit "b4f45a4725e0b6d0af59e594c4e3e35ca4105867")
466 (revision "1"))
467 (package (inherit xgcc)
468 (name "propeller-gcc")
469 (version (string-append "6.0.0-" revision "." (string-take commit 9)))
470 (source (origin
471 (method git-fetch)
472 (uri (git-reference
473 (url "https://github.com/totalspectrum/gcc-propeller.git")
474 (commit commit)))
475 (file-name (string-append name "-" commit "-checkout"))
476 (sha256
477 (base32
478 "0d9kdxm2fzanjqa7q5850kzbsfl0fqyaahxn74h6nkxxacwa11zb"))
479 (patches
480 (append
481 (origin-patches (package-source gcc-6))
482 (search-patches "gcc-cross-environment-variables.patch")))))
483 (native-inputs
484 `(("flex" ,flex)
485 ,@(package-native-inputs xgcc)))
486 ;; All headers and cross libraries of the propeller toolchain are
487 ;; installed under the "propeller-elf" prefix.
488 (native-search-paths
489 (list (search-path-specification
490 (variable "CROSS_C_INCLUDE_PATH")
491 (files '("propeller-elf/include")))
492 (search-path-specification
493 (variable "CROSS_LIBRARY_PATH")
494 (files '("propeller-elf/lib")))))
495 (home-page "https://github.com/totalspectrum/gcc-propeller")
496 (synopsis "GCC for the Parallax Propeller"))))
497
db90eb8c 498(define-public propeller-gcc-4
bb19b2eb 499 (let ((xgcc propeller-gcc-6)
791cfa67
RW
500 (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
501 (revision "2"))
db90eb8c
RW
502 (package (inherit xgcc)
503 (name "propeller-gcc")
504 (version (string-append "4.6.1-" revision "." (string-take commit 9)))
505 (source (origin
506 (method git-fetch)
507 (uri (git-reference
791cfa67 508 (url "https://github.com/parallaxinc/propgcc.git")
db90eb8c
RW
509 (commit commit)))
510 (file-name (string-append name "-" commit "-checkout"))
511 (sha256
512 (base32
791cfa67
RW
513 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
514 (patch-flags (list "-p1" "--directory=gcc"))
db90eb8c
RW
515 (patches
516 (append
517 (origin-patches (package-source gcc-4.7))
1d3be5d9
RW
518 (search-patches "gcc-4.6-gnu-inline.patch"
519 "gcc-cross-environment-variables.patch")))))
791cfa67
RW
520 (arguments
521 (substitute-keyword-arguments (package-arguments propeller-gcc-6)
522 ((#:phases phases)
523 `(modify-phases ,phases
524 (add-after 'unpack 'chdir
525 (lambda _ (chdir "gcc") #t))))))
526 (home-page "https://github.com/parallaxinc/propgcc")
57e96e48 527 (supported-systems (delete "aarch64-linux" %supported-systems)))))
db90eb8c 528
bb19b2eb
RW
529;; Version 6 is experimental and may not work correctly. This is why we
530;; default to version 4, which is also used in the binary toolchain bundle
531;; provided by Parallax Inc.
532(define-public propeller-gcc propeller-gcc-4)
533
791cfa67
RW
534
535;; FIXME: We do not build the tiny library because that would require C++
536;; headers, which are not available. This may require adding a propeller-elf
537;; variant of the libstdc++ package.
0d0079b2 538(define-public proplib
791cfa67
RW
539 (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
540 (revision "2"))
0d0079b2
RW
541 (package
542 (name "proplib")
543 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
544 (source (origin
545 (method git-fetch)
546 (uri (git-reference
791cfa67 547 (url "https://github.com/parallaxinc/propgcc.git")
0d0079b2
RW
548 (commit commit)))
549 (file-name (string-append name "-" commit "-checkout"))
550 (sha256
551 (base32
791cfa67 552 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
0d0079b2
RW
553 (build-system gnu-build-system)
554 (arguments
555 `(#:tests? #f ; no tests
556 #:make-flags
557 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
558 (string-append "BUILD=" (getcwd) "/build"))
559 #:phases
560 (modify-phases %standard-phases
561 (delete 'configure)
791cfa67
RW
562 (add-after 'unpack 'chdir
563 (lambda _ (chdir "lib") #t))
564 (add-after 'chdir 'fix-Makefile
0d0079b2
RW
565 (lambda _
566 (substitute* "Makefile"
0d0079b2
RW
567 ;; Control the installation time of the headers.
568 ((" install-includes") ""))
569 #t))
570 ;; The Makefile does not separate building from installation, so we
571 ;; have to create the target directories at build time.
572 (add-before 'build 'create-target-directories
573 (lambda* (#:key make-flags #:allow-other-keys)
574 (zero? (apply system* "make" "install-dirs" make-flags))))
575 (add-before 'build 'set-cross-environment-variables
576 (lambda* (#:key outputs #:allow-other-keys)
577 (setenv "CROSS_LIBRARY_PATH"
578 (string-append (assoc-ref outputs "out")
579 "/propeller-elf/lib:"
580 (or (getenv "CROSS_LIBRARY_PATH") "")))
581 (setenv "CROSS_C_INCLUDE_PATH"
582 (string-append (assoc-ref outputs "out")
583 "/propeller-elf/include:"
584 (or (getenv "CROSS_C_INCLUDE_PATH") "")))
585 #t))
791cfa67 586 (add-before 'install 'install-includes
0d0079b2 587 (lambda* (#:key make-flags #:allow-other-keys)
791cfa67 588 (zero? (apply system* "make" "install-includes" make-flags)))))))
0d0079b2
RW
589 (native-inputs
590 `(("propeller-gcc" ,propeller-gcc)
591 ("propeller-binutils" ,propeller-binutils)
592 ("perl" ,perl)))
791cfa67 593 (home-page "https://github.com/parallaxinc/propgcc")
0d0079b2
RW
594 (synopsis "C library for the Parallax Propeller")
595 (description "This is a C library for the Parallax Propeller
596micro-controller.")
597 ;; Most of the code is released under the Expat license. Some of the
598 ;; included code is public domain and some changes are BSD licensed.
599 (license license:expat))))
600
eb88fbaf
RW
601(define-public propeller-toolchain
602 (package
603 (name "propeller-toolchain")
604 (version (package-version propeller-gcc))
605 (source #f)
606 (build-system trivial-build-system)
607 (arguments '(#:builder (mkdir %output)))
608 (propagated-inputs
609 `(("binutils" ,propeller-binutils)
610 ("libc" ,proplib)
611 ("gcc" ,propeller-gcc)))
612 (synopsis "Complete GCC tool chain for Propeller micro-controllers")
613 (description "This package provides a complete GCC tool chain for
614Propeller micro-controller development.")
615 (home-page (package-home-page propeller-gcc))
616 (license (package-license propeller-gcc))))
617
150e0a1e
RW
618(define-public openspin
619 (package
620 (name "openspin")
621 (version "1.00.78")
622 (source (origin
623 (method url-fetch)
624 (uri (string-append "https://github.com/parallaxinc/"
625 "OpenSpin/archive/" version ".tar.gz"))
626 (file-name (string-append name "-" version ".tar.gz"))
627 (sha256
628 (base32
629 "1k2dbz1v604g4r2d9qhckg2m8dnhiya760mbsqfsg4waxal87yb7"))))
630 (build-system gnu-build-system)
631 (arguments
632 `(#:tests? #f ; no tests
633 #:phases
634 (modify-phases %standard-phases
635 (delete 'configure)
636 (add-after 'unpack 'remove-timestamp
637 (lambda _
638 (substitute* "SpinSource/openspin.cpp"
639 ((" Compiled on.*$") "\\n\");"))
640 #t))
641 ;; Makefile does not include "install" target
642 (replace 'install
643 (lambda* (#:key outputs #:allow-other-keys)
644 (let ((bin (string-append (assoc-ref outputs "out")
645 "/bin")))
646 (mkdir-p bin)
647 (install-file "build/openspin" bin)
648 #t))))))
649 (home-page "https://github.com/parallaxinc/OpenSpin")
650 (synopsis "Spin/PASM compiler for the Parallax Propeller")
651 (description "OpenSpin is a compiler for the Spin/PASM language of the
652Parallax Propeller. It was ported from Chip Gracey's original x86 assembler
653code.")
654 (license license:expat)))
655
c6b96af7 656(define-public propeller-load
791cfa67
RW
657 (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
658 (revision "2"))
c6b96af7
RW
659 (package
660 (name "propeller-load")
661 (version "3.4.0")
662 (source (origin
663 (method git-fetch)
664 (uri (git-reference
791cfa67 665 (url "https://github.com/parallaxinc/propgcc.git")
c6b96af7
RW
666 (commit commit)))
667 (file-name (string-append name "-" commit "-checkout"))
668 (sha256
669 (base32
791cfa67 670 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
c6b96af7
RW
671 (build-system gnu-build-system)
672 (arguments
673 `(#:tests? #f ; no tests
674 #:make-flags
675 (list "OS=linux"
676 (string-append "TARGET=" (assoc-ref %outputs "out")))
677 #:phases
678 (modify-phases %standard-phases
791cfa67
RW
679 (add-after 'unpack 'chdir
680 (lambda _ (chdir "loader") #t))
c6b96af7
RW
681 (delete 'configure))))
682 (native-inputs
683 `(("openspin" ,openspin)
684 ("propeller-toolchain" ,propeller-toolchain)))
791cfa67 685 (home-page "https://github.com/parallaxinc/propgcc")
c6b96af7
RW
686 (synopsis "Loader for Parallax Propeller micro-controllers")
687 (description "This package provides the tool @code{propeller-load} to
688upload binaries to a Parallax Propeller micro-controller.")
689 (license license:expat))))
690
0a7860c4
RW
691(define-public spin2cpp
692 (package
693 (name "spin2cpp")
9fc7cc31 694 (version "3.6.3")
0a7860c4
RW
695 (source (origin
696 (method url-fetch)
697 (uri (string-append "https://github.com/totalspectrum/spin2cpp/"
698 "archive/v" version ".tar.gz"))
699 (file-name (string-append name "-" version ".tar.gz"))
700 (sha256
701 (base32
9fc7cc31 702 "0v5vzh69bp1r2byrpz12rql1w24ff2v9msr31596zq6hd6n82lnh"))))
0a7860c4
RW
703 (build-system gnu-build-system)
704 (arguments
705 `(#:tests? #f ;; The tests assume that a micro-controller is connected.
706 #:phases
707 (modify-phases %standard-phases
708 (delete 'configure)
709 (add-before 'build 'set-cross-environment-variables
710 (lambda* (#:key inputs #:allow-other-keys)
711 (setenv "CROSS_LIBRARY_PATH"
712 (string-append (assoc-ref inputs "propeller-toolchain")
713 "/propeller-elf/lib"))
714 (setenv "CROSS_C_INCLUDE_PATH"
715 (string-append (assoc-ref inputs "propeller-toolchain")
716 "/propeller-elf/include"))
717 #t))
718 (replace 'install
719 (lambda* (#:key outputs #:allow-other-keys)
720 (let ((bin (string-append (assoc-ref outputs "out")
721 "/bin")))
722 (for-each (lambda (file)
723 (install-file (string-append "build/" file)
724 bin))
725 '("testlex" "spin2cpp" "fastspin")))
726 #t)))))
727 (native-inputs
728 `(("bison" ,bison)
729 ("propeller-load" ,propeller-load)
730 ("propeller-toolchain" ,propeller-toolchain)))
731 (home-page "https://github.com/totalspectrum/spin2cpp")
732 (synopsis "Convert Spin code to C, C++, or PASM code")
733 (description "This is a set of tools for converting the Spin language for
734the Parallax Propeller micro-controller into C or C++ code, into PASM, or even
735directly into an executable binary. The binaries produced use LMM PASM, so
736they are much faster than regular Spin bytecodes (but also quite a bit
737larger).")
738 (license license:expat)))
739
3ebc86d9
RW
740(define-public spinsim
741 (let ((commit "66915a7ad1a3a2cf990a725bb341fab8d11eb620")
742 (revision "1"))
743 (package
744 (name "spinsim")
745 (version (string-append "0.75-" revision "." (string-take commit 9)))
746 (source (origin
747 (method git-fetch)
748 (uri (git-reference
749 (url "https://github.com/parallaxinc/spinsim.git")
750 (commit commit)))
751 (file-name (string-append name "-" commit "-checkout"))
752 (sha256
753 (base32
754 "1n9kdhlxsdx7bz6c80w8dhi96zp633gd6qs0x9i4ii8qv4i7sj5k"))))
755 (build-system gnu-build-system)
756 (arguments
757 `(#:tests? #f ; no tests
758 #:phases
759 (modify-phases %standard-phases
760 (delete 'configure)
761 (replace 'install
762 (lambda* (#:key outputs #:allow-other-keys)
763 (let ((bin (string-append (assoc-ref outputs "out")
764 "/bin")))
765 (install-file "build/spinsim" bin))
766 #t)))))
767 (home-page "https://github.com/parallaxinc/spinsim")
768 (synopsis "Spin simulator")
769 (description "This package provides the tool @code{spinsim}, a simulator
770and simple debugger for Spin programs written for a Parallax Propeller
771micro-controller. Spinsim supports execution from cog memory and hub
772execution, but it does not support multi-tasking. It supports about
773two-thirds of the opcodes in the P2 instruction set.")
774 (license license:expat))))
775
395bbfdb
RW
776(define-public propeller-development-suite
777 (package
778 (name "propeller-development-suite")
779 (version (package-version propeller-gcc))
780 (source #f)
781 (build-system trivial-build-system)
782 (arguments '(#:builder (mkdir %output)))
783 (propagated-inputs
784 `(("toolchain" ,propeller-toolchain)
785 ("openspin" ,openspin)
786 ("propeller-load" ,propeller-load)
787 ("spin2cpp" ,spin2cpp)
788 ("spinsim" ,spinsim)))
789 (synopsis "Complete development suite for Propeller micro-controllers")
790 (description "This meta-package provides a complete environment for the
791development with Parallax Propeller micro-controllers. It includes the GCC
792toolchain, the loader, the Openspin compiler, the Spin2cpp tool, and the Spin
793simulator.")
794 (home-page (package-home-page propeller-gcc))
795 (license (package-license propeller-gcc))))
8ea42482
DM
796
797(define-public binutils-vc4
798 (let ((commit "708acc851880dbeda1dd18aca4fd0a95b2573b36"))
799 (package
800 (name "binutils-vc4")
801 (version (string-append "2.23.51-0." (string-take commit 7)))
802 (source (origin
803 (method git-fetch)
804 (uri (git-reference
805 (url "https://github.com/puppeh/binutils-vc4.git")
806 (commit commit)))
493ae57e 807 (file-name (string-append name "-" version "-checkout"))
8ea42482
DM
808 (sha256
809 (base32
810 "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"))))
811 (build-system gnu-build-system)
812 (arguments
813 `(#:configure-flags '("--target=vc4-elf"
814 "--disable-werror"
815 "--enable-cgen-maint")
816 #:phases
817 (modify-phases %standard-phases
818 (add-after 'unpack 'unpack-cgen
819 (lambda* (#:key inputs #:allow-other-keys)
820 (copy-recursively (string-append (assoc-ref inputs "cgen")
821 "/cgen") "cgen")
822 #t))
823 (add-after 'unpack-cgen 'fix-cgen-guile
824 (lambda _
825 (substitute* "opcodes/Makefile.in"
826 (("guile\\{,-\\}1.8") "guile"))
827 (zero? (system* "which" "guile")))))))
828 (native-inputs
829 `(("cgen"
830 ,(origin
831 (method git-fetch)
832 (uri (git-reference
833 (url "https://github.com/puppeh/cgen.git")
834 (commit "d8e2a9eb70425f180fdd5bfd032884b0855f2032")))
835 (sha256
836 (base32
837 "14b3h2ji740s8zq5vwm4qdcxs4aa4wxi6wb9di3bv1h39x14nyr9"))))
838 ("texinfo" ,texinfo)
5e54f4ad 839 ("flex" ,flex)
8ea42482
DM
840 ("bison" ,bison)
841 ("guile-1.8" ,guile-1.8)
842 ("which" ,base:which)))
843 (synopsis "Binutils for VC4")
844 (description "This package provides @code{binutils} for VideoCore IV,
845the Raspberry Pi chip.")
846 (license license:gpl3+)
847 (home-page "https://github.com/puppeh/vc4-toolchain/"))))
7cf06d62
DM
848
849(define-public gcc-vc4
850 (let ((commit "165f6d0e11d2e76ee799533bb45bd5c92bf60dc2")
7b3318e3 851 (xgcc (cross-gcc "vc4-elf" #:xbinutils binutils-vc4)))
7cf06d62
DM
852 (package (inherit xgcc)
853 (name "gcc-vc4")
854 (source (origin
855 (method git-fetch)
856 (uri (git-reference
857 (url "https://github.com/puppeh/gcc-vc4.git")
858 (commit commit)))
859 (file-name (string-append name
860 "-"
861 (package-version xgcc)
862 "-checkout"))
863 (sha256
864 (base32
865 "13h30qjcwnlz6lfma1d82nnvfmjnhh7abkagip4vly6vm5fpnvf2"))))
866 (native-inputs
867 `(("flex" ,flex)
868 ,@(package-native-inputs xgcc)))
869 (synopsis "GCC for VC4")
870 (description "This package provides @code{gcc} for VideoCore IV,
871the Raspberry Pi chip."))))
1a6497de
DM
872
873(define-public python2-libmpsse
874 (package
875 (name "python2-libmpsse")
876 (version "1.3")
877 (source
878 (origin
879 (method url-fetch)
880 (uri (string-append "https://storage.googleapis.com/"
881 "google-code-archive-downloads/v2/"
882 "code.google.com/libmpsse/"
883 "libmpsse-" version ".tar.gz"))
884 (sha256
885 (base32
886 "0jq7nhqq3na8675jnpfcar3pd3dp3adhhc4lw900swkla01a1wh8"))))
887 (build-system gnu-build-system)
888 (inputs
889 `(("libftdi" ,libftdi)
890 ("python" ,python-2)))
891 (native-inputs
892 `(("pkg-config" ,pkg-config)
893 ("swig" ,swig)
894 ("which" ,base:which)))
895 (arguments
896 `(#:tests? #f ; No tests exist.
897 #:make-flags
898 (list (string-append "CFLAGS=-Wall -fPIC -fno-strict-aliasing -g -O2 "
899 "$(shell pkg-config --cflags libftdi1)"))
900 #:phases
901 (modify-phases %standard-phases
902 (add-after 'unpack 'set-environment-up
903 (lambda* (#:key inputs outputs #:allow-other-keys)
904 (chdir "src")
905 (setenv "PYDEV" (string-append (assoc-ref inputs "python")
906 "/include/python2.7"))
907 #t))
908 (add-after 'unpack 'patch-global-variable
909 (lambda _
910 ;; fast_rw_buf was defined in a header file which was making
911 ;; the build not reproducible.
912 (substitute* "src/fast.c"
913 (("^int fast_build_block_buffer") "
914
915unsigned char fast_rw_buf[SPI_RW_SIZE + CMD_SIZE];
916int fast_build_block_buffer"))
917 (substitute* "src/mpsse.h"
918 (("unsigned char fast_rw_buf.*") "
919"))
920 #t))
921 (replace 'install
922 (lambda* (#:key outputs make-flags #:allow-other-keys #:rest args)
923 (let* ((out (assoc-ref outputs "out"))
924 (out-python (string-append out
925 "/lib/python2.7/site-packages"))
926 (install (assoc-ref %standard-phases 'install)))
927 (install #:make-flags (cons (string-append "PYLIB=" out-python)
928 make-flags))))))))
929 (home-page "https://code.google.com/archive/p/libmpsse/")
930 (synopsis "Python library for MPSSE SPI I2C JTAG adapter by FTDI")
931 (description "This package provides a library in order to support the
932MPSSE (Multi-Protocol Synchronous Serial Engine) adapter by FTDI that can do
933SPI, I2C, JTAG.")
934 (license license:gpl2+)))
981bccf1
DM
935
936(define-public picprog
937 (package
938 (name "picprog")
939 (version "1.9.1")
940 (source (origin
941 (method url-fetch)
942 (uri (string-append "http://www.iki.fi/hyvatti/pic/picprog-"
943 version ".tar.gz"))
944 (file-name (string-append name "-" version ".tar.gz"))
945 (sha256
946 (base32
947 "1r04hg1n3v2jf915qr05la3q9cxy7a5jnh9cc98j04lh6c9p4x85"))))
948 (build-system gnu-build-system)
949 (arguments
950 `(#:tests? #f ; No tests exist.
951 #:phases
952 (modify-phases %standard-phases
953 (add-after 'unpack 'patch-paths
954 (lambda* (#:key outputs #:allow-other-keys)
955 (substitute* "Makefile"
956 (("/usr/local") (assoc-ref outputs "out"))
957 ((" -o 0 -g 0 ") " "))
958 #t))
959 (add-before 'install 'mkdir
960 (lambda* (#:key outputs #:allow-other-keys)
961 (let ((out (assoc-ref outputs "out")))
962 (mkdir-p (string-append out "/bin"))
963 (mkdir-p (string-append out "/man/man1"))
964 #t)))
965 (delete 'configure))))
966 (synopsis "Programs Microchip's PIC microcontrollers")
967 (description "This program programs Microchip's PIC microcontrollers.")
968 (home-page "http://hyvatti.iki.fi/~jaakko/pic/picprog.html")
969 (license license:gpl3+)))