1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
5 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages avr)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix utils)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix packages)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system trivial)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages cross-base)
36 #:use-module (gnu packages flashing-tools)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages vim))
40 (define-public avr-binutils
42 (inherit (cross-binutils "avr"))
43 (name "avr-binutils")))
46 (let ((xgcc (cross-gcc "avr" #:xgcc gcc #:xbinutils avr-binutils)))
51 (substitute-keyword-arguments (package-arguments xgcc)
53 `(modify-phases ,phases
54 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
55 (lambda* (#:key inputs #:allow-other-keys)
56 (let ((gcc (assoc-ref inputs "gcc")))
57 ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
58 ;; prevent header conflict with the GCC from native-inputs.
59 (setenv "CPLUS_INCLUDE_PATH"
61 (delete (string-append gcc "/include/c++")
62 (string-split (getenv "CPLUS_INCLUDE_PATH")
66 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
67 (getenv "CPLUS_INCLUDE_PATH"))
69 ;; Without a working multilib build, the resulting GCC lacks
70 ;; support for nearly every AVR chip.
71 (add-after 'unpack 'fix-genmultilib
73 ;; patch-shebang doesn't work here because there are actually
74 ;; several scripts inside this script, each with a #!/bin/sh
75 ;; that needs patching.
76 (substitute* "gcc/genmultilib"
77 (("#!/bin/sh") (string-append "#!" (which "sh"))))
79 ((#:configure-flags flags)
80 `(delete "--disable-multilib" ,flags))))
82 (list (search-path-specification
83 (variable "CROSS_C_INCLUDE_PATH")
84 (files '("avr/include")))
85 (search-path-specification
86 (variable "CROSS_CPLUS_INCLUDE_PATH")
87 (files '("avr/include")))
88 (search-path-specification
89 (variable "CROSS_OBJC_INCLUDE_PATH")
90 (files '("avr/include")))
91 (search-path-specification
92 (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
93 (files '("avr/include")))
94 (search-path-specification
95 (variable "CROSS_LIBRARY_PATH")
96 (files '("avr/lib")))))
99 ,@(package-native-inputs xgcc))))))
107 (uri (string-append "mirror://savannah//avr-libc/avr-libc-"
111 "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj"))))
112 (build-system gnu-build-system)
114 '(#:out-of-source? #t
115 #:configure-flags '("--host=avr")))
116 (native-inputs `(("avr-binutils" ,avr-binutils)
117 ("avr-gcc" ,avr-gcc)))
118 (home-page "https://www.nongnu.org/avr-libc/")
119 (synopsis "The AVR C Library")
121 "AVR Libc is a project whose goal is to provide a high quality C library
122 for use with GCC on Atmel AVR microcontrollers.")
124 (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt"))))
126 (define-public avr-toolchain
127 ;; avr-libc checks the compiler version and passes "--enable-device-lib" for avr-gcc > 5.1.0.
128 ;; It wouldn't install the library for atmega32u4 etc if we didn't use the corret avr-gcc.
130 (name "avr-toolchain")
131 (version (package-version avr-gcc))
133 (build-system trivial-build-system)
134 (arguments '(#:builder (begin (mkdir %output) #t)))
136 `(("avrdude" ,avrdude)
137 ("binutils" ,avr-binutils)
140 (synopsis "Complete GCC tool chain for AVR microcontroller development")
141 (description "This package provides a complete GCC tool chain for AVR
142 microcontroller development. This includes the GCC AVR cross compiler and
143 avrdude for firmware flashing. The supported programming languages are C and
145 (home-page (package-home-page avr-libc))
146 (license (package-license avr-gcc))))
148 (define-public microscheme
156 (url "https://github.com/ryansuchocki/microscheme")
157 (commit (string-append "v" version))))
159 (base32 "1r3ng4pw1s9yy1h5rafra1rq19d3vmb5pzbpcz1913wz22qdd976"))
160 (file-name (git-file-name name version))))
161 (build-system gnu-build-system)
163 `(#:parallel-build? #f ; fails to build otherwise
164 #:tests? #f ; no tests
166 (modify-phases %standard-phases
169 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
173 (home-page "https://github.com/ryansuchocki/microscheme/")
174 (synopsis "Scheme subset for Atmel microcontrollers")
176 "Microscheme, or @code{(ms)} for short, is a functional programming
177 language for the Arduino, and for Atmel 8-bit AVR microcontrollers in general.
178 Microscheme is a subset of Scheme, in the sense that every valid @code{(ms)}
179 program is also a valid Scheme program (with the exception of Arduino
180 hardware-specific primitives). The @code{(ms)} compiler performs function
181 inlining, and features an aggressive tree-shaker, eliminating unused top-level
182 definitions. Microscheme has a robust @dfn{Foreign Function Interface} (FFI)
183 meaning that C code may be invoked directly from (ms) programs.")
184 (license license:expat)))