projects/guix·blob sysadmin-team · refs

2091 lines · 86.4 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016-2019, 2023-2026 Ricardo Wurmus <[email protected]>
3;;; Copyright © 2016, 2017 Theodoros Foradis <[email protected]>
4;;; Copyright © 2016 David Craven <[email protected]>
5;;; Copyright © 2017, 2020 Efraim Flashner <[email protected]>
6;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <[email protected]>
7;;; Copyright © 2018, 2019, 2021 Clément Lassieur <[email protected]>
8;;; Copyright © 2020, 2022 Marius Bakke <[email protected]>
9;;; Copyright © 2020 Björn Höfling <[email protected]>
10;;; Copyright © 2021 Julien Lepiller <[email protected]>
11;;; Copyright © 2020, 2021, 2022 Simon South <[email protected]>
12;;; Copyright © 2021 Morgan Smith <[email protected]>
13;;; Copyright © 2022 Mathieu Othacehe <[email protected]>
14;;; Copyright © 2022, 2023 Maxim Cournoyer <[email protected]>
15;;; Copyright © 2023 Janneke Nieuwenhuizen <[email protected]>
16;;; Copyright © 2024, 2026 Artyom V. Poptsov <[email protected]>
17;;; Copyright © 2025 Junker [email protected]
18;;; Copyright © 2025 Reza Housseini <[email protected]>
19;;;
20;;; This file is part of GNU Guix.
21;;;
22;;; GNU Guix is free software; you can redistribute it and/or modify it
23;;; under the terms of the GNU General Public License as published by
24;;; the Free Software Foundation; either version 3 of the License, or (at
25;;; your option) any later version.
26;;;
27;;; GNU Guix is distributed in the hope that it will be useful, but
28;;; WITHOUT ANY WARRANTY; without even the implied warranty of
29;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30;;; GNU General Public License for more details.
31;;;
32;;; You should have received a copy of the GNU General Public License
33;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
34
35(define-module (gnu packages embedded)
36 #:use-module (guix utils)
37 #:use-module (guix packages)
38 #:use-module (guix deprecation)
39 #:use-module (guix download)
40 #:use-module (guix gexp)
41 #:use-module (guix memoization)
42 #:use-module (guix svn-download)
43 #:use-module (guix git-download)
44 #:use-module ((guix licenses) #:prefix license:)
45 #:use-module (guix build-system cargo)
46 #:use-module (guix build-system cmake)
47 #:use-module (guix build-system gnu)
48 #:use-module (guix build-system pyproject)
49 #:use-module (guix build-system trivial)
50 #:use-module ((guix build utils) #:select (alist-replace delete-file-recursively))
51 #:use-module (gnu packages)
52 #:use-module (gnu packages admin)
53 #:use-module (gnu packages autotools)
54 #:use-module (gnu packages base)
55 #:use-module (gnu packages bison)
56 #:use-module (gnu packages boost)
57 #:use-module (gnu packages build-tools)
58 #:use-module (gnu packages check)
59 #:use-module (gnu packages compression)
60 #:use-module (gnu packages cross-base)
61 #:use-module (gnu packages dejagnu)
62 #:use-module (gnu packages compiler-tools)
63 #:use-module (gnu packages gcc)
64 #:use-module (gnu packages gdb)
65 #:use-module (gnu packages guile)
66 #:use-module (gnu packages libffi)
67 #:use-module (gnu packages libftdi)
68 #:use-module (gnu packages libusb)
69 #:use-module (gnu packages linux)
70 #:use-module (gnu packages messaging)
71 #:use-module (gnu packages ncurses)
72 #:use-module (gnu packages perl)
73 #:use-module (gnu packages pkg-config)
74 #:use-module (gnu packages protobuf)
75 #:use-module (gnu packages python)
76 #:use-module (gnu packages python-build)
77 #:use-module (gnu packages python-crypto)
78 #:use-module (gnu packages python-web)
79 #:use-module (gnu packages python-xyz)
80 #:use-module (gnu packages qt)
81 #:use-module (gnu packages readline)
82 #:use-module (gnu packages rust)
83 #:use-module (gnu packages swig)
84 #:use-module (gnu packages texinfo)
85 #:use-module (gnu packages tls)
86 #:use-module (gnu packages version-control)
87 #:use-module (gnu packages xorg)
88 #:use-module (srfi srfi-1)
89 #:export (make-gcc-arm-none-eabi-4.9
90 make-gcc-arm-none-eabi-6
91 make-gcc-arm-none-eabi-7-2018-q2-update
92 make-gcc-arm-none-eabi-9-2020-q2-update
93 make-gcc-arm-none-eabi-12.3.rel1
94
95 make-newlib-arm-none-eabi
96 make-newlib-arm-none-eabi-7-2018-q2-update
97 make-newlib-arm-none-eabi-9-2020-q2-update
98 make-newlib-arm-none-eabi-12.3.rel1
99
100 make-newlib-nano-arm-none-eabi
101 make-newlib-nano-arm-none-eabi-7-2018-q2-update
102 make-newlib-nano-arm-none-eabi-9-2020-q2-update
103 make-newlib-nano-arm-none-eabi-12.3.rel1
104
105 make-arm-none-eabi-toolchain-4.9
106 make-arm-none-eabi-toolchain-6
107 make-arm-none-eabi-toolchain-7-2018-q2-update
108 make-arm-none-eabi-toolchain-9-2020-q2-update
109 make-arm-none-eabi-toolchain-12.3.rel1
110
111 make-arm-none-eabi-nano-toolchain-4.9
112 make-arm-none-eabi-nano-toolchain-6
113 make-arm-none-eabi-nano-toolchain-7-2018-q2-update
114 make-arm-none-eabi-nano-toolchain-9-2020-q2-update
115 make-arm-none-eabi-nano-toolchain-12.3.rel1
116
117 make-gdb-arm-none-eabi
118
119 make-propeller-gcc
120 make-propeller-gcc-4
121 make-propeller-gcc-6
122 make-propeller-toolchain))
123
124;;; Commentary:
125;;;
126;;; This modules contains toolchain generators as well as packages for use in
127;;; embedded contexts. Note: the toolchain and specialized packages are
128;;; procedures, so as to delay their references to top level bindings such as
129;;; 'gcc' or 'cross-gcc', etc.
130;;;
131
132;; We must not use the released GCC sources here, because the cross-compiler
133;; does not produce working binaries. Instead we take the very same SVN
134;; revision from the branch that is used for a release of the "GCC ARM
135;; embedded" project on launchpad.
136;; See https://launchpadlibrarian.net/218827644/release.txt
137(define make-gcc-arm-none-eabi-4.9
138 (mlambda ()
139 (let ((xgcc (cross-gcc "arm-none-eabi"
140 #:xgcc gcc-4.9
141 #:xbinutils (cross-binutils "arm-none-eabi")))
142 (revision "1")
143 (svn-revision 227977))
144 (package
145 (inherit xgcc)
146 (version (string-append (package-version xgcc) "-"
147 revision "." (number->string svn-revision)))
148 (source
149 (origin
150 (method svn-fetch)
151 (uri (svn-reference
152 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/\
153embedded-4_9-branch/")
154 (revision svn-revision)))
155 (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
156 (sha256
157 (base32
158 "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
159
160 (patches (cons (search-patch "gcc-4.9-inline.patch")
161 ;; Remove the one patch that doesn't apply to this
162 ;; 4.9 snapshot (the patch is for 4.9.4 and later
163 ;; but this svn snapshot is older).
164 (remove (lambda (patch)
165 (string=? (basename patch)
166 "gcc-arm-bug-71399.patch"))
167 (origin-patches (package-source xgcc)))))))
168 (native-inputs
169 `(("flex" ,flex)
170 ("gcc@5" ,gcc-5)
171 ,@(package-native-inputs xgcc)))
172 (arguments
173 (substitute-keyword-arguments arguments
174 ((#:phases phases)
175 #~(modify-phases #$phases
176 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
177 (lambda* (#:key inputs #:allow-other-keys)
178 (let ((gcc (assoc-ref inputs "gcc")))
179 ;; Remove the default compiler from CPLUS_INCLUDE_PATH
180 ;; to prevent header conflict with the GCC from
181 ;; native-inputs.
182 (setenv "CPLUS_INCLUDE_PATH"
183 (string-join
184 (delete (string-append gcc "/include/c++")
185 (string-split (getenv "CPLUS_INCLUDE_PATH")
186 #\:))
187 ":"))
188 (format #t
189 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
190 (getenv "CPLUS_INCLUDE_PATH")))))
191 (add-after 'unpack 'fix-genmultilib
192 (lambda _
193 (substitute* "gcc/genmultilib"
194 (("#!/bin/sh") (string-append "#!" (which "sh"))))))))
195 ((#:configure-flags flags)
196 ;; The configure flags are largely identical to the flags used by the
197 ;; "GCC ARM embedded" project.
198 #~(append (list "--enable-multilib"
199 "--with-newlib"
200 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
201 "--with-host-libstdcxx=-static-libgcc \
202-Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
203 "--enable-plugins"
204 "--disable-decimal-float"
205 "--disable-libffi"
206 "--disable-libgomp"
207 "--disable-libmudflap"
208 "--disable-libquadmath"
209 "--disable-libssp"
210 "--disable-libstdcxx-pch"
211 "--disable-nls"
212 "--disable-shared"
213 "--disable-threads"
214 "--disable-tls")
215 (delete "--disable-multilib" #$flags)))))
216 (native-search-paths
217 (list (search-path-specification
218 (variable "CROSS_C_INCLUDE_PATH")
219 (files '("arm-none-eabi/include")))
220 (search-path-specification
221 (variable "CROSS_CPLUS_INCLUDE_PATH")
222 (files '("arm-none-eabi/include/c++"
223 "arm-none-eabi/include/c++/arm-none-eabi"
224 "arm-none-eabi/include")))
225 (search-path-specification
226 (variable "CROSS_LIBRARY_PATH")
227 (files '("arm-none-eabi/lib")))))))))
228
229(define make-gcc-arm-none-eabi-6
230 (mlambda ()
231 (package
232 (inherit (make-gcc-arm-none-eabi-4.9))
233 (version (package-version gcc-6))
234 (source (origin
235 (inherit (package-source gcc-6))
236 (patches
237 (append
238 (origin-patches (package-source gcc-6))
239 (search-patches "gcc-6-cross-environment-variables.patch"
240 "gcc-6-arm-none-eabi-multilib.patch"))))))))
241
242(define make-newlib-arm-none-eabi
243 (mlambda ()
244 (package
245 (name "newlib")
246 (version "2.4.0")
247 (source (origin
248 (method url-fetch)
249 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
250 version ".tar.gz"))
251 (sha256
252 (base32
253 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
254 (build-system gnu-build-system)
255 (arguments
256 `(#:out-of-source? #t
257 ;; The configure flags are identical to the flags used by the "GCC ARM
258 ;; embedded" project.
259 #:configure-flags '("--target=arm-none-eabi"
260 "--enable-newlib-io-long-long"
261 "--enable-newlib-register-fini"
262 "--disable-newlib-supplied-syscalls"
263 "--disable-nls")
264 #:phases
265 (modify-phases %standard-phases
266 (add-after 'unpack 'fix-references-to-/bin/sh
267 (lambda _
268 (substitute* (find-files "libgloss" "^Makefile\\.in$")
269 (("/bin/sh") (which "sh")))
270 #t)))))
271 (native-inputs
272 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
273 ("xgcc" ,(make-gcc-arm-none-eabi-4.9))
274 ("texinfo" ,texinfo)))
275 (home-page "https://www.sourceware.org/newlib/")
276 (synopsis "C library for use on embedded systems")
277 (description "Newlib is a C library intended for use on embedded
278systems. It is a conglomeration of several library parts that are easily
279usable on embedded products.")
280 (license (license:non-copyleft
281 "https://www.sourceware.org/newlib/COPYING.NEWLIB")))))
282
283(define make-newlib-nano-arm-none-eabi
284 (mlambda ()
285 (let ((base (make-newlib-arm-none-eabi)))
286 (package
287 (inherit base)
288 (name "newlib-nano")
289 (arguments
290 (substitute-keyword-arguments arguments
291 ;; The configure flags are identical to the flags used by the "GCC
292 ;; ARM embedded" project. They optimize newlib for use on small
293 ;; embedded systems with limited memory.
294 ((#:configure-flags _)
295 ''("--target=arm-none-eabi"
296 "--enable-multilib"
297 "--disable-newlib-supplied-syscalls"
298 "--enable-newlib-reent-small"
299 "--disable-newlib-fvwrite-in-streamio"
300 "--disable-newlib-fseek-optimization"
301 "--disable-newlib-wide-orient"
302 "--enable-newlib-nano-malloc"
303 "--disable-newlib-unbuf-stream-opt"
304 "--enable-lite-exit"
305 "--enable-newlib-global-atexit"
306 "--enable-newlib-nano-formatted-io"
307 "--disable-nls"))
308 ((#:phases phases)
309 `(modify-phases ,phases
310 ;; XXX: Most arm toolchains offer both *.a and *_nano.a as
311 ;; newlib and newlib-nano respectively. The headers are
312 ;; usually arm-none-eabi/include/newlib.h for newlib and
313 ;; arm-none-eabi/include/newlib-nano/newlib.h for newlib-nano.
314 ;; We have two different toolchain packages for each which
315 ;; works but is a little strange.
316 (add-after 'install 'hardlink-newlib
317 (lambda* (#:key outputs #:allow-other-keys)
318 (let ((out (assoc-ref outputs "out")))
319 ;; The nano.specs file says that newlib-nano files should
320 ;; end in "_nano.a" instead of just ".a". Note that this
321 ;; applies to all the multilib folders too.
322 (for-each
323 (lambda (file)
324 (link file
325 (string-append
326 ;; Strip ".a" off the end
327 (substring file 0 (- (string-length file) 2))
328 ;; Add "_nano.a" onto the end
329 "_nano.a")))
330 (find-files
331 out
332 "^(libc.a|libg.a|librdimon.a|libstdc\\+\\+.a|\
333libsupc\\+\\+.a)$"))
334
335 ;; newlib.h is usually in this location instead so both
336 ;; newlib and newlib-nano can be in the toolchain at the
337 ;; same time
338 (mkdir (string-append
339 out "/arm-none-eabi/include/newlib-nano"))
340 (symlink
341 "../newlib.h"
342 (string-append
343 out
344 "/arm-none-eabi/include/newlib-nano/newlib.h")))))))))
345 (synopsis "Newlib variant for small systems with limited memory")))))
346
347
348;;; The following definitions are for the "7-2018-q2-update" variant of the
349;;; ARM cross toolchain as offered on https://developer.arm.com
350(define make-gcc-arm-none-eabi-7-2018-q2-update
351 (mlambda ()
352 (let ((xgcc (cross-gcc "arm-none-eabi"
353 #:xgcc gcc-7
354 #:xbinutils (cross-binutils "arm-none-eabi")))
355 (revision "1")
356 (svn-revision 261907))
357 (package (inherit xgcc)
358 (version (string-append "7-2018-q2-update-"
359 revision "."
360 (number->string svn-revision)))
361 (source
362 (origin
363 (method svn-fetch)
364 (uri (svn-reference
365 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/\
366embedded-7-branch/")
367 (revision svn-revision)))
368 (file-name (string-append "gcc-arm-embedded-" version
369 "-checkout"))
370 (sha256
371 (base32
372 "192ggs63bixf3irpijgfkjks73yx1r3a4i6grk1y0i0iny76pmx5"))
373 (patches
374 (append
375 (origin-patches (package-source gcc-7))
376 (search-patches
377 "gcc-7-cross-environment-variables.patch")))))
378 (native-inputs
379 (modify-inputs native-inputs
380 (delete "isl")
381 (prepend flex isl-0.18)))
382 (arguments
383 (substitute-keyword-arguments arguments
384 ((#:phases phases)
385 #~(modify-phases #$phases
386 (add-after 'unpack 'expand-version-string
387 (lambda _
388 (make-file-writable "gcc/DEV-PHASE")
389 (with-output-to-file "gcc/DEV-PHASE"
390 (lambda ()
391 (display "7-2018-q2-update")))))
392 (add-after 'unpack 'fix-genmultilib
393 (lambda _
394 (substitute* "gcc/genmultilib"
395 (("#!/bin/sh")
396 (string-append "#!" (which "sh"))))))
397 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
398 (lambda* (#:key inputs #:allow-other-keys)
399 (let ((gcc (assoc-ref inputs "gcc")))
400 ;; Remove the default compiler from
401 ;; CPLUS_INCLUDE_PATH to prevent header conflict
402 ;; with the GCC from native-inputs.
403 (setenv "CPLUS_INCLUDE_PATH"
404 (string-join
405 (delete (string-append gcc "/include/c++")
406 (string-split
407 (getenv "CPLUS_INCLUDE_PATH")
408 #\:))
409 ":"))
410 (format #t
411 "environment variable `CPLUS_INCLUDE_PATH'\
412 changed to ~a~%"
413 (getenv "CPLUS_INCLUDE_PATH")))))))
414 ((#:configure-flags flags)
415 ;; The configure flags are largely identical to the flags
416 ;; used by the "GCC ARM embedded" project.
417 #~(append (list "--enable-multilib"
418 "--with-newlib"
419 "--with-multilib-list=rmprofile"
420 "--with-host-libstdcxx=-static-libgcc \
421-Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
422 "--enable-plugins"
423 "--disable-decimal-float"
424 "--disable-libffi"
425 "--disable-libgomp"
426 "--disable-libmudflap"
427 "--disable-libquadmath"
428 "--disable-libssp"
429 "--disable-libstdcxx-pch"
430 "--disable-nls"
431 "--disable-shared"
432 "--disable-threads"
433 "--disable-tls")
434 (delete "--disable-multilib" #$flags)))))
435 (native-search-paths
436 (list (search-path-specification
437 (variable "CROSS_C_INCLUDE_PATH")
438 (files '("arm-none-eabi/include")))
439 (search-path-specification
440 (variable "CROSS_CPLUS_INCLUDE_PATH")
441 (files '("arm-none-eabi/include/c++"
442 "arm-none-eabi/include/c++/arm-none-eabi"
443 "arm-none-eabi/include")))
444 (search-path-specification
445 (variable "CROSS_LIBRARY_PATH")
446 (files '("arm-none-eabi/lib")))))))))
447
448(define make-base-newlib-arm-none-eabi-7-2018-q2-update
449 ;; This is the same commit as used for the 7-2018-q2-update release
450 ;; according to the release.txt.
451 (mlambda (base)
452 (let ((commit "3ccfb407af410ba7e54ea0da11ae1e40b554a6f4")
453 (revision "0"))
454 (package
455 (inherit base)
456 (version (git-version "3.0.0" revision commit))
457 (source
458 (origin
459 (method git-fetch)
460 (uri (git-reference
461 (url "http://sourceware.org/git/newlib-cygwin.git")
462 (commit commit)))
463 (file-name (git-file-name "newlib" commit))
464 (sha256
465 (base32
466 "1dq23fqrk75g1a4v7569fvnnw5q440zawbxi3w0g05n8jlqsmvcy"))))
467 (arguments
468 (substitute-keyword-arguments arguments
469 ;; The configure flags are identical to the flags used by the "GCC
470 ;; ARM embedded" project.
471 ((#:configure-flags flags)
472 `(cons* "--enable-newlib-io-c99-formats"
473 "--enable-newlib-retargetable-locking"
474 "--with-headers=yes"
475 ,flags))))
476 (native-inputs
477 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
478 ("xgcc" ,(make-gcc-arm-none-eabi-7-2018-q2-update))
479 ("texinfo" ,texinfo)))))))
480
481(define make-newlib-arm-none-eabi-7-2018-q2-update
482 (mlambda ()
483 (make-base-newlib-arm-none-eabi-7-2018-q2-update (make-newlib-arm-none-eabi))))
484
485(define make-newlib-nano-arm-none-eabi-7-2018-q2-update
486 (mlambda ()
487 (make-base-newlib-arm-none-eabi-7-2018-q2-update (make-newlib-nano-arm-none-eabi))))
488
489
490;;; The following definitions are for the "9-2020-q2-update" variant of the
491;;; ARM cross toolchain as offered on https://developer.arm.com
492(define make-gcc-arm-none-eabi-9-2020-q2-update
493 (mlambda ()
494 (let ((xgcc (cross-gcc "arm-none-eabi"
495 #:xgcc gcc-9
496 #:xbinutils (cross-binutils "arm-none-eabi")))
497 (commit "13861a80750d118fbdca6006ab175903bacbb7ec")
498 (revision "1"))
499 (package (inherit xgcc)
500 (version (git-version "9-2020-q2-update" revision commit))
501 (source
502 (origin
503 (inherit (package-source xgcc))
504 (method git-fetch)
505 (uri (git-reference
506 (url "git://gcc.gnu.org/git/gcc.git")
507 (commit commit)))
508 (file-name (git-file-name "gcc-arm-embedded" version))
509 (sha256
510 (base32
511 "1cshb1wbynjac3icbf2na633k4d8r7nqn4nv0d65q6f78w295h97"))
512 (patches
513 (append
514 (origin-patches (package-source gcc-9))
515 (search-patches
516 "gcc-10-cross-environment-variables.patch")))))
517 (native-inputs
518 (modify-inputs native-inputs
519 (delete "isl")
520 (prepend flex isl-0.18)))
521 (arguments
522 (substitute-keyword-arguments arguments
523 ((#:phases phases)
524 #~(modify-phases #$phases
525 (add-after 'unpack 'expand-version-string
526 (lambda _
527 (make-file-writable "gcc/DEV-PHASE")
528 (with-output-to-file "gcc/DEV-PHASE"
529 (lambda ()
530 (display "9-2020-q2-update")))))
531 (add-after 'unpack 'fix-genmultilib
532 (lambda _
533 (substitute* "gcc/genmultilib"
534 (("#!/bin/sh")
535 (string-append "#!" (which "sh"))))))
536 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
537 (lambda* (#:key inputs #:allow-other-keys)
538 (let ((gcc (assoc-ref inputs "gcc")))
539 ;; Remove the default compiler from
540 ;; CPLUS_INCLUDE_PATH to prevent header conflict
541 ;; with the GCC from native-inputs.
542 (setenv "CPLUS_INCLUDE_PATH"
543 (string-join
544 (delete (string-append gcc "/include/c++")
545 (string-split
546 (getenv "CPLUS_INCLUDE_PATH")
547 #\:))
548 ":"))
549 (format #t
550 "environment variable `CPLUS_INCLUDE_PATH'\
551 changed to ~a~%"
552 (getenv "CPLUS_INCLUDE_PATH")))))))
553 ((#:configure-flags flags)
554 ;; The configure flags are largely identical to the flags
555 ;; used by the "GCC ARM embedded" project.
556 #~(append (list "--enable-multilib"
557 "--with-newlib"
558 "--with-multilib-list=rmprofile"
559 "--with-host-libstdcxx=-static-libgcc \
560-Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
561 "--enable-plugins"
562 "--disable-decimal-float"
563 "--disable-libffi"
564 "--disable-libgomp"
565 "--disable-libmudflap"
566 "--disable-libquadmath"
567 "--disable-libssp"
568 "--disable-libstdcxx-pch"
569 "--disable-nls"
570 "--disable-shared"
571 "--disable-threads"
572 "--disable-tls")
573 (delete "--disable-multilib" #$flags)))))
574 (native-search-paths
575 (list (search-path-specification
576 (variable "CROSS_C_INCLUDE_PATH")
577 (files '("arm-none-eabi/include")))
578 (search-path-specification
579 (variable "CROSS_CPLUS_INCLUDE_PATH")
580 (files '("arm-none-eabi/include/c++"
581 "arm-none-eabi/include/c++/arm-none-eabi"
582 "arm-none-eabi/include")))
583 (search-path-specification
584 (variable "CROSS_LIBRARY_PATH")
585 (files '("arm-none-eabi/lib")))))))))
586
587(define make-base-newlib-arm-none-eabi-9-2020-q2-update
588 ;; This is the same commit as used for the 9-2020-q2-update release
589 ;; according to the release.txt.
590 (mlambda (base)
591 (let ((commit "6d79e0a58866548f435527798fbd4a6849d05bc7")
592 (revision "0"))
593 (package
594 (inherit base)
595 (version (git-version "3.3.0" revision commit))
596 (source
597 (origin
598 (method git-fetch)
599 (uri (git-reference
600 (url "http://sourceware.org/git/newlib-cygwin.git")
601 (commit commit)))
602 (file-name (git-file-name "newlib" version))
603 (sha256
604 (base32
605 "095j23mg928rmf4yqmj39wc0nsd207liqrdw4ygh58nygsm4gpmh"))))
606 (arguments
607 (substitute-keyword-arguments arguments
608 ;; The configure flags are identical to the flags used by the "GCC
609 ;; ARM embedded" project.
610 ((#:configure-flags flags)
611 `(cons* "--enable-newlib-io-c99-formats"
612 "--enable-newlib-retargetable-locking"
613 "--with-headers=yes"
614 ,flags))))
615 (native-inputs
616 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
617 ("xgcc" ,(make-gcc-arm-none-eabi-9-2020-q2-update))
618 ("texinfo" ,texinfo)))))))
619
620(define make-newlib-arm-none-eabi-9-2020-q2-update
621 (mlambda ()
622 (make-base-newlib-arm-none-eabi-9-2020-q2-update (make-newlib-arm-none-eabi))))
623
624(define make-newlib-nano-arm-none-eabi-9-2020-q2-update
625 (mlambda ()
626 (make-base-newlib-arm-none-eabi-9-2020-q2-update (make-newlib-nano-arm-none-eabi))))
627
628
629;;; The following definitions are for the "12.3.rel1" variant of the
630;;; ARM cross toolchain as offered on https://developer.arm.com
631(define-public make-gcc-arm-none-eabi-12.3.rel1
632 (mlambda ()
633 (let ((base (make-gcc-arm-none-eabi-7-2018-q2-update))
634 (xgcc-base (cross-gcc "arm-none-eabi"
635 #:xgcc gcc-12
636 #:xbinutils (cross-binutils "arm-none-eabi"))))
637 (package
638 (inherit base)
639 (version "12.3.rel1")
640 (source
641 (origin
642 (inherit (package-source xgcc-base))
643 (method git-fetch)
644 (uri (git-reference
645 (url "git://gcc.gnu.org/git/gcc.git")
646 (commit "0f54a73b998b72f7c8452a63730ec3b16fc47854")))
647 (sha256
648 (base32 "0r6q0m3d8g3k3rkmnqjw8aw5fcnsrmywf4ispdkxmk1al3whk1vk"))))
649 (arguments
650 (substitute-keyword-arguments arguments
651 ((#:phases phases)
652 #~(modify-phases #$phases
653 (replace 'expand-version-string
654 (lambda _
655 (make-file-writable "gcc/DEV-PHASE")
656 (with-output-to-file "gcc/DEV-PHASE"
657 (lambda ()
658 (display "12.3.rel1")))))))
659 ((#:configure-flags flags)
660 #~(cons* "--with-multilib-list=aprofile,rmprofile"
661 "--with-headers=yes"
662 "--enable-checking=release"
663 "--with-gnu-as"
664 "--with-gnu-ld"
665 (filter
666 (lambda (flag)
667 (not (member flag
668 '("--with-multilib-list=rmprofile"
669 "--enable-plugins"
670 "--disable-libffi"))))
671 #$flags)))))))))
672
673(define make-base-newlib-arm-none-eabi-12.3.rel1
674 (mlambda (original-base)
675 (let ((base (make-base-newlib-arm-none-eabi-7-2018-q2-update original-base))
676 (commit "4c7d0dfec5793cbf5cf3930b91f930479126d8ce")
677 (revision "0"))
678 (package
679 (inherit base)
680 (version (git-version "4.3.0" revision commit))
681 (source
682 (origin
683 (method git-fetch)
684 (uri (git-reference
685 (url "http://sourceware.org/git/newlib-cygwin.git")
686 (commit commit)))
687 (sha256
688 (base32
689 "0drs9v8avh4y2h5bs0ixjn9x662jzkkikx8z034wgl41dxmn6786"))))
690 (arguments (substitute-keyword-arguments arguments
691 ((#:configure-flags flags)
692 #~(cons* "--enable-newlib-mb"
693 "--enable-newlib-reent-check-verify"
694 "--enable-newlib-register-fini"
695 #$flags))))))))
696
697(define make-newlib-arm-none-eabi-12.3.rel1
698 (mlambda ()
699 (make-base-newlib-arm-none-eabi-12.3.rel1 (make-newlib-arm-none-eabi))))
700
701(define make-newlib-nano-arm-none-eabi-12.3.rel1
702 (mlambda ()
703 (make-base-newlib-arm-none-eabi-12.3.rel1 (make-newlib-nano-arm-none-eabi))))
704
705
706(define make-libstdc++-arm-none-eabi
707 (mlambda (xgcc newlib)
708 (let* ((libstdc++ (make-libstdc++ xgcc))
709 (src (package-source libstdc++)))
710 (package
711 (inherit libstdc++)
712 (source
713 (origin
714 (inherit src)
715 (patches (append
716 ; libstdc++ cannot be linked with since the configure phase
717 ; cannot detect properly the presence of getentropy function.
718 ; The function is inside of a header, but it's not present in the resulting
719 ; newlib. configure will conclude getentropy is present,
720 ; random will use getentropy, and any linking with random will fail.
721 (if (version>=? (package-version xgcc) "12.0")
722 (search-patches "newlib-getentropy.patch")
723 '())
724 (origin-patches src)))))
725 (name "libstdc++-arm-none-eabi")
726 (arguments
727 (substitute-keyword-arguments (package-arguments libstdc++)
728 ((#:make-flags flags #f)
729 #~(cons* "CFLAGS=-g -O2 -fdata-sections -ffunction-sections"
730 "CXXFLAGS=-g -O2 -fdata-sections -ffunction-sections"
731 (or #$flags '())))
732 ((#:configure-flags _)
733 ``(; This is more of a hack. This option doesn't really seem
734 ; to change what subdir is used eventually, but without it there is
735 ; error: Link tests are not allowed after GCC_NO_EXECUTABLES with
736 ; The 12.3 toolchain
737 "--with-target-subdir=\".\""
738 "--target=arm-none-eabi"
739 "--host=arm-none-eabi"
740 "--disable-libstdcxx-pch"
741 "--enable-multilib"
742 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
743 "--disable-shared"
744 "--disable-tls"
745 "--disable-plugin"
746 "--with-newlib"
747 ,(string-append "--libdir="
748 (assoc-ref %outputs "out")
749 "/arm-none-eabi/lib")
750 ,(string-append "--with-gxx-include-dir="
751 (assoc-ref %outputs "out")
752 "/arm-none-eabi/include/c++")))
753 ((#:strip-directories _ #f)
754 ''("arm-none-eabi/lib"))))
755 (native-inputs
756 `(("newlib" ,newlib)
757 ("xgcc" ,xgcc)
758 ,@(package-native-inputs libstdc++)))))))
759
760(define make-libstdc++-nano-arm-none-eabi
761 (mlambda (xgcc newlib-nano)
762 (let ((base (make-libstdc++-arm-none-eabi xgcc newlib-nano)))
763 (package
764 (inherit base)
765 (name "libstdc++-nano-arm-none-eabi")
766 (arguments (substitute-keyword-arguments arguments
767 ((#:make-flags flags)
768 #~(map (lambda (flag)
769 (if (or (string-prefix? "CFLAGS=" flag)
770 (string-prefix? "CXXFLAGS=" flag))
771 (string-append flag " -fno-exceptions")
772 flag))
773 #$flags))
774 ((#:phases phases)
775 #~(modify-phases #$phases
776 (add-after 'install 'hardlink-libstdc++
777 ;; XXX: Most arm toolchains offer both *.a and *_nano.a as
778 ;; newlib and newlib-nano respectively. The headers are
779 ;; usually arm-none-eabi/include/newlib.h for newlib and
780 ;; arm-none-eabi/include/newlib-nano/newlib.h for newlib-nano.
781 ;; We have two different toolchain packages for each which
782 ;; works but is a little strange.
783 (lambda* (#:key outputs #:allow-other-keys)
784 (let ((out (assoc-ref outputs "out")))
785 ;; The nano.specs file says that newlib-nano files should
786 ;; end in "_nano.a" instead of just ".a". Note that this
787 ;; applies to all the multilib folders too.
788 (for-each
789 (lambda (file)
790 (link file
791 (string-append
792 ;; Strip ".a" off the end
793 (substring file 0 (- (string-length file) 2))
794 ;; Add "_nano.a" onto the end
795 "_nano.a")))
796 (find-files
797 out "^(libstdc\\+\\+.a|libsupc\\+\\+.a)$")))))))))))))
798
799(define make-arm-none-eabi-toolchain
800 (mlambda (xgcc newlib)
801 "Produce a cross-compiler toolchain package with the compiler XGCC and the
802C library variant NEWLIB."
803 (let* ((nano? (string=? (package-name newlib)
804 "newlib-nano"))
805 (newlib-with-xgcc
806 (package
807 (inherit newlib)
808 (native-inputs
809 (alist-replace "xgcc" (list xgcc)
810 (package-native-inputs newlib)))))
811 (libstdc++
812 (if nano?
813 (make-libstdc++-nano-arm-none-eabi xgcc newlib-with-xgcc)
814 (make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))))
815 (package
816 (name (string-append "arm-none-eabi"
817 (if nano? "-nano" "")
818 "-toolchain"))
819 (version (package-version xgcc))
820 (source #f)
821 (build-system trivial-build-system)
822 (arguments
823 '(#:modules ((guix build union))
824 #:builder
825 (begin
826 (use-modules (ice-9 match)
827 (guix build union))
828 (match %build-inputs
829 (((names . directories) ...)
830 (union-build (assoc-ref %outputs "out")
831 directories))))))
832 (propagated-inputs
833 `(("binutils" ,(cross-binutils "arm-none-eabi"))
834 ("libstdc++" ,libstdc++)
835 ("gcc" ,xgcc)
836 ("newlib" ,newlib-with-xgcc)))
837 (synopsis "Complete GCC tool chain for ARM bare metal development")
838 (description "This package provides a complete GCC tool chain for ARM
839bare metal development. This includes the GCC arm-none-eabi cross compiler
840and newlib (or newlib-nano) as the C library. The supported programming
841languages are C and C++.")
842 (home-page (package-home-page xgcc))
843 (license (package-license xgcc))))))
844
845(define make-arm-none-eabi-toolchain-4.9
846 (mlambda ()
847 (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-4.9)
848 (make-newlib-arm-none-eabi))))
849
850(define make-arm-none-eabi-nano-toolchain-4.9
851 (mlambda ()
852 (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-4.9)
853 (make-newlib-nano-arm-none-eabi))))
854
855(define make-arm-none-eabi-toolchain-6
856 (mlambda ()
857 (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-6)
858 (make-newlib-arm-none-eabi))))
859
860(define make-arm-none-eabi-nano-toolchain-6
861 (mlambda ()
862 (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-6)
863 (make-newlib-nano-arm-none-eabi))))
864
865(define make-arm-none-eabi-toolchain-7-2018-q2-update
866 (mlambda ()
867 (make-arm-none-eabi-toolchain
868 (make-gcc-arm-none-eabi-7-2018-q2-update)
869 (make-newlib-arm-none-eabi-7-2018-q2-update))))
870
871(define make-arm-none-eabi-nano-toolchain-7-2018-q2-update
872 (mlambda ()
873 (make-arm-none-eabi-toolchain
874 (make-gcc-arm-none-eabi-7-2018-q2-update)
875 (make-newlib-nano-arm-none-eabi-7-2018-q2-update))))
876
877(define make-arm-none-eabi-toolchain-9-2020-q2-update
878 (mlambda ()
879 (make-arm-none-eabi-toolchain
880 (make-gcc-arm-none-eabi-9-2020-q2-update)
881 (make-newlib-arm-none-eabi-9-2020-q2-update))))
882
883(define make-arm-none-eabi-nano-toolchain-9-2020-q2-update
884 (mlambda ()
885 (make-arm-none-eabi-toolchain
886 (make-gcc-arm-none-eabi-9-2020-q2-update)
887 (make-newlib-nano-arm-none-eabi-9-2020-q2-update))))
888
889(define make-arm-none-eabi-toolchain-12.3.rel1
890 (mlambda ()
891 (make-arm-none-eabi-toolchain
892 (make-gcc-arm-none-eabi-12.3.rel1)
893 (make-newlib-arm-none-eabi-12.3.rel1))))
894
895(define make-arm-none-eabi-nano-toolchain-12.3.rel1
896 (mlambda ()
897 (make-arm-none-eabi-toolchain
898 (make-gcc-arm-none-eabi-12.3.rel1)
899 (make-newlib-nano-arm-none-eabi-12.3.rel1))))
900
901(define make-gdb-arm-none-eabi
902 (mlambda ()
903 (package
904 (inherit gdb)
905 (name "gdb-arm-none-eabi")
906 (arguments
907 (substitute-keyword-arguments arguments
908 ((#:configure-flags flags '())
909 #~(cons* "--target=arm-none-eabi"
910 "--enable-multilib"
911 "--enable-interwork"
912 "--enable-languages=c,c++"
913 "--disable-nls"
914 #$flags)))))))
915
916(define-public libjaylink
917 (package
918 (name "libjaylink")
919 (version "0.3.1")
920 (source (origin
921 (method git-fetch)
922 (uri (git-reference
923 (url "https://repo.or.cz/libjaylink.git")
924 (commit version)))
925 (file-name (git-file-name name version))
926 (sha256
927 (base32
928 "1wps72ir2kwdr7dphx4vp6cy0d46dm3nkwbk0mpryn9la09l7lm1"))))
929 (build-system gnu-build-system)
930 (native-inputs
931 (list autoconf automake libtool pkg-config))
932 (inputs
933 (list libusb))
934 (home-page "https://repo.or.cz/w/libjaylink.git")
935 (synopsis "Library to interface Segger J-Link devices")
936 (description "libjaylink is a shared library written in C to access
937SEGGER J-Link and compatible devices.")
938 (license license:gpl2+)))
939
940;; Deprecated on 2026-06-27.
941(define-deprecated/public-alias jimtcl
942 (@ (gnu packages tcl) jimtcl))
943
944(define-public openocd
945 (package
946 (name "openocd")
947 (version "0.12.0")
948 (source (origin
949 (method git-fetch)
950 (uri (git-reference
951 (url "https://git.code.sf.net/p/openocd/code")
952 (commit (string-append "v" version))))
953 (file-name (string-append name "-" version "-checkout"))
954 (sha256
955 (base32
956 "09wb11zlmrw6rx1bql3kafgi3ilzp9mhvb6j6rql216by06csing"))))
957 (build-system gnu-build-system)
958 (native-inputs
959 (list autoconf
960 automake
961 libtool
962 which
963 pkg-config
964 texinfo))
965 (inputs
966 (list hidapi (@ (gnu packages tcl) jimtcl) libftdi libjaylink openssl))
967 (arguments
968 '(#:configure-flags
969 (append (list "LIBS=-lutil -lcrypto -lssl"
970 "--disable-werror"
971 "--enable-sysfsgpio"
972 "--disable-internal-jimtcl"
973 "--disable-internal-libjaylink")
974 (map (lambda (programmer)
975 (string-append "--enable-" programmer))
976 '("amtjtagaccel" "armjtagew" "buspirate" "ftdi"
977 "gw16012" "jlink" "opendous" "osbdm"
978 "parport" "aice" "cmsis-dap" "dummy" "jtag_vpi"
979 "remote-bitbang" "rlink" "stlink" "ti-icdi" "ulink"
980 "usbprog" "vsllink" "usb-blaster-2" "usb_blaster"
981 "presto" "openjtag" "rshim" "ft232r" "xds110"
982 "cmsis-dap-v2" "nulink" "kitprog" "jtag_dpi"
983 "bcm2835gpio" "imx_gpio" "ep93xx" "at91rm9200"
984 "sysfsgpio" "xlnx-pcie-xvc")))
985 #:phases
986 (modify-phases %standard-phases
987 (replace 'bootstrap
988 (lambda _
989 ;; Make build reproducible.
990 (substitute* "src/Makefile.am"
991 (("-DPKGBLDDATE=") "-DDISABLED_PKGBLDDATE="))
992 (patch-shebang "bootstrap")
993 (invoke "./bootstrap" "nosubmodule")))
994 (add-after 'unpack 'change-udev-group
995 (lambda _
996 (substitute* "contrib/60-openocd.rules"
997 (("plugdev") "dialout"))))
998 (add-after 'install 'install-udev-rules
999 (lambda* (#:key outputs #:allow-other-keys)
1000 (install-file "contrib/60-openocd.rules"
1001 (string-append
1002 (assoc-ref outputs "out")
1003 "/lib/udev/rules.d/")))))))
1004 (home-page "https://openocd.org/")
1005 (synopsis "On-Chip Debugger")
1006 (description "OpenOCD provides on-chip programming and debugging support
1007with a layered architecture of JTAG interface and TAP support.")
1008 (license license:gpl2+)))
1009
1010;; The commits for all propeller tools are the stable versions published at
1011;; https://github.com/propellerinc/propgcc in the release_1_0. According to
1012;; personal correspondence with the developers in July 2017, more recent
1013;; versions are currently incompatible with the "Simple Libraries".
1014
1015(define make-propeller-binutils
1016 (mlambda ()
1017 (let ((xbinutils (cross-binutils "propeller-elf"))
1018 (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
1019 (revision "2"))
1020 (package
1021 (inherit xbinutils)
1022 (name "propeller-binutils")
1023 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
1024 (source (origin
1025 (inherit (package-source xbinutils))
1026 (method git-fetch)
1027 (uri (git-reference
1028 (url "https://github.com/parallaxinc/propgcc")
1029 (commit commit)))
1030 (file-name (string-append name "-" commit "-checkout"))
1031 (sha256
1032 (base32
1033 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
1034 (patches '())))
1035 (arguments
1036 (substitute-keyword-arguments arguments
1037 ((#:configure-flags flags)
1038 #~(cons "--disable-werror" #$flags))
1039 ;; FIXME: For some reason there are many test failures. It's not
1040 ;; obvious how to fix the failures.
1041 ((#:tests? tests? #false) #false)
1042 ((#:phases phases '%standard-phases)
1043 `(modify-phases ,phases
1044 (add-after 'unpack 'chdir
1045 (lambda _ (chdir "binutils")))))))
1046 (native-inputs
1047 `(("bison" ,bison)
1048 ("flex" ,flex)
1049 ("texinfo" ,texinfo)
1050 ("dejagnu" ,dejagnu)
1051 ,@(package-native-inputs xbinutils)))))))
1052
1053(define make-propeller-gcc-6
1054 (mlambda ()
1055 (let ((xgcc (cross-gcc "propeller-elf"
1056 #:xbinutils (make-propeller-binutils)))
1057 (commit "b4f45a4725e0b6d0af59e594c4e3e35ca4105867")
1058 (revision "1"))
1059 (package
1060 (inherit xgcc)
1061 (name "propeller-gcc")
1062 (version (string-append "6.0.0-" revision "." (string-take commit 9)))
1063 (source (origin
1064 (method git-fetch)
1065 (uri (git-reference
1066 (url "https://github.com/totalspectrum/gcc-propeller")
1067 (commit commit)))
1068 (file-name (string-append name "-" commit "-checkout"))
1069 (sha256
1070 (base32
1071 "0d9kdxm2fzanjqa7q5850kzbsfl0fqyaahxn74h6nkxxacwa11zb"))
1072 (patches
1073 (append
1074 (origin-patches (package-source gcc-6))
1075 (search-patches "gcc-cross-environment-variables.patch")))))
1076 (native-inputs
1077 (modify-inputs native-inputs
1078 (prepend flex)))
1079 ;; All headers and cross libraries of the propeller toolchain are
1080 ;; installed under the "propeller-elf" prefix.
1081 (native-search-paths
1082 (list (search-path-specification
1083 (variable "CROSS_C_INCLUDE_PATH")
1084 (files '("propeller-elf/include")))
1085 (search-path-specification
1086 (variable "CROSS_LIBRARY_PATH")
1087 (files '("propeller-elf/lib")))))
1088 (home-page "https://github.com/totalspectrum/gcc-propeller")
1089 (synopsis "GCC for the Parallax Propeller")))))
1090
1091(define make-propeller-gcc-4
1092 (mlambda ()
1093 (let ((xgcc (make-propeller-gcc-6))
1094 (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
1095 (revision "2"))
1096 (package
1097 (inherit xgcc)
1098 (name "propeller-gcc")
1099 (version (string-append "4.6.1-" revision "." (string-take commit 9)))
1100 (source (origin
1101 (method git-fetch)
1102 (uri (git-reference
1103 (url "https://github.com/parallaxinc/propgcc")
1104 (commit commit)))
1105 (file-name (string-append name "-" commit "-checkout"))
1106 (sha256
1107 (base32
1108 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
1109 (patch-flags (list "-p1" "--directory=gcc"))
1110 (patches
1111 (append
1112 (origin-patches (package-source gcc-base))
1113 (search-patches
1114 "gcc-cross-environment-variables.patch")))))
1115 (arguments
1116 (substitute-keyword-arguments arguments
1117 ((#:phases phases)
1118 #~(modify-phases #$phases
1119 (delete 'pre-x86-configure)
1120 (add-after 'unpack 'chdir
1121 (lambda _ (chdir "gcc")))))))
1122 (native-inputs
1123 (modify-inputs native-inputs
1124 (prepend gcc-5)))
1125 (home-page "https://github.com/parallaxinc/propgcc")
1126 (supported-systems (delete "aarch64-linux" %supported-systems))))))
1127
1128;; Version 6 is experimental and may not work correctly. This is why we
1129;; default to version 4, which is also used in the binary toolchain bundle
1130;; provided by Parallax Inc.
1131(define make-propeller-gcc make-propeller-gcc-4)
1132
1133
1134;; FIXME: We do not build the tiny library because that would require C++
1135;; headers, which are not available. This may require adding a propeller-elf
1136;; variant of the libstdc++ package.
1137(define-public proplib
1138 (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
1139 (revision "2"))
1140 (package
1141 (name "proplib")
1142 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
1143 (source (origin
1144 (method git-fetch)
1145 (uri (git-reference
1146 (url "https://github.com/parallaxinc/propgcc")
1147 (commit commit)))
1148 (file-name (string-append name "-" commit "-checkout"))
1149 (sha256
1150 (base32
1151 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
1152 (build-system gnu-build-system)
1153 (arguments
1154 `(#:tests? #f ; no tests
1155 #:make-flags
1156 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
1157 (string-append "BUILD=" (getcwd) "/build"))
1158 #:phases
1159 (modify-phases %standard-phases
1160 (delete 'configure)
1161 (add-after 'unpack 'chdir
1162 (lambda _ (chdir "lib") #t))
1163 (add-after 'chdir 'fix-Makefile
1164 (lambda _
1165 (substitute* "Makefile"
1166 ;; Control the installation time of the headers.
1167 ((" install-includes") ""))
1168 #t))
1169 ;; The Makefile does not separate building from installation, so we
1170 ;; have to create the target directories at build time.
1171 (add-before 'build 'create-target-directories
1172 (lambda* (#:key make-flags #:allow-other-keys)
1173 (apply invoke "make" "install-dirs" make-flags)))
1174 (add-before 'build 'set-cross-environment-variables
1175 (lambda* (#:key outputs #:allow-other-keys)
1176 (setenv "CROSS_LIBRARY_PATH"
1177 (string-append (assoc-ref outputs "out")
1178 "/propeller-elf/lib:"
1179 (or (getenv "CROSS_LIBRARY_PATH") "")))
1180 (setenv "CROSS_C_INCLUDE_PATH"
1181 (string-append (assoc-ref outputs "out")
1182 "/propeller-elf/include:"
1183 (or (getenv "CROSS_C_INCLUDE_PATH") "")))
1184 #t))
1185 (add-before 'install 'install-includes
1186 (lambda* (#:key make-flags #:allow-other-keys)
1187 (apply invoke "make" "install-includes" make-flags))))))
1188 (native-inputs
1189 (list (make-propeller-gcc) (make-propeller-binutils) perl))
1190 (home-page "https://github.com/parallaxinc/propgcc")
1191 (synopsis "C library for the Parallax Propeller")
1192 (description "This is a C library for the Parallax Propeller
1193micro-controller.")
1194 ;; Most of the code is released under the Expat license. Some of the
1195 ;; included code is public domain and some changes are BSD licensed.
1196 (license license:expat))))
1197
1198(define make-propeller-toolchain
1199 (mlambda ()
1200 (let ((propeller-gcc (make-propeller-gcc)))
1201 (package
1202 (name "propeller-toolchain")
1203 (version (package-version propeller-gcc))
1204 (source #f)
1205 (build-system trivial-build-system)
1206 (arguments '(#:builder (begin (mkdir %output) #t)))
1207 (propagated-inputs
1208 `(("binutils" ,(make-propeller-binutils))
1209 ("libc" ,proplib)
1210 ("gcc" ,propeller-gcc)))
1211 (synopsis "Complete GCC tool chain for Propeller micro-controllers")
1212 (description "This package provides a complete GCC tool chain for
1213Propeller micro-controller development.")
1214 (home-page (package-home-page propeller-gcc))
1215 (license (package-license propeller-gcc))))))
1216
1217(define-public openspin
1218 (package
1219 (name "openspin")
1220 (version "1.00.78")
1221 (source (origin
1222 (method git-fetch)
1223 (uri (git-reference
1224 (url "https://github.com/parallaxinc/OpenSpin")
1225 (commit version)))
1226 (file-name (git-file-name name version))
1227 (sha256
1228 (base32
1229 "0ghk8hj4717ydhqzx2pfs6737s1cxng6sgg2xgbkwvcfclxdbrd0"))))
1230 (build-system gnu-build-system)
1231 (arguments
1232 `(#:tests? #f ; no tests
1233 #:phases
1234 (modify-phases %standard-phases
1235 (delete 'configure)
1236 (add-after 'unpack 'remove-timestamp
1237 (lambda _
1238 (substitute* "SpinSource/openspin.cpp"
1239 ((" Compiled on.*$") "\\n\");"))
1240 #t))
1241 ;; Makefile does not include "install" target
1242 (replace 'install
1243 (lambda* (#:key outputs #:allow-other-keys)
1244 (let ((bin (string-append (assoc-ref outputs "out")
1245 "/bin")))
1246 (mkdir-p bin)
1247 (install-file "build/openspin" bin)
1248 #t))))))
1249 (home-page "https://github.com/parallaxinc/OpenSpin")
1250 (synopsis "Spin/PASM compiler for the Parallax Propeller")
1251 (description "OpenSpin is a compiler for the Spin/PASM language of the
1252Parallax Propeller. It was ported from Chip Gracey's original x86 assembler
1253code.")
1254 (license license:expat)))
1255
1256(define-public propeller-load
1257 (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
1258 (revision "2"))
1259 (package
1260 (name "propeller-load")
1261 (version "3.4.0")
1262 (source (origin
1263 (method git-fetch)
1264 (uri (git-reference
1265 (url "https://github.com/parallaxinc/propgcc")
1266 (commit commit)))
1267 (file-name (string-append name "-" commit "-checkout"))
1268 (sha256
1269 (base32
1270 "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
1271 (build-system gnu-build-system)
1272 (arguments
1273 (list
1274 #:tests? #false ;no tests
1275 #:parallel-build? #false ;not supported
1276 #:make-flags
1277 #~(list "OS=linux"
1278 (string-append "TARGET=" #$output))
1279 #:phases
1280 '(modify-phases %standard-phases
1281 (add-after 'unpack 'chdir
1282 (lambda _ (chdir "loader")))
1283 (add-after 'chdir 'patch-for-readlink
1284 (lambda _
1285 (substitute* "src/system.c"
1286 (("#include <stdio.h>")
1287 "\
1288#include <stdio.h>
1289#include <unistd.h>"))))
1290 (delete 'configure))))
1291 (native-inputs
1292 (list openspin (make-propeller-toolchain)))
1293 (home-page "https://github.com/parallaxinc/propgcc")
1294 (synopsis "Loader for Parallax Propeller micro-controllers")
1295 (description "This package provides the tool @code{propeller-load} to
1296upload binaries to a Parallax Propeller micro-controller.")
1297 (license license:expat))))
1298
1299(define-public spinsim
1300 (let ((commit "66915a7ad1a3a2cf990a725bb341fab8d11eb620")
1301 (revision "1"))
1302 (package
1303 (name "spinsim")
1304 (version (string-append "0.75-" revision "." (string-take commit 9)))
1305 (source (origin
1306 (method git-fetch)
1307 (uri (git-reference
1308 (url "https://github.com/parallaxinc/spinsim")
1309 (commit commit)))
1310 (file-name (string-append name "-" commit "-checkout"))
1311 (sha256
1312 (base32
1313 "1n9kdhlxsdx7bz6c80w8dhi96zp633gd6qs0x9i4ii8qv4i7sj5k"))))
1314 (build-system gnu-build-system)
1315 (arguments
1316 `(#:tests? #f ; no tests
1317 #:phases
1318 (modify-phases %standard-phases
1319 (delete 'configure)
1320 (replace 'install
1321 (lambda* (#:key outputs #:allow-other-keys)
1322 (let ((bin (string-append (assoc-ref outputs "out")
1323 "/bin")))
1324 (install-file "build/spinsim" bin))
1325 #t)))))
1326 (home-page "https://github.com/parallaxinc/spinsim")
1327 (synopsis "Spin simulator")
1328 (description "This package provides the tool @code{spinsim}, a simulator
1329and simple debugger for Spin programs written for a Parallax Propeller
1330micro-controller. Spinsim supports execution from cog memory and hub
1331execution, but it does not support multi-tasking. It supports about
1332two-thirds of the opcodes in the P2 instruction set.")
1333 (license license:expat))))
1334
1335(define-public imx-usb-loader
1336 ;; There are no proper releases.
1337 (let ((commit "30b43d69770cd69e84c045dc9dcabb1f3e9d975a")
1338 (revision "0"))
1339 (package
1340 (name "imx-usb-loader")
1341 ;; For the version string, see IMX_LOADER_VERSION in imx_loader.h.
1342 (version (git-version "0.2pre" revision commit))
1343 (source (origin
1344 (method git-fetch)
1345 (uri (git-reference
1346 (url "https://github.com/boundarydevices/imx_usb_loader")
1347 (commit commit)))
1348 (file-name (git-file-name name version))
1349 (sha256
1350 (base32
1351 "1jdxbg63qascyl8x32njs9k9gzy86g209q7hc0jp74qyh0i6fwwc"))))
1352 (build-system gnu-build-system)
1353 (arguments
1354 (list #:test-target "tests"
1355 #:make-flags #~(list (string-append "CC=" #$(cc-for-target))
1356 (string-append "prefix=" #$output))
1357 #:phases #~(modify-phases %standard-phases
1358 (delete 'configure))))
1359 (native-inputs (list pkg-config))
1360 (inputs (list libusb))
1361 (home-page "https://github.com/boundarydevices/imx_usb_loader")
1362 (synopsis "USB and UART loader for i.MX5/6/7/8 series")
1363 (description "This utility downloads and executes code on Freescale
1364i.MX5/i.MX6/i.MX7 and Vybrid SoCs through the Serial Download Protocol (SDP).
1365Depending on the board, there is usually some kind of recovery button to bring
1366the SoC into serial download boot mode; check the documentation of your
1367hardware. The utility support USB and UART as serial link.")
1368 (license license:lgpl2.1+))))
1369
1370(define-public python-cmsis-pack-manager
1371 (package
1372 (name "python-cmsis-pack-manager")
1373 (version "0.6.0")
1374 (source
1375 (origin
1376 (method git-fetch)
1377 (uri (git-reference
1378 (url "https://github.com/pyocd/cmsis-pack-manager")
1379 (commit (string-append "v" version))))
1380 (file-name (git-file-name name version))
1381 (sha256
1382 (base32 "0djxvmpw6krv459w0w98cva9clrpqicwfr0fx55hkaix1x51bgci"))))
1383 (build-system pyproject-build-system)
1384 (arguments
1385 (list
1386 #:imported-modules `(,@%cargo-build-system-modules
1387 ,@%pyproject-build-system-modules)
1388 #:modules '(((guix build cargo-build-system) #:prefix cargo:)
1389 (guix build pyproject-build-system)
1390 (guix build utils))
1391 #:phases
1392 #~(modify-phases %standard-phases
1393 (add-after 'unpack 'prepare-cargo-build-system
1394 (lambda args
1395 (for-each
1396 (lambda (phase)
1397 (format #t "Running cargo phase: ~a~%" phase)
1398 (apply (assoc-ref cargo:%standard-phases phase)
1399 #:cargo-target #$(cargo-triplet)
1400 args))
1401 '(prepare-rust-crates
1402 unpack-rust-crates
1403 configure
1404 check-for-pregenerated-files
1405 patch-cargo-checksums)))))))
1406 (propagated-inputs
1407 (list python-appdirs
1408 python-cffi
1409 python-pyyaml))
1410 (native-inputs
1411 (append
1412 (list maturin
1413 python-wrapper
1414 python-jinja2
1415 python-pytest
1416 rust
1417 `(,rust "cargo"))
1418 (or (and=> (%current-target-system)
1419 (compose list make-rust-sysroot))
1420 '())))
1421 (inputs (cargo-inputs 'python-cmsis-pack-manager))
1422 (home-page "https://github.com/pyocd/cmsis-pack-manager")
1423 (synopsis "CMSIS-Pack index manager")
1424 (description
1425 "@code{cmsis-pack-manager} is a Python module, Rust crate and command line
1426utility for managing current device information that is stored in many
1427@acronym{Common Microcontroller Software Interface Standard, CMSIS}
1428PACKs. Users of @code{cmsis-pack-manager} may query for information such as
1429processor type, flash algorithm and memory layout information in a Python
1430program or through the command line utility, @code{pack-manager}, provided as
1431part of this module.")
1432 (license license:asl2.0)))
1433
1434(define-public python-libmpsse
1435 (package
1436 (name "python-libmpsse")
1437 (version "1.4.1")
1438 (source
1439 (origin
1440 (method git-fetch)
1441 (uri (git-reference
1442 (url "https://github.com/daym/libmpsse")
1443 (commit (string-append "v" version))))
1444 (file-name "libmpsse-checkout")
1445 (sha256
1446 (base32
1447 "1rypfb96k2szqgygp3jnwg2zq9kwmfz0460dsahn3r2vkzml8wn7"))))
1448 (build-system gnu-build-system)
1449 (inputs
1450 (list libftdi python))
1451 (native-inputs
1452 (list pkg-config swig-4.4 which))
1453 (arguments
1454 `(#:tests? #f ; No tests exist.
1455 #:parallel-build? #f ; Would be buggy.
1456 #:make-flags
1457 (list (string-append "CFLAGS=-Wall -fPIC -fno-strict-aliasing -g -O2 "
1458 "$(shell pkg-config --cflags libftdi1)"))
1459 #:phases
1460 (modify-phases %standard-phases
1461 (add-after 'unpack 'set-environment-up
1462 (lambda* (#:key inputs outputs #:allow-other-keys)
1463 (let ((python (assoc-ref inputs "python")))
1464 (chdir "src")
1465 (setenv "PYDEV" (string-append python
1466 "/include/python"
1467 ,(version-major+minor (package-version python))))
1468 #t)))
1469 (replace 'install
1470 (lambda* (#:key inputs outputs make-flags #:allow-other-keys #:rest args)
1471 (let* ((out (assoc-ref outputs "out"))
1472 (out-python (string-append out
1473 "/lib/python"
1474 ,(version-major+minor (package-version python))
1475 "/site-packages"))
1476 (install (assoc-ref %standard-phases 'install)))
1477 (install #:make-flags (cons (string-append "PYLIB=" out-python)
1478 make-flags))))))))
1479 (home-page "https://code.google.com/archive/p/libmpsse/")
1480 (synopsis "Python library for MPSSE SPI I2C JTAG adapter by FTDI")
1481 (description "This package provides a library in order to support the
1482MPSSE (Multi-Protocol Synchronous Serial Engine) adapter by FTDI that can do
1483SPI, I2C, JTAG.")
1484 (license license:gpl2+)))
1485
1486(define-public picprog
1487 (package
1488 (name "picprog")
1489 (version "1.9.1")
1490 (source (origin
1491 (method url-fetch)
1492 (uri (string-append "http://www.iki.fi/hyvatti/pic/picprog-"
1493 version ".tar.gz"))
1494 (file-name (string-append name "-" version ".tar.gz"))
1495 (sha256
1496 (base32
1497 "1r04hg1n3v2jf915qr05la3q9cxy7a5jnh9cc98j04lh6c9p4x85"))
1498 (patches (search-patches "picprog-non-intel-support.patch"))))
1499 (build-system gnu-build-system)
1500 (arguments
1501 `(#:tests? #f ; No tests exist.
1502 #:phases
1503 (modify-phases %standard-phases
1504 (add-after 'unpack 'patch-paths
1505 (lambda* (#:key outputs #:allow-other-keys)
1506 (substitute* "Makefile"
1507 (("/usr/local") (assoc-ref outputs "out"))
1508 ((" -o 0 -g 0 ") " ")
1509 (("testport") ""))
1510 #t))
1511 (add-before 'install 'mkdir
1512 (lambda* (#:key outputs #:allow-other-keys)
1513 (let ((out (assoc-ref outputs "out")))
1514 (mkdir-p (string-append out "/bin"))
1515 (mkdir-p (string-append out "/man/man1"))
1516 #t)))
1517 (delete 'configure))))
1518 (synopsis "Programs Microchip's PIC microcontrollers")
1519 (description "This program programs Microchip's PIC microcontrollers.")
1520 (home-page "https://hyvatti.iki.fi/~jaakko/pic/picprog.html")
1521 (license license:gpl3+)))
1522
1523(define-public stcgal
1524 (package
1525 (name "stcgal")
1526 (version "1.10")
1527 (source
1528 (origin
1529 (method git-fetch)
1530 (uri (git-reference
1531 (url "https://github.com/grigorig/stcgal")
1532 (commit (string-append "v" version))))
1533 (file-name (git-file-name name version))
1534 (sha256
1535 (base32 "04hsj49sw5mb6swhd3sdsm7dzwp1frnzpmq70wgsn5vmjavb1ka8"))))
1536 (build-system pyproject-build-system)
1537 (propagated-inputs (list python-pyserial python-pyusb python-tqdm))
1538 (native-inputs
1539 ;; For tests.
1540 (list python-pytest python-pyyaml python-setuptools))
1541 (home-page "https://github.com/grigorig/stcgal")
1542 (synopsis "Programmer for STC 8051-compatible microcontrollers")
1543 (description "stcgal is a command-line flash-programming tool for STC
1544MCU's line of Intel 8051-compatible microcontrollers, including those in the
1545STC89, STC90, STC10, STC11, STC12, STC15, STC8 and STC32 series.")
1546 (license license:expat)))
1547
1548(define-public stlink
1549 (let ((commit "6a6718b3342b6c5e282a4e33325b9f97908a0692")
1550 (revision "0"))
1551 (package
1552 (name "stlink")
1553 (version (git-version "1.8.0" revision commit))
1554 (source
1555 (origin
1556 (method git-fetch)
1557 (uri (git-reference
1558 (url "https://github.com/stlink-org/stlink")
1559 (commit commit)))
1560 (file-name (git-file-name name version))
1561 (sha256
1562 (base32
1563 "1sk9qr3f8v1rm735vq6pxckgwzsgr4k2kl6skh79f4v2qm0hc4qd"))))
1564 (build-system cmake-build-system)
1565 (arguments
1566 (list #:tests? #f ;no tests
1567 #:configure-flags
1568 #~(let* ((etc (in-vicinity #$output "etc"))
1569 (modprobe (in-vicinity etc "modprobe.d"))
1570 (udev-rules (in-vicinity etc "udev/rules.d")))
1571 (list (string-append "-DSTLINK_UDEV_RULES_DIR=" udev-rules)
1572 (string-append "-DSTLINK_MODPROBED_DIR=" modprobe)))))
1573 (inputs
1574 (list libusb))
1575 (synopsis "Programmer for STM32 Discovery boards")
1576 (description "This package provides a firmware programmer for the STM32
1577 Discovery boards. It supports two versions of the chip: ST-LINK/V1 (on
1578 STM32VL discovery kits) and ST-LINK/V2 (on STM32L discovery and later kits).
1579 Two different transport layers are used: ST-LINK/V1 uses SCSI passthru
1580 commands over USB, and ST-LINK/V2 and ST-LINK/V2-1 (seen on Nucleo boards) use
1581 raw USB commands.")
1582 (home-page "https://github.com/stlink-org/stlink")
1583 ;; The flashloaders/stm32l0x.s and flashloaders/stm32lx.s source files are
1584 ;; licensed under the GPLv2+.
1585 (license (list license:bsd-3 license:gpl2+)))))
1586
1587(define-public west
1588 (package
1589 (name "west")
1590 (version "1.5.0")
1591 (source
1592 (origin
1593 (method git-fetch)
1594 (uri (git-reference
1595 (url "https://github.com/zephyrproject-rtos/west")
1596 (commit (string-append "v" version))))
1597 (file-name (git-file-name name version))
1598 (sha256
1599 (base32 "0fa3bbw69khw8la4mi4q18d8brixywwj5yby7dh36hd40wxspzk3"))))
1600 (build-system pyproject-build-system)
1601 (arguments
1602 (list
1603 #:test-flags
1604 ;; XXX: This test tries to access the network.
1605 #~(list "-k" "not test_init_with_clone_option_depth_one")
1606 #:phases
1607 #~(modify-phases %standard-phases
1608 (add-before 'check 'configure-tests
1609 (lambda _
1610 (setenv "TOXTEMPDIR"
1611 (mkdtemp
1612 (string-append (dirname (getcwd)) "/tmpXXXXXX"))))))))
1613 (propagated-inputs
1614 (list python-colorama
1615 python-packaging
1616 python-pykwalify
1617 python-pyyaml))
1618 (native-inputs (list git-minimal/pinned python-pytest python-setuptools))
1619 (home-page "https://github.com/zephyrproject-rtos/west")
1620 (synopsis "Zephyr RTOS Project meta-tool")
1621 (description
1622 "West is the swiss-army knife command line tool of the Zephyr project.
1623Its built-in commands provide a multiple repository management system with
1624features inspired by Google’s Repo tool and Git submodules. West simplifies
1625configuration and is also pluggable: you can write your own west \"extension
1626commands\" which add additional features to west. Zephyr uses this feature to
1627provide conveniences for building applications, flashing and debugging them,
1628and more.")
1629 (license license:expat)))
1630
1631(define-public ebusd
1632 (package
1633 (name "ebusd")
1634 (version "26.1")
1635 (source (origin
1636 (method git-fetch)
1637 (uri (git-reference
1638 (url "https://github.com/john30/ebusd")
1639 (commit version)))
1640 (file-name (string-append name "-" version "-checkout"))
1641 (sha256
1642 (base32
1643 "1as59bjv9m6hgzg7bjy4nwwzqkwf18a1ss515wjzziaz8a32nq0a"))))
1644 (build-system gnu-build-system)
1645 (arguments
1646 (list #:configure-flags #~(list "--localstatedir=/var")
1647 #:phases
1648 #~(modify-phases %standard-phases
1649 (add-after 'unpack 'patch
1650 (lambda _
1651 (let ((config (string-append #$output "/share/ebusd/")))
1652 (substitute* "src/ebusd/main.h"
1653 (("#define CONFIG_PATH .*")
1654 (format #f "#define CONFIG_PATH \"~a\"\n" config))))))
1655 ;; If we don't set GIT_REVISION, then the build system will include the
1656 ;; current date in the version string, making the build unreproducible.
1657 ;;
1658 ;; See:
1659 ;; * https://codeberg.org/guix/guix/issues/6638
1660 ;; * https://github.com/john30/ebusd/blob/v22.4/configure.ac#L159-L163
1661 (add-after 'unpack 'set-version-info
1662 (lambda _
1663 (setenv "GIT_REVISION" #$version)))
1664 (add-after 'install 'install-config
1665 (lambda _
1666 (let ((config-destination (string-append #$output
1667 "/share/ebusd"))
1668 (config #$(this-package-native-input "config")))
1669 (copy-recursively (string-append config "/src/")
1670 config-destination)))))))
1671 (inputs
1672 (list mosquitto))
1673 (native-inputs
1674 `(("automake" ,automake)
1675 ("autoconf" ,autoconf)
1676 ("config"
1677 ,(origin
1678 (method git-fetch)
1679 (uri (git-reference
1680 (url "https://github.com/john30/ebusd-configuration")
1681 (commit "f72859829a4a6a03c51f5374356f4c0d6353e897")))
1682 (file-name "ebusd-configuration")
1683 (sha256
1684 (base32
1685 "0683jnj6nvvhp6w6sam8ldakw39lf64wjlwjzva9v35ly2fddj5g"))))))
1686 (synopsis "Daemon for communicating with eBUS devices")
1687 (description "This package provides @command{ebusd}, a daemon for
1688handling communication with eBUS devices connected to a 2-wire bus system
1689(\"energy bus\" used by numerous heating systems).")
1690 (home-page "https://ebusd.eu/")
1691 (license license:gpl3+)))
1692
1693(define-public ucsim
1694 (package
1695 (name "ucsim")
1696 (version "0.8.2")
1697 (source (origin
1698 (method url-fetch)
1699 (uri (string-append
1700 "http://mazsola.iit.uni-miskolc.hu/ucsim/download/"
1701 "v" (version-major+minor version) ".x/"
1702 "ucsim_" version "_orig.tar.gz"))
1703 (sha256
1704 (base32
1705 "1zdvzfhdsbydyyjy5rf2934bn06skdlnky6l9ngbp2k645g0ynlh"))))
1706 (build-system gnu-build-system)
1707 (arguments
1708 (list
1709 #:phases
1710 #~(modify-phases %standard-phases
1711 (add-after 'unpack 'patch-makefiles
1712 (lambda _
1713 (substitute* (find-files "." "(\\.mk$|\\.in$)")
1714 (("/bin/sh") (which "sh")))
1715
1716 ;; Ensure the documentation is installed to the correct path,
1717 ;; without a duplicate "ucsim" segment (necessary as we are
1718 ;; building μCsim outside of SDCC).
1719 (substitute* "doc/Makefile.in"
1720 (("@docdir@/ucsim") "@docdir@")))))
1721 ;; μCsim's regression-test suite is of little use in this context since
1722 ;; it doesn't stop or return an error code when it encounters a problem.
1723 #:tests? #f))
1724 (inputs
1725 (list ncurses))
1726 (native-inputs
1727 (list bison flex))
1728 (outputs '("out" "doc"))
1729 (home-page "http://mazsola.iit.uni-miskolc.hu/ucsim/")
1730 (synopsis "Simulators for various microcontroller families")
1731 (description "μCsim is a collection of software simulators for
1732microcontrollers in the Atmel AVR; Fairchild F8; Intel MCS-51 (8051) and 8085;
1733MOS Technology 6502; Motorola 6800, 6809, 68HC08, 68HC11 and 68HC12; P1516;
1734Padauk PDK13, PDK14 and PDK15; STMicroelectronics ST7 and STM8; Xilinx
1735PicoBlaze; and Zilog Z80 families, plus many of their variants.")
1736 (license license:gpl2+)))
1737
1738(define-public sdcc
1739 (package
1740 (name "sdcc")
1741 (version "4.4.0")
1742 (source (origin
1743 (method url-fetch)
1744 (uri (string-append
1745 "mirror://sourceforge/sdcc/sdcc"
1746 "/" version "/sdcc-src-" version ".tar.bz2"))
1747 (sha256
1748 (base32
1749 "0xbaj3vx5cp3na1kmyhy4jvhcqwrg648scjbykgq0xmibqb1535f"))
1750 (modules '((guix build utils)))
1751 (snippet
1752 #~(begin
1753 ;; Remove non-free source files.
1754 (delete-file-recursively "device/non-free")
1755 ;; Remove bundled μCsim source.
1756 (delete-file-recursively "sim")))
1757 (patches (search-patches "sdcc-disable-non-free-code.patch"))))
1758 (build-system gnu-build-system)
1759 (arguments
1760 (list
1761 #:configure-flags
1762 #~(list
1763 ;; GPUTILS is required for the PIC ports, but the licensing status of
1764 ;; some of the files contained in its distribution is unclear (see
1765 ;; https://issues.guix.gnu.org/44557). For this reason it is not yet
1766 ;; available as a package in Guix.
1767 "--disable-pic14-port"
1768 "--disable-pic16-port"
1769
1770 ;; Do not build or install the bundled copy of μCsim, for which Guix
1771 ;; has its own package.
1772 "--disable-ucsim")
1773 #:phases
1774 #~(modify-phases %standard-phases
1775 (add-after 'unpack 'patch-makefiles
1776 (lambda _
1777 (substitute* (find-files "." "(\\.mk$|\\.in$)")
1778 (("/bin/sh") (which "sh")))
1779 ;; --disable-ucsim disables sdcc-misc, patch it back in.
1780 (substitute* "Makefile.in"
1781 (("debugger/mcs51" line)
1782 (string-append line "\n"
1783 "TARGETS += sdcc-misc\n"
1784 "PKGS += $(SDCC_MISC)")))))
1785 (add-after 'patch-makefiles 'embed-absolute-ucsim-reference
1786 (lambda _
1787 ;; Embed in the debugger an absolute reference to the MCS-51
1788 ;; simulator from Guix's μCsim package to ensure it is always
1789 ;; available.
1790 (substitute* "debugger/mcs51/sdcdb.c"
1791 (("s51")
1792 (string-append #$(this-package-input "ucsim")
1793 "/bin/s51"))))))))
1794 (inputs
1795 (list readline ucsim))
1796 (native-inputs
1797 (list bison boost flex python-minimal-wrapper texinfo zlib))
1798 (home-page "https://sdcc.sourceforge.net/")
1799 (synopsis "C compiler suite for 8-bit microcontrollers")
1800 (description "SDCC is a retargetable, optimizing Standard C compiler suite
1801that targets 8-bit microcontrollers in the Intel MCS-51 (8051); MOS Technology
18026502; Motorola 68HC08; Padauk PDK13, PDK14 and PDK15; STMicroelectronics STM8;
1803and Zilog Z80 families, plus many of their variants.")
1804 (license (list license:gpl2+
1805 license:gpl3+
1806 license:lgpl2.0+
1807 license:lgpl2.1+
1808 license:lgpl3+
1809 license:public-domain
1810 license:zlib))))
1811
1812(define-public python-psptool
1813 (package
1814 (name "python-psptool")
1815 (version "3.6")
1816 (source
1817 (origin
1818 (method git-fetch)
1819 (uri (git-reference
1820 (url "https://github.com/PSPReverse/psptool")
1821 (commit version)))
1822 (file-name (git-file-name name version))
1823 (sha256
1824 (base32 "1s53bqimh1ih0xqmyppm2ikphi8r9492k67kn4pz3jngh2gp1wnf"))))
1825 (build-system pyproject-build-system)
1826 (arguments
1827 (list #:test-backend #~'unittest))
1828 (native-inputs
1829 (list python-hatch-vcs
1830 python-hatchling
1831 python-psptrace-bootstrap
1832 python-setuptools))
1833 (propagated-inputs
1834 (list python-cryptography
1835 python-prettytable))
1836 (home-page "https://github.com/PSPReverse/psptool")
1837 (synopsis "Tool for dealing with AMD binary blobs")
1838 (description "PSPTool is a tool for dealing with AMD binary blobs.")
1839 (license license:gpl3+)))
1840
1841(define-public python-psptrace
1842 (package
1843 (name "python-psptrace")
1844 (version "0.11")
1845 (source
1846 (origin
1847 (method url-fetch)
1848 (uri (pypi-uri "psptrace" version))
1849 (sha256
1850 (base32 "0lzv0dy2m5g6q4rpjd4wpw0p7n8v8crkx7akbp53lpy1c6y40iw8"))))
1851 (build-system pyproject-build-system)
1852 (arguments
1853 (list #:tests? #f)) ;no tests in PyPI or Git
1854 (native-inputs
1855 (list python-hatch-vcs
1856 python-hatchling
1857 python-setuptools))
1858 (propagated-inputs
1859 (list python-prettytable
1860 python-psptool))
1861 (home-page "https://github.com/PSPReverse/PSPTrace")
1862 (synopsis "Capture of an AMD boot procedure")
1863 (description
1864 "PSPTrace is a tool for correlating an SPI capture of an AMD boot
1865procedure to the PSP firmware components.")
1866 (license license:gpl3+)))
1867
1868(define-public python-psptrace-bootstrap
1869 (hidden-package
1870 (package/inherit python-psptrace
1871 (name "python-psptrace")
1872 (arguments
1873 (list #:tests? #f
1874 #:phases
1875 #~(modify-phases %standard-phases
1876 (delete 'sanity-check))))
1877 (propagated-inputs '()))))
1878
1879(define-public agent-proxy
1880 (let ((commit "8927798a71d246871ea8fc22b4512296a3fa1765")
1881 (revision "0"))
1882 (package
1883 (name "agent-proxy")
1884 (version (git-version "1.98" revision commit))
1885 (home-page
1886 "https://git.kernel.org/pub/scm/utils/kernel/kgdb/agent-proxy.git")
1887 (source (origin
1888 (method git-fetch)
1889 (uri (git-reference (url home-page) (commit commit)))
1890 (file-name (git-file-name name version))
1891 (sha256
1892 (base32
1893 "1bxkzwsqfld4pknmiq8j3k55pv90n8s6kzh0xh42bhy2jv1wxz2z"))))
1894 (build-system gnu-build-system)
1895 (arguments
1896 `(#:tests? #f
1897 #:phases
1898 (modify-phases %standard-phases
1899 (delete 'configure)
1900 (add-after 'build 'build-kdmx
1901 (lambda _
1902 (invoke "make" "-C" "kdmx")
1903 #t))
1904 (replace 'install
1905 (lambda* (#:key outputs #:allow-other-keys)
1906 (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
1907 (install-file "agent-proxy" bin)
1908 (install-file "kdmx/kdmx" bin)
1909 #t))))))
1910 (synopsis "Proxies to run kgdb/gdbserver and console on a serial port")
1911 (description "These programs are proxies allowing to run kgdb/gdbserver
1912and console on a single serial port. agent-proxy creates network sockets,
1913whereas kdmx creates pseudo-ttys.")
1914 (license license:gpl2))))
1915
1916(define-public mbed-tools
1917 (package
1918 (name "mbed-tools")
1919 (version "7.59.0")
1920 (source
1921 (origin
1922 (method url-fetch)
1923 (uri (pypi-uri "mbed-tools" version))
1924 (sha256
1925 (base32 "12h8g8mv3llwqcjii4zvz94mv7cmhmbc204w4nqd6nnhwfvcl6ky"))))
1926 (build-system pyproject-build-system)
1927 (arguments
1928 (list
1929 ;; tests: 631 passed, 27 skipped, 1 warning
1930 #:test-flags
1931 ;; E ModuleNotFoundError: No module named 'mbed_tools_ci_scripts'
1932 #~(list "--ignore=tests/ci_scripts/test_sync_board_db.py")))
1933 (native-inputs
1934 (list python-factory-boy
1935 python-pytest
1936 python-requests-mock
1937 python-semver
1938 python-setuptools
1939 python-setuptools-scm))
1940 (propagated-inputs
1941 (list python-click
1942 python-dotenv
1943 python-gitpython
1944 python-jinja2
1945 python-psutil
1946 python-pyserial
1947 python-pyudev
1948 python-requests
1949 python-tabulate
1950 python-tqdm
1951 python-typing-extensions))
1952 (home-page "https://github.com/ARMmbed/mbed-tools")
1953 (synopsis "ARM Mbed command line tools")
1954 (description "This package is the successor of @code{mbed-cli}. It
1955provides command line tools for Mbed OS to detect Mbed enabled devices
1956connected by USB, checkout Mbed projects and perform builds amongst other
1957operations.")
1958 (license license:asl2.0)))
1959
1960(define-public ts4900-utils
1961 (package
1962 (name "ts4900-utils")
1963 (version "3.0.0")
1964 (source (origin
1965 (method git-fetch)
1966 (uri (git-reference
1967 (url "https://github.com/embeddedTS/ts4900-utils")
1968 (commit (string-append "v" version))))
1969 (file-name (git-file-name name version))
1970 (sha256
1971 (base32
1972 "08x40ii56v4cmnz9hk6rvjrc500k1bij5ns52360vczznc8lx8bx"))))
1973 (build-system gnu-build-system)
1974 (native-inputs
1975 (list autoconf
1976 automake
1977 libgpiod
1978 pkg-config))
1979 (home-page "https://github.com/embeddedTS/ts4900-utils")
1980 (synopsis "Utilities for the TS-4900 board family")
1981 (description "This package contains utilities useful for boards of the
1982TS-4900 family. The included commands are:
1983@itemize @code
1984@item adc8390
1985@item gpioctl
1986@item isl12020rtc
1987@item load_fpga
1988@item nvramctl
1989@item tshwctl
1990@item tsmicroctl
1991@item tsmicroupdate
1992@item tssilomon
1993@end itemize")
1994 (license license:bsd-2)))
1995
1996(define-public cc-tool
1997 (package
1998 (name "cc-tool")
1999 (version "0.27")
2000 (source
2001 (origin
2002 (method git-fetch)
2003 (uri (git-reference
2004 (url "https://github.com/dashesy/cc-tool")
2005 (commit (string-append "v" version))))
2006 (file-name (git-file-name name version))
2007 (sha256
2008 (base32 "1bnyp3fxhzhz6in4yx8s6vh004gslykrpysdz6b8x8b96ha35c7c"))))
2009 (build-system gnu-build-system)
2010 (inputs (list libusb))
2011 (native-inputs (list pkg-config
2012 boost-1.83
2013 automake
2014 autoconf
2015 libtool))
2016 (home-page "https://github.com/dashesy/cc-tool")
2017 (synopsis "Support for Texas Instruments CC Debugger in Linux")
2018 (description
2019 "cc-tool provides support for Texas Instruments CC Debugger for Linux OS
2020in order to program 8051-based System-On-Chip devices: CC254x CC253x CC243x
2021CC251x CC111x.")
2022 (license license:gpl2)))
2023
2024(define-public qflipper
2025 (package
2026 (name "qflipper")
2027 (version "1.3.3")
2028 (source
2029 (origin
2030 (method git-fetch)
2031 (uri (git-reference
2032 (url "https://github.com/flipperdevices/qFlipper")
2033 (commit version)))
2034 (file-name (git-file-name name version))
2035 (sha256
2036 (base32 "0q68pkkak1ji0800hxbypshgj89vzwkql3j5x53sd32v96c8j7yp"))
2037 (patches
2038 (search-patches "qflipper-qt6.9-compat.patch"))))
2039 (build-system gnu-build-system)
2040 (arguments
2041 (list
2042 #:phases
2043 #~(modify-phases %standard-phases
2044 (replace 'configure
2045 (lambda* (#:key inputs #:allow-other-keys)
2046 (invoke "qmake"
2047 (string-append "PREFIX=" #$output)
2048 (string-append
2049 "QT_TOOL.lrelease.binary="
2050 (search-input-file inputs "/bin/lrelease"))
2051 "DEFINES+=DISABLE_APPLICATION_UPDATES")))
2052 (add-after 'unpack 'fix-version
2053 (lambda _
2054 (substitute* "qflipper_common.pri"
2055 (("GIT_VERSION =.*") (string-append "GIT_VERSION = \"" #$version "\"\n")))))
2056 (add-after 'unpack 'unbundle-nanopb
2057 (lambda _
2058 (substitute* "qFlipper.pro"
2059 ((".*3rdparty.*") ""))
2060 (substitute* "plugins/flipperproto0/flipperproto0.pro"
2061 (("-l3rdparty") "-lprotobuf-nanopb")))))))
2062 (native-inputs (list pkg-config))
2063 (inputs
2064 (list libusb
2065 nanopb-malloc
2066 qt5compat
2067 qtbase
2068 qtdeclarative
2069 qtserialport
2070 qtsvg
2071 qttools
2072 qtwayland
2073 zlib))
2074 (home-page "https://github.com/flipperdevices/qFlipper")
2075 (synopsis "Desktop application for Flipper Zero")
2076 (description
2077 "qFlipper is a graphical application for Flipper Zero with the following features:
2078
2079@itemize @bullet
2080@item Update Flipper's firmware and supplemental data
2081@item Repair a broken firmware installation
2082@item Stream Flipper's display and control it remotely
2083@item Install firmware from a @code{.dfu} file
2084@item Backup and restore settings, progress and pairing data
2085@item Command line interface
2086@end itemize
2087
2088Tip: to be able to use this application as a regular user, search for the
2089@code{42-flipperzero.rules} file in the contents of the package, install it
2090using udev-rules-service, then add your user to the dialout group.")
2091 (license license:gpl3)))