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