From: Las Safin Date: Sun, 26 Sep 2021 21:13:19 +0000 (+0000) Subject: Add script for loading Libre-SOC onto Versa ECP5 board! X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d6fc8e024be79be3701b9c3ab4049fd6a5b8a34c;p=soc.git Add script for loading Libre-SOC onto Versa ECP5 board! --- diff --git a/flake.lock b/flake.lock index 8193dbc8..64e72d09 100644 --- a/flake.lock +++ b/flake.lock @@ -97,6 +97,26 @@ "url": "https://git.libre-soc.org/git/nmigen-soc.git" } }, + "openocd": { + "flake": false, + "locked": { + "allRefs": true, + "lastModified": 1632577048, + "narHash": "sha256-jL6CvgEFslg3V4WIH3irLgXQRa1HczBZowZhTztW7nM=", + "ref": "master", + "rev": "c3993d3188da5976a64f47d4cbf4d7e5b63f0c8d", + "revCount": 9294, + "submodules": true, + "type": "git", + "url": "https://github.com/openocd-org/openocd?rev=35eed36ffdd082f5abfc16d4cc93511f6e225284&allR" + }, + "original": { + "allRefs": true, + "submodules": true, + "type": "git", + "url": "https://github.com/openocd-org/openocd?rev=35eed36ffdd082f5abfc16d4cc93511f6e225284&allR" + } + }, "root": { "inputs": { "c4m-jtag": "c4m-jtag", @@ -105,6 +125,7 @@ "nixpkgs": "nixpkgs", "nmigen": "nmigen", "nmigen-soc": "nmigen-soc", + "openocd": "openocd", "yosys": "yosys" } }, diff --git a/flake.nix b/flake.nix index 3bd7f9e9..2027d9bf 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,7 @@ inputs.migen.flake = false; inputs.yosys.url = "github:YosysHQ/yosys?rev=a58571d0fe8971cb7d3a619a31b2c21be6d75bac"; inputs.yosys.flake = false; + # submodules needed inputs.nix-litex.url = "git+https://git.sr.ht/~lschuermann/nix-litex?ref=main"; inputs.nix-litex.flake = false; @@ -37,8 +38,8 @@ in { overlay = final: prev: { - python37Packages = prev.python37Packages.override { - overrides = lib.composeExtensions (litex final).pythonOverlay (pfinal: pprev: { + python37 = prev.python37.override { + packageOverrides = lib.composeExtensions (litex final).pythonOverlay (pfinal: pprev: { libresoc-ieee754fpu = pfinal.callPackage ./nix/ieee754fpu.nix {}; libresoc-openpower-isa = pfinal.callPackage ./nix/openpower-isa.nix {}; c4m-jtag = pfinal.callPackage (import ./nix/c4m-jtag.nix { src = c4m-jtag; version = getv c4m-jtag; }) {}; @@ -71,15 +72,25 @@ libresoc-pre-litex = final.callPackage (import ./nix/pre-litex.nix { version = getv self; }) { python3Packages = final.python37Packages; }; libresoc-ls180 = final.callPackage (import ./nix/ls180.nix { version = getv self; }) { python3Packages = final.python37Packages; }; libresoc-ecp5 = final.callPackage (import ./nix/ecp5.nix { version = getv self; }) { python3Packages = final.python37Packages; }; + libresoc-ecp5-program = final.callPackage (import ./nix/ecp5-program.nix { version = getv self; }) { python3Packages = final.python37Packages; }; libresoc-pinmux = final.callPackage (import ./nix/pinmux.nix { version = getv self; }) {}; }; + apps = forAllSystems (system: { + ecp5 = { + type = "app"; + program = "${nixpkgsFor.${system}.libresoc-ecp5-program}"; + }; + }); + defaultApp = forAllSystems (system: self.apps.${system}.ecp5); + packages = forAllSystems (system: { soc = nixpkgsFor.${system}.python37Packages.libresoc-soc; pre-litex = nixpkgsFor.${system}.libresoc-pre-litex; pinmux = nixpkgsFor.${system}.libresoc-pinmux; ls180 = nixpkgsFor.${system}.libresoc-ls180; ecp5 = nixpkgsFor.${system}.libresoc-ecp5; + ecp5-program = nixpkgsFor.${system}.libresoc-ecp5-program; openpower-isa = nixpkgsFor.${system}.python37Packages.libresoc-openpower-isa; debugNixpkgs = nixpkgsFor.${system}; }); diff --git a/nix/ecp5-program.nix b/nix/ecp5-program.nix new file mode 100644 index 00000000..fdf6c683 --- /dev/null +++ b/nix/ecp5-program.nix @@ -0,0 +1,21 @@ +{ version }: + +{ writeShellScript, openocd, python3Packages, libresoc-ecp5, yosys, libresoc-pre-litex, libresoc-pinmux, pkgsCross +, nextpnr, trellis }: + +let + pythonWithEnv = python3Packages.python.withPackages (ps: with ps; [ + requests migen libresoc-soc litex-boards litex litedram liteeth liteiclink litescope litesdcard + ]); +in +writeShellScript "program-ecp5-libresoc" '' + export PATH="${openocd}/bin:${pythonWithEnv}/bin:${trellis}/bin:${nextpnr}/bin:$PATH" + + dir="$(mktemp -d)" + cd "$dir" + echo "$dir" + + export PYTHONPATH="${../src/soc/litex/florent}:$PYTHONPATH" + + python ${../src/soc/litex/florent/versa_ecp5.py} --sys-clk-freq=55e6 --load-from ${libresoc-ecp5} +'' diff --git a/src/soc/litex/florent b/src/soc/litex/florent index 42f73576..b55917aa 160000 --- a/src/soc/litex/florent +++ b/src/soc/litex/florent @@ -1 +1 @@ -Subproject commit 42f7357660b245c4491297d24eebc28b4ac2c21f +Subproject commit b55917aafa6bbc9f16e1d97dc095e929c31aa81a