gnu: Add external-program.
[jackhill/guix/guix.git] / gnu / packages / embedded.scm
index 91c6003..67c6fda 100644 (file)
@@ -1,7 +1,10 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2016, 2017 Theodoros Foradis <theodoros@foradis.org>
 ;;; Copyright © 2016 David Craven <david@craven.ch>
+;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018, 2019 Clément Lassieur <clement@lassieur.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,7 +28,9 @@
   #:use-module (guix svn-download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
   #:use-module (guix build utils)
   #:use-module (gnu packages)
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages xorg)
   #:use-module (srfi srfi-1))
 
 ;; We must not use the released GCC sources here, because the cross-compiler
@@ -78,6 +87,7 @@
                           (origin-patches (package-source xgcc))))))
       (native-inputs
        `(("flex" ,flex)
+         ("gcc" ,gcc-5)
          ,@(package-native-inputs xgcc)))
       (arguments
        (substitute-keyword-arguments (package-arguments xgcc)
@@ -197,6 +207,124 @@ usable on embedded products.")
            "--disable-nls"))))
     (synopsis "Newlib variant for small systems with limited memory")))
 
+\f
+;;; The following definitions are for the "7-2018-q2-update" variant of the
+;;; ARM cross toolchain as offered on https://developer.arm.com
+(define-public gcc-arm-none-eabi-7-2018-q2-update
+  (let ((xgcc (cross-gcc "arm-none-eabi"
+                         #:xgcc gcc-7
+                         #:xbinutils (cross-binutils "arm-none-eabi")))
+        (revision "1")
+        (svn-revision 261907))
+    (package (inherit xgcc)
+      (version (string-append "7-2018-q2-update-"
+                              revision "." (number->string svn-revision)))
+      (source
+       (origin
+         (method svn-fetch)
+         (uri (svn-reference
+               (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-7-branch/")
+               (revision svn-revision)))
+         (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
+         (sha256
+          (base32
+           "192ggs63bixf3irpijgfkjks73yx1r3a4i6grk1y0i0iny76pmx5"))
+         (patches
+          (append
+           (origin-patches (package-source gcc-7))
+           (search-patches "gcc-7-cross-environment-variables.patch")))))
+      (native-inputs
+       `(("gcc" ,gcc-5)
+         ("flex" ,flex)
+         ("isl" ,isl-0.18)
+         ,@(alist-delete "isl" (package-native-inputs xgcc))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments xgcc)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'unpack 'expand-version-string
+               (lambda _
+                 (make-file-writable "gcc/DEV-PHASE")
+                 (with-output-to-file "gcc/DEV-PHASE"
+                   (lambda ()
+                     (display "7-2018-q2-update")))
+                 #t))
+             (add-after 'unpack 'fix-genmultilib
+               (lambda _
+                 (substitute* "gcc/genmultilib"
+                   (("#!/bin/sh") (string-append "#!" (which "sh"))))
+                 #t))))
+         ((#:configure-flags flags)
+          ;; The configure flags are largely identical to the flags used by the
+          ;; "GCC ARM embedded" project.
+          `(append (list "--enable-multilib"
+                         "--with-newlib"
+                         "--with-multilib-list=rmprofile"
+                         "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
+                         "--enable-plugins"
+                         "--disable-decimal-float"
+                         "--disable-libffi"
+                         "--disable-libgomp"
+                         "--disable-libmudflap"
+                         "--disable-libquadmath"
+                         "--disable-libssp"
+                         "--disable-libstdcxx-pch"
+                         "--disable-nls"
+                         "--disable-shared"
+                         "--disable-threads"
+                         "--disable-tls")
+                   (delete "--disable-multilib" ,flags)))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "CROSS_C_INCLUDE_PATH")
+              (files '("arm-none-eabi/include")))
+             (search-path-specification
+              (variable "CROSS_CPLUS_INCLUDE_PATH")
+              (files '("arm-none-eabi/include")))
+             (search-path-specification
+              (variable "CROSS_LIBRARY_PATH")
+              (files '("arm-none-eabi/lib"))))))))
+
+(define-public newlib-arm-none-eabi-7-2018-q2-update
+  ;; This is the same commit as used for the 7-2018-q2-update release
+  ;; according to the release.txt.
+  (let ((commit "3ccfb407af410ba7e54ea0da11ae1e40b554a6f4")
+        (revision "0"))
+    (package
+      (inherit newlib-arm-none-eabi)
+      (version (git-version "3.0.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "http://sourceware.org/git/newlib-cygwin.git")
+               (commit commit)))
+         (file-name (git-file-name "newlib" commit))
+         (sha256
+          (base32
+           "1dq23fqrk75g1a4v7569fvnnw5q440zawbxi3w0g05n8jlqsmvcy"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
+         ;; The configure flags are identical to the flags used by the "GCC ARM
+         ;; embedded" project.
+         ((#:configure-flags flags)
+          `(cons* "--enable-newlib-io-c99-formats"
+                  "--enable-newlib-retargetable-locking"
+                  "--with-headers=yes"
+                  ,flags))))
+      (native-inputs
+       `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
+         ("xgcc" ,gcc-arm-none-eabi-7-2018-q2-update)
+         ("texinfo" ,texinfo))))))
+
+(define-public newlib-nano-arm-none-eabi-7-2018-q2-update
+  (package (inherit newlib-arm-none-eabi-7-2018-q2-update)
+    (name "newlib-nano")
+    (arguments
+     (package-arguments newlib-nano-arm-none-eabi))
+    (synopsis "Newlib variant for small systems with limited memory")))
+
+\f
 (define (make-libstdc++-arm-none-eabi xgcc newlib)
   (let ((libstdc++ (make-libstdc++ xgcc)))
     (package (inherit libstdc++)
@@ -246,7 +374,8 @@ library variant NEWLIB."
            (match %build-inputs
              (((names . directories) ...)
               (union-build (assoc-ref %outputs "out")
-                           directories))))))
+                           directories)
+              #t)))))
       (propagated-inputs
        `(("binutils" ,(cross-binutils "arm-none-eabi"))
          ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
@@ -276,6 +405,14 @@ languages are C and C++.")
   (arm-none-eabi-toolchain gcc-arm-none-eabi-6
                            newlib-nano-arm-none-eabi))
 
+(define-public arm-none-eabi-toolchain-7-2018-q2-update
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-7-2018-q2-update
+                           newlib-arm-none-eabi-7-2018-q2-update))
+
+(define-public arm-none-eabi-nano-toolchain-7-2018-q2-update
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-7-2018-q2-update
+                           newlib-nano-arm-none-eabi-7-2018-q2-update))
+
 (define-public gdb-arm-none-eabi
   (package
     (inherit gdb)
@@ -313,12 +450,6 @@ languages are C and C++.")
          ("pkg-config" ,pkg-config)))
       (inputs
        `(("libusb" ,libusb)))
-      (arguments
-       `(#:phases
-         (modify-phases %standard-phases
-           (add-after 'unpack 'autoreconf
-             (lambda _
-               (zero? (system* "autoreconf" "-vfi")))))))
       (home-page "http://repo.or.cz/w/libjaylink.git")
       (synopsis "Library to interface Segger J-Link devices")
       (description "libjaylink is a shared library written in C to access
@@ -346,8 +477,8 @@ SEGGER J-Link and compatible devices.")
          (replace 'configure
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
-               (zero? (system* "./configure"
-                               (string-append "--prefix=" out)))))))))
+               (invoke "./configure"
+                       (string-append "--prefix=" out))))))))
     (home-page "http://jim.tcl.tk")
     (synopsis "Small footprint Tcl implementation")
     (description "Jim is a small footprint implementation of the Tcl programming
@@ -396,9 +527,9 @@ language.")
                       "presto" "openjtag")))
        #:phases
        (modify-phases %standard-phases
+         ;; Required because of patched sources.
          (add-before 'configure 'autoreconf
-           (lambda _
-             (zero? (system* "autoreconf" "-vfi"))))
+           (lambda _ (invoke "autoreconf" "-vfi") #t))
          (add-after 'autoreconf 'change-udev-group
            (lambda _
              (substitute* "contrib/60-openocd.rules"
@@ -409,20 +540,23 @@ language.")
              (install-file "contrib/60-openocd.rules"
                            (string-append
                             (assoc-ref outputs "out")
-                            "/lib/udev/rules.d/")))))))
+                            "/lib/udev/rules.d/"))
+             #t)))))
     (home-page "http://openocd.org")
     (synopsis "On-Chip Debugger")
     (description "OpenOCD provides on-chip programming and debugging support
 with a layered architecture of JTAG interface and TAP support.")
     (license license:gpl2+)))
 
-;; The commits for all propeller tools are the latest versions as published
-;; here: https://github.com/dbetz/propeller-gcc
+;; The commits for all propeller tools are the stable versions published at
+;; https://github.com/propellerinc/propgcc in the release_1_0.  According to
+;; personal correspondence with the developers in July 2017, more recent
+;; versions are currently incompatible with the "Simple Libraries".
 
 (define propeller-binutils
   (let ((xbinutils (cross-binutils "propeller-elf"))
-        (commit "3bfba30076f8ce160a2f42914fdb68f24445fd44")
-        (revision "1"))
+        (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
+        (revision "2"))
     (package
       (inherit xbinutils)
       (name "propeller-binutils")
@@ -430,28 +564,24 @@ with a layered architecture of JTAG interface and TAP support.")
       (source (origin (inherit (package-source xbinutils))
                 (method git-fetch)
                 (uri (git-reference
-                      (url "https://github.com/totalspectrum/binutils-propeller.git")
+                      (url "https://github.com/parallaxinc/propgcc.git")
                       (commit commit)))
                 (file-name (string-append name "-" commit "-checkout"))
                 (sha256
                  (base32
-                  "1v3rgxwj7b8817wy5ccf8621v75qcxvcxygk4acr3hbc6yqybr8h"))))
+                  "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
+                (patch-flags (list "-p1" "--directory=binutils"))))
       (arguments
-       `(;; FIXME: For some reason there are many test failures.  Some of them
-         ;; appear to be due to regular expression mismatch, but it's not
+       `(;; FIXME: For some reason there are many test failures.  It's not
          ;; obvious how to fix the failures.
          #:tests? #f
          #:phases
          (modify-phases %standard-phases
-           (add-after 'unpack 'patch-/bin/sh-in-tests
-             (lambda _
-               (substitute* '("sim/testsuite/Makefile.in"
-                              "sim/testsuite/mips64el-elf/Makefile.in"
-                              "sim/testsuite/d10v-elf/Makefile.in"
-                              "sim/testsuite/sim/cris/asm/badarch1.ms")
-                 (("/bin/sh") (which "sh")))
-               #t)))
-         ,@(package-arguments xbinutils)))
+           (add-after 'unpack 'chdir
+             (lambda _ (chdir "binutils") #t)))
+         ,@(substitute-keyword-arguments (package-arguments xbinutils)
+            ((#:configure-flags flags)
+             `(cons "--disable-werror" ,flags)))))
       (native-inputs
        `(("bison" ,bison)
          ("flex" ,flex)
@@ -497,26 +627,36 @@ with a layered architecture of JTAG interface and TAP support.")
 
 (define-public propeller-gcc-4
   (let ((xgcc propeller-gcc-6)
-        (commit "f1b01001b760d691a91ff1db4830d41bb712557f")
-        (revision "1"))
+        (commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
+        (revision "2"))
     (package (inherit xgcc)
       (name "propeller-gcc")
       (version (string-append "4.6.1-" revision "." (string-take commit 9)))
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
-                      (url "https://github.com/dbetz/propgcc-gcc.git")
+                      (url "https://github.com/parallaxinc/propgcc.git")
                       (commit commit)))
                 (file-name (string-append name "-" commit "-checkout"))
                 (sha256
                  (base32
-                  "15mxrhk2v4vqmdkvcqy33ag1wrg9x9q20kx2w33kkw8pkrijknbi"))
+                  "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))
+                (patch-flags (list "-p1" "--directory=gcc"))
                 (patches
                  (append
                   (origin-patches (package-source gcc-4.7))
                   (search-patches "gcc-4.6-gnu-inline.patch"
                                   "gcc-cross-environment-variables.patch")))))
-      (home-page "https://github.com/dbetz/propgcc-gcc")
+      (arguments
+       (substitute-keyword-arguments (package-arguments propeller-gcc-6)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'unpack 'chdir
+               (lambda _ (chdir "gcc") #t))))))
+      (native-inputs
+       `(("gcc-4" ,gcc-4.9)
+         ,@(package-native-inputs propeller-gcc-6)))
+      (home-page "https://github.com/parallaxinc/propgcc")
       (supported-systems (delete "aarch64-linux" %supported-systems)))))
 
 ;; Version 6 is experimental and may not work correctly.  This is why we
@@ -524,23 +664,25 @@ with a layered architecture of JTAG interface and TAP support.")
 ;; provided by Parallax Inc.
 (define-public propeller-gcc propeller-gcc-4)
 
-;; There is no release, so we take the latest version as referenced from here:
-;; https://github.com/dbetz/propeller-gcc
+
+;; FIXME: We do not build the tiny library because that would require C++
+;; headers, which are not available.  This may require adding a propeller-elf
+;; variant of the libstdc++ package.
 (define-public proplib
-  (let ((commit "844741fe0ceb140ab2fdf9d0667f68c1c39c31da")
-        (revision "1"))
+  (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
+        (revision "2"))
     (package
       (name "proplib")
       (version (string-append "0.0.0-" revision "." (string-take commit 9)))
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
-                      (url "https://github.com/totalspectrum/proplib.git")
+                      (url "https://github.com/parallaxinc/propgcc.git")
                       (commit commit)))
                 (file-name (string-append name "-" commit "-checkout"))
                 (sha256
                  (base32
-                  "0q7irf1x8iqx07n7lzksax9armrdkizs49swsz76nbks0mw67wiv"))))
+                  "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
       (build-system gnu-build-system)
       (arguments
        `(#:tests? #f ; no tests
@@ -550,12 +692,11 @@ with a layered architecture of JTAG interface and TAP support.")
          #:phases
          (modify-phases %standard-phases
            (delete 'configure)
-           (add-after 'unpack 'fix-Makefile
+           (add-after 'unpack 'chdir
+             (lambda _ (chdir "lib") #t))
+           (add-after 'chdir 'fix-Makefile
              (lambda _
                (substitute* "Makefile"
-                 ;; The GCC sources are not part of this package, so we cannot
-                 ;; install the out-of-tree license file.
-                 (("cp \\.\\..*") "")
                  ;; Control the installation time of the headers.
                  ((" install-includes") ""))
                #t))
@@ -563,7 +704,7 @@ with a layered architecture of JTAG interface and TAP support.")
            ;; have to create the target directories at build time.
            (add-before 'build 'create-target-directories
              (lambda* (#:key make-flags #:allow-other-keys)
-               (zero? (apply system* "make" "install-dirs" make-flags))))
+               (apply invoke "make" "install-dirs" make-flags)))
            (add-before 'build 'set-cross-environment-variables
              (lambda* (#:key outputs #:allow-other-keys)
                (setenv "CROSS_LIBRARY_PATH"
@@ -575,23 +716,14 @@ with a layered architecture of JTAG interface and TAP support.")
                                       "/propeller-elf/include:"
                                       (or (getenv "CROSS_C_INCLUDE_PATH") "")))
                #t))
-           (add-after 'build 'build-tiny
-             (lambda* (#:key make-flags #:allow-other-keys)
-               (zero? (apply system* "make" "tiny" make-flags))))
-           ;; The build of the tiny libraries depends on the includes to be
-           ;; available.  Since we set CROSS_C_INCLUDE_PATH to the output
-           ;; directory, we have to install the includes first.
-           (add-before 'build-tiny 'install-includes
-             (lambda* (#:key make-flags #:allow-other-keys)
-               (zero? (apply system* "make" "install-includes" make-flags))))
-           (add-after 'install 'install-tiny
+           (add-before 'install 'install-includes
              (lambda* (#:key make-flags #:allow-other-keys)
-               (zero? (apply system* "make" "install-tiny" make-flags)))))))
+               (apply invoke "make" "install-includes" make-flags))))))
       (native-inputs
        `(("propeller-gcc" ,propeller-gcc)
          ("propeller-binutils" ,propeller-binutils)
          ("perl" ,perl)))
-      (home-page "https://github.com/totalspectrum/proplib")
+      (home-page "https://github.com/parallaxinc/propgcc")
       (synopsis "C library for the Parallax Propeller")
       (description "This is a C library for the Parallax Propeller
 micro-controller.")
@@ -605,7 +737,7 @@ micro-controller.")
     (version (package-version propeller-gcc))
     (source #f)
     (build-system trivial-build-system)
-    (arguments '(#:builder (mkdir %output)))
+    (arguments '(#:builder (begin (mkdir %output) #t)))
     (propagated-inputs
      `(("binutils" ,propeller-binutils)
        ("libc" ,proplib)
@@ -655,20 +787,20 @@ code.")
     (license license:expat)))
 
 (define-public propeller-load
-  (let ((commit "ba9c0a7251cf751d8d292ae19ffa03132097c0c0")
-        (revision "1"))
+  (let ((commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
+        (revision "2"))
     (package
       (name "propeller-load")
       (version "3.4.0")
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
-                      (url "https://github.com/dbetz/propeller-load.git")
+                      (url "https://github.com/parallaxinc/propgcc.git")
                       (commit commit)))
                 (file-name (string-append name "-" commit "-checkout"))
                 (sha256
                  (base32
-                  "1qv3xaapl9fmj3zn58b60sprp4rnvnlpci8ci0pdrzkw6fhvx3pg"))))
+                  "0w0dff3s7wv2d9m78a4jhckiik58q38wx6wpbba5hzbs4yxz35ck"))))
       (build-system gnu-build-system)
       (arguments
        `(#:tests? #f ; no tests
@@ -677,11 +809,13 @@ code.")
                (string-append "TARGET=" (assoc-ref %outputs "out")))
          #:phases
          (modify-phases %standard-phases
+           (add-after 'unpack 'chdir
+             (lambda _ (chdir "loader") #t))
            (delete 'configure))))
       (native-inputs
        `(("openspin" ,openspin)
          ("propeller-toolchain" ,propeller-toolchain)))
-      (home-page "https://github.com/dbetz/propeller-load")
+      (home-page "https://github.com/parallaxinc/propgcc")
       (synopsis "Loader for Parallax Propeller micro-controllers")
       (description "This package provides the tool @code{propeller-load} to
 upload binaries to a Parallax Propeller micro-controller.")
@@ -690,7 +824,7 @@ upload binaries to a Parallax Propeller micro-controller.")
 (define-public spin2cpp
   (package
     (name "spin2cpp")
-    (version "3.6.3")
+    (version "3.6.4")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://github.com/totalspectrum/spin2cpp/"
@@ -698,7 +832,7 @@ upload binaries to a Parallax Propeller micro-controller.")
               (file-name (string-append name "-" version ".tar.gz"))
               (sha256
                (base32
-                "0v5vzh69bp1r2byrpz12rql1w24ff2v9msr31596zq6hd6n82lnh"))))
+                "05qak187sn0xg7vhrxw27b19xhmid1b8ab8kax3gv0faavzablfw"))))
     (build-system gnu-build-system)
     (arguments
      `(#:tests? #f ;; The tests assume that a micro-controller is connected.
@@ -778,7 +912,7 @@ two-thirds of the opcodes in the P2 instruction set.")
     (version (package-version propeller-gcc))
     (source #f)
     (build-system trivial-build-system)
-    (arguments '(#:builder (mkdir %output)))
+    (arguments '(#:builder (begin (mkdir %output) #t)))
     (propagated-inputs
      `(("toolchain" ,propeller-toolchain)
        ("openspin" ,openspin)
@@ -823,7 +957,7 @@ simulator.")
              (lambda _
                (substitute* "opcodes/Makefile.in"
                  (("guile\\{,-\\}1.8") "guile"))
-               (zero? (system* "which" "guile")))))))
+               (invoke "which" "guile"))))))
       (native-inputs
        `(("cgen"
           ,(origin
@@ -868,3 +1002,319 @@ the Raspberry Pi chip.")
       (synopsis "GCC for VC4")
       (description "This package provides @code{gcc} for VideoCore IV,
 the Raspberry Pi chip."))))
+
+(define-public python-libmpsse
+  (package
+    (name "python-libmpsse")
+    (version "1.4")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+              (url "https://github.com/daym/libmpsse.git")
+              (commit (string-append "v" version))))
+        (file-name "libmpsse-checkout")
+        (sha256
+          (base32
+            "14f1kiiia4kfd9mzwx4h63aa8bpz9aknbrrr7mychnsp3arw0z25"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("libftdi" ,libftdi)
+       ("python" ,python)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("swig" ,swig)
+       ("which" ,base:which)))
+    (arguments
+     `(#:tests? #f ; No tests exist.
+       #:parallel-build? #f  ; Would be buggy.
+       #:make-flags
+       (list (string-append "CFLAGS=-Wall -fPIC -fno-strict-aliasing -g -O2 "
+                            "$(shell pkg-config --cflags libftdi1)"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'set-environment-up
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((python (assoc-ref inputs "python")))
+               (chdir "src")
+               (setenv "PYDEV" (string-append python
+                               "/include/python"
+                               ,(version-major+minor (package-version python))
+                               "m"))
+               #t)))
+         (replace 'install
+           (lambda* (#:key inputs outputs make-flags #:allow-other-keys #:rest args)
+             (let* ((out (assoc-ref outputs "out"))
+                    (out-python (string-append out
+                                               "/lib/python"
+                                               ,(version-major+minor (package-version python))
+                                               "/site-packages"))
+                    (install (assoc-ref %standard-phases 'install)))
+               (install #:make-flags (cons (string-append "PYLIB=" out-python)
+                                           make-flags))))))))
+    (home-page "https://code.google.com/archive/p/libmpsse/")
+    (synopsis "Python library for MPSSE SPI I2C JTAG adapter by FTDI")
+    (description "This package provides a library in order to support the
+MPSSE (Multi-Protocol Synchronous Serial Engine) adapter by FTDI that can do
+SPI, I2C, JTAG.")
+    (license license:gpl2+)))
+
+(define-public python2-libmpsse
+  (package
+    (inherit python-libmpsse)
+    (name "python2-libmpsse")
+    (arguments
+     (substitute-keyword-arguments (package-arguments python-libmpsse)
+      ((#:phases phases)
+       `(modify-phases ,phases
+         (replace 'set-environment-up
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((python (assoc-ref inputs "python")))
+               (chdir "src")
+               (setenv "PYDEV" (string-append python
+                               "/include/python"
+                               ,(version-major+minor (package-version python-2))))
+               #t)))
+         (replace 'install
+           (lambda* (#:key inputs outputs make-flags #:allow-other-keys #:rest args)
+             (let* ((out (assoc-ref outputs "out"))
+                    (out-python (string-append out
+                                               "/lib/python"
+                                               ,(version-major+minor (package-version python-2))
+                                               "/site-packages"))
+                    (install (assoc-ref %standard-phases 'install)))
+               (install #:make-flags (cons (string-append "PYLIB=" out-python)
+                                           make-flags)))))))))
+    (inputs
+     (alist-replace "python" (list python-2)
+                    (package-inputs python-libmpsse)))))
+
+(define-public picprog
+  (package
+    (name "picprog")
+    (version "1.9.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "http://www.iki.fi/hyvatti/pic/picprog-"
+                                  version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1r04hg1n3v2jf915qr05la3q9cxy7a5jnh9cc98j04lh6c9p4x85"))
+              (patches (search-patches "picprog-non-intel-support.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f                      ; No tests exist.
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-paths
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* "Makefile"
+               (("/usr/local") (assoc-ref outputs "out"))
+               ((" -o 0 -g 0 ") " ")
+               (("testport") ""))
+             #t))
+         (add-before 'install 'mkdir
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (mkdir-p (string-append out "/bin"))
+               (mkdir-p (string-append out "/man/man1"))
+               #t)))
+         (delete 'configure))))
+    (synopsis "Programs Microchip's PIC microcontrollers")
+    (description "This program programs Microchip's PIC microcontrollers.")
+    (home-page "http://hyvatti.iki.fi/~jaakko/pic/picprog.html")
+    (license license:gpl3+)))
+
+(define-public fc-host-tools
+  (package
+    (name "fc-host-tools")
+    (version "11")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "ftp://ftp.freecalypso.org/pub/GSM/"
+                                  "FreeCalypso/fc-host-tools-r" version ".tar.bz2"))
+              (sha256
+               (base32
+                "0s87lp6gd8i8ivrdd7mnnalysr65035nambcm992rgla7sk76sj1"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f                      ; No tests exist.
+       #:make-flags
+       (list (string-append "INSTALL_PREFIX=" %output)
+             (string-append "INCLUDE_INSTALL_DIR=" %output "include/rvinterf"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-installation-paths
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* '("Makefile"
+                            "rvinterf/etmsync/fsiomain.c"
+                            "rvinterf/etmsync/fsnew.c"
+                            "rvinterf/asyncshell/help.c"
+                            "rvinterf/libinterf/launchrvif.c"
+                            "loadtools/defpath.c"
+                            "loadtools/Makefile"
+                            "miscutil/c139explore"
+                            "miscutil/pirexplore"
+                            "ffstools/tiffs-wrappers/installpath.c"
+                            "uptools/atcmd/atinterf.c")
+               (("/opt/freecalypso/loadtools")
+                (string-append (assoc-ref outputs "out") "/lib/freecalypso/loadtools"))
+               (("\\$\\{INSTALL_PREFIX\\}/loadtools")
+                (string-append (assoc-ref outputs "out") "/lib/freecalypso/loadtools"))
+               (("\\$\\{INSTALL_PREFIX\\}/target-bin")
+                (string-append (assoc-ref outputs "out") "/lib/freecalypso/target-bin"))
+               (("/opt/freecalypso")
+                (assoc-ref outputs "out")))
+             #t))
+         (delete 'configure))))
+    (inputs
+     `(("libx11" ,libx11)))
+    (synopsis "Freecalypso host tools")
+    (description "This package provides some tools for debugging FreeCalypso phones and the FreeCalypso FCDEV3B dev board.
+
+@enumerate
+@item fc-e1decode: Decodes a binary Melody E1 file into an ASCII source file.
+@item fc-e1gen: Encodes an ASCII Melody E1 file into a binary Melody E1 file.
+@item fc-fr2tch: Converts a GSM 06.10 speech recording from libgsm to hex
+strings of TCH bits to be fed to the GSM 05.03 channel encoder of a TI
+Calypso GSM device.
+@item fc-tch2fr: Converts hex strings of TCH bits to libgsm.
+@item fc-gsm2vm: utility converts a GSM 06.10 speech sample from the libgsm
+source format into a voice memo file that can be uploaded into the FFS of a
+FreeCalypso device and played with the audio_vm_play_start() API or the
+AT@@VMP command that invokes the latter.
+@item fc-rgbconv: Convers RGB 5:6:5 to RGB 8:8:8 and vice versa.
+@item rvinterf: Communicates with a TI Calypso GSM device via RVTMUX.
+@item rvtdump: produces a human-readable dump of all output emitted by a
+TI-based GSM fw on the RVTMUX binary packet interface.
+@item fc-shell: FreeCalypso firmwares have a feature of our own invention
+(not present in any pre-existing ones) to accept AT commands over the RVTMUX
+interface.  It is useful when no second UART is available for a dedicated
+standard AT command interface.  fc-shell is the tool that allows you to send
+AT commands to the firmware in this manner.
+@item fc-memdump: Captures a memory dump from a GSM device.
+@item fc-serterm: Trivial serial terminal.  Escapes binary chars.
+@item fc-fsio: Going through rvinterf, this tool connects to GSM devices and
+allows you to manipulate the device's flash file system.
+@item tiaud-compile: Compiles an audio mode configuration table for TI's
+Audio Service from our own ASCII source format into the binary format for
+uploading into FreeCalypso GSM device FFS with fc-fsio.
+@item tiaud-decomp: Decodes TI's audio mode configuration files read out of
+FFS into our own ASCII format.
+@item tiaud-mkvol: Generates the *.vol binary files which need to accompany
+the main *.cfg ones.
+@item fc-compalram: Allows running programs on the device without writing
+them to flash storage.
+@item fc-xram: Allows running programs on the device without writing them
+to flash storage.
+@item fc-iram: Allows running programs on the device without writing them
+to flash storage.
+@item fc-loadtool: Writes programs to the device's flash storage.
+@item pirffs: Allows listing and extracting FFS content captured as a raw
+flash image from Pirelli phones.
+@item mokoffs: Allows listing and extracting FFS content captured as a raw
+flash image from OpenMoko phones.
+@item tiffs: Allows listing and extracting FFS content captured as a raw
+flash image from TI phones.
+@item c139explore: Run-from-RAM program for C139 phones that
+exercises their peripheral hardware: LCD, keypad backlight, buzzer, vibrator.
+@item pirexplore: Run-from-RAM program for Pirelli DP-L10 phones that
+exercises their peripheral hardware, primarily their LCD.
+@item tfc139: Breaks into Mot C1xx phones via shellcode injection, allowing
+you to reflash locked phones with new firmware with fc-loadtool.
+@item ctracedec: GSM firmwares built in TI's Windows environment have a
+compressed trace misfeature whereby many of the ASCII strings
+in debug trace messages get replaced with numeric indices at
+build time, and these numeric indices are all that gets emitted
+on the RVTMUX serial channel.  This tools decodes these numeric indices
+back to strings in trace output.
+@item fc-cal2text: This utility takes a dump of TI's /gsm/rf flash file system
+directory subtree as input (either extracted in vitro with tiffs
+or read out in vivo with fc-fsio) and converts all RF tables
+found therein into a readable ASCII format.
+@item imei-luhn: Computes or verifies the Luhn check digit of an IMEI number.
+@item fc-dspapidump: Reads and dumps the contents of the DSP API RAM in a
+target Calypso GSM device.
+@item fc-vm2hex: Converts the old-fashioned (non-AMR) voice memo files read
+out of FFS into hex strings.
+@item fc-buzplay: Plays piezoelectic buzzer melodies on an actual
+Calypso device equipped with such a buzzer (Mot C1xx, TI's D-Sample board,
+our planned future HSMBP) by loading a buzplayer agent onto the target and
+feeding melodies to be played to it.
+@item fc-tmsh: TI-based GSM firmwares provide a rich set of Test Mode commands
+that can be issued through the RVTMUX (debug trace) serial channel.
+This program is our test mode shell for sending Test Mode commands to targets
+and displaying decoded target responses.
+@item fcup-smsend: Send a short message via SMS
+@item fcup-smsendmult: Send multiple short messages via SMS in one go
+@item fcup-smsendpdu: Send multiple short messages given in PDU format via SMS
+@item sms-pdu-decode: Decode PDU format messages
+@end enumerate")
+    (home-page "https://www.freecalypso.org/")
+    (license license:public-domain)))
+
+(define-public stlink
+  (package
+    (name "stlink")
+    (version "1.5.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/texane/stlink/archive/v"
+                           version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "01z1cz1a5xbbhd163qrqcgp4bi1k145pb80jmwdz50g7sfzmy570"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:tests? #f                      ;no tests
+       #:configure-flags
+       (let* ((out (assoc-ref %outputs "out"))
+              (etc (in-vicinity out "etc"))
+              (modprobe (in-vicinity etc "modprobe.d"))
+              (udev-rules (in-vicinity etc "udev/rules.d")))
+         (list (string-append "-DSTLINK_UDEV_RULES_DIR=" udev-rules)
+               (string-append "-DSTLINK_MODPROBED_DIR=" modprobe)))))
+    (inputs
+     `(("libusb" ,libusb)))
+    (synopsis "Programmer for STM32 Discovery boards")
+    (description "This package provides a firmware programmer for the STM32
+Discovery boards.  It supports two versions of the chip: ST-LINK/V1 (on
+STM32VL discovery kits) and ST-LINK/V2 (on STM32L discovery and later kits).
+Two different transport layers are used: ST-LINK/V1 uses SCSI passthru
+commands over USB, and ST-LINK/V2 and ST-LINK/V2-1 (seen on Nucleo boards) use
+raw USB commands.")
+    (home-page "https://github.com/texane/stlink")
+    ;; The flashloaders/stm32l0x.s and flashloaders/stm32lx.s source files are
+    ;; licensed under the GPLv2+.
+    (license (list license:bsd-3 license:gpl2+))))
+
+(define-public west
+  (package
+    (name "west")
+    (version "0.6.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "west" version))
+       (sha256
+        (base32
+         "0ql6ij1hrj2ir5wkxm96zgig5qwvfwa75w77wh2y13w6b9cqcr4b"))))
+    (propagated-inputs
+     `(("python-colorama" ,python-colorama)
+       ("python-configobj" ,python-configobj)
+       ("python-pykwalify" ,python-pykwalify)
+       ("python-pyyaml" ,python-pyyaml)))
+    (build-system python-build-system)
+    (home-page "https://github.com/zephyrproject-rtos/west")
+    (synopsis "Zephyr RTOS Project meta-tool")
+    (description "West is the swiss-army knife command line tool of the Zephyr
+project.  Its built-in commands provide a multiple repository management
+system with features inspired by Google’s Repo tool and Git submodules.  West
+simplifies configuration and is also pluggable: you can write your own west
+\"extension commands\" which add additional features to west.  Zephyr uses
+this feature to provide conveniences for building applications, flashing and
+debugging them, and more.")
+    (license license:expat)))