Commit | Line | Data |
---|---|---|
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) |
2d7c9213 | 33 | #:use-module (gnu packages bison) |
35a37efb | 34 | #:use-module (gnu packages cross-base) |
2d7c9213 | 35 | #:use-module (gnu packages dejagnu) |
35a37efb | 36 | #:use-module (gnu packages flex) |
dbc3c34e | 37 | #:use-module (gnu packages gcc) |
94f36a4f | 38 | #:use-module (gnu packages gdb) |
5b83b7b8 | 39 | #:use-module (gnu packages libftdi) |
e5e45c06 | 40 | #:use-module (gnu packages libusb) |
35a37efb | 41 | #:use-module (gnu packages perl) |
e5e45c06 | 42 | #:use-module (gnu packages pkg-config) |
7894ea61 LC |
43 | #:use-module (gnu packages texinfo) |
44 | #:use-module (srfi srfi-1)) | |
35a37efb RW |
45 | |
46 | ;; We must not use the released GCC sources here, because the cross-compiler | |
47 | ;; does not produce working binaries. Instead we take the very same SVN | |
48 | ;; revision from the branch that is used for a release of the "GCC ARM | |
49 | ;; embedded" project on launchpad. | |
50 | ;; See https://launchpadlibrarian.net/218827644/release.txt | |
51 | (define-public gcc-arm-none-eabi-4.9 | |
52 | (let ((xgcc (cross-gcc "arm-none-eabi" | |
53 | (cross-binutils "arm-none-eabi"))) | |
54 | (revision "1") | |
55 | (svn-revision 227977)) | |
56 | (package (inherit xgcc) | |
57 | (version (string-append (package-version xgcc) "-" | |
58 | revision "." (number->string svn-revision))) | |
59 | (source | |
60 | (origin | |
61 | (method svn-fetch) | |
62 | (uri (svn-reference | |
63 | (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/") | |
64 | (revision svn-revision))) | |
65 | (file-name (string-append "gcc-arm-embedded-" version "-checkout")) | |
66 | (sha256 | |
67 | (base32 | |
68 | "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr")) | |
7894ea61 LC |
69 | |
70 | ;; Remove the one patch that doesn't apply to this 4.9 snapshot (the | |
71 | ;; patch is for 4.9.4 and later but this svn snapshot is older). | |
72 | (patches (remove (lambda (patch) | |
73 | (string=? (basename patch) | |
74 | "gcc-arm-bug-71399.patch")) | |
75 | (origin-patches (package-source xgcc)))))) | |
35a37efb RW |
76 | (native-inputs |
77 | `(("flex" ,flex) | |
78 | ,@(package-native-inputs xgcc))) | |
79 | (arguments | |
80 | (substitute-keyword-arguments (package-arguments xgcc) | |
81 | ((#:phases phases) | |
82 | `(modify-phases ,phases | |
83 | (add-after 'unpack 'fix-genmultilib | |
84 | (lambda _ | |
85 | (substitute* "gcc/genmultilib" | |
86 | (("#!/bin/sh") (string-append "#!" (which "sh")))) | |
87 | #t)))) | |
88 | ((#:configure-flags flags) | |
89 | ;; The configure flags are largely identical to the flags used by the | |
90 | ;; "GCC ARM embedded" project. | |
91 | `(append (list "--enable-multilib" | |
92 | "--with-newlib" | |
93 | "--with-multilib-list=armv6-m,armv7-m,armv7e-m" | |
94 | "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm" | |
95 | "--enable-plugins" | |
96 | "--disable-decimal-float" | |
97 | "--disable-libffi" | |
98 | "--disable-libgomp" | |
99 | "--disable-libmudflap" | |
100 | "--disable-libquadmath" | |
101 | "--disable-libssp" | |
102 | "--disable-libstdcxx-pch" | |
103 | "--disable-nls" | |
104 | "--disable-shared" | |
105 | "--disable-threads" | |
106 | "--disable-tls") | |
107 | (delete "--disable-multilib" ,flags))))) | |
108 | (native-search-paths | |
109 | (list (search-path-specification | |
110 | (variable "CROSS_C_INCLUDE_PATH") | |
111 | (files '("arm-none-eabi/include"))) | |
112 | (search-path-specification | |
113 | (variable "CROSS_CPLUS_INCLUDE_PATH") | |
114 | (files '("arm-none-eabi/include"))) | |
115 | (search-path-specification | |
116 | (variable "CROSS_LIBRARY_PATH") | |
117 | (files '("arm-none-eabi/lib")))))))) | |
6c39886a | 118 | |
dbc3c34e TF |
119 | (define-public gcc-arm-none-eabi-6 |
120 | (package | |
121 | (inherit gcc-arm-none-eabi-4.9) | |
122 | (version (package-version gcc-6)) | |
123 | (source (origin (inherit (package-source gcc-6)) | |
124 | (patches | |
125 | (append | |
126 | (origin-patches (package-source gcc-6)) | |
127 | (search-patches "gcc-6-cross-environment-variables.patch" | |
128 | "gcc-6-arm-none-eabi-multilib.patch"))))))) | |
129 | ||
6c39886a RW |
130 | (define-public newlib-arm-none-eabi |
131 | (package | |
132 | (name "newlib") | |
133 | (version "2.4.0") | |
134 | (source (origin | |
135 | (method url-fetch) | |
136 | (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-" | |
137 | version ".tar.gz")) | |
138 | (sha256 | |
139 | (base32 | |
140 | "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl")))) | |
141 | (build-system gnu-build-system) | |
142 | (arguments | |
143 | `(#:out-of-source? #t | |
144 | ;; The configure flags are identical to the flags used by the "GCC ARM | |
145 | ;; embedded" project. | |
146 | #:configure-flags '("--target=arm-none-eabi" | |
147 | "--enable-newlib-io-long-long" | |
148 | "--enable-newlib-register-fini" | |
149 | "--disable-newlib-supplied-syscalls" | |
150 | "--disable-nls") | |
151 | #:phases | |
152 | (modify-phases %standard-phases | |
153 | (add-after 'unpack 'fix-references-to-/bin/sh | |
154 | (lambda _ | |
155 | (substitute* '("libgloss/arm/cpu-init/Makefile.in" | |
156 | "libgloss/arm/Makefile.in" | |
157 | "libgloss/libnosys/Makefile.in" | |
158 | "libgloss/Makefile.in") | |
159 | (("/bin/sh") (which "sh"))) | |
160 | #t))))) | |
161 | (native-inputs | |
162 | `(("xbinutils" ,(cross-binutils "arm-none-eabi")) | |
163 | ("xgcc" ,gcc-arm-none-eabi-4.9) | |
164 | ("texinfo" ,texinfo))) | |
165 | (home-page "http://www.sourceware.org/newlib/") | |
166 | (synopsis "C library for use on embedded systems") | |
167 | (description "Newlib is a C library intended for use on embedded | |
168 | systems. It is a conglomeration of several library parts that are easily | |
169 | usable on embedded products.") | |
170 | (license (license:non-copyleft | |
171 | "https://www.sourceware.org/newlib/COPYING.NEWLIB")))) | |
a299a899 RW |
172 | |
173 | (define-public newlib-nano-arm-none-eabi | |
174 | (package (inherit newlib-arm-none-eabi) | |
175 | (name "newlib-nano") | |
176 | (arguments | |
177 | (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi) | |
178 | ;; The configure flags are identical to the flags used by the "GCC ARM | |
179 | ;; embedded" project. They optimize newlib for use on small embedded | |
180 | ;; systems with limited memory. | |
181 | ((#:configure-flags flags) | |
182 | ''("--target=arm-none-eabi" | |
183 | "--enable-multilib" | |
184 | "--disable-newlib-supplied-syscalls" | |
185 | "--enable-newlib-reent-small" | |
186 | "--disable-newlib-fvwrite-in-streamio" | |
187 | "--disable-newlib-fseek-optimization" | |
188 | "--disable-newlib-wide-orient" | |
189 | "--enable-newlib-nano-malloc" | |
190 | "--disable-newlib-unbuf-stream-opt" | |
191 | "--enable-lite-exit" | |
192 | "--enable-newlib-global-atexit" | |
193 | "--enable-newlib-nano-formatted-io" | |
194 | "--disable-nls")))) | |
195 | (synopsis "Newlib variant for small systems with limited memory"))) | |
569f6016 TF |
196 | |
197 | (define (arm-none-eabi-toolchain xgcc newlib) | |
198 | "Produce a cross-compiler toolchain package with the compiler XGCC and the C | |
199 | library variant NEWLIB." | |
200 | (let ((newlib-with-xgcc (package (inherit newlib) | |
201 | (native-inputs | |
202 | (alist-replace "xgcc" (list xgcc) | |
203 | (package-native-inputs newlib)))))) | |
204 | (package | |
205 | (name (string-append "arm-none-eabi" | |
206 | (if (string=? (package-name newlib-with-xgcc) | |
207 | "newlib-nano") | |
208 | "-nano" "") | |
209 | "-toolchain")) | |
210 | (version (package-version xgcc)) | |
211 | (source #f) | |
212 | (build-system trivial-build-system) | |
213 | (arguments '(#:builder (mkdir %output))) | |
214 | (propagated-inputs | |
215 | `(("binutils" ,(cross-binutils "arm-none-eabi")) | |
216 | ("gcc" ,xgcc) | |
217 | ("newlib" ,newlib-with-xgcc))) | |
218 | (synopsis "Complete GCC tool chain for ARM bare metal development") | |
219 | (description "This package provides a complete GCC tool chain for ARM | |
220 | bare metal development. This includes the GCC arm-none-eabi cross compiler | |
221 | and newlib (or newlib-nano) as the C library. The supported programming | |
222 | languages are C and C++.") | |
223 | (home-page (package-home-page xgcc)) | |
224 | (license (package-license xgcc))))) | |
225 | ||
226 | (define-public arm-none-eabi-toolchain-4.9 | |
227 | (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9 | |
228 | newlib-arm-none-eabi)) | |
229 | ||
230 | (define-public arm-none-eabi-nano-toolchain-4.9 | |
231 | (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9 | |
232 | newlib-nano-arm-none-eabi)) | |
233 | ||
234 | (define-public arm-none-eabi-toolchain-6 | |
235 | (arm-none-eabi-toolchain gcc-arm-none-eabi-6 | |
236 | newlib-arm-none-eabi)) | |
237 | ||
238 | (define-public arm-none-eabi-nano-toolchain-6 | |
239 | (arm-none-eabi-toolchain gcc-arm-none-eabi-6 | |
240 | newlib-nano-arm-none-eabi)) | |
94f36a4f TF |
241 | |
242 | (define-public gdb-arm-none-eabi | |
243 | (package | |
244 | (inherit gdb) | |
245 | (name "gdb-arm-none-eabi") | |
246 | (arguments | |
247 | `(#:configure-flags '("--target=arm-none-eabi" | |
248 | "--enable-multilib" | |
249 | "--enable-interwork" | |
250 | "--enable-languages=c,c++" | |
251 | "--disable-nls") | |
252 | ,@(package-arguments gdb))))) | |
e5e45c06 DC |
253 | |
254 | (define-public libjaylink | |
255 | ;; No release tarballs available. | |
256 | (let ((commit "faa2a433fdd3de211728f3da5921133214af9dd3") | |
257 | (revision "1")) | |
258 | (package | |
259 | (name "libjaylink") | |
260 | (version (string-append "0.1.0-" revision "." | |
261 | (string-take commit 7))) | |
262 | (source (origin | |
263 | (method git-fetch) | |
264 | (uri (git-reference | |
265 | (url "git://git.zapb.de/libjaylink.git") | |
266 | (commit commit))) | |
267 | (file-name (string-append name "-" version "-checkout")) | |
268 | (sha256 | |
269 | (base32 | |
270 | "02crr56csz8whq3q4mrmdzzgwp5b0qvxm0fb18drclc3zj44yxl2")))) | |
271 | (build-system gnu-build-system) | |
272 | (native-inputs | |
273 | `(("autoconf" ,autoconf) | |
274 | ("automake" ,automake) | |
275 | ("libtool" ,libtool) | |
276 | ("pkg-config" ,pkg-config))) | |
277 | (inputs | |
278 | `(("libusb" ,libusb))) | |
279 | (arguments | |
280 | `(#:phases | |
281 | (modify-phases %standard-phases | |
282 | (add-before 'configure 'autoreconf | |
283 | (lambda _ | |
284 | (zero? (system* "autoreconf" "-vfi"))))))) | |
285 | (home-page "http://repo.or.cz/w/libjaylink.git") | |
286 | (synopsis "Library to interface Segger J-Link devices") | |
287 | (description "libjaylink is a shared library written in C to access | |
288 | SEGGER J-Link and compatible devices.") | |
289 | (license license:gpl2+)))) | |
91ba6935 DC |
290 | |
291 | (define-public jimtcl | |
292 | (package | |
293 | (name "jimtcl") | |
294 | (version "0.77") | |
295 | (source (origin | |
296 | (method url-fetch) | |
297 | (uri (string-append | |
298 | "https://github.com/msteveb/jimtcl" | |
299 | "/archive/" version ".tar.gz")) | |
300 | (file-name (string-append name "-" version ".tar.gz")) | |
301 | (sha256 | |
302 | (base32 | |
303 | "1cmk3qscqckg70chjyimzxa2qcka4qac0j4wq908kiijp45cax08")))) | |
304 | (build-system gnu-build-system) | |
305 | (arguments | |
306 | `(#:phases | |
307 | (modify-phases %standard-phases | |
308 | ;; Doesn't use autoconf. | |
309 | (replace 'configure | |
310 | (lambda* (#:key outputs #:allow-other-keys) | |
311 | (let ((out (assoc-ref outputs "out"))) | |
312 | (zero? (system* "./configure" | |
313 | (string-append "--prefix=" out))))))))) | |
314 | (home-page "http://jim.tcl.tk") | |
315 | (synopsis "Small footprint Tcl implementation") | |
316 | (description "Jim is a small footprint implementation of the Tcl programming | |
317 | language.") | |
318 | (license license:bsd-2))) | |
5b83b7b8 TF |
319 | |
320 | (define-public openocd | |
321 | ;; FIXME: Use tarball release after nrf52 patch is merged. | |
322 | (let ((commit "674141e8a7a6413cb803d90c2a20150260015f81") | |
323 | (revision "1")) | |
324 | (package | |
325 | (name "openocd") | |
326 | (version (string-append "0.9.0-" revision "." | |
327 | (string-take commit 7))) | |
328 | (source (origin | |
329 | (method git-fetch) | |
330 | (uri (git-reference | |
331 | (url "git://git.code.sf.net/p/openocd/code.git") | |
332 | (commit commit))) | |
333 | (sha256 | |
334 | (base32 | |
335 | "1i86jp0wawq78d73z8hp7q1pn7lmlvhjjr19f7299h4w40a5jf8j")) | |
336 | (file-name (string-append name "-" version "-checkout")) | |
337 | (patches | |
338 | (search-patches "openocd-nrf52.patch")))) | |
339 | (build-system gnu-build-system) | |
340 | (native-inputs | |
341 | `(("autoconf" ,autoconf) | |
342 | ("automake" ,automake) | |
343 | ("libtool" ,libtool) | |
344 | ("pkg-config" ,pkg-config))) | |
345 | (inputs | |
346 | `(("hidapi" ,hidapi) | |
347 | ("jimtcl" ,jimtcl) | |
348 | ("libftdi" ,libftdi) | |
349 | ("libjaylink" ,libjaylink) | |
350 | ("libusb-compat" ,libusb-compat))) | |
351 | (arguments | |
352 | '(#:configure-flags | |
353 | (append (list "--disable-werror" | |
354 | "--disable-internal-jimtcl" | |
355 | "--disable-internal-libjaylink") | |
356 | (map (lambda (programmer) | |
357 | (string-append "--enable-" programmer)) | |
358 | '("amtjtagaccel" "armjtagew" "buspirate" "ftdi" | |
359 | "gw16012" "jlink" "oocd_trace" "opendous" "osbdm" | |
360 | "parport" "aice" "cmsis-dap" "dummy" "jtag_vpi" | |
361 | "remote-bitbang" "rlink" "stlink" "ti-icdi" "ulink" | |
362 | "usbprog" "vsllink" "usb-blaster-2" "usb_blaster" | |
363 | "presto" "openjtag"))) | |
364 | #:phases | |
365 | (modify-phases %standard-phases | |
366 | (add-before 'configure 'autoreconf | |
367 | (lambda _ | |
368 | (zero? (system* "autoreconf" "-vfi"))))))) | |
369 | (home-page "http://openocd.org") | |
370 | (synopsis "On-Chip Debugger") | |
371 | (description "OpenOCD provides on-chip programming and debugging support | |
372 | with a layered architecture of JTAG interface and TAP support.") | |
6d1b3bf5 | 373 | (license license:gpl2+)))) |
2d7c9213 RW |
374 | |
375 | ;; The commits for all propeller tools are the latest versions as published | |
376 | ;; here: https://github.com/dbetz/propeller-gcc | |
377 | ||
378 | (define propeller-binutils | |
379 | (let ((xbinutils (cross-binutils "propeller-elf")) | |
380 | (commit "3bfba30076f8ce160a2f42914fdb68f24445fd44") | |
381 | (revision "1")) | |
382 | (package | |
383 | (inherit xbinutils) | |
384 | (name "propeller-binutils") | |
385 | (version (string-append "0.0.0-" revision "." (string-take commit 9))) | |
386 | (source (origin (inherit (package-source xbinutils)) | |
387 | (method git-fetch) | |
388 | (uri (git-reference | |
389 | (url "https://github.com/totalspectrum/binutils-propeller.git") | |
390 | (commit commit))) | |
391 | (file-name (string-append name "-" commit "-checkout")) | |
392 | (sha256 | |
393 | (base32 | |
394 | "1v3rgxwj7b8817wy5ccf8621v75qcxvcxygk4acr3hbc6yqybr8h")))) | |
395 | (arguments | |
396 | `(;; FIXME: For some reason there are many test failures. Some of them | |
397 | ;; appear to be due to regular expression mismatch, but it's not | |
398 | ;; obvious how to fix the failures. | |
399 | #:tests? #f | |
400 | #:phases | |
401 | (modify-phases %standard-phases | |
402 | (add-after 'unpack 'patch-/bin/sh-in-tests | |
403 | (lambda _ | |
404 | (substitute* '("sim/testsuite/Makefile.in" | |
405 | "sim/testsuite/mips64el-elf/Makefile.in" | |
406 | "sim/testsuite/d10v-elf/Makefile.in" | |
407 | "sim/testsuite/sim/cris/asm/badarch1.ms") | |
408 | (("/bin/sh") (which "sh"))) | |
409 | #t))) | |
410 | ,@(package-arguments xbinutils))) | |
411 | (native-inputs | |
412 | `(("bison" ,bison) | |
413 | ("flex" ,flex) | |
414 | ("texinfo" ,texinfo) | |
415 | ("dejagnu" ,dejagnu) | |
416 | ,@(package-native-inputs xbinutils)))))) | |
417 |