summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2019-03-29 16:11:22 -0400
committerGitHub <noreply@github.com>2019-03-29 16:11:22 -0400
commit842b14ba98e037ff954eefe7f2bb60b7707735e9 (patch)
tree6c8ef00653e664843c343b6b02d1df3e48be0311
parentb46e9ad84b96ffce579ae5132f311b28b6d78506 (diff)
parentc17cf32a3724bf6c23cb3146acb639c414c8edd8 (diff)
downloadnixpkgs-842b14ba98e037ff954eefe7f2bb60b7707735e9.tar
nixpkgs-842b14ba98e037ff954eefe7f2bb60b7707735e9.tar.gz
nixpkgs-842b14ba98e037ff954eefe7f2bb60b7707735e9.tar.bz2
nixpkgs-842b14ba98e037ff954eefe7f2bb60b7707735e9.tar.lz
nixpkgs-842b14ba98e037ff954eefe7f2bb60b7707735e9.tar.xz
nixpkgs-842b14ba98e037ff954eefe7f2bb60b7707735e9.tar.zst
nixpkgs-842b14ba98e037ff954eefe7f2bb60b7707735e9.zip
Merge pull request #58330 from AerialX/msp430
TI MSP430 cross compiling
-rw-r--r--lib/systems/default.nix1
-rw-r--r--lib/systems/examples.nix5
-rw-r--r--lib/systems/inspect.nix1
-rw-r--r--lib/systems/parse.nix1
-rw-r--r--maintainers/maintainer-list.nix5
-rw-r--r--pkgs/build-support/bintools-wrapper/default.nix1
-rw-r--r--pkgs/development/misc/msp430/gcc-support.nix31
-rw-r--r--pkgs/development/misc/msp430/mspdebug.nix25
-rw-r--r--pkgs/development/misc/msp430/newlib.nix25
-rw-r--r--pkgs/top-level/all-packages.nix11
-rw-r--r--pkgs/top-level/release-cross.nix1
11 files changed, 107 insertions, 0 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index b3f7363fe61..9c6b51400dc 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -34,6 +34,7 @@ rec {
         else if final.isUClibc              then "uclibc"
         else if final.isAndroid             then "bionic"
         else if final.isLinux /* default */ then "glibc"
+        else if final.isMsp430              then "newlib"
         else if final.isAvr                 then "avrlibc"
         # TODO(@Ericson2314) think more about other operating systems
         else                                     "native/impure";
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index ac1633a1a15..27a32181df8 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -102,6 +102,11 @@ rec {
   riscv64 = riscv "64";
   riscv32 = riscv "32";
 
+  msp430 = {
+    config = "msp430-elf";
+    libc = "newlib";
+  };
+
   avr = {
     config = "avr";
   };
diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix
index 932f8fd1e53..f8d5ca84d7a 100644
--- a/lib/systems/inspect.nix
+++ b/lib/systems/inspect.nix
@@ -20,6 +20,7 @@ rec {
     isRiscV        = { cpu = { family = "riscv"; }; };
     isSparc        = { cpu = { family = "sparc"; }; };
     isWasm         = { cpu = { family = "wasm"; }; };
+    isMsp430       = { cpu = { family = "msp430"; }; };
     isAvr          = { cpu = { family = "avr"; }; };
     isAlpha        = { cpu = { family = "alpha"; }; };
 
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index fab50bc0ebd..8cc7d3ae271 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -109,6 +109,7 @@ rec {
     
     alpha    = { bits = 64; significantByte = littleEndian; family = "alpha"; };
 
+    msp430   = { bits = 16; significantByte = littleEndian; family = "msp430"; };
     avr      = { bits = 8; family = "avr"; };
   };
 
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index e59cf106a75..40340ec04fb 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -147,6 +147,11 @@
     github = "aepsil0n";
     name = "Eduard Bopp";
   };
+  aerialx = {
+    email = "aaron+nixos@aaronlindsay.com";
+    github = "AerialX";
+    name = "Aaron Lindsay";
+  };
   aespinosa = {
     email = "allan.espinosa@outlook.com";
     github = "aespinosa";
diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix
index 142f5255caa..72327d2bb67 100644
--- a/pkgs/build-support/bintools-wrapper/default.nix
+++ b/pkgs/build-support/bintools-wrapper/default.nix
@@ -186,6 +186,7 @@ stdenv.mkDerivation {
         }.${targetPlatform.parsed.cpu.name}
       else if targetPlatform.isPower then if targetPlatform.isBigEndian then "ppc" else "lppc"
       else if targetPlatform.isSparc then "sparc"
+      else if targetPlatform.isMsp430 then "msp430"
       else if targetPlatform.isAvr then "avr"
       else if targetPlatform.isAlpha then "alpha"
       else throw "unknown emulation for platform: " + targetPlatform.config;
diff --git a/pkgs/development/misc/msp430/gcc-support.nix b/pkgs/development/misc/msp430/gcc-support.nix
new file mode 100644
index 00000000000..a6f84bc86d7
--- /dev/null
+++ b/pkgs/development/misc/msp430/gcc-support.nix
@@ -0,0 +1,31 @@
+{ stdenvNoCC, fetchzip }:
+
+let
+  mspgccVersion = "6_1_0_0";
+  version = "1.206";
+in stdenvNoCC.mkDerivation {
+  name = "msp430-gcc-support-files-${version}";
+  src = fetchzip {
+    url = "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/${mspgccVersion}/exports/msp430-gcc-support-files-${version}.zip";
+    sha256 = "0h297jms3gkmdcqmfpr3cg6v9wxnms34qbwvwl2fkmrz20vk766q";
+  };
+
+  buildCommand = ''
+    find $src/include -name '*.ld' | xargs install -Dm0644 -t $out/lib
+    find $src/include -name '*.h' | xargs install -Dm0644 -t $out/include
+    install -Dm0644 -t $out/include $src/include/devices.csv
+
+    # appease bintoolsWrapper_addLDVars, search path needed for ld scripts
+    touch $out/lib/lib
+  '';
+
+  meta = with stdenvNoCC.lib; {
+    description = ''
+      Development headers and linker scripts for TI MSP430 microcontrollers
+    '';
+    homepage = https://www.ti.com/tool/msp430-gcc-opensource;
+    license = licenses.bsd3;
+    platforms = [ "msp430-none" ];
+    maintainers = with maintainers; [ aerialx ];
+  };
+}
diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix
new file mode 100644
index 00000000000..0456c8eae76
--- /dev/null
+++ b/pkgs/development/misc/msp430/mspdebug.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, libusb, readline ? null }:
+
+let
+  version = "0.25";
+in stdenv.mkDerivation {
+  name = "mspdebug-${version}";
+  src = fetchFromGitHub {
+    owner = "dlbeer";
+    repo = "mspdebug";
+    rev = "v${version}";
+    sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c";
+  };
+
+  buildInputs = [ libusb readline ];
+  makeFlags = [ "PREFIX=$(out)" "INSTALL=install" ] ++
+    (if readline == null then [ "WITHOUT_READLINE=1" ] else []);
+
+  meta = with stdenv.lib; {
+    description = "A free programmer, debugger, and gdb proxy for MSP430 MCUs";
+    homepage = https://dlbeer.co.nz/mspdebug/;
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ aerialx ];
+  };
+}
diff --git a/pkgs/development/misc/msp430/newlib.nix b/pkgs/development/misc/msp430/newlib.nix
new file mode 100644
index 00000000000..4ea98bfc8b2
--- /dev/null
+++ b/pkgs/development/misc/msp430/newlib.nix
@@ -0,0 +1,25 @@
+{ stdenvNoCC, lndir, newlib, msp430GccSupport }:
+
+stdenvNoCC.mkDerivation {
+  name = "msp430-${newlib.name}";
+  inherit newlib;
+  inherit msp430GccSupport;
+
+  preferLocalBuild = true;
+  allowSubstitutes = false;
+
+  buildCommand = ''
+    mkdir $out
+    ${lndir}/bin/lndir -silent $newlib $out
+    ${lndir}/bin/lndir -silent $msp430GccSupport/include $out/${newlib.incdir}
+    ${lndir}/bin/lndir -silent $msp430GccSupport/lib $out/${newlib.libdir}
+  '';
+
+  passthru = {
+    inherit (newlib) incdir libdir;
+  };
+
+  meta = {
+    platforms = [ "msp430-none" ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index d8c3459e987..08b3df6f382 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -8373,6 +8373,16 @@ in
     binutils-arm-embedded = pkgsCross.arm-embedded.buildPackages.binutils;
   };
 
+  msp430GccSupport = callPackage ../development/misc/msp430/gcc-support.nix { };
+
+  msp430Newlib      = callPackage ../development/misc/msp430/newlib.nix { };
+  msp430NewlibCross = callPackage ../development/misc/msp430/newlib.nix {
+    inherit (buildPackages.xorg) lndir;
+    newlib = newlibCross;
+  };
+
+  mspdebug = callPackage ../development/misc/msp430/mspdebug.nix { };
+
   pharo-vms = callPackage ../development/pharo/vm { };
   pharo = pharo-vms.multi-vm-wrapper;
   pharo-cog32 = pharo-vms.cog32;
@@ -10141,6 +10151,7 @@ in
     else if name == "bionic" then targetPackages.bionic or bionic
     else if name == "uclibc" then targetPackages.uclibcCross or uclibcCross
     else if name == "avrlibc" then targetPackages.avrlibcCross or avrlibcCross
+    else if name == "newlib" && stdenv.targetPlatform.isMsp430 then targetPackages.msp430NewlibCross or msp430NewlibCross
     else if name == "newlib" then targetPackages.newlibCross or newlibCross
     else if name == "musl" then targetPackages.muslCross or muslCross
     else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
diff --git a/pkgs/top-level/release-cross.nix b/pkgs/top-level/release-cross.nix
index b06bb5393be..f4210fcfc72 100644
--- a/pkgs/top-level/release-cross.nix
+++ b/pkgs/top-level/release-cross.nix
@@ -140,6 +140,7 @@ in
   android64 = mapTestOnCross lib.systems.examples.aarch64-android-prebuilt (linuxCommon // {
   });
 
+  msp430 = mapTestOnCross lib.systems.examples.msp430 embedded;
   avr = mapTestOnCross lib.systems.examples.avr embedded;
   arm-embedded = mapTestOnCross lib.systems.examples.arm-embedded embedded;
   powerpc-embedded = mapTestOnCross lib.systems.examples.ppc-embedded embedded;