From 1eca945e948f89cf8baf0bfc6f91c303985fefbf Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Mon, 25 Mar 2019 19:17:37 -0700 Subject: systems: support TI MSP430 microcontrollers --- lib/systems/examples.nix | 5 +++++ lib/systems/inspect.nix | 1 + lib/systems/parse.nix | 1 + pkgs/build-support/bintools-wrapper/default.nix | 1 + pkgs/top-level/release-cross.nix | 1 + 5 files changed, 9 insertions(+) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index ac1633a1a15f..27a32181df88 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 932f8fd1e536..f8d5ca84d7aa 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 fab50bc0ebd7..8cc7d3ae271f 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/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 142f5255caad..72327d2bb671 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/top-level/release-cross.nix b/pkgs/top-level/release-cross.nix index b06bb5393bea..f4210fcfc72e 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; -- cgit 1.4.1 From 02a1d3b24a94a21844ae545a9eb9ee00b61e0f63 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Mon, 25 Mar 2019 19:31:23 -0700 Subject: msp430: vendor header package --- maintainers/maintainer-list.nix | 5 +++++ pkgs/development/misc/msp430/gcc-support.nix | 30 ++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 37 insertions(+) create mode 100644 pkgs/development/misc/msp430/gcc-support.nix diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index e59cf106a75b..40340ec04fb1 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/development/misc/msp430/gcc-support.nix b/pkgs/development/misc/msp430/gcc-support.nix new file mode 100644 index 000000000000..c24af9920198 --- /dev/null +++ b/pkgs/development/misc/msp430/gcc-support.nix @@ -0,0 +1,30 @@ +{ 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 = '' + install -Dm0644 -t $out/lib $src/include/*.ld + install -Dm0644 -t $out/include $src/include/*.h + + # 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 = platforms.all; + maintainers = with maintainers; [ aerialx ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 33464ab30a45..f7fdc29556ca 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8372,6 +8372,8 @@ in binutils-arm-embedded = pkgsCross.arm-embedded.buildPackages.binutils; }; + msp430GccSupport = callPackage ../development/misc/msp430/gcc-support.nix { }; + pharo-vms = callPackage ../development/pharo/vm { }; pharo = pharo-vms.multi-vm-wrapper; pharo-cog32 = pharo-vms.cog32; -- cgit 1.4.1 From 1c7bb464d99301e42cbb0fe438c927c1440800c6 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Mon, 25 Mar 2019 20:33:39 -0700 Subject: msp430: include vendor headers with stdenv --- lib/systems/default.nix | 1 + pkgs/development/misc/msp430/newlib.nix | 18 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 7 +++++++ 3 files changed, 26 insertions(+) create mode 100644 pkgs/development/misc/msp430/newlib.nix diff --git a/lib/systems/default.nix b/lib/systems/default.nix index b3f7363fe612..9c6b51400dcb 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/pkgs/development/misc/msp430/newlib.nix b/pkgs/development/misc/msp430/newlib.nix new file mode 100644 index 000000000000..9586a2ff21d3 --- /dev/null +++ b/pkgs/development/misc/msp430/newlib.nix @@ -0,0 +1,18 @@ +{ runCommand, lndir, newlib, msp430GccSupport }: + +runCommand "msp430-${newlib.name}" { + inherit newlib; + inherit msp430GccSupport; + + preferLocalBuild = true; + allowSubstitutes = false; + + passthru = { + inherit (newlib) incdir libdir; + }; +} '' + 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} +'' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f7fdc29556ca..08eb5a91c8a3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8374,6 +8374,12 @@ in msp430GccSupport = callPackage ../development/misc/msp430/gcc-support.nix { }; + msp430Newlib = callPackage ../development/misc/msp430/newlib.nix { }; + msp430NewlibCross = callPackage ../development/misc/msp430/newlib.nix { + inherit (pkgs.buildPackages.xorg) lndir; + newlib = pkgs.newlibCross; + }; + pharo-vms = callPackage ../development/pharo/vm { }; pharo = pharo-vms.multi-vm-wrapper; pharo-cog32 = pharo-vms.cog32; @@ -10146,6 +10152,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 -- cgit 1.4.1 From e3f6b083078c6948be9dedfca735d9fae30337c2 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Mon, 25 Mar 2019 22:12:52 -0700 Subject: wip: better packaging? --- pkgs/development/misc/msp430/gcc-support.nix | 2 +- pkgs/development/misc/msp430/newlib.nix | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pkgs/development/misc/msp430/gcc-support.nix b/pkgs/development/misc/msp430/gcc-support.nix index c24af9920198..8e3bfd7a1dc2 100644 --- a/pkgs/development/misc/msp430/gcc-support.nix +++ b/pkgs/development/misc/msp430/gcc-support.nix @@ -24,7 +24,7 @@ in stdenvNoCC.mkDerivation { ''; homepage = https://www.ti.com/tool/msp430-gcc-opensource; license = licenses.bsd3; - platforms = platforms.all; + platforms = [ "msp430-none" ]; maintainers = with maintainers; [ aerialx ]; }; } diff --git a/pkgs/development/misc/msp430/newlib.nix b/pkgs/development/misc/msp430/newlib.nix index 9586a2ff21d3..4ea98bfc8b2e 100644 --- a/pkgs/development/misc/msp430/newlib.nix +++ b/pkgs/development/misc/msp430/newlib.nix @@ -1,18 +1,25 @@ -{ runCommand, lndir, newlib, msp430GccSupport }: +{ stdenvNoCC, lndir, newlib, msp430GccSupport }: -runCommand "msp430-${newlib.name}" { +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; }; -} '' - 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} -'' + + meta = { + platforms = [ "msp430-none" ]; + }; +} -- cgit 1.4.1 From bc2c8db7f834a07a1b7b619fb0346cdca3fbe9ec Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 26 Mar 2019 11:19:09 -0700 Subject: mspdebug: init at 0.25 --- pkgs/development/misc/msp430/mspdebug.nix | 27 +++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/development/misc/msp430/mspdebug.nix diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix new file mode 100644 index 000000000000..a39dd4cfc046 --- /dev/null +++ b/pkgs/development/misc/msp430/mspdebug.nix @@ -0,0 +1,27 @@ +{ 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 = [ readline libusb ]; + 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/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 08eb5a91c8a3..82726f8cac1b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8380,6 +8380,8 @@ in newlib = pkgs.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; -- cgit 1.4.1 From 9785df65dad2be4d3225619c7b7a41ddf57748ac Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 26 Mar 2019 11:22:23 -0700 Subject: fixup! msp430: vendor header package --- pkgs/development/misc/msp430/gcc-support.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/misc/msp430/gcc-support.nix b/pkgs/development/misc/msp430/gcc-support.nix index 8e3bfd7a1dc2..297ae41bfe86 100644 --- a/pkgs/development/misc/msp430/gcc-support.nix +++ b/pkgs/development/misc/msp430/gcc-support.nix @@ -12,7 +12,7 @@ in stdenvNoCC.mkDerivation { buildCommand = '' install -Dm0644 -t $out/lib $src/include/*.ld - install -Dm0644 -t $out/include $src/include/*.h + install -Dm0644 -t $out/include $src/include/*.h $src/include/devices.csv # appease bintoolsWrapper_addLDVars, search path needed for ld scripts touch $out/lib/lib @@ -20,7 +20,7 @@ in stdenvNoCC.mkDerivation { meta = with stdenvNoCC.lib; { description = '' - Development headers and linker scripts for TI MSP430 microcontrollers. + Development headers and linker scripts for TI MSP430 microcontrollers ''; homepage = https://www.ti.com/tool/msp430-gcc-opensource; license = licenses.bsd3; -- cgit 1.4.1 From a4cc81746a0de17ffceeb90a3700fe242cb5cb5b Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 26 Mar 2019 22:37:06 -0700 Subject: fixup! msp430: vendor header package --- pkgs/development/misc/msp430/gcc-support.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/misc/msp430/gcc-support.nix b/pkgs/development/misc/msp430/gcc-support.nix index 297ae41bfe86..a6f84bc86d7d 100644 --- a/pkgs/development/misc/msp430/gcc-support.nix +++ b/pkgs/development/misc/msp430/gcc-support.nix @@ -11,8 +11,9 @@ in stdenvNoCC.mkDerivation { }; buildCommand = '' - install -Dm0644 -t $out/lib $src/include/*.ld - install -Dm0644 -t $out/include $src/include/*.h $src/include/devices.csv + 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 -- cgit 1.4.1 From 6bfdee81073572950922ce491b5b9be261fc8848 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 26 Mar 2019 22:50:05 -0700 Subject: fixup! mspdebug: init at 0.25 --- pkgs/development/misc/msp430/mspdebug.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix index a39dd4cfc046..0456c8eae769 100644 --- a/pkgs/development/misc/msp430/mspdebug.nix +++ b/pkgs/development/misc/msp430/mspdebug.nix @@ -11,11 +11,9 @@ in stdenv.mkDerivation { sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"; }; - buildInputs = [ readline libusb ]; - makeFlags = [ - "PREFIX=$(out)" - "INSTALL=install" - ] ++ (if readline == null then ["WITHOUT_READLINE=1"] else []); + 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"; -- cgit 1.4.1 From c17cf32a3724bf6c23cb3146acb639c414c8edd8 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Fri, 29 Mar 2019 11:08:37 -0700 Subject: fixup! msp430: include vendor headers with stdenv --- pkgs/top-level/all-packages.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 82726f8cac1b..b5d56d5c07f4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8376,8 +8376,8 @@ in msp430Newlib = callPackage ../development/misc/msp430/newlib.nix { }; msp430NewlibCross = callPackage ../development/misc/msp430/newlib.nix { - inherit (pkgs.buildPackages.xorg) lndir; - newlib = pkgs.newlibCross; + inherit (buildPackages.xorg) lndir; + newlib = newlibCross; }; mspdebug = callPackage ../development/misc/msp430/mspdebug.nix { }; -- cgit 1.4.1