[PATCH 0/7] Add msp430 toolchain

OpenSubmitted by Morgan Smith.
Details
2 participants
  • Morgan Smith
  • Maxime Devos
Owner
unassigned
Severity
normal
M
M
Morgan Smith wrote on 1 Jun 2021 01:08
(address . guix-patches@gnu.org)
BYAPR05MB402338010B759846D3148453C53F9@BYAPR05MB4023.namprd05.prod.outlook.com
This is far from perfect but I think it's a good start. I don't have C++
working. This isn't quite the version I want for each piece. However,
I'd like to get this in since it does work. I'll iron it out a little
later.

The gcc cross compile patch doesn't work for gcc 10+ btw. I might fix
that while ironing things out later.
M
M
Morgan.J.Smith wrote on 1 Jun 2021 05:09
[PATCH 2/7] gnu: Add gcc-msp430.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
BYAPR05MB4023F18791493CAA20462B02C53E9@BYAPR05MB4023.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (gcc-msp430): New variable.
---
gnu/packages/bootstrap.scm | 1 +
gnu/packages/embedded.scm | 46 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)

Toggle diff (71 lines)
diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index c598cedc0a..54a028e977 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -311,6 +311,7 @@ (define* (glibc-dynamic-linker
         ((string=? system "arm-eabi") "no-ld.so")
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
+        ((string=? system "msp430-elf") "no-ld.so")
         ((string=? system "propeller-elf") "no-ld.so")
         ((string=? system "i686-mingw") "no-ld.so")
         ((string=? system "x86_64-mingw") "no-ld.so")
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 3e66382eed..cf48c61a93 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -530,6 +530,52 @@ (define-public gcc-msp430-support-files
      `(("unzip" ,unzip)))
     (license license:bsd-3)))
 
+(define-public gcc-msp430
+  (let ((xgcc (cross-gcc "msp430-elf"
+                         #:xgcc gcc-9
+                         #:xbinutils (cross-binutils "msp430-elf"))))
+    (package
+      (inherit xgcc)
+      (name "gcc-msp430")
+      (native-inputs
+       `(("gcc" ,gcc-9)
+         ,@(package-native-inputs xgcc)))
+      (arguments
+       (substitute-keyword-arguments (package-arguments xgcc)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (let ((gcc (assoc-ref inputs  "gcc")))
+                   ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
+                   ;; prevent header conflict with the GCC from native-inputs.
+                   (setenv "CPLUS_INCLUDE_PATH"
+                           (string-join
+                            (delete (string-append gcc "/include/c++")
+                                    (string-split (getenv "CPLUS_INCLUDE_PATH")
+                                                  #\:))
+                            ":"))
+                   (format #t
+                           "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
+                           (getenv "CPLUS_INCLUDE_PATH"))
+                   #t)))))
+         ((#:configure-flags flags)
+          `(append (list
+                    "--target=msp430-elf"
+                    "--enable-languages=c,c++"
+                    "--disable-nls"
+                    "--enable-initfini-array"
+                    "--enable-target-optspace"
+                    "--enable-newlib-nano-formatted-io")
+                   ,flags))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "CROSS_C_INCLUDE_PATH")
+              (files '("msp430-elf/include")))
+             (search-path-specification
+              (variable "CROSS_LIBRARY_PATH")
+              (files '("msp430-elf/lib"))))))))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.31.1
M
M
Morgan.J.Smith wrote on 1 Jun 2021 05:09
[PATCH 1/7] gnu: Add gcc-msp430-support-files.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
BYAPR05MB4023937268A372DD359AD3EDC53E9@BYAPR05MB4023.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (gcc-msp430-support-files): New variable.
---
gnu/packages/embedded.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (49 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 8109ec24a1..3e66382eed 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -33,6 +33,7 @@ (define-module (gnu packages embedded)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
@@ -501,6 +502,34 @@ (define-public gdb-arm-none-eabi
                            "--disable-nls")
      ,@(package-arguments gdb)))))
 
+(define-public gcc-msp430-support-files
+  (package
+    (name "gcc-msp430-support-files")
+    (version "1.211")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://software-dl.ti.com/msp430/msp430_public_sw/"
+                                  "mcu/msp430/MSPGCC/9_3_1_1/export/"
+                                  "msp430-gcc-support-files-" version ".zip"))
+
+              (sha256
+               (base32
+                "0lb30aff4jq4g332ckj0phpahd483qkjazjz7ggpmm4j46vryn07"))))
+    (build-system copy-build-system)
+    (home-page "https://www.ti.com/tool/MSP430-GCC-OPENSOURCE")
+    (synopsis "GCC headers and linker scripts for MSP430 microcontrollers")
+    (description "GCC headers and linker scripts for MSP430 microcontrollers")
+    (native-search-paths
+     (list (search-path-specification
+            (variable "CROSS_C_INCLUDE_PATH")
+            (files '("include")))
+           (search-path-specification
+            (variable "CROSS_LIBRARY_PATH")
+            (files '("include")))))
+    (native-inputs
+     `(("unzip" ,unzip)))
+    (license license:bsd-3)))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.31.1
M
M
Morgan.J.Smith wrote on 1 Jun 2021 05:09
[PATCH 4/7] gnu: Add msp430-toolchain.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
BYAPR05MB40239DEB0EDC2517F6A1D39FC53E9@BYAPR05MB4023.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (msp430-toolchain): New variable.
---
gnu/packages/embedded.scm | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

Toggle diff (51 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index af8c451573..dc324e54a1 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -615,6 +615,44 @@ (define-public newlib-msp430
     (license (license:non-copyleft
               "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
 
+(define (make-msp430-toolchain xgcc newlib)
+  "Produce a cross-compiler toolchain package with the compiler XGCC and the C
+library variant NEWLIB."
+  (let ((newlib-with-xgcc (package (inherit newlib)
+                                   (native-inputs
+                                    (alist-replace "xgcc" (list xgcc)
+                                                   (package-native-inputs newlib))))))
+    (package
+      (name "msp430-toolchain")
+      (version (package-version xgcc))
+      (source #f)
+      (build-system trivial-build-system)
+      (arguments
+       '(#:modules ((guix build union))
+         #:builder
+         (begin
+           (use-modules (ice-9 match)
+                        (guix build union))
+           (match %build-inputs
+             (((names . directories) ...)
+              (union-build (assoc-ref %outputs "out")
+                           directories)
+              #t)))))
+      (propagated-inputs
+       `(("binutils" ,(cross-binutils "msp430"))
+         ("gcc" ,xgcc)
+         ("gcc-msp430-support-files" ,gcc-msp430-support-files)
+         ("newlib" ,newlib-with-xgcc)))
+      (synopsis "Complete GCC tool chain for MSP430")
+      (description "This package provides a complete GCC tool chain for MSP430.
+This includes the GCC msp430-elf cross compiler and newlib as the C library.
+The supported programming language is C.")
+      (home-page (package-home-page xgcc))
+      (license (package-license xgcc)))))
+
+(define-public msp430-toolchain
+  (make-msp430-toolchain gcc-msp430 newlib-msp430))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.31.1
M
M
Morgan.J.Smith wrote on 1 Jun 2021 05:09
[PATCH 3/7] gnu: Add newlib-msp430.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
BYAPR05MB402314F6AE2BFA10E3BA5C57C53E9@BYAPR05MB4023.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (newlib-msp430): New variable.
---
gnu/packages/embedded.scm | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)

Toggle diff (52 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index cf48c61a93..af8c451573 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -576,6 +576,45 @@ (define-public gcc-msp430
               (variable "CROSS_LIBRARY_PATH")
               (files '("msp430-elf/lib"))))))))
 
+(define-public newlib-msp430
+  (package
+    (name "newlib")
+    (version "2.4.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:out-of-source? #t
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-references-to-/bin/sh
+           (lambda _
+             (substitute* '("libgloss/msp430/Makefile.in"
+                            "libgloss/libnosys/Makefile.in"
+                            "libgloss/Makefile.in")
+               (("/bin/sh") (which "sh")))
+             #t)))
+       #:configure-flags '("--target=msp430-elf"
+                           "--enable-languages=c,c++"
+                           "--disable-nls"
+                           "--enable-initfini-array")))
+    (native-inputs
+     `(("xbinutils" ,(cross-binutils "msp430-elf"))
+       ("xgcc" ,gcc-msp430)
+       ("texinfo" ,texinfo)))
+    (home-page "https://www.sourceware.org/newlib/")
+    (synopsis "C library for use on embedded systems")
+    (description "Newlib is a C library intended for use on embedded
+systems.  It is a conglomeration of several library parts that are easily
+usable on embedded products.")
+    (license (license:non-copyleft
+              "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.31.1
M
M
Morgan.J.Smith wrote on 1 Jun 2021 05:09
[PATCH 5/7] gnu: Add gdb-msp430.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
BYAPR05MB40235589CED984F80F4E1671C53E9@BYAPR05MB4023.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (gdb-msp430): New variable.
---
gnu/packages/embedded.scm | 15 +++++++++++++++
1 file changed, 15 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index dc324e54a1..6c9a8470d5 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -653,6 +653,21 @@ (define (make-msp430-toolchain xgcc newlib)
 (define-public msp430-toolchain
   (make-msp430-toolchain gcc-msp430 newlib-msp430))
 
+(define-public gdb-msp430
+  (package
+    (inherit gdb)
+    (name "gdb-msp430")
+    (arguments
+     `(#:configure-flags '("--target=msp430-elf"
+                           "--enable-languages=c,c++"
+                           "--disable-nls"
+                           "--enable-initfini-array"
+
+                           ;; These two options are used by python if support is enabled
+                           "--program-prefix=msp430-elf-"
+                           "--program-suffix=-py")
+       ,@(package-arguments gdb)))))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.31.1
M
M
Morgan.J.Smith wrote on 1 Jun 2021 05:09
[PATCH 6/7] gnu: mspdebug: Update to 0.25-0.4c4d94e.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
BYAPR05MB402301B53B315ADA4A8811CDC53E9@BYAPR05MB4023.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/debug.scm (mspdebug): Update to 0.25-0.4c4d94e.
---
gnu/packages/debug.scm | 61 ++++++++++++++++++++++--------------------
1 file changed, 32 insertions(+), 29 deletions(-)

Toggle diff (82 lines)
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index 3a29886b0e..c12013e50a 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -5,7 +5,7 @@
 ;;; Copyright © 2018, 2019 Rutger Helling <rhelling@mykolab.com>
 ;;; Copyright © 2019 Pkill -9 <pkill9@runbox.com>
 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
-;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
+;;; Copyright © 2020, 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -703,35 +703,38 @@ (define-public libleak
     (license license:gpl2+)))
 
 (define-public mspdebug
-  (package
-    (name "mspdebug")
-    (version "0.25")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/dlbeer/mspdebug")
-                    (commit (string-append "v" version))))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32 "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"))))
-    (build-system gnu-build-system)
-    (arguments
-     `(#:tests? #f                         ; no test suite
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure))              ; no configure script
-       #:make-flags
-       (list (string-append "CC=" ,(cc-for-target))
-             "INSTALL=install"
-             (string-append "PREFIX=" %output))))
-  (inputs
-     `(("libusb-compat" ,libusb-compat)
-       ("readline" ,readline)))
-    (synopsis "Debugging tool for MSP430 MCUs")
-    (description "MspDebug supports FET430UIF, eZ430, RF2500 and Olimex
+  ;; Last official release was 24 July 2017
+  (let ((commit "4c4d94e43bc4a18ecf82070ff81cd38dd5641e3b")
+        (revision "0"))
+    (package
+      (name "mspdebug")
+      (version (git-version "0.25" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/dlbeer/mspdebug")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32 "1lgw1dsc1aglyja610ichadvgs5b0df3wlarinczb0ykf431gjln"))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:tests? #f                         ; no test suite
+         #:phases
+         (modify-phases %standard-phases
+           (delete 'configure))              ; no configure script
+         #:make-flags
+         (list (string-append "CC=" ,(cc-for-target))
+               "INSTALL=install"
+               (string-append "PREFIX=" %output))))
+      (inputs
+       `(("libusb-compat" ,libusb-compat)
+         ("readline" ,readline)))
+      (synopsis "Debugging tool for MSP430 MCUs")
+      (description "MspDebug supports FET430UIF, eZ430, RF2500 and Olimex
 MSP430-JTAG-TINY programmers, as well as many other compatible
 devices.  It can be used as a proxy for gdb or as an independent
 debugger with support for programming, disassembly and reverse
 engineering.")
-    (home-page "https://github.com/dlbeer/mspdebug")
-    (license license:gpl2+)))
+      (home-page "https://github.com/dlbeer/mspdebug")
+      (license license:gpl2+))))
-- 
2.31.1
M
M
Morgan.J.Smith wrote on 1 Jun 2021 05:09
[PATCH 7/7] gnu: Add msp430lib.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
BYAPR05MB40233AE7EE9617C72B7C501CC53E9@BYAPR05MB4023.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/debug.scm (msp430lib): New variable.
---
gnu/packages/debug.scm | 59 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)

Toggle diff (76 lines)
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index c12013e50a..b4b037eb2a 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -36,6 +36,7 @@ (define-module (gnu packages debug)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages boost)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages c)
   #:use-module (gnu packages code)
@@ -738,3 +739,61 @@ (define-public mspdebug
 engineering.")
       (home-page "https://github.com/dlbeer/mspdebug")
       (license license:gpl2+))))
+
+(define (version-with-underscores version)
+  (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version))
+
+(define-public msp430lib
+  (package
+    (name "msp430lib")
+    (version "3.15.1.1")
+    (source (origin
+              (method url-fetch/zipbomb)
+              (uri (string-append
+                    "https://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPDS/"
+                    (version-with-underscores (version-major+minor+point version))
+                    "_001/export/MSPDebugStack_OS_Package_"
+                    (version-with-underscores version) ".zip"))
+              (sha256
+               (base32
+                "1j5sljqwc20zrb50mrji4mnmw5i680qc7n0lb0pakrrxqjc9m9g3"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags
+       (list
+        (string-append "BOOST_DIR=" (assoc-ref %build-inputs "boost"))
+        (string-append "HIDOBJ=-I" (assoc-ref %build-inputs "hidapi") "/include/hidapi"
+                       " -lhidapi-libusb")
+        "STATIC_LIBS=-lbsl430")
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (delete 'check)
+         (add-before 'build 'fix-hidapi-includes
+           (lambda _
+             (substitute*
+                 '("ThirdParty/BSL430_DLL/BSL430_DLL/Physical_Interfaces/MSPBSL_PhysicalInterfaceUSB.h"
+                   "DLL430_v3/src/TI/DLL430/HidUpdateManager.cpp")
+               (("hidapi.h") "hidapi/hidapi.h"))
+             #t))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (install-file "libmsp430.so"
+                           (string-append (assoc-ref outputs "out") "/lib"))
+             #t)))))
+    (inputs
+     `(("boost" ,boost)
+       ("hidapi" ,hidapi)
+       ("libusb" ,libusb)))
+    (native-search-paths
+     (list (search-path-specification
+            ;; Used by mspdebug. mspdebug has a few different drivers it can
+            ;; use to interact with MSP430's so this is an optional dependency
+            (variable "MSPDEBUG_TILIB_PATH")
+            (files '("lib")))))
+    (home-page "https://www.ti.com/tool/MSPDS")
+    (synopsis "Library used to program and debug MSP430 microcontrollers")
+    (description "This library facilitates communication between a host computer and
+certain MSP430 debuggers.  This is an optional dependency of mspdebug (which calls
+this library \"tilib\")")
+    (license license:bsd-3)))
-- 
2.31.1
M
M
Morgan.J.Smith wrote on 26 Sep 2021 16:51
[PATCH 1/6] gnu: Add gcc-msp430-support-files.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
SN6PR05MB4031380C2AF40FB072970869C5A69@SN6PR05MB4031.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (gcc-msp430-support-files): New variable.
---
gnu/packages/embedded.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (49 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index f388c11c3d..f1f17e83a7 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -33,6 +33,7 @@
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
@@ -501,6 +502,34 @@ languages are C and C++.")
                            "--disable-nls")
      ,@(package-arguments gdb)))))
 
+(define-public gcc-msp430-support-files
+  (package
+    (name "gcc-msp430-support-files")
+    (version "1.212")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://software-dl.ti.com/msp430/msp430_public_sw/"
+                                  "mcu/msp430/MSPGCC/9_3_1_2/export/"
+                                  "msp430-gcc-support-files-" version ".zip"))
+
+              (sha256
+               (base32
+                "1mmqn1gql4sv369nks1v05jw1x6fpqssqq3yfvxzwk9l1bqkj6iv"))))
+    (build-system copy-build-system)
+    (home-page "https://www.ti.com/tool/MSP430-GCC-OPENSOURCE")
+    (synopsis "GCC headers and linker scripts for MSP430 microcontrollers")
+    (description "GCC headers and linker scripts for MSP430 microcontrollers")
+    (native-search-paths
+     (list (search-path-specification
+            (variable "CROSS_C_INCLUDE_PATH")
+            (files '("include")))
+           (search-path-specification
+            (variable "CROSS_LIBRARY_PATH")
+            (files '("include")))))
+    (native-inputs
+     `(("unzip" ,unzip)))
+    (license license:bsd-3)))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.33.0
M
M
Morgan.J.Smith wrote on 26 Sep 2021 16:51
[PATCH 3/6] gnu: Add newlib-msp430.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
SN6PR05MB40312BC5DD6C91D909E7C1E0C5A69@SN6PR05MB4031.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (newlib-msp430): New variable.
---
gnu/packages/embedded.scm | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)

Toggle diff (48 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 7073168b57..49f3eda5fb 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -563,6 +563,41 @@ languages are C and C++.")
               (variable "CROSS_LIBRARY_PATH")
               (files '("msp430-elf/lib"))))))))
 
+(define-public newlib-msp430
+  (package
+    (name "newlib")
+    (version "2.4.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:out-of-source? #t
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-references-to-/bin/sh
+           (lambda _
+             (substitute* '("libgloss/msp430/Makefile.in"
+                            "libgloss/libnosys/Makefile.in"
+                            "libgloss/Makefile.in")
+               (("/bin/sh") (which "sh"))))))
+       #:configure-flags '("--target=msp430-elf")))
+    (native-inputs
+     `(("xbinutils" ,(cross-binutils "msp430-elf"))
+       ("xgcc" ,gcc-msp430)
+       ("texinfo" ,texinfo)))
+    (home-page "https://www.sourceware.org/newlib/")
+    (synopsis "C library for use on embedded systems")
+    (description "Newlib is a C library intended for use on embedded
+systems.  It is a conglomeration of several library parts that are easily
+usable on embedded products.")
+    (license (license:non-copyleft
+              "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.33.0
M
M
Morgan.J.Smith wrote on 26 Sep 2021 16:51
[PATCH 4/6] gnu: Add msp430-toolchain.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
SN6PR05MB40319CAAE61EBCBA14998A00C5A69@SN6PR05MB4031.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (msp430-toolchain): New variable.
---
gnu/packages/embedded.scm | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

Toggle diff (51 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 49f3eda5fb..8401f68542 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -598,6 +598,44 @@ usable on embedded products.")
     (license (license:non-copyleft
               "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
 
+(define (make-msp430-toolchain xgcc newlib)
+  "Produce a cross-compiler toolchain package with the compiler XGCC and the C
+library variant NEWLIB."
+  (let ((newlib-with-xgcc (package (inherit newlib)
+                                   (native-inputs
+                                    (alist-replace "xgcc" (list xgcc)
+                                                   (package-native-inputs newlib))))))
+    (package
+      (name "msp430-toolchain")
+      (version (package-version xgcc))
+      (source #f)
+      (build-system trivial-build-system)
+      (arguments
+       '(#:modules ((guix build union))
+         #:builder
+         (begin
+           (use-modules (ice-9 match)
+                        (guix build union))
+           (match %build-inputs
+             (((names . directories) ...)
+              (union-build (assoc-ref %outputs "out")
+                           directories)
+              #t)))))
+      (propagated-inputs
+       `(("binutils" ,(cross-binutils "msp430-elf"))
+         ("gcc" ,xgcc)
+         ("gcc-msp430-support-files" ,gcc-msp430-support-files)
+         ("newlib" ,newlib-with-xgcc)))
+      (synopsis "Complete GCC tool chain for MSP430")
+      (description "This package provides a complete GCC tool chain for MSP430.
+This includes the GCC msp430-elf cross compiler and newlib as the C library.
+The supported programming language is C.")
+      (home-page (package-home-page xgcc))
+      (license (package-license xgcc)))))
+
+(define-public msp430-toolchain
+  (make-msp430-toolchain gcc-msp430 newlib-msp430))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.33.0
M
M
Morgan.J.Smith wrote on 26 Sep 2021 16:51
[PATCH 5/6] gnu: Add gdb-msp430.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
SN6PR05MB40314E4928AD3F7AEA7973BFC5A69@SN6PR05MB4031.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (gdb-msp430): New variable.
---
gnu/packages/embedded.scm | 11 +++++++++++
1 file changed, 11 insertions(+)

Toggle diff (24 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 8401f68542..f79092de72 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -636,6 +636,17 @@ The supported programming language is C.")
 (define-public msp430-toolchain
   (make-msp430-toolchain gcc-msp430 newlib-msp430))
 
+(define-public gdb-msp430
+  (package
+    (inherit gdb)
+    (name "gdb-msp430")
+    (arguments
+     `(#:configure-flags '("--target=msp430-elf"
+                           "--enable-languages=c,c++"
+                           "--disable-nls"
+                           "--enable-initfini-array")
+       ,@(package-arguments gdb)))))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.33.0
M
M
Morgan.J.Smith wrote on 26 Sep 2021 16:51
[PATCH 6/6] gnu: Add msp430lib.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
SN6PR05MB40310196EAD67B1772A298FDC5A69@SN6PR05MB4031.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/debug.scm (msp430lib): New variable.
---
gnu/packages/debug.scm | 57 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)

Toggle diff (74 lines)
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index 7363d45c43..263a72e5ce 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -36,6 +36,7 @@
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages boost)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages c)
   #:use-module (gnu packages check)
@@ -789,3 +790,59 @@ debugger with support for programming, disassembly and reverse
 engineering.")
     (home-page "https://github.com/dlbeer/mspdebug")
     (license license:gpl2+)))
+
+(define (version-with-underscores version)
+  (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version))
+
+(define-public msp430lib
+  (package
+    (name "msp430lib")
+    (version "3.15.1.1")
+    (source (origin
+              (method url-fetch/zipbomb)
+              (uri (string-append
+                    "https://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPDS/"
+                    (version-with-underscores (version-major+minor+point version))
+                    "_001/export/MSPDebugStack_OS_Package_"
+                    (version-with-underscores version) ".zip"))
+              (sha256
+               (base32
+                "1j5sljqwc20zrb50mrji4mnmw5i680qc7n0lb0pakrrxqjc9m9g3"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags
+       (list
+        (string-append "BOOST_DIR=" (assoc-ref %build-inputs "boost"))
+        (string-append "HIDOBJ=-I" (assoc-ref %build-inputs "hidapi") "/include/hidapi"
+                       " -lhidapi-libusb"))
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (add-before 'build 'fix-hidapi-includes
+           (lambda _
+             (substitute*
+                 '("ThirdParty/BSL430_DLL/BSL430_DLL/Physical_Interfaces/MSPBSL_PhysicalInterfaceUSB.h"
+                   "DLL430_v3/src/TI/DLL430/HidUpdateManager.cpp")
+               (("hidapi.h") "hidapi/hidapi.h"))))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (install-file "libmsp430.so"
+                           (string-append (assoc-ref outputs "out") "/lib")))))))
+    (inputs
+     `(("boost" ,boost)
+       ("hidapi" ,hidapi)
+       ("libusb" ,libusb)))
+    (native-search-paths
+     (list (search-path-specification
+            ;; Used by mspdebug. mspdebug has a few different drivers it can
+            ;; use to interact with MSP430's so this is an optional dependency
+            (variable "MSPDEBUG_TILIB_PATH")
+            (files '("lib")))))
+    (home-page "https://www.ti.com/tool/MSPDS")
+    (synopsis "Library used to program and debug MSP430 microcontrollers")
+    (description "This library facilitates communication between a host computer and certain
+MSP430 debuggers.  It is also know as @acronym{MSPDS, MSP430 Debug Stack}.
+This is an optional dependency of mspdebug (which calls this library
+@code{tilib})")
+    (license license:bsd-3)))
-- 
2.33.0
M
M
Morgan.J.Smith wrote on 26 Sep 2021 16:51
[PATCH 2/6] gnu: Add gcc-msp430.
(address . 48767@debbugs.gnu.org)(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
SN6PR05MB4031E5913CC5D130D8F4B056C5A69@SN6PR05MB4031.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (gcc-msp430): New variable.
---
gnu/packages/bootstrap.scm | 1 +
gnu/packages/embedded.scm | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)

Toggle diff (58 lines)
diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index c598cedc0a..54a028e977 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -311,6 +311,7 @@ or false to signal an error."
         ((string=? system "arm-eabi") "no-ld.so")
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
+        ((string=? system "msp430-elf") "no-ld.so")
         ((string=? system "propeller-elf") "no-ld.so")
         ((string=? system "i686-mingw") "no-ld.so")
         ((string=? system "x86_64-mingw") "no-ld.so")
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index f1f17e83a7..7073168b57 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -530,6 +530,39 @@ languages are C and C++.")
      `(("unzip" ,unzip)))
     (license license:bsd-3)))
 
+(define-public gcc-msp430
+  (let ((xgcc (cross-gcc "msp430-elf"
+                         #:xgcc gcc-9
+                         #:xbinutils (cross-binutils "msp430-elf"))))
+    (package
+      (inherit xgcc)
+      (name "gcc-msp430")
+      (arguments
+       (substitute-keyword-arguments (package-arguments xgcc)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (let ((gcc (assoc-ref inputs  "gcc")))
+                   ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
+                   ;; prevent header conflict with the GCC from native-inputs.
+                   (setenv "CPLUS_INCLUDE_PATH"
+                           (string-join
+                            (delete (string-append gcc "/include/c++")
+                                    (string-split (getenv "CPLUS_INCLUDE_PATH")
+                                                  #\:))
+                            ":"))
+                   (format #t
+                           "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
+                           (getenv "CPLUS_INCLUDE_PATH")))))))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "CROSS_C_INCLUDE_PATH")
+              (files '("msp430-elf/include")))
+             (search-path-specification
+              (variable "CROSS_LIBRARY_PATH")
+              (files '("msp430-elf/lib"))))))))
+
 (define-public libjaylink
   (package
     (name "libjaylink")
-- 
2.33.0
M
M
Maxime Devos wrote on 26 Sep 2021 17:51
2e7f75188f8cef65077d2e19efa3b5efdeb71781.camel@telenet.be
Morgan.J.Smith@outlook.com schreef op zo 26-09-2021 om 10:51 [-0400]:
Toggle quote (55 lines)
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
>
> * gnu/packages/embedded.scm (gcc-msp430): New variable.
> ---
> gnu/packages/bootstrap.scm | 1 +
> gnu/packages/embedded.scm | 33 +++++++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
> index c598cedc0a..54a028e977 100644
> --- a/gnu/packages/bootstrap.scm
> +++ b/gnu/packages/bootstrap.scm
> @@ -311,6 +311,7 @@ or false to signal an error."
> ((string=? system "arm-eabi") "no-ld.so")
> ((string=? system "xtensa-elf") "no-ld.so")
> ((string=? system "avr") "no-ld.so")
> + ((string=? system "msp430-elf") "no-ld.so")
> ((string=? system "propeller-elf") "no-ld.so")
> ((string=? system "i686-mingw") "no-ld.so")
> ((string=? system "x86_64-mingw") "no-ld.so")
> diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
> index f1f17e83a7..7073168b57 100644
> --- a/gnu/packages/embedded.scm
> +++ b/gnu/packages/embedded.scm
> @@ -530,6 +530,39 @@ languages are C and C++.")
> `(("unzip" ,unzip)))
> (license license:bsd-3)))
>
> +(define-public gcc-msp430
> + (let ((xgcc (cross-gcc "msp430-elf"
> + #:xgcc gcc-9
> + #:xbinutils (cross-binutils "msp430-elf"))))
> + (package
> + (inherit xgcc)
> + (name "gcc-msp430")
> + (arguments
> + (substitute-keyword-arguments (package-arguments xgcc)
> + ((#:phases phases)
> + `(modify-phases ,phases
> + (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
> + (lambda* (#:key inputs #:allow-other-keys)
> + (let ((gcc (assoc-ref inputs "gcc")))
> + ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
> + ;; prevent header conflict with the GCC from native-inputs.
> + (setenv "CPLUS_INCLUDE_PATH"
> + (string-join
> + (delete (string-append gcc "/include/c++")
> + (string-split (getenv "CPLUS_INCLUDE_PATH")
> + #\:))
> + ":"))
> + (format #t
> + "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
> + (getenv "CPLUS_INCLUDE_PATH")))))))))
> + (native-search-paths

Shouldn't these be 'search-paths' instead of 'native-search-paths',
as "gcc-msp430" is a cross-compiler? (I know other GCC cross-compiler
packages in (gnu packages embedded) are using native-search-paths as well,
but I don't understand why.)

Toggle quote (7 lines)
> + (list (search-path-specification
> + (variable "CROSS_C_INCLUDE_PATH")
> + (files '("msp430-elf/include")))
> + (search-path-specification
> + (variable "CROSS_LIBRARY_PATH")
> + (files '("msp430-elf/lib"))))))))

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVCXEBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lEPAQCiVKWRtL3uSnNdYp5Y38Sx9y2x
yNxx94HMpVo5xbKFQgD/c+gCiUAfcD3cgktGRR/OzKuf+Hs3ur28n/A88dD3hAA=
=6IfO
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 26 Sep 2021 18:04
Re: [bug#48767] [PATCH 3/6] gnu: Add newlib-msp430.
e0b7d2e9b6bc8347cad4f2463f63d62199afb073.camel@telenet.be
Morgan.J.Smith@outlook.com schreef op zo 26-09-2021 om 10:51 [-0400]:
Toggle quote (28 lines)
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
>
> * gnu/packages/embedded.scm (newlib-msp430): New variable.
> ---
> gnu/packages/embedded.scm | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
> index 7073168b57..49f3eda5fb 100644
> --- a/gnu/packages/embedded.scm
> +++ b/gnu/packages/embedded.scm
> @@ -563,6 +563,41 @@ languages are C and C++.")
> (variable "CROSS_LIBRARY_PATH")
> (files '("msp430-elf/lib"))))))))
>
> +(define-public newlib-msp430
> + (package
> + (name "newlib")
> + (version "2.4.0")
> + (source (origin
> + (method url-fetch)
> + (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
> + version ".tar.gz"))
> + (sha256
> + (base32
> + "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
> + (build-system gnu-build-system)

There already is a newlib package: newlib-arm-none-eabi.
Could you use (package (inherit "newlib-msp430") ...) to reduce duplication?
Also, could you
(a) change the name to, say, "newlib-msp430"
or (b) instead of defining a new "newlib" package, keep a single newlib package
and make the architecture-dependent tweaks depend on (%current-target-system)?

such that "newlib@2.4.0" is an unambigious specification (or, at least, not
more ambigious than it was before), usable for "specification->package"?

Toggle quote (11 lines)
> + (arguments
> + `(#:out-of-source? #t
> + #:phases
> + (modify-phases %standard-phases
> + (add-after 'unpack 'fix-references-to-/bin/sh
> + (lambda _
> + (substitute* '("libgloss/msp430/Makefile.in"
> + "libgloss/libnosys/Makefile.in"
> + "libgloss/Makefile.in")
> + (("/bin/sh") (which "sh"))))))

This duplication can be removed by inheriting from 'newlib-arm-none-eabi'.

Toggle quote (2 lines)
> + #:configure-flags '("--target=msp430-elf")))

I'd suggest adding #:target "msp430-elf" to 'arguments' instead
of setting #:configure-flags directly. That way, guix knows we are
cross-compiling and won't try to run tests and won't try to
run 'ldconfig'.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVCaHRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7tOVAP9ifeuzNHMb7yOzDVH/vECNk7dG
NVg0DOe3zHmhCi1IwwEA2nqLv/R4G4407Zq1mzu9B2bnzFi2EgVqEaTstb5xdgA=
=gb2l
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 26 Sep 2021 18:08
Re: [bug#48767] [PATCH 4/6] gnu: Add msp430-toolchain.
44fab925e75100318f0bf71b81897dee36bc2469.camel@telenet.be
Morgan.J.Smith@outlook.com schreef op zo 26-09-2021 om 10:51 [-0400]:
Toggle quote (19 lines)
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
>
> * gnu/packages/embedded.scm (msp430-toolchain): New variable.
> ---
> gnu/packages/embedded.scm | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
> index 49f3eda5fb..8401f68542 100644
> --- a/gnu/packages/embedded.scm
> +++ b/gnu/packages/embedded.scm
> @@ -598,6 +598,44 @@ usable on embedded products.")
> (license (license:non-copyleft
> "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
>
> +(define (make-msp430-toolchain xgcc newlib)
> + "Produce a cross-compiler toolchain package with the compiler XGCC and the C
> +library variant NEWLIB." [...]

There appears to be some duplication with arm-none-eabi-toolchain.
Perhaps arm-none-eabi-toolchain could be extended to support both arm
and msp430?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVCa5xccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7kFpAQDpXG9AmQh9mP2lZfrjHAilxpxF
cbMcdlYYH79tUqTaQAD+NCGIZqWoF5lwwXqDKbYh02AnhjVxP+diN4zTHs9CZAo=
=RJ5C
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 26 Sep 2021 18:16
Re: [bug#48767] [PATCH 5/6] gnu: Add gdb-msp430.
47dabfe964ab90af20299ce113e35a5d25474491.camel@telenet.be
Morgan.J.Smith@outlook.com schreef op zo 26-09-2021 om 10:51 [-0400]:
Toggle quote (26 lines)
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
>
> * gnu/packages/embedded.scm (gdb-msp430): New variable.
> ---
> gnu/packages/embedded.scm | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
> index 8401f68542..f79092de72 100644
> --- a/gnu/packages/embedded.scm
> +++ b/gnu/packages/embedded.scm
> @@ -636,6 +636,17 @@ The supported programming language is C.")
> (define-public msp430-toolchain
> (make-msp430-toolchain gcc-msp430 newlib-msp430))
>
> +(define-public gdb-msp430
> + (package
> + (inherit gdb)
> + (name "gdb-msp430")
> + (arguments
> + `(#:configure-flags '("--target=msp430-elf"
> + "--enable-languages=c,c++"
> + "--disable-nls"
> + "--enable-initfini-array")
> + ,@(package-arguments gdb)))))

It would be more future-proof to use 'substitute-keyword-arguments' here,
as possibly a future package definition of 'gdb' could set #:configure-flags.

It would also be nice to adjust the description and synopsis a bit.
Maybe something like

(synopsis "The GNU debugger for remotely debugging msp430 systems")
(description "This is the GNU debugger, configured for debugging msp430 systems
from a system of another architecture.")

and add to the description of 'gdb' something like

"This variant of the GNU debugger only supports debugging programs compiled for
the same architecture as the GNU debugger runs on. For remote debugging, the
variants @code{gdb-msp430} or @code{gdb-arm-none-eabi} may be required."

(Assuming that's correct.) (These descriptions could be improved.)

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVCczhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7vngAP9f5fqVOauAKd9UTJys1gO6cya5
7nnnm3c3arGtyXambgEA4ls0Uu/eEtOkmKIcEjBdRyGm9pWFOBp4jpJ3p8U0qw4=
=5vmb
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 26 Sep 2021 18:31
Re: [bug#48767] [PATCH 6/6] gnu: Add msp430lib.
ac28008de79705a3eaca71f51c91fdbcce6d8596.camel@telenet.be
Morgan.J.Smith@outlook.com schreef op zo 26-09-2021 om 10:51 [-0400]:
Toggle quote (80 lines)
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
>
> * gnu/packages/debug.scm (msp430lib): New variable.
> ---
> gnu/packages/debug.scm | 57 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 57 insertions(+)
>
> diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
> index 7363d45c43..263a72e5ce 100644
> --- a/gnu/packages/debug.scm
> +++ b/gnu/packages/debug.scm
> @@ -36,6 +36,7 @@
> #:use-module (gnu packages autotools)
> #:use-module (gnu packages base)
> #:use-module (gnu packages bash)
> + #:use-module (gnu packages boost)
> #:use-module (gnu packages bison)
> #:use-module (gnu packages c)
> #:use-module (gnu packages check)
> @@ -789,3 +790,59 @@ debugger with support for programming, disassembly and reverse
> engineering.")
> (home-page "https://github.com/dlbeer/mspdebug")
> (license license:gpl2+)))
> +
> +(define (version-with-underscores version)
> + (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version))
> +
> +(define-public msp430lib
> + (package
> + (name "msp430lib")
> + (version "3.15.1.1")
> + (source (origin
> + (method url-fetch/zipbomb)
> + (uri (string-append
> + "https://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPDS/"
> + (version-with-underscores (version-major+minor+point version))
> + "_001/export/MSPDebugStack_OS_Package_"
> + (version-with-underscores version) ".zip"))
> + (sha256
> + (base32
> + "1j5sljqwc20zrb50mrji4mnmw5i680qc7n0lb0pakrrxqjc9m9g3"))))
> + (build-system gnu-build-system)
> + (arguments
> + `(#:make-flags
> + (list
> + (string-append "BOOST_DIR=" (assoc-ref %build-inputs "boost"))
> + (string-append "HIDOBJ=-I" (assoc-ref %build-inputs "hidapi") "/include/hidapi"
> + " -lhidapi-libusb"))
> + #:tests? #f
> + #:phases
> + (modify-phases %standard-phases
> + (delete 'configure)
> + (add-before 'build 'fix-hidapi-includes
> + (lambda _
> + (substitute*
> + '("ThirdParty/BSL430_DLL/BSL430_DLL/Physical_Interfaces/MSPBSL_PhysicalInterfaceUSB.h"
> + "DLL430_v3/src/TI/DLL430/HidUpdateManager.cpp")
> + (("hidapi.h") "hidapi/hidapi.h"))))
> + (replace 'install
> + (lambda* (#:key outputs #:allow-other-keys)
> + (install-file "libmsp430.so"
> + (string-append (assoc-ref outputs "out") "/lib")))))))
> + (inputs
> + `(("boost" ,boost)
> + ("hidapi" ,hidapi)
> + ("libusb" ,libusb)))
> + (native-search-paths
> + (list (search-path-specification
> + ;; Used by mspdebug. mspdebug has a few different drivers it can
> + ;; use to interact with MSP430's so this is an optional dependency
> + (variable "MSPDEBUG_TILIB_PATH")
> + (files '("lib")))))
> + (home-page "https://www.ti.com/tool/MSPDS")
> + (synopsis "Library used to program and debug MSP430 microcontrollers")
> + (description "This library facilitates communication between a host computer and certain
> +MSP430 debuggers. It is also know as @acronym{MSPDS, MSP430 Debug Stack}.
> +This is an optional dependency of mspdebug (which calls this library
> +@code{tilib})")
> + (license license:bsd-3)))

I downloaded the ZIP and opened MSPDebugStackOpenSourcePackage_manifest.html, and noted:

[...] No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any [...]

which isn't BSD-3, and isn't free software. I also see BSD-3 in that file.
We would need to carefully check what conditions apply to the parts of MSPDS that
are used here, and remove the non-free components.

I noticed PLATFORM := $(shell uname -s) and ifeq ($(PLATFORM),Linux) in a Makefile.
I expect that won't work on the Hurd. Maybe make that unconditional. I also noticed
CXX:=g++. Possibly some substitutions or (setenv "CXX" (cxx-for-target)) are required
to make the package cross-compilable.

There is a blob in Bios/include/UifBiosCore.h. Possibly it can simply be removed.

Greetings,
Maxime
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVCgcBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sROAQCZ5ZBY+0xiwNgh1cx8aH6HK29h
6OsF+K0o4m9MwinNfgD/WGb/AwMrMWsidP7TsjpUnQlp6rtmLqzPx0OPpGodCAc=
=yVDZ
-----END PGP SIGNATURE-----


M
M
Morgan.J.Smith wrote on 27 Sep 2021 23:59
[PATCH] gnu: gcc-arm-none-eabi-7-2018-q2-update: Simplify build
(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
SN6PR05MB4031A60A6B1D19CB3BCFF8CAC5A79@SN6PR05MB4031.namprd05.prod.outlook.com
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm
(gcc-arm-none-eabi-4.9)[phases]: Add expand-version-string phase

(gcc-arm-none-eabi-7-2018-q2-update): Inherit from gcc-arm-none-eabi-4.9 and
remove all the redundant bits.
---


Hello Maxime,

Thanks for the review!

Is this the appropriate time to tell you I also have a very eerily similar
patch set read to go for a riscv cross compiler? Maybe trying to make this
stuff reusable is a good thing to do. First step is to clean up the arm stuff I
suppose.

I pretty sure this patch doesn't really change the packages at all in any
meaningful way. Adding the DEV-PHASE version thing means that now when people
type 'arm-none-eabi-gcc --version' they'll see in brackets the guix version
number beside the actual version number. Also
gcc-arm-none-eabi-7-2018-q2-update now has the 'with-multilib-list' configure
flag set twice but it's pretty clear it just uses the latter value as it won't
even compile with the inherited flag value.

There seems to be a weird glitch when you inherit a phase the uses
`this-package' but you also specify arguments. I found a work around though.

To test this patch I compiled gcc-arm-none-eabi-4.9, gcc-arm-none-eabi-6, and
gcc-arm-none-eabi-7-2018-q2-update successfully. Than I installed
arm-none-eabi-toolchain and made sure it could successfully compile the arm
stuff I'm working on. Everything seems to work great.


Morgan



gnu/packages/embedded.scm | 144 +++++++++++++-------------------------
1 file changed, 48 insertions(+), 96 deletions(-)

Toggle diff (174 lines)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index f388c11c3d..809708187f 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -115,13 +115,17 @@
                             ":"))
                    (format #t
                            "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
-                           (getenv "CPLUS_INCLUDE_PATH"))
-                   #t)))
+                           (getenv "CPLUS_INCLUDE_PATH")))))
              (add-after 'unpack 'fix-genmultilib
                (lambda _
                  (substitute* "gcc/genmultilib"
-                   (("#!/bin/sh") (string-append "#!" (which "sh"))))
-                 #t))))
+                   (("#!/bin/sh") (string-append "#!" (which "sh"))))))
+             (add-after 'unpack 'expand-version-string
+               (lambda _
+                 (make-file-writable "gcc/DEV-PHASE")
+                 (with-output-to-file "gcc/DEV-PHASE"
+                   (lambda ()
+                     (display ,(package-version this-package))))))))
          ((#:configure-flags flags)
           ;; The configure flags are largely identical to the flags used by the
           ;; "GCC ARM embedded" project.
@@ -166,6 +170,46 @@
                       (search-patches "gcc-6-cross-environment-variables.patch"
                                       "gcc-6-arm-none-eabi-multilib.patch")))))))
 
+;;; 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 ((revision "2")
+        (svn-revision 261907))
+    (package (inherit gcc-arm-none-eabi-6)
+      (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")))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments gcc-arm-none-eabi-4.9)
+         ((#:configure-flags flags)
+          ;; I add this flag on the end so it overrides the previously set value
+          `(append ,flags (list "--with-multilib-list=rmprofile")))
+         ((#:phases phases)
+          `(modify-phases ,phases
+             ;; XXX: I replicated this phase just so that the version is
+             ;; correct.  This phase automatically gets the correct version if
+             ;; I don't specify any arguments for a package for some reason
+             ;; (see gcc-arm-none-eabi-6)
+             (replace 'expand-version-string
+               (lambda _
+                 (make-file-writable "gcc/DEV-PHASE")
+                 (with-output-to-file "gcc/DEV-PHASE"
+                   (lambda ()
+                     (display ,(package-version this-package)))))))))))))
+
 (define-public newlib-arm-none-eabi
   (package
     (name "newlib")
@@ -268,98 +312,6 @@ usable on embedded products.")
     (synopsis "Newlib variant for small systems with limited memory")))
 
 
-;;; 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
-       `(("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))
-             (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
-               (lambda* (#:key inputs #:allow-other-keys)
-                 (let ((gcc (assoc-ref inputs  "gcc")))
-                   ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
-                   ;; prevent header conflict with the GCC from native-inputs.
-                   (setenv "CPLUS_INCLUDE_PATH"
-                           (string-join
-                            (delete (string-append gcc "/include/c++")
-                                    (string-split (getenv "CPLUS_INCLUDE_PATH")
-                                                  #\:))
-                            ":"))
-                   (format #t
-                           "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
-                           (getenv "CPLUS_INCLUDE_PATH"))
-                   #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"
-                       "arm-none-eabi/include/c++"
-                       "arm-none-eabi/include/c++/arm-none-eabi")))
-             (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
-- 
2.33.0
M
M
Maxime Devos wrote on 1 Oct 2021 10:56
dbc48ef83474e4b22cc903e11b202df5824283d8.camel@telenet.be
Morgan.J.Smith@outlook.com schreef op ma 27-09-2021 om 17:59 [-0400]:
Toggle quote (9 lines)
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
>
> * gnu/packages/embedded.scm
> (gcc-arm-none-eabi-4.9)[phases]: Add expand-version-string phase
>
> (gcc-arm-none-eabi-7-2018-q2-update): Inherit from gcc-arm-none-eabi-4.9 and
> remove all the redundant bits.
> ---

I see you moved the definition of gcc-arm-none-eabi-7-2018-q2-update. This patch
would be easier to review if it wasn't moved, as the diff would then be smaller.

Toggle quote (10 lines)
>
> Hello Maxime,
>
> Thanks for the review!
>
> Is this the appropriate time to tell you I also have a very eerily similar
> patch set read to go for a riscv cross compiler? Maybe trying to make this
> stuff reusable is a good thing to do. First step is to clean up the arm stuff I
> suppose.

I'm not really familiar with cross-compilation as done in (gnu packages embedded);
I'm more familiar with cross-compilation with "guix build PACKAGE --target=riscv64-...".
If you're doing the latter, you'll need to look at glibc-dynamic-linker in
(gnu packages bootstrap) and (gnu packages cross-base).

Toggle quote (12 lines)
> I pretty sure this patch doesn't really change the packages at all in any
> meaningful way. Adding the DEV-PHASE version thing means that now when people
> type 'arm-none-eabi-gcc --version' they'll see in brackets the guix version
> number beside the actual version number.

> Also gcc-arm-none-eabi-7-2018-q2-update now has the 'with-multilib-list' configure
> flag set twice but it's pretty clear it just uses the latter value as it won't
> even compile with the inherited flag value.
>
> There seems to be a weird glitch when you inherit a phase the uses
> `this-package' but you also specify arguments. I found a work around though.

Alternatively, you could use

(receive (name version)
(package-name->name+version (strip-store-file-name (assoc-ref outputs "out")))
(write version to gcc/DEV-PHASE))

in the 'expand-version-string build phase of gcc-arm-none-eabi-4.9.
Or set the version in a snippet of the 'origin' records (gcc/DEV-PHASE is source
code, right?). Possibly using (display ,version) instead of
(display ,(package-version this-package)) avoids the issue (not 100% sure though).

[...]

Toggle quote (8 lines)
> +;;; 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 ((revision "2")
> + (svn-revision 261907))
> + (package (inherit gcc-arm-none-eabi-6)
> + (version (string-append "7-2018-q2-update-"

The version strings of GCC are things like "11.2.0" or "6.5.0",
not strings like "7.5.0". As this is a SVN snapshot, and appears to be
based on the 7.?.? series, maybe something like "7.MINOR.PATCH-REVISION-SVNREVISION"
would be appropriate?

I'm wondering why a SVN revision revision is used, as presumably the embedded-7-branch
has been merged and would be available from an appropriately-configured gcc@8.6.0, gcc@9.4.0,
or gcc@10.3.0?

A comment next to gcc-arm-none-eabi-4.9 says

;; We must not use the released GCC sources here, because the cross-compiler
;; does not produce working binaries. Instead we take the very same SVN
;; revision from the branch that is used for a release of the "GCC ARM
;; embedded" project on launchpad.

but maybe these bugs have been solved by now, or is using the branch still required?

Toggle quote (34 lines)
> + 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")))))
> + (arguments
> + (substitute-keyword-arguments (package-arguments gcc-arm-none-eabi-4.9)
> + ((#:configure-flags flags)
> + ;; I add this flag on the end so it overrides the previously set value
> + `(append ,flags (list "--with-multilib-list=rmprofile")))
> + ((#:phases phases)
> + `(modify-phases ,phases
> + ;; XXX: I replicated this phase just so that the version is
> + ;; correct. This phase automatically gets the correct version if
> + ;; I don't specify any arguments for a package for some reason
> + ;; (see gcc-arm-none-eabi-6)
> + (replace 'expand-version-string
> + (lambda _
> + (make-file-writable "gcc/DEV-PHASE")
> + (with-output-to-file "gcc/DEV-PHASE"
> + (lambda ()
> + (display ,(package-version this-package)))))))))))))
> +

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVbNWRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sFWAQCkjAw2Wv4eDlwrYLcgy3goGjpR
XlV4ruhnXuxnNdVA3QD/eCUvn/SCWzFp6cmfpS3/lYp0q1v5EXekzy/2+Nx+0ws=
=qr8S
-----END PGP SIGNATURE-----


?