gnu: Fetch several Git sources over HTTPS.
[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>
dbc3c34e 3;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.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)
7894ea61
LC
45 #:use-module (gnu packages texinfo)
46 #:use-module (srfi srfi-1))
35a37efb
RW
47
48;; We must not use the released GCC sources here, because the cross-compiler
49;; does not produce working binaries. Instead we take the very same SVN
50;; revision from the branch that is used for a release of the "GCC ARM
51;; embedded" project on launchpad.
52;; See https://launchpadlibrarian.net/218827644/release.txt
53(define-public gcc-arm-none-eabi-4.9
54 (let ((xgcc (cross-gcc "arm-none-eabi"
7b3318e3
RW
55 #:xgcc gcc-4.9
56 #:xbinutils (cross-binutils "arm-none-eabi")))
35a37efb
RW
57 (revision "1")
58 (svn-revision 227977))
59 (package (inherit xgcc)
60 (version (string-append (package-version xgcc) "-"
61 revision "." (number->string svn-revision)))
62 (source
63 (origin
64 (method svn-fetch)
65 (uri (svn-reference
66 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
67 (revision svn-revision)))
68 (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
69 (sha256
70 (base32
71 "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
7894ea61
LC
72
73 ;; Remove the one patch that doesn't apply to this 4.9 snapshot (the
74 ;; patch is for 4.9.4 and later but this svn snapshot is older).
75 (patches (remove (lambda (patch)
76 (string=? (basename patch)
77 "gcc-arm-bug-71399.patch"))
78 (origin-patches (package-source xgcc))))))
35a37efb
RW
79 (native-inputs
80 `(("flex" ,flex)
81 ,@(package-native-inputs xgcc)))
82 (arguments
83 (substitute-keyword-arguments (package-arguments xgcc)
84 ((#:phases phases)
85 `(modify-phases ,phases
86 (add-after 'unpack 'fix-genmultilib
87 (lambda _
88 (substitute* "gcc/genmultilib"
89 (("#!/bin/sh") (string-append "#!" (which "sh"))))
90 #t))))
91 ((#:configure-flags flags)
92 ;; The configure flags are largely identical to the flags used by the
93 ;; "GCC ARM embedded" project.
94 `(append (list "--enable-multilib"
95 "--with-newlib"
96 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
97 "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
98 "--enable-plugins"
99 "--disable-decimal-float"
100 "--disable-libffi"
101 "--disable-libgomp"
102 "--disable-libmudflap"
103 "--disable-libquadmath"
104 "--disable-libssp"
105 "--disable-libstdcxx-pch"
106 "--disable-nls"
107 "--disable-shared"
108 "--disable-threads"
109 "--disable-tls")
110 (delete "--disable-multilib" ,flags)))))
111 (native-search-paths
112 (list (search-path-specification
113 (variable "CROSS_C_INCLUDE_PATH")
114 (files '("arm-none-eabi/include")))
115 (search-path-specification
116 (variable "CROSS_CPLUS_INCLUDE_PATH")
117 (files '("arm-none-eabi/include")))
118 (search-path-specification
119 (variable "CROSS_LIBRARY_PATH")
120 (files '("arm-none-eabi/lib"))))))))
6c39886a 121
dbc3c34e
TF
122(define-public gcc-arm-none-eabi-6
123 (package
124 (inherit gcc-arm-none-eabi-4.9)
125 (version (package-version gcc-6))
126 (source (origin (inherit (package-source gcc-6))
127 (patches
128 (append
129 (origin-patches (package-source gcc-6))
130 (search-patches "gcc-6-cross-environment-variables.patch"
131 "gcc-6-arm-none-eabi-multilib.patch")))))))
132
6c39886a
RW
133(define-public newlib-arm-none-eabi
134 (package
135 (name "newlib")
136 (version "2.4.0")
137 (source (origin
138 (method url-fetch)
139 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
140 version ".tar.gz"))
141 (sha256
142 (base32
143 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
144 (build-system gnu-build-system)
145 (arguments
146 `(#:out-of-source? #t
147 ;; The configure flags are identical to the flags used by the "GCC ARM
148 ;; embedded" project.
149 #:configure-flags '("--target=arm-none-eabi"
150 "--enable-newlib-io-long-long"
151 "--enable-newlib-register-fini"
152 "--disable-newlib-supplied-syscalls"
153 "--disable-nls")
154 #:phases
155 (modify-phases %standard-phases
156 (add-after 'unpack 'fix-references-to-/bin/sh
157 (lambda _
158 (substitute* '("libgloss/arm/cpu-init/Makefile.in"
159 "libgloss/arm/Makefile.in"
160 "libgloss/libnosys/Makefile.in"
161 "libgloss/Makefile.in")
162 (("/bin/sh") (which "sh")))
163 #t)))))
164 (native-inputs
165 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
166 ("xgcc" ,gcc-arm-none-eabi-4.9)
167 ("texinfo" ,texinfo)))
168 (home-page "http://www.sourceware.org/newlib/")
169 (synopsis "C library for use on embedded systems")
170 (description "Newlib is a C library intended for use on embedded
171systems. It is a conglomeration of several library parts that are easily
172usable on embedded products.")
173 (license (license:non-copyleft
174 "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
a299a899
RW
175
176(define-public newlib-nano-arm-none-eabi
177 (package (inherit newlib-arm-none-eabi)
178 (name "newlib-nano")
179 (arguments
180 (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
181 ;; The configure flags are identical to the flags used by the "GCC ARM
182 ;; embedded" project. They optimize newlib for use on small embedded
183 ;; systems with limited memory.
184 ((#:configure-flags flags)
185 ''("--target=arm-none-eabi"
186 "--enable-multilib"
187 "--disable-newlib-supplied-syscalls"
188 "--enable-newlib-reent-small"
189 "--disable-newlib-fvwrite-in-streamio"
190 "--disable-newlib-fseek-optimization"
191 "--disable-newlib-wide-orient"
192 "--enable-newlib-nano-malloc"
193 "--disable-newlib-unbuf-stream-opt"
194 "--enable-lite-exit"
195 "--enable-newlib-global-atexit"
196 "--enable-newlib-nano-formatted-io"
197 "--disable-nls"))))
198 (synopsis "Newlib variant for small systems with limited memory")))
569f6016 199
1a1e8336
RW
200(define (make-libstdc++-arm-none-eabi xgcc newlib)
201 (let ((libstdc++ (make-libstdc++ xgcc)))
202 (package (inherit libstdc++)
203 (name "libstdc++-arm-none-eabi")
204 (arguments
205 (substitute-keyword-arguments (package-arguments libstdc++)
206 ((#:configure-flags flags)
207 ``("--target=arm-none-eabi"
208 "--host=arm-none-eabi"
209 "--disable-libstdcxx-pch"
210 "--enable-multilib"
211 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
212 "--disable-shared"
213 "--disable-tls"
214 "--disable-plugin"
215 "--with-newlib"
216 ,(string-append "--with-gxx-include-dir="
217 (assoc-ref %outputs "out")
218 "/arm-none-eabi/include")))))
219 (native-inputs
220 `(("newlib" ,newlib)
221 ("xgcc" ,xgcc)
222 ,@(package-native-inputs libstdc++))))))
223
569f6016
TF
224(define (arm-none-eabi-toolchain xgcc newlib)
225 "Produce a cross-compiler toolchain package with the compiler XGCC and the C
226library variant NEWLIB."
227 (let ((newlib-with-xgcc (package (inherit newlib)
228 (native-inputs
229 (alist-replace "xgcc" (list xgcc)
230 (package-native-inputs newlib))))))
231 (package
232 (name (string-append "arm-none-eabi"
233 (if (string=? (package-name newlib-with-xgcc)
234 "newlib-nano")
235 "-nano" "")
236 "-toolchain"))
237 (version (package-version xgcc))
238 (source #f)
239 (build-system trivial-build-system)
9cdf4872
RW
240 (arguments
241 '(#:modules ((guix build union))
242 #:builder
243 (begin
244 (use-modules (ice-9 match)
245 (guix build union))
246 (match %build-inputs
247 (((names . directories) ...)
248 (union-build (assoc-ref %outputs "out")
249 directories))))))
569f6016
TF
250 (propagated-inputs
251 `(("binutils" ,(cross-binutils "arm-none-eabi"))
8ea169d0 252 ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
569f6016
TF
253 ("gcc" ,xgcc)
254 ("newlib" ,newlib-with-xgcc)))
255 (synopsis "Complete GCC tool chain for ARM bare metal development")
256 (description "This package provides a complete GCC tool chain for ARM
257bare metal development. This includes the GCC arm-none-eabi cross compiler
258and newlib (or newlib-nano) as the C library. The supported programming
259languages are C and C++.")
260 (home-page (package-home-page xgcc))
261 (license (package-license xgcc)))))
262
263(define-public arm-none-eabi-toolchain-4.9
264 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
265 newlib-arm-none-eabi))
266
267(define-public arm-none-eabi-nano-toolchain-4.9
268 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
269 newlib-nano-arm-none-eabi))
270
271(define-public arm-none-eabi-toolchain-6
272 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
273 newlib-arm-none-eabi))
274
275(define-public arm-none-eabi-nano-toolchain-6
276 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
277 newlib-nano-arm-none-eabi))
94f36a4f
TF
278
279(define-public gdb-arm-none-eabi
280 (package
281 (inherit gdb)
282 (name "gdb-arm-none-eabi")
283 (arguments
284 `(#:configure-flags '("--target=arm-none-eabi"
285 "--enable-multilib"
286 "--enable-interwork"
287 "--enable-languages=c,c++"
288 "--disable-nls")
289 ,@(package-arguments gdb)))))
e5e45c06
DC
290
291(define-public libjaylink
292 ;; No release tarballs available.
293 (let ((commit "faa2a433fdd3de211728f3da5921133214af9dd3")
294 (revision "1"))
295 (package
296 (name "libjaylink")
297 (version (string-append "0.1.0-" revision "."
298 (string-take commit 7)))
299 (source (origin
300 (method git-fetch)
301 (uri (git-reference
5f13bf09 302 (url "https://git.zapb.de/libjaylink.git")
e5e45c06
DC
303 (commit commit)))
304 (file-name (string-append name "-" version "-checkout"))
305 (sha256
306 (base32
307 "02crr56csz8whq3q4mrmdzzgwp5b0qvxm0fb18drclc3zj44yxl2"))))
308 (build-system gnu-build-system)
309 (native-inputs
310 `(("autoconf" ,autoconf)
311 ("automake" ,automake)
312 ("libtool" ,libtool)
313 ("pkg-config" ,pkg-config)))
314 (inputs
315 `(("libusb" ,libusb)))
316 (arguments
317 `(#:phases
318 (modify-phases %standard-phases
319 (add-before 'configure 'autoreconf
320 (lambda _
321 (zero? (system* "autoreconf" "-vfi")))))))
322 (home-page "http://repo.or.cz/w/libjaylink.git")
323 (synopsis "Library to interface Segger J-Link devices")
324 (description "libjaylink is a shared library written in C to access
325SEGGER J-Link and compatible devices.")
326 (license license:gpl2+))))
91ba6935
DC
327
328(define-public jimtcl
329 (package
330 (name "jimtcl")
331 (version "0.77")
332 (source (origin
333 (method url-fetch)
334 (uri (string-append
335 "https://github.com/msteveb/jimtcl"
336 "/archive/" version ".tar.gz"))
337 (file-name (string-append name "-" version ".tar.gz"))
338 (sha256
339 (base32
340 "1cmk3qscqckg70chjyimzxa2qcka4qac0j4wq908kiijp45cax08"))))
341 (build-system gnu-build-system)
342 (arguments
343 `(#:phases
344 (modify-phases %standard-phases
345 ;; Doesn't use autoconf.
346 (replace 'configure
347 (lambda* (#:key outputs #:allow-other-keys)
348 (let ((out (assoc-ref outputs "out")))
349 (zero? (system* "./configure"
350 (string-append "--prefix=" out)))))))))
351 (home-page "http://jim.tcl.tk")
352 (synopsis "Small footprint Tcl implementation")
353 (description "Jim is a small footprint implementation of the Tcl programming
354language.")
355 (license license:bsd-2)))
5b83b7b8
TF
356
357(define-public openocd
358 ;; FIXME: Use tarball release after nrf52 patch is merged.
359 (let ((commit "674141e8a7a6413cb803d90c2a20150260015f81")
360 (revision "1"))
361 (package
362 (name "openocd")
363 (version (string-append "0.9.0-" revision "."
364 (string-take commit 7)))
365 (source (origin
366 (method git-fetch)
367 (uri (git-reference
5f13bf09 368 (url "https://git.code.sf.net/p/openocd/code.git")
5b83b7b8
TF
369 (commit commit)))
370 (sha256
371 (base32
372 "1i86jp0wawq78d73z8hp7q1pn7lmlvhjjr19f7299h4w40a5jf8j"))
373 (file-name (string-append name "-" version "-checkout"))
374 (patches
375 (search-patches "openocd-nrf52.patch"))))
376 (build-system gnu-build-system)
377 (native-inputs
378 `(("autoconf" ,autoconf)
379 ("automake" ,automake)
380 ("libtool" ,libtool)
381 ("pkg-config" ,pkg-config)))
382 (inputs
383 `(("hidapi" ,hidapi)
384 ("jimtcl" ,jimtcl)
385 ("libftdi" ,libftdi)
386 ("libjaylink" ,libjaylink)
387 ("libusb-compat" ,libusb-compat)))
388 (arguments
389 '(#:configure-flags
390 (append (list "--disable-werror"
391 "--disable-internal-jimtcl"
392 "--disable-internal-libjaylink")
393 (map (lambda (programmer)
394 (string-append "--enable-" programmer))
395 '("amtjtagaccel" "armjtagew" "buspirate" "ftdi"
396 "gw16012" "jlink" "oocd_trace" "opendous" "osbdm"
397 "parport" "aice" "cmsis-dap" "dummy" "jtag_vpi"
398 "remote-bitbang" "rlink" "stlink" "ti-icdi" "ulink"
399 "usbprog" "vsllink" "usb-blaster-2" "usb_blaster"
400 "presto" "openjtag")))
401 #:phases
402 (modify-phases %standard-phases
403 (add-before 'configure 'autoreconf
404 (lambda _
405 (zero? (system* "autoreconf" "-vfi")))))))
406 (home-page "http://openocd.org")
407 (synopsis "On-Chip Debugger")
408 (description "OpenOCD provides on-chip programming and debugging support
409with a layered architecture of JTAG interface and TAP support.")
6d1b3bf5 410 (license license:gpl2+))))
2d7c9213
RW
411
412;; The commits for all propeller tools are the latest versions as published
413;; here: https://github.com/dbetz/propeller-gcc
414
415(define propeller-binutils
416 (let ((xbinutils (cross-binutils "propeller-elf"))
417 (commit "3bfba30076f8ce160a2f42914fdb68f24445fd44")
418 (revision "1"))
419 (package
420 (inherit xbinutils)
421 (name "propeller-binutils")
422 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
423 (source (origin (inherit (package-source xbinutils))
424 (method git-fetch)
425 (uri (git-reference
426 (url "https://github.com/totalspectrum/binutils-propeller.git")
427 (commit commit)))
428 (file-name (string-append name "-" commit "-checkout"))
429 (sha256
430 (base32
431 "1v3rgxwj7b8817wy5ccf8621v75qcxvcxygk4acr3hbc6yqybr8h"))))
432 (arguments
433 `(;; FIXME: For some reason there are many test failures. Some of them
434 ;; appear to be due to regular expression mismatch, but it's not
435 ;; obvious how to fix the failures.
436 #:tests? #f
437 #:phases
438 (modify-phases %standard-phases
439 (add-after 'unpack 'patch-/bin/sh-in-tests
440 (lambda _
441 (substitute* '("sim/testsuite/Makefile.in"
442 "sim/testsuite/mips64el-elf/Makefile.in"
443 "sim/testsuite/d10v-elf/Makefile.in"
444 "sim/testsuite/sim/cris/asm/badarch1.ms")
445 (("/bin/sh") (which "sh")))
446 #t)))
447 ,@(package-arguments xbinutils)))
448 (native-inputs
449 `(("bison" ,bison)
5e54f4ad 450 ("flex" ,flex)
2d7c9213
RW
451 ("texinfo" ,texinfo)
452 ("dejagnu" ,dejagnu)
453 ,@(package-native-inputs xbinutils))))))
454
bb19b2eb 455(define-public propeller-gcc-6
68cb2784 456 (let ((xgcc (cross-gcc "propeller-elf"
7b3318e3 457 #:xbinutils propeller-binutils))
68cb2784
RW
458 (commit "b4f45a4725e0b6d0af59e594c4e3e35ca4105867")
459 (revision "1"))
460 (package (inherit xgcc)
461 (name "propeller-gcc")
462 (version (string-append "6.0.0-" revision "." (string-take commit 9)))
463 (source (origin
464 (method git-fetch)
465 (uri (git-reference
466 (url "https://github.com/totalspectrum/gcc-propeller.git")
467 (commit commit)))
468 (file-name (string-append name "-" commit "-checkout"))
469 (sha256
470 (base32
471 "0d9kdxm2fzanjqa7q5850kzbsfl0fqyaahxn74h6nkxxacwa11zb"))
472 (patches
473 (append
474 (origin-patches (package-source gcc-6))
475 (search-patches "gcc-cross-environment-variables.patch")))))
476 (native-inputs
477 `(("flex" ,flex)
478 ,@(package-native-inputs xgcc)))
479 ;; All headers and cross libraries of the propeller toolchain are
480 ;; installed under the "propeller-elf" prefix.
481 (native-search-paths
482 (list (search-path-specification
483 (variable "CROSS_C_INCLUDE_PATH")
484 (files '("propeller-elf/include")))
485 (search-path-specification
486 (variable "CROSS_LIBRARY_PATH")
487 (files '("propeller-elf/lib")))))
488 (home-page "https://github.com/totalspectrum/gcc-propeller")
489 (synopsis "GCC for the Parallax Propeller"))))
490
db90eb8c 491(define-public propeller-gcc-4
bb19b2eb 492 (let ((xgcc propeller-gcc-6)
db90eb8c
RW
493 (commit "f1b01001b760d691a91ff1db4830d41bb712557f")
494 (revision "1"))
495 (package (inherit xgcc)
496 (name "propeller-gcc")
497 (version (string-append "4.6.1-" revision "." (string-take commit 9)))
498 (source (origin
499 (method git-fetch)
500 (uri (git-reference
501 (url "https://github.com/dbetz/propgcc-gcc.git")
502 (commit commit)))
503 (file-name (string-append name "-" commit "-checkout"))
504 (sha256
505 (base32
506 "15mxrhk2v4vqmdkvcqy33ag1wrg9x9q20kx2w33kkw8pkrijknbi"))
507 (patches
508 (append
509 (origin-patches (package-source gcc-4.7))
1d3be5d9
RW
510 (search-patches "gcc-4.6-gnu-inline.patch"
511 "gcc-cross-environment-variables.patch")))))
57e96e48
EF
512 (home-page "https://github.com/dbetz/propgcc-gcc")
513 (supported-systems (delete "aarch64-linux" %supported-systems)))))
db90eb8c 514
bb19b2eb
RW
515;; Version 6 is experimental and may not work correctly. This is why we
516;; default to version 4, which is also used in the binary toolchain bundle
517;; provided by Parallax Inc.
518(define-public propeller-gcc propeller-gcc-4)
519
0d0079b2
RW
520;; There is no release, so we take the latest version as referenced from here:
521;; https://github.com/dbetz/propeller-gcc
522(define-public proplib
523 (let ((commit "844741fe0ceb140ab2fdf9d0667f68c1c39c31da")
524 (revision "1"))
525 (package
526 (name "proplib")
527 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
528 (source (origin
529 (method git-fetch)
530 (uri (git-reference
531 (url "https://github.com/totalspectrum/proplib.git")
532 (commit commit)))
533 (file-name (string-append name "-" commit "-checkout"))
534 (sha256
535 (base32
536 "0q7irf1x8iqx07n7lzksax9armrdkizs49swsz76nbks0mw67wiv"))))
537 (build-system gnu-build-system)
538 (arguments
539 `(#:tests? #f ; no tests
540 #:make-flags
541 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
542 (string-append "BUILD=" (getcwd) "/build"))
543 #:phases
544 (modify-phases %standard-phases
545 (delete 'configure)
546 (add-after 'unpack 'fix-Makefile
547 (lambda _
548 (substitute* "Makefile"
549 ;; The GCC sources are not part of this package, so we cannot
550 ;; install the out-of-tree license file.
551 (("cp \\.\\..*") "")
552 ;; Control the installation time of the headers.
553 ((" install-includes") ""))
554 #t))
555 ;; The Makefile does not separate building from installation, so we
556 ;; have to create the target directories at build time.
557 (add-before 'build 'create-target-directories
558 (lambda* (#:key make-flags #:allow-other-keys)
559 (zero? (apply system* "make" "install-dirs" make-flags))))
560 (add-before 'build 'set-cross-environment-variables
561 (lambda* (#:key outputs #:allow-other-keys)
562 (setenv "CROSS_LIBRARY_PATH"
563 (string-append (assoc-ref outputs "out")
564 "/propeller-elf/lib:"
565 (or (getenv "CROSS_LIBRARY_PATH") "")))
566 (setenv "CROSS_C_INCLUDE_PATH"
567 (string-append (assoc-ref outputs "out")
568 "/propeller-elf/include:"
569 (or (getenv "CROSS_C_INCLUDE_PATH") "")))
570 #t))
571 (add-after 'build 'build-tiny
572 (lambda* (#:key make-flags #:allow-other-keys)
573 (zero? (apply system* "make" "tiny" make-flags))))
574 ;; The build of the tiny libraries depends on the includes to be
575 ;; available. Since we set CROSS_C_INCLUDE_PATH to the output
576 ;; directory, we have to install the includes first.
577 (add-before 'build-tiny 'install-includes
578 (lambda* (#:key make-flags #:allow-other-keys)
579 (zero? (apply system* "make" "install-includes" make-flags))))
580 (add-after 'install 'install-tiny
581 (lambda* (#:key make-flags #:allow-other-keys)
582 (zero? (apply system* "make" "install-tiny" make-flags)))))))
583 (native-inputs
584 `(("propeller-gcc" ,propeller-gcc)
585 ("propeller-binutils" ,propeller-binutils)
586 ("perl" ,perl)))
587 (home-page "https://github.com/totalspectrum/proplib")
588 (synopsis "C library for the Parallax Propeller")
589 (description "This is a C library for the Parallax Propeller
590micro-controller.")
591 ;; Most of the code is released under the Expat license. Some of the
592 ;; included code is public domain and some changes are BSD licensed.
593 (license license:expat))))
594
eb88fbaf
RW
595(define-public propeller-toolchain
596 (package
597 (name "propeller-toolchain")
598 (version (package-version propeller-gcc))
599 (source #f)
600 (build-system trivial-build-system)
601 (arguments '(#:builder (mkdir %output)))
602 (propagated-inputs
603 `(("binutils" ,propeller-binutils)
604 ("libc" ,proplib)
605 ("gcc" ,propeller-gcc)))
606 (synopsis "Complete GCC tool chain for Propeller micro-controllers")
607 (description "This package provides a complete GCC tool chain for
608Propeller micro-controller development.")
609 (home-page (package-home-page propeller-gcc))
610 (license (package-license propeller-gcc))))
611
150e0a1e
RW
612(define-public openspin
613 (package
614 (name "openspin")
615 (version "1.00.78")
616 (source (origin
617 (method url-fetch)
618 (uri (string-append "https://github.com/parallaxinc/"
619 "OpenSpin/archive/" version ".tar.gz"))
620 (file-name (string-append name "-" version ".tar.gz"))
621 (sha256
622 (base32
623 "1k2dbz1v604g4r2d9qhckg2m8dnhiya760mbsqfsg4waxal87yb7"))))
624 (build-system gnu-build-system)
625 (arguments
626 `(#:tests? #f ; no tests
627 #:phases
628 (modify-phases %standard-phases
629 (delete 'configure)
630 (add-after 'unpack 'remove-timestamp
631 (lambda _
632 (substitute* "SpinSource/openspin.cpp"
633 ((" Compiled on.*$") "\\n\");"))
634 #t))
635 ;; Makefile does not include "install" target
636 (replace 'install
637 (lambda* (#:key outputs #:allow-other-keys)
638 (let ((bin (string-append (assoc-ref outputs "out")
639 "/bin")))
640 (mkdir-p bin)
641 (install-file "build/openspin" bin)
642 #t))))))
643 (home-page "https://github.com/parallaxinc/OpenSpin")
644 (synopsis "Spin/PASM compiler for the Parallax Propeller")
645 (description "OpenSpin is a compiler for the Spin/PASM language of the
646Parallax Propeller. It was ported from Chip Gracey's original x86 assembler
647code.")
648 (license license:expat)))
649
c6b96af7
RW
650(define-public propeller-load
651 (let ((commit "ba9c0a7251cf751d8d292ae19ffa03132097c0c0")
652 (revision "1"))
653 (package
654 (name "propeller-load")
655 (version "3.4.0")
656 (source (origin
657 (method git-fetch)
658 (uri (git-reference
659 (url "https://github.com/dbetz/propeller-load.git")
660 (commit commit)))
661 (file-name (string-append name "-" commit "-checkout"))
662 (sha256
663 (base32
664 "1qv3xaapl9fmj3zn58b60sprp4rnvnlpci8ci0pdrzkw6fhvx3pg"))))
665 (build-system gnu-build-system)
666 (arguments
667 `(#:tests? #f ; no tests
668 #:make-flags
669 (list "OS=linux"
670 (string-append "TARGET=" (assoc-ref %outputs "out")))
671 #:phases
672 (modify-phases %standard-phases
673 (delete 'configure))))
674 (native-inputs
675 `(("openspin" ,openspin)
676 ("propeller-toolchain" ,propeller-toolchain)))
677 (home-page "https://github.com/dbetz/propeller-load")
678 (synopsis "Loader for Parallax Propeller micro-controllers")
679 (description "This package provides the tool @code{propeller-load} to
680upload binaries to a Parallax Propeller micro-controller.")
681 (license license:expat))))
682
0a7860c4
RW
683(define-public spin2cpp
684 (package
685 (name "spin2cpp")
9fc7cc31 686 (version "3.6.3")
0a7860c4
RW
687 (source (origin
688 (method url-fetch)
689 (uri (string-append "https://github.com/totalspectrum/spin2cpp/"
690 "archive/v" version ".tar.gz"))
691 (file-name (string-append name "-" version ".tar.gz"))
692 (sha256
693 (base32
9fc7cc31 694 "0v5vzh69bp1r2byrpz12rql1w24ff2v9msr31596zq6hd6n82lnh"))))
0a7860c4
RW
695 (build-system gnu-build-system)
696 (arguments
697 `(#:tests? #f ;; The tests assume that a micro-controller is connected.
698 #:phases
699 (modify-phases %standard-phases
700 (delete 'configure)
701 (add-before 'build 'set-cross-environment-variables
702 (lambda* (#:key inputs #:allow-other-keys)
703 (setenv "CROSS_LIBRARY_PATH"
704 (string-append (assoc-ref inputs "propeller-toolchain")
705 "/propeller-elf/lib"))
706 (setenv "CROSS_C_INCLUDE_PATH"
707 (string-append (assoc-ref inputs "propeller-toolchain")
708 "/propeller-elf/include"))
709 #t))
710 (replace 'install
711 (lambda* (#:key outputs #:allow-other-keys)
712 (let ((bin (string-append (assoc-ref outputs "out")
713 "/bin")))
714 (for-each (lambda (file)
715 (install-file (string-append "build/" file)
716 bin))
717 '("testlex" "spin2cpp" "fastspin")))
718 #t)))))
719 (native-inputs
720 `(("bison" ,bison)
721 ("propeller-load" ,propeller-load)
722 ("propeller-toolchain" ,propeller-toolchain)))
723 (home-page "https://github.com/totalspectrum/spin2cpp")
724 (synopsis "Convert Spin code to C, C++, or PASM code")
725 (description "This is a set of tools for converting the Spin language for
726the Parallax Propeller micro-controller into C or C++ code, into PASM, or even
727directly into an executable binary. The binaries produced use LMM PASM, so
728they are much faster than regular Spin bytecodes (but also quite a bit
729larger).")
730 (license license:expat)))
731
3ebc86d9
RW
732(define-public spinsim
733 (let ((commit "66915a7ad1a3a2cf990a725bb341fab8d11eb620")
734 (revision "1"))
735 (package
736 (name "spinsim")
737 (version (string-append "0.75-" revision "." (string-take commit 9)))
738 (source (origin
739 (method git-fetch)
740 (uri (git-reference
741 (url "https://github.com/parallaxinc/spinsim.git")
742 (commit commit)))
743 (file-name (string-append name "-" commit "-checkout"))
744 (sha256
745 (base32
746 "1n9kdhlxsdx7bz6c80w8dhi96zp633gd6qs0x9i4ii8qv4i7sj5k"))))
747 (build-system gnu-build-system)
748 (arguments
749 `(#:tests? #f ; no tests
750 #:phases
751 (modify-phases %standard-phases
752 (delete 'configure)
753 (replace 'install
754 (lambda* (#:key outputs #:allow-other-keys)
755 (let ((bin (string-append (assoc-ref outputs "out")
756 "/bin")))
757 (install-file "build/spinsim" bin))
758 #t)))))
759 (home-page "https://github.com/parallaxinc/spinsim")
760 (synopsis "Spin simulator")
761 (description "This package provides the tool @code{spinsim}, a simulator
762and simple debugger for Spin programs written for a Parallax Propeller
763micro-controller. Spinsim supports execution from cog memory and hub
764execution, but it does not support multi-tasking. It supports about
765two-thirds of the opcodes in the P2 instruction set.")
766 (license license:expat))))
767
395bbfdb
RW
768(define-public propeller-development-suite
769 (package
770 (name "propeller-development-suite")
771 (version (package-version propeller-gcc))
772 (source #f)
773 (build-system trivial-build-system)
774 (arguments '(#:builder (mkdir %output)))
775 (propagated-inputs
776 `(("toolchain" ,propeller-toolchain)
777 ("openspin" ,openspin)
778 ("propeller-load" ,propeller-load)
779 ("spin2cpp" ,spin2cpp)
780 ("spinsim" ,spinsim)))
781 (synopsis "Complete development suite for Propeller micro-controllers")
782 (description "This meta-package provides a complete environment for the
783development with Parallax Propeller micro-controllers. It includes the GCC
784toolchain, the loader, the Openspin compiler, the Spin2cpp tool, and the Spin
785simulator.")
786 (home-page (package-home-page propeller-gcc))
787 (license (package-license propeller-gcc))))
8ea42482
DM
788
789(define-public binutils-vc4
790 (let ((commit "708acc851880dbeda1dd18aca4fd0a95b2573b36"))
791 (package
792 (name "binutils-vc4")
793 (version (string-append "2.23.51-0." (string-take commit 7)))
794 (source (origin
795 (method git-fetch)
796 (uri (git-reference
797 (url "https://github.com/puppeh/binutils-vc4.git")
798 (commit commit)))
493ae57e 799 (file-name (string-append name "-" version "-checkout"))
8ea42482
DM
800 (sha256
801 (base32
802 "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"))))
803 (build-system gnu-build-system)
804 (arguments
805 `(#:configure-flags '("--target=vc4-elf"
806 "--disable-werror"
807 "--enable-cgen-maint")
808 #:phases
809 (modify-phases %standard-phases
810 (add-after 'unpack 'unpack-cgen
811 (lambda* (#:key inputs #:allow-other-keys)
812 (copy-recursively (string-append (assoc-ref inputs "cgen")
813 "/cgen") "cgen")
814 #t))
815 (add-after 'unpack-cgen 'fix-cgen-guile
816 (lambda _
817 (substitute* "opcodes/Makefile.in"
818 (("guile\\{,-\\}1.8") "guile"))
819 (zero? (system* "which" "guile")))))))
820 (native-inputs
821 `(("cgen"
822 ,(origin
823 (method git-fetch)
824 (uri (git-reference
825 (url "https://github.com/puppeh/cgen.git")
826 (commit "d8e2a9eb70425f180fdd5bfd032884b0855f2032")))
827 (sha256
828 (base32
829 "14b3h2ji740s8zq5vwm4qdcxs4aa4wxi6wb9di3bv1h39x14nyr9"))))
830 ("texinfo" ,texinfo)
5e54f4ad 831 ("flex" ,flex)
8ea42482
DM
832 ("bison" ,bison)
833 ("guile-1.8" ,guile-1.8)
834 ("which" ,base:which)))
835 (synopsis "Binutils for VC4")
836 (description "This package provides @code{binutils} for VideoCore IV,
837the Raspberry Pi chip.")
838 (license license:gpl3+)
839 (home-page "https://github.com/puppeh/vc4-toolchain/"))))
7cf06d62
DM
840
841(define-public gcc-vc4
842 (let ((commit "165f6d0e11d2e76ee799533bb45bd5c92bf60dc2")
7b3318e3 843 (xgcc (cross-gcc "vc4-elf" #:xbinutils binutils-vc4)))
7cf06d62
DM
844 (package (inherit xgcc)
845 (name "gcc-vc4")
846 (source (origin
847 (method git-fetch)
848 (uri (git-reference
849 (url "https://github.com/puppeh/gcc-vc4.git")
850 (commit commit)))
851 (file-name (string-append name
852 "-"
853 (package-version xgcc)
854 "-checkout"))
855 (sha256
856 (base32
857 "13h30qjcwnlz6lfma1d82nnvfmjnhh7abkagip4vly6vm5fpnvf2"))))
858 (native-inputs
859 `(("flex" ,flex)
860 ,@(package-native-inputs xgcc)))
861 (synopsis "GCC for VC4")
862 (description "This package provides @code{gcc} for VideoCore IV,
863the Raspberry Pi chip."))))