embedded.scm 36 KB

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