From a5496d0328073a52623a7c7f4998f630d40959d8 Mon Sep 17 00:00:00 2001 From: Martijn Bastiaan Date: Wed, 31 Jan 2024 09:37:22 +0100 Subject: [PATCH] Add VexRiscv's OpenOCD to Nix environment --- nix/nixpkgs.nix | 1 + nix/openocd-vexriscv.nix | 32 ++++++++++++++++++++++++++++++++ shell.nix | 3 +++ 3 files changed, 36 insertions(+) create mode 100644 nix/openocd-vexriscv.nix diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix index 9a58743..0432755 100644 --- a/nix/nixpkgs.nix +++ b/nix/nixpkgs.nix @@ -9,6 +9,7 @@ let # Nix tooling niv = (import sources.niv {}).niv; gitignore = import sources.gitignore { inherit (nixpkgs) lib; }; + openocd-vexriscv = import ./openocd-vexriscv.nix { inherit (nixpkgs) pkgs; }; # Haskell overrides haskellPackages = nixpkgs.haskellPackages.override { diff --git a/nix/openocd-vexriscv.nix b/nix/openocd-vexriscv.nix new file mode 100644 index 0000000..67f9ac0 --- /dev/null +++ b/nix/openocd-vexriscv.nix @@ -0,0 +1,32 @@ +{ pkgs ? import ./nixpkgs.nix {} }: + +pkgs.stdenv.mkDerivation rec { + name = "openocd-vexriscv"; + + buildInputs = [ + pkgs.autoconf + pkgs.automake + pkgs.coreutils + pkgs.git + pkgs.libtool + pkgs.libusb1 + pkgs.libyaml + pkgs.pkg-config + pkgs.texinfo + pkgs.which + ]; + + src = pkgs.fetchgit { + url = "https://github.com/SpinalHDL/openocd_riscv.git"; + rev = "058dfa50d625893bee9fecf8d604141911fac125"; + sha256 = "sha256-5BvR45A3/7NqivQpYwaFnu7ra/Rf8giRig8R3zSYVd8="; + }; + + installPhase = '' + SKIP_SUBMODULE=1 ./bootstrap + ./configure --enable-ftdi --enable-dummy --prefix=$out + make -j $(nproc) + make install + mv $out/bin/openocd $out/bin/openocd-vexriscv + ''; +} diff --git a/shell.nix b/shell.nix index 3458391..29645f1 100644 --- a/shell.nix +++ b/shell.nix @@ -17,6 +17,9 @@ pkgs.mkShell { (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml) + # VexRiscV needs a special openocd + pkgs.openocd-vexriscv + # For Cabal to clone git repos pkgs.buildPackages.git ]