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/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/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/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/development/misc/msp430/gcc-support.nix b/pkgs/development/misc/msp430/gcc-support.nix new file mode 100644 index 000000000000..a6f84bc86d7d --- /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 000000000000..0456c8eae769 --- /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 000000000000..4ea98bfc8b2e --- /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 d8c3459e9874..08b3df6f382c 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 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;