diff --git a/configuration.nix b/configuration.nix index 669fe60..0110598 100644 --- a/configuration.nix +++ b/configuration.nix @@ -36,5 +36,5 @@ }; #environment.systemPackages = with pkgs; [ vim gdb neofetch gcc bintools ]; - #environment.systemPackages = with pkgs; [ rvb unalignedCheck ]; + #environment.systemPackages = with pkgs; [ rvb riscv-tools ]; } diff --git a/lagarto-ox.nix b/lagarto-ox.nix index 01f54f9..3e5e404 100644 --- a/lagarto-ox.nix +++ b/lagarto-ox.nix @@ -261,12 +261,9 @@ ''; }; - # Add the csrtool to the initrd so we can change the - # in-order/out-of-order, and memtool to stress the memory. + # Add riscv-tools to initrd extraUtilsCommands = '' - cp -a ${pkgs.csrtool}/bin/csrtool $out/bin - cp -a ${pkgs.memtool}/bin/memtool $out/bin - cp -a ${pkgs.plictool}/bin/plictool $out/bin + cp -a ${pkgs.riscv-tools}/bin/* $out/bin ''; # Write a counter to the DMA region, so we can check the kernel is not diff --git a/overlay.nix b/overlay.nix index bc60e91..9cf6788 100644 --- a/overlay.nix +++ b/overlay.nix @@ -21,68 +21,10 @@ final: prev: ]; }); - unalignedCheck = prev.stdenv.mkDerivation { - name = "unaligned-check"; - src = ./unalign.c; - unpackPhase = '' - cp ${./unalign.c} unalign.c - ''; - dontConfigure = true; - buildPhase = '' - $CC unalign.c -o unalign_check - ''; - installPhase = '' - mkdir -p $out/bin - cp unalign_check $out/bin/ - ''; - }; - - csrtool = prev.pkgsStatic.stdenv.mkDerivation { - name = "csrtool"; - src = ./csrtool.c; - unpackPhase = '' - cp ${./csrtool.c} csrtool.c - ''; - dontConfigure = true; - buildPhase = '' - $CC -static csrtool.c -o csrtool - ''; - installPhase = '' - mkdir -p $out/bin - cp csrtool $out/bin/ - ''; - }; - - memtool = prev.pkgsStatic.stdenv.mkDerivation { - name = "memtool"; - src = ./memtool.c; - unpackPhase = '' - cp ${./memtool.c} memtool.c - ''; - dontConfigure = true; - buildPhase = '' - $CC -static memtool.c -o memtool - ''; - installPhase = '' - mkdir -p $out/bin - cp memtool $out/bin/ - ''; - }; - - plictool = prev.pkgsStatic.stdenv.mkDerivation { - name = "plictool"; - src = ./tools/plictool.c; - unpackPhase = '' - cp ${./tools/plictool.c} plictool.c - ''; - dontConfigure = true; - buildPhase = '' - $CC -static plictool.c -o plictool - ''; - installPhase = '' - mkdir -p $out/bin - cp plictool $out/bin/ - ''; + riscv-tools = prev.pkgsStatic.stdenv.mkDerivation { + name = "riscv-tools"; + src = ./tools; + makeFlags = [ "PREFIX=${placeholder "out"}" ]; }; bitstreams = builtins.fetchGit { diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000..c79a82f --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1,4 @@ +plictool +csrtool +memtool +*.bin diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 0000000..c57de84 --- /dev/null +++ b/tools/Makefile @@ -0,0 +1,20 @@ +CFLAGS=-static +PREFIX?=/usr/local +bin=plictool csrtool memtool unalign + +all: $(bin) + +clean: + rm -f $(bin) + +install: + mkdir -p $(PREFIX)/bin + cp -a $(bin) $(PREFIX)/bin + +plictool: plictool.c + +csrtool: csrtool.c + +memtool: memtool.c + +unalign: unalign.c diff --git a/csrtool.c b/tools/csrtool.c similarity index 100% rename from csrtool.c rename to tools/csrtool.c diff --git a/memtool.c b/tools/memtool.c similarity index 100% rename from memtool.c rename to tools/memtool.c diff --git a/unalign.c b/tools/unalign.c similarity index 100% rename from unalign.c rename to tools/unalign.c