From 24d92030dda5bbe03542e0bae51c8810f3a48548 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 2 Jul 2024 03:02:26 -0400 Subject: initial commit --- .gitignore | 4 +++ LICENSE | 19 ++++++++++++ README.md | 4 +++ crosstools-arm-gcc.nix | 29 ++++++++++++++++++ flake.lock | 27 +++++++++++++++++ flake.nix | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 165 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 crosstools-arm-gcc.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..825f67e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# nix +result +result-* +repl-result-* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b3b1528 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2024 seth + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa492cc --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# t3200-toolchain + +The very, very old [Actiontec T3200](https://opensource.actiontec.com/t3200.html) +cross compilation toolchain, now (hopefully) on your modern system diff --git a/crosstools-arm-gcc.nix b/crosstools-arm-gcc.nix new file mode 100644 index 0000000..c722496 --- /dev/null +++ b/crosstools-arm-gcc.nix @@ -0,0 +1,29 @@ +{ + stdenvNoCC, + autoPatchelfHook, + ncurses5, + sourceRelease, + releaseVersion, +}: +stdenvNoCC.mkDerivation { + pname = "t3200-crosstools-arm-gcc"; + version = "4.6-${releaseVersion}"; + + src = sourceRelease + "/crosstools-arm-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21-NPTL.tar.bz2"; + + nativeBuildInputs = [ autoPatchelfHook ]; + + buildInputs = [ ncurses5 ]; + + installPhase = '' + runHook preInstall + + mv toolchains/crosstools-arm-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21-NPTL $out + rm $out/lib + mv $out/usr/{,.}* $out + rmdir $out/usr + ln -sf $out/lib $out/arm-unknown-linux-uclibcgnueabi/sysroot/lib + + runHook postInstall + ''; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2bd77da --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1719826879, + "narHash": "sha256-xs7PlULe8O1SAcs/9e/HOjeUjBrU5FNtkAF/bSEcFto=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b9014df496d5b68bf7c0145d0e9b0f529ce4f2a8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..aced115 --- /dev/null +++ b/flake.nix @@ -0,0 +1,82 @@ +{ + description = "Toolchain for Actiontec's T3200 Series DSL Gateway"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = + { self, nixpkgs, ... }: + let + inherit (nixpkgs) lib; + + # Since we're building 32-bit linux packages, we can only (usually) run this on + # systems that are x86{,-64} and Linux themselves. This should evaluate to + # [ "x86_64-linux" "i686-linux" ] + systems = lib.intersectLists lib.platforms.linux lib.platforms.x86; + + forAllSystems = lib.genAttrs systems; + nixpkgsFor = forAllSystems ( + system: + let + native = nixpkgs.legacyPackages.${system}; + in + { + inherit native; + cross = { + i686 = native.pkgsi686Linux; + }; + } + ); + in + { + formatter = forAllSystems (system: nixpkgsFor.${system}.native.nixfmt-rfc-style); + + packages = forAllSystems ( + system: + let + nixpkgsFor' = nixpkgsFor.${system}; + pkgs = nixpkgsFor'.native; + pkgsi686 = nixpkgsFor'.cross.i686; + + # https://opensource.actiontec.com/t3200.html + # + # some of these releases contain different toolchains + # no idea if any of these are meaningful changes, but lets + # support multiple for fun + releases = [ + { + version = "31.164l.32"; + hash = "sha256-SRS9N1dpmvAksF6zWudUUv6DWL2TQVCte3x1PL8d02g="; + } + { + version = "31.164l.33"; + hash = "sha256-tN31mGv27vUoIncM6xadhyiMdal4pdtFgn5tu5oFtF4="; + } + ]; + + releaseInfo = map ( + { version, hash }: + { + inherit version; + src = pkgs.fetchzip { + url = "https://opensource.actiontec.com/sourcecode/t3200x/bt_bcm963xx_t3200_${version}_gpl_consumer_release.tar.gz"; + inherit hash; + stripRoot = false; + }; + } + ) releases; + + releasePackages = map ( + { src, version }: + { + name = "toolchain-" + version; + value = pkgsi686.callPackage ./crosstools-arm-gcc.nix { + sourceRelease = src; + releaseVersion = version; + }; + } + ) releaseInfo; + in + lib.listToAttrs releasePackages // { default = self.packages.${system}."toolchain-31.164l.33"; } + ); + }; +} -- cgit v1.2.3