diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 922d894c5..20699ee15 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -17,8 +17,9 @@ on: - main paths: - 'bin/wally-tool-chain-install.sh' - - 'bin/wally-distro-check.sh' + - 'bin/wally-environment-check.sh' - 'bin/wally-package-install.sh' + - 'bin/installation/*' - '.github/workflows/install.yml' schedule: - cron: "0 7 * * 3" # Run at 12:00 AM Pacific Time on Wednesdays @@ -102,6 +103,7 @@ jobs: apt-get install -y git elif [ ${{ matrix.imageFamily }} == "redhat" ]; then dnf install -y git + # Red Hat images come with curl-minimal, which breaks the installation script. This replaces it with regular curl. dnf install curl -y --allowerasing || true elif [ ${{ matrix.imageFamily }} == "suse" ]; then zypper install -y git @@ -111,7 +113,7 @@ jobs: - name: Clone Necessary Submodules run: | git config --global --add safe.directory '*' - git submodule update --init addins/riscv-arch-test addins/verilog-ethernet + git submodule update --init addins/riscv-arch-test addins/cvw-arch-verif addins/verilog-ethernet # Free up space on the host machine, either from the container or the host - name: Free Up Storage run: | @@ -122,6 +124,17 @@ jobs: nsenter -t 1 -m -u -n -i bash -c "$(cat .github/scripts/cli-space-cleanup.sh)" fi df -h + # Set $RISCV so log files can be found and uploaded + - name: Set RISCV Environment Variable + run: | + if [ ! -z ${{ matrix.riscv_path }} ]; then + export RISCV=${{ matrix.riscv_path }} + elif [ ! -z ${{ matrix.user }} ]; then + export RISCV=$HOME/riscv + else + export RISCV=/opt/riscv + fi + echo "RISCV=${RISCV}" >> $GITHUB_ENV # Run main tool chain installation script, either as a user or system wide - name: Install run: | @@ -133,15 +146,10 @@ jobs: sudo ./bin/wally-package-install.sh ./bin/wally-tool-chain-install.sh --clean ${{ matrix.riscv_path }} fi - # Set environment variables for the rest of the job - - name: Set Environment Variables - if: always() - run: | - if [ ! -z ${{ matrix.riscv_path }} ]; then - sed -i 's,exit 1,export RISCV=${{ matrix.riscv_path }},g' setup.sh - fi - source setup.sh - echo "RISCV=$RISCV" >> "$GITHUB_ENV" + # Update setup.sh if using a custom $RISCV path + - name: Update setup.sh + if: ${{ matrix.riscv_path != null }} + run: sed -i 's,~/riscv,${{ matrix.riscv_path }},g' setup.sh # Upload installation logs for debugging - name: Upload Installation Logs uses: actions/upload-artifact@v4 @@ -160,7 +168,7 @@ jobs: - name: make tests run: | source setup.sh - make riscof zsbl --jobs $(nproc --ignore 1) + make riscof zsbl deriv coverage --jobs $(nproc --ignore 1) # Run standard regression, skipping distros that are known to be broken with Verilator - name: Regression if: ${{ matrix.regressionFail != true }} diff --git a/README.md b/README.md index 1f79dca35..1ffc48e81 100644 --- a/README.md +++ b/README.md @@ -118,16 +118,16 @@ If a user-level installation is desired, the script can instead be run by any us $ sudo $WALLY/bin/wally-package-install.sh ``` -In either case, the installation directory can be overridden by passing the desired directory as the last argument to the installation script. For example, +In either case, the installation directory can be overridden by passing the desired directory as an argument to the installation script. For example, ```bash $ sudo $WALLY/bin/wally-tool-chain-install.sh /home/riscv ``` -See `wally-tool-chain-install.sh` for a detailed description of each component, or to issue the commands one at a time to install on the command line. +See `wally-tool-chain-install.sh` and the scripts in the `$WALLY/bin/installation` directory for a detailed description of each component, or to issue the commands one at a time to install on the command line. > [!NOTE] -> The complete installation process requires ~55 GB of free space. If the `--clean` flag is passed to the installation script then the final consumed space is only ~26 GB, but upgrading the tools will reinstall everything from scratch. +> The complete installation process requires ~55 GB of free space. If the `--clean` flag is passed to the installation script then the final consumed space is only ~26 GB. The `--clean` flag removes source files and build directories. ### Configuration `$WALLY/setup.sh` sources `$RISCV/site-setup.sh`. If the toolchain was installed in either of the default locations (`/opt/riscv` or `~/riscv`), `$RISCV` will automatically be set to the correct path when `setup.sh` is run. If a custom installation directory was used, then `$WALLY/setup.sh` must be modified to set the correct path. diff --git a/addins/cvw-arch-verif b/addins/cvw-arch-verif index 1afacf04e..7141afd7f 160000 --- a/addins/cvw-arch-verif +++ b/addins/cvw-arch-verif @@ -1 +1 @@ -Subproject commit 1afacf04ee975c6bcbc65d36e8648e96f18ea0d4 +Subproject commit 7141afd7feb81a04db8c3110df0ef7d526e4efdb diff --git a/addins/cvw-riscv-arch-test b/addins/cvw-riscv-arch-test index 44832a9d3..77907f0c5 160000 --- a/addins/cvw-riscv-arch-test +++ b/addins/cvw-riscv-arch-test @@ -1 +1 @@ -Subproject commit 44832a9d3bea991b099c6beb4c962e5b7c1ad3a3 +Subproject commit 77907f0c5eb7b3da44a13597b26fb878d79ba7f5 diff --git a/benchmarks/coremark/expected_coremark_results.csv b/benchmarks/coremark/expected_coremark_results.csv index fff7b0055..b2b3d23ba 100644 --- a/benchmarks/coremark/expected_coremark_results.csv +++ b/benchmarks/coremark/expected_coremark_results.csv @@ -1,13 +1,13 @@ Architecture,CM / MHz,CPI,MTIME,MINSTRET,Load Stalls,Store Stalls,D$ Accesses,D$ Misses,I$ Accesses,I$ Misses,Branches,Branch Mispredicts,BTB Misses,Jump/JR,RAS Wrong,Returns,BP Class Pred Wrong -rv32i_zicsr,1.20,1.16,8269385,7124630,261886,22307,716317,73,7827908,1040,2009578,443447,5476,122015,3468,113645,20699 -rv32im_zicsr,3.26,1.12,3061233,2716910,264489,22198,690506,73,2975498,827,543885,45067,5483,30033,69,15237,20898 -rv32imc_zicsr,3.24,1.13,3085767,2716550,264404,23853,690507,75,3011253,285,543761,44223,5615,29675,171,15237,20295 -rv32im_zicsr_zba_zbb_zbs,3.38,1.12,2954414,2624181,266850,22258,689232,75,2878922,494,544408,42375,4295,29685,18,15249,14980 -rv32gc,3.24,1.13,3085783,2716550,264134,23852,690500,74,3010201,286,543485,44182,5563,29668,162,15230,20108 -rv32gc_zba_zbb_zbs,3.32,1.14,3003843,2624181,272635,22141,689226,74,2929468,280,543245,44490,6087,29680,23,15242,22189 -rv64i_zicsr,1.02,1.13,9731538,8559698,273929,22198,720375,85,9242621,588,2340171,459594,4842,128954,178,109383,15941 -rv64im_zicsr,2.86,1.10,3493939,3156218,271101,22149,691714,83,3406099,340,547671,42901,4651,34669,14,15099,15726 -rv64imc_zicsr,2.82,1.12,3545301,3156218,271029,25304,691715,86,3457798,263,547535,43990,4970,34671,5,15099,15889 -rv64im_zicsr_zba_zbb_zbs,3.08,1.11,3241375,2901479,273442,24665,689242,85,3150626,424,547796,41798,4635,34680,43,15111,16143 -rv64gc,2.82,1.12,3545281,3156218,270740,25304,691708,86,3456812,264,547229,43969,4970,34664,5,15092,15889 -rv64gc_zba_zbb_zbs,3.03,1.13,3297540,2901479,273107,26696,689236,83,3200848,250,547359,46238,6197,34675,73,15104,21328 +rv32i_zicsr,1.20,1.16,8269377,7124630,262876,22307,716340,75,7831331,1038,2010591,443551,5476,122038,3467,113668,20699 +rv32im_zicsr,3.26,1.12,3061215,2716910,265481,22198,690529,75,2978839,829,544899,45098,5483,30056,69,15260,20901 +rv32imc_zicsr,3.24,1.13,3085748,2716550,265386,23854,690530,75,3014578,285,544767,44249,5615,29698,171,15260,20295 +rv32im_zicsr_zba_zbb_zbs,3.38,1.12,2954396,2624181,267836,22258,689255,75,2882239,495,545416,42412,4295,29708,18,15272,14980 +rv32gc,3.24,1.13,3085785,2716550,265126,23851,690523,74,3013537,286,544500,44191,5563,29691,162,15253,20108 +rv32gc_zba_zbb_zbs,3.32,1.14,3003858,2624181,273728,22141,689249,75,2932896,280,544260,44486,6087,29703,23,15265,22189 +rv64i_zicsr,1.02,1.13,9731538,8559698,274922,22198,720398,86,9245947,588,2341187,459621,4842,128977,178,109406,15941 +rv64im_zicsr,2.86,1.10,3493929,3156218,272083,22149,691737,85,3409423,340,548686,42924,4651,34692,14,15122,15724 +rv64imc_zicsr,2.82,1.12,3545291,3156218,272037,25303,691738,85,3461141,261,548556,43997,4970,34694,5,15122,15889 +rv64im_zicsr_zba_zbb_zbs,3.08,1.11,3241385,2901479,274441,24666,689265,84,3153960,424,548818,41807,4635,34703,43,15134,16146 +rv64gc,2.82,1.12,3545279,3156218,271734,25303,691731,86,3460160,263,548246,43992,4970,34687,5,15115,15887 +rv64gc_zba_zbb_zbs,3.03,1.13,3297532,2901479,274101,26696,689259,84,3204202,249,548376,46265,6197,34698,73,15127,21328 diff --git a/benchmarks/embench/expected_embench_results/wallySizeOpt_speed.json b/benchmarks/embench/expected_embench_results/wallySizeOpt_speed.json index f9a787973..75944f70d 100644 --- a/benchmarks/embench/expected_embench_results/wallySizeOpt_speed.json +++ b/benchmarks/embench/expected_embench_results/wallySizeOpt_speed.json @@ -1,29 +1,29 @@ { "speed results" : { "detailed speed results" : - { "aha-mont64" : 0.81, + { "aha-mont64" : 0.82, "crc32" : 1.00, "cubic" : 0.42, - "edn" : 0.88, + "edn" : 0.94, "huffbench" : 1.38, "matmult-int" : 1.11, - "md5sum" : 2.00, - "minver" : 0.63, - "nbody" : 0.67, - "nettle-aes" : 0.82, - "nettle-sha256" : 0.96, + "md5sum" : 1.98, + "minver" : 0.62, + "nbody" : 0.66, + "nettle-aes" : 0.81, + "nettle-sha256" : 0.97, "nsichneu" : 1.14, "picojpeg" : 0.79, "primecount" : 1.30, - "qrduino" : 1.22, + "qrduino" : 1.23, "sglib-combined" : 1.17, - "slre" : 1.25, + "slre" : 1.26, "st" : 0.84, - "statemate" : 2.15, + "statemate" : 2.16, "tarfind" : 2.42, - "ud" : 0.88, + "ud" : 0.89, "wikisort" : 1.71 }, "speed geometric mean" : 1.07, - "speed geometric standard deviation" : 1.51 + "speed geometric standard deviation" : 1.50 } } diff --git a/benchmarks/embench/expected_embench_results/wallySpeedOpt_speed.json b/benchmarks/embench/expected_embench_results/wallySpeedOpt_speed.json index 837d3ef2a..aabc21b1c 100644 --- a/benchmarks/embench/expected_embench_results/wallySpeedOpt_speed.json +++ b/benchmarks/embench/expected_embench_results/wallySpeedOpt_speed.json @@ -1,27 +1,27 @@ { "speed results" : { "detailed speed results" : - { "aha-mont64" : 0.84, + { "aha-mont64" : 0.85, "crc32" : 1.05, "cubic" : 0.42, "edn" : 1.06, "huffbench" : 1.58, "matmult-int" : 1.11, "md5sum" : 1.92, - "minver" : 0.65, + "minver" : 0.66, "nbody" : 0.67, "nettle-aes" : 0.93, "nettle-sha256" : 0.99, - "nsichneu" : 0.70, - "picojpeg" : 0.99, + "nsichneu" : 0.75, + "picojpeg" : 1.00, "primecount" : 1.41, - "qrduino" : 1.32, + "qrduino" : 1.35, "sglib-combined" : 1.41, - "slre" : 1.54, + "slre" : 1.52, "st" : 0.86, - "statemate" : 3.13, - "tarfind" : 3.31, + "statemate" : 3.16, + "tarfind" : 3.21, "ud" : 0.94, - "wikisort" : 1.74 + "wikisort" : 1.76 }, "speed geometric mean" : 1.15, "speed geometric standard deviation" : 1.61 diff --git a/bin/derivgen.pl b/bin/derivgen.pl index dd736895d..748b3aca3 100755 --- a/bin/derivgen.pl +++ b/bin/derivgen.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env -S perl -w +#!/usr/bin/env perl ########################################### ## derivgen.pl diff --git a/bin/elf2hex.sh b/bin/elf2hex.sh deleted file mode 100755 index d36678e9c..000000000 --- a/bin/elf2hex.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -########################################### -## Written: james.stine@okstate.edu -## Created: 4 Jan 2022 -## Modified: -## -## Purpose: Script to run elf2hex for memfile for -## Imperas and riscv-arch-test benchmarks -## -## A component of the CORE-V-WALLY configurable RISC-V project. -## https://github.com/openhwgroup/cvw -## -## Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University -## -## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -## -## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -## except in compliance with the License, or, at your option, the Apache License version 2.0. You -## may obtain a copy of the License at -## -## https:##solderpad.org/licenses/SHL-2.1/ -## -## Unless required by applicable law or agreed to in writing, any work distributed under the -## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -## either express or implied. See the License for the specific language governing permissions -## and limitations under the License. -################################################################################################ - -for file in work/rv64i_m/*/*.elf ; do - memfile=${file%.elf}.elf.memfile - echo riscv64-unknown-elf-elf2hex --bit-width 64 --input "$file" - riscv64-unknown-elf-elf2hex --bit-width 64 --input "$file" --output "$memfile" -done - -for file in work/rv32i_m/*/*.elf ; do - memfile=${file%.elf}.elf.memfile - echo riscv64-unknown-elf-elf2hex --bit-width 32 --input "$file" - riscv64-unknown-elf-elf2hex --bit-width 32 --input "$file" --output "$memfile" -done diff --git a/bin/exe2memfile.pl b/bin/exe2memfile.pl deleted file mode 100755 index bab777151..000000000 --- a/bin/exe2memfile.pl +++ /dev/null @@ -1,197 +0,0 @@ -#!/usr/bin/env -S perl -w - -########################################### -## exe2memfile.pl -## -## Written: David_Harris@hmc.edu -## Created: 26 November 2020 -## Modified: -## -## Purpose: Converts an executable file to a series of 32-bit hex instructions -## to read into a Verilog simulation with $readmemh -## -## A component of the CORE-V-WALLY configurable RISC-V project. -## https://github.com/openhwgroup/cvw -## -## Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University -## -## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -## -## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -## except in compliance with the License, or, at your option, the Apache License version 2.0. You -## may obtain a copy of the License at -## -## https:##solderpad.org/licenses/SHL-2.1/ -## -## Unless required by applicable law or agreed to in writing, any work distributed under the -## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -## either express or implied. See the License for the specific language governing permissions -## and limitations under the License. -################################################################################################ - -# -# - -use File::stat; -use IO::Handle; - -if ($#ARGV == -1) { - die("Usage: $0 executable_file"); -} - -# array to hold contents of memory file -my $maxmemfilesize = 1000000; -my @memfilebytes = (0)*$maxmemfilesize*4; -my $maxaddress = 0; - -STDOUT->autoflush(1); -my $numfiles = $#ARGV+1; -if ($numfiles > 1) { - print ("Processing $numfiles memfiles: "); -} -my $frac = $#ARGV/10; -for(my $i=0; $i<=$#ARGV; $i++) { - if ($i > 0 && ($i < 10 || $i % $frac == 0)) { print ("$i ") }; - my $fname = $ARGV[$i]; -# print "fname = $fname"; - my $ofile = $fname.".objdump"; - my $memfile = $fname.".memfile"; - - my $needsprocessing = 0; - if (!-e $memfile) { $needsprocessing = 1; } # create memfile if it doesn't exist - else { - my $osb = stat($ofile) || die("Can't stat $ofile"); - my $msb = stat($memfile) || die("Can't stat $memfile"); - my $otime = $osb->mtime; - my $mtime = $msb->mtime; - if ($otime > $mtime) { $needsprocessing = 1; } # is memfile out of date? - } - - if ($needsprocessing == 1) { - open(FILE, $ofile) || die("Can't read $ofile"); - my $mode = 0; # parse for code - my $address; - - # initialize to all zeros; - for (my $i=0; $i < $maxmemfilesize*4; $i++) { - $memfilebytes[$i] = "00"; - } - - while() { - if ($mode == 0) { # Parse code - # print("Examining $_\n"); - if (/^\s*(\S\S\S\S\S\S\S\S):\s+(\S+)\s+/) { - $address = &fixadr($1); - my $instr = $2; - my $len = length($instr); - for (my $i=0; $i<$len/2; $i++) { - $memfilebytes[$address+$i] = substr($instr, $len-2-2*$i, 2); - } - # print ("address $address $instr\n"); - } - if (/Disassembly of section .data:/) { $mode = 1;} - } elsif ($mode == 1) { # Parse data segment -# if (/^\s*(\S\S\S\S\S\S\S\S):\s+(.*)/) { # changed to \t 30 Oct 2021 dmh to fix parsing issue in d_fmadd_b17 - if (/^\s*(\S\S\S\S\S\S\S\S):\s+(.*)/) { - $address = &fixadr($1); - # print "address $address maxaddress $maxaddress\n"; - if ($address > $maxaddress) { $maxaddress = $address; } - #print "test $address $1 $2\n"; - my $lineorig = $2; - my $line = $2; - # strip off leading 0x - $line =~ s/^0x//; - # merge chunks with spaces - $line =~ s/(\S)\s(\S)/$1$2/g; - my $linemerge = $line; - # strip off comments - $line =~ /^(\S*)/; - $payload = $1; -# if ($address >= 17520 && $address <= 17552) { # was 12304 -# print "Address: $address\n orig: $lineorig \n merge: $linemerge \n line: $line \n payload: $payload\n"; -# } - &emitData($address, $payload); - } - if (/Disassembly of section .riscv.attributes:/) { $mode = 2; } - } - } - close(FILE); -# print("maxaddress: $maxaddress\n"); - $maxaddress += 32; # pad some zeros at the end -# print("maxaddress: $maxaddress\n"); - - # print to memory file - if ($fname =~ /rv32/) { - open(MEMFILE, ">$memfile") || die("Can't write $memfile"); - for (my $i=0; $i<= $maxaddress; $i = $i + 4) { - for ($j=3; $j>=0; $j--) { - if (defined($memfilebytes[$i+$j])) { - print MEMFILE "$memfilebytes[$i+$j]"; - } else { - print MEMFILE "00"; - } - } - print MEMFILE "\n"; - } - close(MEMFILE); - } else { - open(MEMFILE, ">$memfile") || die("Can't write $memfile"); - for (my $i=0; $i<= $maxaddress; $i = $i + 8) { - for ($j=7; $j>=0; $j--) { - my $loc = $i+$j; -# if ($loc >= 17520 && $loc <= 17552) { -# print "loc: $loc val $memfilebytes[$loc]\n"; -# } - if (defined($memfilebytes[$loc])) { - print MEMFILE "$memfilebytes[$loc]"; - } else { - print MEMFILE "00"; - } - } - print MEMFILE "\n"; - } - close(MEMFILE); - } - } -} -print("\n"); - -sub emitData { - # print the data portion of the ELF into a memory file, including 0s for empty stuff - # deal with endianness - my $address = shift; - my $payload = shift; - -# if ($address > 17520 && $address < 17552) { # was 12304 -# print("Emitting data. address = $address payload = $payload\n"); -# } - - my $len = length($payload); - if ($len <= 8) { - # print word or halfword - for(my $i=0; $i<$len/2; $i++) { - my $adr = $address+$i; - my $b = substr($payload, $len-2-2*$i, 2); - $memfilebytes[$adr] = $b; -# if ($address >= 17520 && $address <= 17552) { -# print(" Wrote $b to $adr\n"); -# } -# print(" $adr $b\n"); - } - } elsif ($len == 12) { - # weird case of three halfwords on line - &emitData($address, substr($payload, 0, 4)); - &emitData($address+2, substr($payload, 4, 4)); - &emitData($address+4, substr($payload, 8, 4)); - } else { - &emitData($address, substr($payload, 0, 8)); - &emitData($address+4, substr($payload, 8, $len-8)); - } -} - -sub fixadr { - # strip off leading 8 from address and convert to decimal - my $adr = shift; - if ($adr =~ s/^8/0/) { return hex($adr); } - else { die("address $adr lacks leading 8\n"); } -} diff --git a/bin/installation/activate-tools.sh b/bin/installation/activate-tools.sh new file mode 100755 index 000000000..af7e782b2 --- /dev/null +++ b/bin/installation/activate-tools.sh @@ -0,0 +1,72 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: Activate gcc and python virtual environment +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# Activate python virtual environment +# Activate riscv-python Virtual Environment +if [ -e "$RISCV"/riscv-python/bin/activate ]; then + source "$RISCV"/riscv-python/bin/activate +else + echo -e "${FAIL_COLOR}Python virtual environment not found. Run wally-toolchain-install.sh or python-setup.sh to automatically create it.${ENDC}" + return 1 +fi + +# Enable newer version of gcc for older distros (required for QEMU/Verilator) +if [ "$FAMILY" == rhel ]; then + if [ -e /opt/rh/gcc-toolset-13/enable ]; then + source /opt/rh/gcc-toolset-13/enable + else + echo -e "${FAIL_COLOR}GCC toolset 13 not found. Please install it with wally-package-install.sh.${ENDC}" + return 1 + fi +elif [ "$FAMILY" == suse ]; then + if [ ! -e "$RISCV"/gcc-13/bin/gcc ]; then + mkdir -p "$RISCV"/gcc-13/bin + for f in gcc cpp g++ gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool lto-dump; do + ln -vsf /usr/bin/$f-13 "$RISCV"/gcc-13/bin/$f + done + fi + export PATH="$RISCV"/gcc-13/bin:$PATH +elif (( UBUNTU_VERSION == 20 )); then + if [ ! -e "$RISCV"/gcc-10/bin/gcc ]; then + mkdir -p "$RISCV"/gcc-10/bin + for f in gcc cpp g++ gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool lto-dump; do + ln -vsf /usr/bin/$f-10 "$RISCV"/gcc-10/bin/$f + done + fi + export PATH="$RISCV"/gcc-10/bin:$PATH +fi diff --git a/bin/installation/buildroot-install.sh b/bin/installation/buildroot-install.sh new file mode 100755 index 000000000..21c6f9f74 --- /dev/null +++ b/bin/installation/buildroot-install.sh @@ -0,0 +1,56 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: Buildroot and Linux testvector installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# Buildroot and Linux testvectors +# Buildroot is used to boot a minimal version of Linux on Wally. +# Testvectors are generated using QEMU. +section_header "Installing Buildroot and Creating Linux testvectors" +STATUS="buildroot" +export LD_LIBRARY_PATH=$RISCV/lib:$RISCV/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:$RISCV/riscv64-unknown-elf/lib:$RISCV/lib/x86_64-linux-gnu +cd "$WALLY"/linux +if [ ! -e "$RISCV"/buildroot ]; then + FORCE_UNSAFE_CONFIGURE=1 make 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] # FORCE_UNSAFE_CONFIGURE is needed to allow buildroot to compile when run as root + echo -e "${SUCCESS_COLOR}Buildroot successfully installed and Linux testvectors created!${ENDC}" +elif [ ! -e "$RISCV"/linux-testvectors ]; then + echo -e "${OK_COLOR}Buildroot already exists, but Linux testvectors are missing. Generating them now.${ENDC}" + make dumptvs 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + echo -e "${SUCCESS_COLOR}Linux testvectors successfully generated!${ENDC}" +else + echo -e "${OK_COLOR}Buildroot and Linux testvectors already exist.${ENDC}" + echo -e "${WARNING_COLOR}Buildroot is not updated automatically. If you want to install a newer version, delete the existing $RISCV/buildroot directory and rerun this script.${ENDC}" +fi diff --git a/bin/installation/elf2hex-install.sh b/bin/installation/elf2hex-install.sh new file mode 100755 index 000000000..af6409b69 --- /dev/null +++ b/bin/installation/elf2hex-install.sh @@ -0,0 +1,73 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: elf2hex installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +ELF2HEX_VERSION=f28a3103c06131ed3895052b1341daf4ca0b1c9c # Last commit as of May 30, 2025 + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# elf2hex (https://github.com/sifive/elf2hex) +# The elf2hex utility to converts executable files into hexadecimal files for Verilog simulation. +# Note: The exe2hex utility that comes with Spike doesn’t work for our purposes because it doesn’t +# handle programs that start at 0x80000000. The SiFive version above is touchy to install. +# For example, if Python version 2.x is in your path, it won’t install correctly. +# Also, be sure riscv64-unknown-elf-objcopy shows up in your path in $RISCV/bin +# at the time of compilation, or elf2hex won’t work properly. +section_header "Installing/Updating elf2hex" +STATUS="elf2hex" +cd "$RISCV" +if check_tool_version $ELF2HEX_VERSION; then + # Verify riscv64-unknown-elf-objcopy is available + if ! command -v riscv64-unknown-elf-objcopy >/dev/null 2>&1; then + echo -e "${FAIL_COLOR}ERROR: riscv64-unknown-elf-objcopy not found in \$PATH.${ENDC}" + echo -e "${FAIL_COLOR}Run wally-tool-chain-install.sh or riscv-gnu-toolchain-install.sh before installing elf2hex.${ENDC}" + exit 1 + fi + + git_checkout "elf2hex" "https://github.com/sifive/elf2hex.git" "$ELF2HEX_VERSION" + cd "$RISCV"/elf2hex + autoreconf -i + ./configure --target=riscv64-unknown-elf --prefix="$RISCV" + make 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + if [ "$clean" = true ]; then + cd "$RISCV" + rm -rf elf2hex + fi + echo "$ELF2HEX_VERSION" > "$RISCV"/versions/$STATUS.version # Record installed version + echo -e "${SUCCESS_COLOR}elf2hex successfully installed/updated!${ENDC}" +else + echo -e "${SUCCESS_COLOR}elf2hex already up to date.${ENDC}" +fi diff --git a/bin/installation/glib-installation.sh b/bin/installation/glib-installation.sh new file mode 100755 index 000000000..93e4ac787 --- /dev/null +++ b/bin/installation/glib-installation.sh @@ -0,0 +1,58 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: glib installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# Newer version of glib required for QEMU. +# Anything newer than this won't build on red hat 8 +STATUS="glib" +if [ ! -e "$RISCV"/include/glib-2.0 ]; then + section_header "Installing glib" + pip --require-virtualenv install -U meson # Meson is needed to build glib + cd "$RISCV" + wget -nv --retry-connrefused $retry_on_host_error https://download.gnome.org/sources/glib/2.70/glib-2.70.5.tar.xz + tar -xJf glib-2.70.5.tar.xz + rm -f glib-2.70.5.tar.xz + cd glib-2.70.5 + meson setup _build --prefix="$RISCV" + meson compile -C _build -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + meson install -C _build 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + cd "$RISCV" + rm -rf glib-2.70.5 + echo -e "${SUCCESS_COLOR}glib successfully installed!${ENDC}" +else + echo -e "${OK_COLOR}glib already installed.${ENDC}" +fi \ No newline at end of file diff --git a/bin/installation/python-setup.sh b/bin/installation/python-setup.sh new file mode 100755 index 000000000..dafe3a43a --- /dev/null +++ b/bin/installation/python-setup.sh @@ -0,0 +1,63 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: WALLY python virtual environment setup script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +# NOTE: These three tools need to be kept in sync. Update all versions simultaneously. +export RISCOF_VERSION=be84132874963e001c14d846a140a3edd9c9d48f # Last commit as May 31, 2025 +export RISCV_CONFIG_VERSION=54171f205be802f9f8e0b1cf4156a6cc826fb467 # Last commit as of May 31, 2025 +export RISCV_ISAC_VERSION=450de2eabfe4fcdfdf54135b5ab2dbb1d94805f8 # Last commit as of May 31, 2025 (commit hash of riscv-arch-test repo) + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# Create python virtual environment so the python command targets desired version of python +# and installed packages are isolated from the rest of the system. +section_header "Setting up Python Environment" +STATUS="python_virtual_environment" +cd "$RISCV" +if [ ! -e "$RISCV"/riscv-python/bin/activate ]; then + "$PYTHON_VERSION" -m venv riscv-python --prompt cvw + echo -e "${OK_COLOR}Python virtual environment created!\nInstalling pip packages.${ENDC}" +else + echo -e "${OK_COLOR}Python virtual environment already exists.\nUpdating pip packages.${ENDC}" +fi + +source "$RISCV"/riscv-python/bin/activate # activate python virtual environment + +# Install python packages, including RISCOF (https://github.com/riscv-software-src/riscof.git) +# RISCOF is a RISC-V compliance test framework that is used to run the RISC-V Arch Tests. +STATUS="python packages" +pip --require-virtualenv install --upgrade pip && pip --require-virtualenv install --upgrade -r "$WALLY"/bin/requirements.txt + +echo -e "${SUCCESS_COLOR}Python environment successfully configured!${ENDC}" diff --git a/bin/installation/qemu-install.sh b/bin/installation/qemu-install.sh new file mode 100755 index 000000000..5e2248548 --- /dev/null +++ b/bin/installation/qemu-install.sh @@ -0,0 +1,60 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: QEMU installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +QEMU_VERSION=v10.0.2 # Last release as of May 30, 2025 + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# QEMU (https://www.qemu.org/docs/master/system/target-riscv.html) +# QEMU is an open source machine emulator and virtualizer capable of emulating RISC-V +section_header "Installing/Updating QEMU" +STATUS="qemu" +cd "$RISCV" +if check_tool_version $QEMU_VERSION; then + git_checkout "qemu" "https://github.com/qemu/qemu" "$QEMU_VERSION" + cd "$RISCV"/qemu + ./configure --target-list=riscv64-softmmu --prefix="$RISCV" + make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + if [ "$clean" = true ]; then + cd "$RISCV" + rm -rf qemu + fi + echo "$QEMU_VERSION" > "$RISCV"/versions/$STATUS.version # Record installed version + echo -e "${SUCCESS_COLOR}QEMU successfully installed/updated!${ENDC}" +else + echo -e "${SUCCESS_COLOR}QEMU already up to date.${ENDC}" +fi diff --git a/bin/installation/riscv-gnu-toolchain-install.sh b/bin/installation/riscv-gnu-toolchain-install.sh new file mode 100755 index 000000000..fd3d7963c --- /dev/null +++ b/bin/installation/riscv-gnu-toolchain-install.sh @@ -0,0 +1,63 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: QEMU installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +RISCV_GNU_TOOLCHAIN_VERSION=23863c2ca74e6c050f0c97e7af61f5f1776aadd1 # Last commit with GCC 14.2.0 + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# RISC-V GNU Toolchain (https://github.com/riscv-collab/riscv-gnu-toolchain) +# The RISC-V GNU Toolchain includes the GNU Compiler Collection (gcc), GNU Binutils, Newlib, +# and the GNU Debugger Project (gdb). It is a collection of tools used to compile RISC-V programs. +# To install GCC from source can take hours to compile. +# This configuration enables multilib to target many flavors of RISC-V. +# This book is tested with GCC 13.2.0 and 14.2.0. +section_header "Installing/Updating RISC-V GNU Toolchain" +STATUS="riscv-gnu-toolchain" +cd "$RISCV" +if check_tool_version $RISCV_GNU_TOOLCHAIN_VERSION; then + git_checkout "riscv-gnu-toolchain" "https://github.com/riscv/riscv-gnu-toolchain" "$RISCV_GNU_TOOLCHAIN_VERSION" + cd "$RISCV"/riscv-gnu-toolchain + ./configure --prefix="${RISCV}" --with-multilib-generator="rv32e-ilp32e--;rv32i-ilp32--;rv32im-ilp32--;rv32iac-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32d--;rv64i-lp64--;rv64ic-lp64--;rv64iac-lp64--;rv64imac-lp64--;rv64imafdc-lp64d--;rv64im-lp64--;" + make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + if [ "$clean" = true ]; then + cd "$RISCV" + rm -rf riscv-gnu-toolchain + fi + echo "$RISCV_GNU_TOOLCHAIN_VERSION" > "$RISCV"/versions/$STATUS.version # Record installed version + echo -e "${SUCCESS_COLOR}RISC-V GNU Toolchain successfully installed/updated!${ENDC}" +else + echo -e "${SUCCESS_COLOR}RISC-V GNU Toolchain already up to date.${ENDC}" +fi diff --git a/bin/installation/sail-install.sh b/bin/installation/sail-install.sh new file mode 100755 index 000000000..8b8a0d79c --- /dev/null +++ b/bin/installation/sail-install.sh @@ -0,0 +1,102 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: QEMU installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +SAIL_COMPILER_VERSION=0.19 # Last release as of May 30, 2025 +CMAKE_VERSION=3.31.5 # Only used for distros with a system CMake that is too old (< 3.20) +RISCV_SAIL_MODEL_VERSION=a214c522a2f98dc3b1f381169d0b1a27bbe0acd8 # Last commit as of May 29, 2025 + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# Sail Compiler (https://github.com/rems-project/sail) +# Sail is a formal specification language designed for describing the semantics of an ISA. +# It is used to generate the RISC-V Sail Model, which is the golden reference model for RISC-V. +# The Sail Compiler is written in OCaml, which is an object-oriented extension of ML, which in turn +# is a functional programming language suited to formal verification. +section_header "Installing/Updating Sail Compiler" +STATUS="sail_compiler" +if check_tool_version $SAIL_COMPILER_VERSION; then + cd "$RISCV" + wget -nv --retry-connrefused $retry_on_host_error --output-document=sail.tar.gz "https://github.com/rems-project/sail/releases/download/$SAIL_COMPILER_VERSION-linux-binary/sail.tar.gz" + tar xz --directory="$RISCV" --strip-components=1 -f sail.tar.gz + rm -f sail.tar.gz + echo "$SAIL_COMPILER_VERSION" > "$RISCV"/versions/$STATUS.version # Record installed version + echo -e "${SUCCESS_COLOR}Sail Compiler successfully installed/updated!${ENDC}" +else + echo -e "${SUCCESS_COLOR}Sail Compiler already installed.${ENDC}" +fi + +# Newer version of CMake needed to build sail-riscv model (at least 3.20) +if (( UBUNTU_VERSION == 20 || DEBIAN_VERSION == 11 )); then + STATUS="cmake" + if [ ! -e "$RISCV"/bin/cmake ] || [ "$("$RISCV"/bin/cmake --version | head -n1 | sed 's/cmake version //')" != "$CMAKE_VERSION" ]; then + section_header "Installing CMake" + cd "$RISCV" + wget -nv --retry-connrefused $retry_on_host_error --output-document=cmake.tar.gz "https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz" + tar xz --directory="$RISCV" --strip-components=1 -f cmake.tar.gz + rm -f cmake.tar.gz + echo -e "${SUCCESS_COLOR}CMake successfully installed/updated!${ENDC}" + else + echo -e "${SUCCESS_COLOR}CMake already installed.${ENDC}" + fi +fi + +# Newer version of gmp needed for sail-riscv model on RHEL 8 +# sail-riscv will download and build gmp if told to do so, so no need to install it manually. +if (( RHEL_VERSION == 8 )); then + DOWNLOAD_GMP=TRUE +else + DOWNLOAD_GMP=FALSE +fi + +# RISC-V Sail Model (https://github.com/riscv/sail-riscv) +# The RISC-V Sail Model is the golden reference model for RISC-V. It is written in Sail (described above) +section_header "Installing/Updating RISC-V Sail Model" +STATUS="riscv-sail-model" +if check_tool_version $RISCV_SAIL_MODEL_VERSION; then + git_checkout "sail-riscv" "https://github.com/riscv/sail-riscv.git" "$RISCV_SAIL_MODEL_VERSION" + cd "$RISCV"/sail-riscv + cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="$RISCV" -DDOWNLOAD_GMP="$DOWNLOAD_GMP" -GNinja 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + cmake --build build 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + cmake --install build 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + if [ "$clean" = true ]; then + cd "$RISCV" + rm -rf sail-riscv + fi + echo "$RISCV_SAIL_MODEL_VERSION" > "$RISCV"/versions/$STATUS.version # Record installed version + echo -e "${SUCCESS_COLOR}RISC-V Sail Model successfully installed/updated!${ENDC}" +else + echo -e "${SUCCESS_COLOR}RISC-V Sail Model already up to date.${ENDC}" +fi diff --git a/bin/installation/skywater-lib-install.sh b/bin/installation/skywater-lib-install.sh new file mode 100755 index 000000000..b738ce5ba --- /dev/null +++ b/bin/installation/skywater-lib-install.sh @@ -0,0 +1,53 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: QEMU installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +SKYWATER_LIB_VERSION=ac90ef0c622a9377a16b5218d9da3ac4169eeaaf # Last commit as of May 30, 2025 + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# OSU Skywater 130 cell library (https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_osu_sc_t12) +# The OSU Skywater 130 cell library is a standard cell library that is used to synthesize Wally. +section_header "Installing/Updating OSU Skywater 130 cell library" +STATUS="osu_skywater_130_cell_library" +mkdir -p "$RISCV"/cad/lib +cd "$RISCV"/cad/lib +if check_tool_version $SKYWATER_LIB_VERSION; then + git_checkout "sky130_osu_sc_t12" "https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_osu_sc_t12" "$SKYWATER_LIB_VERSION" + echo "$SKYWATER_LIB_VERSION" > "$RISCV"/versions/$STATUS.version + echo -e "${SUCCESS_COLOR}OSU Skywater library successfully installed!${ENDC}" +else + echo -e "${SUCCESS_COLOR}OSU Skywater library already up to date.${ENDC}" +fi diff --git a/bin/installation/spike-install.sh b/bin/installation/spike-install.sh new file mode 100755 index 000000000..0fc3a9ba9 --- /dev/null +++ b/bin/installation/spike-install.sh @@ -0,0 +1,62 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: Spike installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +SPIKE_VERSION=4c870d063dbbaeb4dc7007fe5c2a1bf8b00a767e # Last commit as of May 30, 2025 + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# Spike (https://github.com/riscv-software-src/riscv-isa-sim) +# Spike is a reference model for RISC-V. It is a functional simulator that can be used to run RISC-V programs. +section_header "Installing/Updating SPIKE" +STATUS="spike" +cd "$RISCV" +if check_tool_version $SPIKE_VERSION; then + git_checkout "riscv-isa-sim" "https://github.com/riscv-software-src/riscv-isa-sim" "$SPIKE_VERSION" + cd "$RISCV"/riscv-isa-sim + mkdir -p build + cd build + ../configure --prefix="$RISCV" + make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + if [ "$clean" = true ]; then + cd "$RISCV" + rm -rf riscv-isa-sim + fi + echo "$SPIKE_VERSION" > "$RISCV"/versions/$STATUS.version # Record installed version + echo -e "${SUCCESS_COLOR}Spike successfully installed/updated!${ENDC}" +else + echo -e "${SUCCESS_COLOR}Spike already up to date.${ENDC}" +fi diff --git a/bin/installation/verilator-install.sh b/bin/installation/verilator-install.sh new file mode 100755 index 000000000..728ee20b9 --- /dev/null +++ b/bin/installation/verilator-install.sh @@ -0,0 +1,79 @@ +#!/bin/bash +########################################### +## Tool chain install script. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: Verilator installation script +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +VERILATOR_VERSION=v5.036 # Last release as of May 30, 2025 + +set -e # break on error +# If run standalone, check environment. Otherwise, use info from main install script +if [ -z "$FAMILY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname $(dirname "$dir"))" + export WALLY + source "${dir}"/../wally-environment-check.sh +fi + +# Mold needed for Verilator, not available in all package managers. +if (( UBUNTU_VERSION == 20 || DEBIAN_VERSION == 11 )) || [ "$FAMILY" == suse ]; then + STATUS="mold" + if [ ! -e "$RISCV"/bin/mold ]; then + section_header "Installing mold" + cd "$RISCV" + wget -nv --retry-connrefused $retry_on_host_error --output-document=mold.tar.gz https://github.com/rui314/mold/releases/download/v2.34.1/mold-2.34.1-x86_64-linux.tar.gz + tar xz --directory="$RISCV" --strip-components=1 -f mold.tar.gz + rm -f mold.tar.gz + echo -e "${SUCCESS_COLOR}Mold successfully installed/updated!${ENDC}" + else + echo -e "${SUCCESS_COLOR}Mold already installed.${ENDC}" + fi +fi + +# Verilator (https://github.com/verilator/verilator) +# Verilator is a fast open-source Verilog simulator that compiles synthesizable Verilog code into C++ code. +# It is used for linting and simulation of Wally. +# Verilator needs to be built from source to get the latest version (Wally needs 5.021 or later). +section_header "Installing/Updating Verilator" +STATUS="verilator" +cd "$RISCV" +if check_tool_version $VERILATOR_VERSION; then + git_checkout "verilator" "https://github.com/verilator/verilator" "$VERILATOR_VERSION" + unset VERILATOR_ROOT + cd "$RISCV"/verilator + autoconf + ./configure --prefix="$RISCV" + make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] + if [ "$clean" = true ]; then + cd "$RISCV" + rm -rf verilator + fi + echo "$VERILATOR_VERSION" > "$RISCV"/versions/$STATUS.version # Record installed version + echo -e "${SUCCESS_COLOR}Verilator successfully installed/updated!${ENDC}" +else + echo -e "${SUCCESS_COLOR}Verilator already up to date.${ENDC}" +fi diff --git a/bin/installation/wally-installation-helper-functions.sh b/bin/installation/wally-installation-helper-functions.sh new file mode 100755 index 000000000..6b4d8c89b --- /dev/null +++ b/bin/installation/wally-installation-helper-functions.sh @@ -0,0 +1,111 @@ +#!/bin/bash +########################################### +## Installation helper functions. +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: May 30 2025 +## Modified: +## +## Purpose: Common functions for toolchain installation scripts +## +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +set -e # break on error + +## Helper functions +# Error handler +error() { + echo -e "${FAIL_COLOR}Error: $STATUS installation failed" + echo -e "Error on line ${BASH_LINENO[0]} with command $BASH_COMMAND${ENDC}" + if [ -e "$RISCV/logs/$STATUS.log" ]; then + echo -e "Please check the log in $RISCV/logs/$STATUS.log for more information." + fi + exit 1 +} + +# Check if the specificed version of a tool is installed +# $1: required version +# Tool inferred from $STATUS variable +check_tool_version() { + local required_version="$1" + local version_file="$RISCV/versions/$STATUS.version" + if [ -f "$version_file" ] && [ "$(cat "$version_file")" = "$required_version" ] + then + return 1 # Tool is up-to-date + else + return 0 # Tool needs installation or update + fi +} + +# Checkout specified version of a git repository +# $1: repo name +# $2: repo url to clone from +# $3: version to checkout (commit hash or tag) +git_checkout() { + local repo=$1 + local url=$2 + local version=$3 + + # Clone repo if it doesn't exist + if [[ ! -e $repo ]]; then + for ((i=1; i<=5; i++)); do + git clone "$url" "$repo" && break + echo -e "${WARNING_COLOR}Failed to clone $repo. Retrying.${ENDC}" + rm -rf "$repo" + sleep $i + done + if [[ ! -e $repo ]]; then + echo -e "${ERROR_COLOR}Failed to clone $repo after 5 attempts. Exiting.${ENDC}" + exit 1 + fi + fi + + # Update the repository + cd "$repo" + git fetch --all + + # Checkout the specified version + git reset --hard "$version" + git clean -f && git submodule update +} + +# Log output to a file and only print lines with keywords +logger() { + local log_file="$RISCV/logs/$STATUS.log" + local keyword_pattern="(\bwarning|\berror|\bfail|\bsuccess|\bstamp|\bdoesn't work)" + local exclude_pattern="(_warning|warning_|_error|error_|-warning|warning-|-error|error-|Werror|error\.o|warning flags)" + + cat < /dev/stdin | tee -a "$log_file" | \ + (grep -iE --color=never "$keyword_pattern" || true) | \ + (grep -viE --color=never "$exclude_pattern" || true) +} + +# Print section header +section_header() { + if tput cols > /dev/null 2>&1; then + printf "${SECTION_COLOR}%$(tput cols)s\n" | tr ' ' '#' + printf "%$(tput cols)s\n" | tr ' ' '#' + printf "%s\n" "$1" + printf "%$(tput cols)s\n" | tr ' ' '#' + printf "%$(tput cols)s${ENDC}\n" | tr ' ' '#' + else + printf "${SECTION_COLOR}%s\n${ENDC}" "$1" + fi +} diff --git a/bin/libppa.pl b/bin/libppa.pl index eddfc3686..06b04b318 100755 --- a/bin/libppa.pl +++ b/bin/libppa.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env -S perl -w +#!/usr/bin/env perl ########################################### ## libppa.pl diff --git a/bin/requirements.txt b/bin/requirements.txt index f0bb082fd..f5440ec93 100644 --- a/bin/requirements.txt +++ b/bin/requirements.txt @@ -4,9 +4,9 @@ Markdown>=3.6 matplotlib>=3.9.0 pre-commit>=4.0.0 PyYAML>=5.2 -riscof @ git+https://github.com/riscv/riscof.git -riscv-config @ git+https://github.com/riscv-software-src/riscv-config -riscv-isac @ git+https://github.com/riscv-non-isa/riscv-arch-test/#subdirectory=riscv-isac +riscof @ git+https://github.com/riscv/riscof.git@${RISCOF_VERSION} # version set in python-setup.sh +riscv-config @ git+https://github.com/riscv-software-src/riscv-config.git@${RISCV_CONFIG_VERSION} # version set in python-setup.sh +riscv-isac @ git+https://github.com/riscv-non-isa/riscv-arch-test.git@${RISCV_ISAC_VERSION}#subdirectory=riscv-isac # version set in python-setup.sh scikit-learn>=1.5.0 scipy>=1.13.0 setuptools diff --git a/bin/testlist.pl b/bin/testlist.pl index 50b77eb78..0649f6261 100755 --- a/bin/testlist.pl +++ b/bin/testlist.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env -S perl -w +#!/usr/bin/env perl ########################################### ## testlist.pl diff --git a/bin/vclean.pl b/bin/vclean.pl index 94a14c54c..e1b36abbd 100755 --- a/bin/vclean.pl +++ b/bin/vclean.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env -S perl -w +#!/usr/bin/env perl ########################################### ## vclean.pl diff --git a/bin/wally-distro-check.sh b/bin/wally-environment-check.sh similarity index 60% rename from bin/wally-distro-check.sh rename to bin/wally-environment-check.sh index 0ea7fdaf3..a36f788aa 100755 --- a/bin/wally-distro-check.sh +++ b/bin/wally-environment-check.sh @@ -1,10 +1,10 @@ #!/bin/bash ########################################### -## Get Linux distro information +## Get Linux distro information and check environment ## ## Written: Jordan Carlin, jcarlin@hmc.edu ## Created: 30 June 2024 -## Modified: +## Modified: May 30 2025 ## ## Purpose: Check for compatible Linux distribution and set variables accordingly ## @@ -29,31 +29,31 @@ set -e # break on error -# Colors +### Colors ### BOLD='\033[1m' UNDERLINE='\033[4m' SECTION_COLOR='\033[95m'$BOLD OK_COLOR='\033[94m' +SUCCESS_COLOR='\033[92m' WARNING_COLOR='\033[93m' FAIL_COLOR='\033[91m' ENDC='\033[0m' # Reset to default color -# Print section header -section_header() { - if tput cols > /dev/null 2>&1; then - printf "${SECTION_COLOR}%$(tput cols)s\n" | tr ' ' '#' - printf "%$(tput cols)s\n" | tr ' ' '#' - printf "%s\n" "$1" - printf "%$(tput cols)s\n" | tr ' ' '#' - printf "%$(tput cols)s${ENDC}\n" | tr ' ' '#' - else - printf "${SECTION_COLOR}%s\n${ENDC}" "$1" - fi -} +if [ -z "$WALLY" ]; then + dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + WALLY="$(dirname "$dir")" + export WALLY +fi + +### Common functions and error handling ### +source "$WALLY"/bin/installation/wally-installation-helper-functions.sh +trap error ERR # run error handler on error +STATUS="setup" # keep track of what part of the installation is running for error messages + section_header "Checking System Requirements and Configuring Installation" -# Get distribution information +### Get distribution information ### if [ -f /etc/os-release ]; then source /etc/os-release else @@ -131,6 +131,85 @@ else exit 1 fi -printf "${OK_COLOR}${UNDERLINE}%s\n${ENDC}" "Detected information" +# wget retry on host error flag not available with older wget on RHEL 8 +if (( RHEL_VERSION != 8 )); then + retry_on_host_error="--retry-on-host-error" +fi + + +### Configure installation ### +# Check flags +clean=false +no_buildroot=false +packages_only=false +while [[ "$#" -gt 0 ]]; do + case $1 in + -c|--clean) clean=true ;; + --no-buildroot) no_buildroot=true ;; + --packages-only) packages_only=true;; + -h|--help) + echo -e "Usage: $0 [\$RISCV] [options]" + echo -e "${BOLD}Options:${ENDC}" + echo -e " -c, --clean Remove build directories after installation" + echo -e " --no-buildroot Skip installing Buildroot and Linux testvectors" + echo -e " \$RISCV Directory to install RISC-V tools (default: /opt/riscv as root, $HOME/riscv otherwise)" + exit 0 ;; + *) RISCV="$1" ;; + esac + shift +done + +# Check if root +ROOT=$( [ "${EUID:=$(id -u)}" == 0 ] && echo true || echo false); + +### Print system information ### +echo -e "${OK_COLOR}${UNDERLINE}Detected information${ENDC}" echo "Distribution: $PRETTY_NAME" echo "Version: $VERSION" +echo "Running as root: $ROOT" + +if [ $packages_only != true ]; then + # Set installation directory based on execution privileges + # If the script is run as root, the default installation path is /opt/riscv + # If the script is run as a user, the default installation path is ~/riscv + # The installation path can be overridden with a positional argument passed to the script. + if [ "$ROOT" == true ]; then + export RISCV="${RISCV:-/opt/riscv}" + else + export RISCV="${RISCV:-$HOME/riscv}" + fi + + # Set environment variables + export PATH=$RISCV/bin:$PATH:/usr/bin + export PKG_CONFIG_PATH=$RISCV/lib64/pkgconfig:$RISCV/lib/pkgconfig:$RISCV/share/pkgconfig:$RISCV/lib/x86_64-linux-gnu/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} + + # Check for incompatible PATH environment variable before proceeding with installation + if [[ ":$PATH:" == *::* || ":$PATH:" == *:.:* ]]; then + echo -e "${FAIL_COLOR}Error: You seem to have the current working directory in your \$PATH environment variable." + echo -e "This won't work. Please update your \$PATH and try again.${ENDC}" + exit 1 + fi + + # Increasing NUM_THREADS will speed up parallel compilation of the tools + NUM_THREADS=$(nproc --ignore 1) # One less than the total number of threads + + # Check available memory + total_mem=$(grep MemTotal < /proc/meminfo | awk '{print $2}') + total_mem_gb=$((total_mem / 1024 / 1024)) + + # Reduce number of threads for systems with less than 8 GB of memory + if ((total_mem < 8400000 )) ; then + NUM_THREADS=1 + echo -e "${WARNING_COLOR}Detected less than or equal to 8 GB of memory. Using a single thread for compiling tools. This may take a while.${ENDC}" + fi + + # Create installation directory + mkdir -p "$RISCV"/logs + mkdir -p "$RISCV"/versions + + # Print more system information + echo "Installation path: $RISCV" + echo "Number of cores: $(nproc)" + echo "Total memory: $total_mem_gb GB" + echo "Using $NUM_THREADS thread(s) for compilation" +fi diff --git a/bin/wally-package-install.sh b/bin/wally-package-install.sh index 7c7285b1c..25e7ac3cf 100755 --- a/bin/wally-package-install.sh +++ b/bin/wally-package-install.sh @@ -4,7 +4,7 @@ ## ## Written: Jordan Carlin, jcarlin@hmc.edu ## Created: 30 June 2024 -## Modified: +## Modified: May 30 2025 ## ## Purpose: Package manager installation for open source tool chain installation script ## @@ -29,26 +29,24 @@ set -e # break on error -# Colors -BOLD='\033[1m' -SECTION_COLOR='\033[95m'$BOLD -SUCCESS_COLOR='\033[92m' -FAIL_COLOR='\033[91m' -ENDC='\033[0m' # Reset to default color +STATUS="system_packages" -# If run standalone, determine distro information. Otherwise, use info from main install script +# If run standalone, check environment. Otherwise, use info from main install script if [ -z "$FAMILY" ]; then dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dir}"/wally-distro-check.sh + WALLY="$(dirname "$dir")" + export WALLY + source "${dir}"/wally-environment-check.sh "--packages-only" fi -# Packages are grouped by which tool requires them. If multiple tools need a package, it is included in the first tool only +# Packages are grouped by which tool requires them. If multiple tools need a package, it is included in each tool's list. # Packages that are constant across distros -GENERAL_PACKAGES+=(rsync git make cmake curl wget tar unzip bzip2 dialog mutt) -GNU_PACKAGES+=(autoconf automake gawk bison flex texinfo gperf libtool patchutils bc gcc) -VERILATOR_PACKAGES+=(help2man perl clang ccache numactl) -BUILDROOT_PACKAGES+=(cpio) +GENERAL_PACKAGES+=(rsync git curl wget tar unzip gzip bzip2 gcc make dialog mutt) # TODO: check what needs dialog +GNU_PACKAGES+=(autoconf automake gawk bison flex texinfo gperf libtool patchutils bc) +SAIL_PACKAGES+=(cmake) +VERILATOR_PACKAGES+=(autoconf flex bison help2man perl ccache numactl) +BUILDROOT_PACKAGES+=(patchutils perl cpio bc) # Distro specific packages and package manager case "$FAMILY" in @@ -57,17 +55,18 @@ case "$FAMILY" in PACKAGE_MANAGER="dnf -y" UPDATE_COMMAND="$PACKAGE_MANAGER update" GENERAL_PACKAGES+=(which "$PYTHON_VERSION" "$PYTHON_VERSION"-pip pkgconf-pkg-config gcc-c++ ssmtp) - GNU_PACKAGES+=(libmpc-devel mpfr-devel gmp-devel zlib-devel expat-devel libslirp-devel ninja-build) - QEMU_PACKAGES+=(glib2-devel libfdt-devel pixman-devel) - SPIKE_PACKAGES+=(dtc boost-regex boost-system) - VERILATOR_PACKAGES+=(gperftools mold) + GNU_PACKAGES+=(libmpc-devel mpfr-devel gmp-devel zlib-devel expat-devel glib2-devel libslirp-devel) + QEMU_PACKAGES+=(glib2-devel libfdt-devel pixman-devel zlib-devel ninja-build) + SPIKE_PACKAGES+=(dtc) # compiling Spike with boost fails on RHEL + SAIL_PACKAGES+=(ninja-build gmp-devel) + VERILATOR_PACKAGES+=(zlib-devel gperftools-devel mold) BUILDROOT_PACKAGES+=(ncurses ncurses-base ncurses-libs ncurses-devel gcc-gfortran) # gcc-gfortran is only needed for compiling spec benchmarks on buildroot linux # Extra packages not available in rhel8, nice for Verilator if (( RHEL_VERSION >= 9 )); then VERILATOR_PACKAGES+=(perl-doc) fi # A newer version of gcc is required for qemu - OTHER_PACKAGES+=(gcc-toolset-13) + GENERAL_PACKAGES+=(gcc-toolset-13) ;; ubuntu | debian) if (( UBUNTU_VERSION >= 24 )); then @@ -76,7 +75,7 @@ case "$FAMILY" in PYTHON_VERSION=python3.11 elif (( UBUNTU_VERSION >= 20 )); then PYTHON_VERSION=python3.9 - OTHER_PACKAGES+=(gcc-10 g++-10 cpp-10) # Newer version of gcc needed for Verilator + GENERAL_PACKAGES+=(gcc-10 g++-10 cpp-10) # Newer version of gcc needed for Verilator elif (( DEBIAN_VERSION >= 12 )); then PYTHON_VERSION=python3.11 elif (( DEBIAN_VERSION >= 11 )); then @@ -88,26 +87,28 @@ case "$FAMILY" in fi PACKAGE_MANAGER="DEBIAN_FRONTEND=noninteractive apt-get -y" UPDATE_COMMAND="$PACKAGE_MANAGER update && $PACKAGE_MANAGER upgrade --with-new-pkgs" - GENERAL_PACKAGES+=("$PYTHON_VERSION" python3-pip "$PYTHON_VERSION"-venv pkg-config g++ ssmtp) - GNU_PACKAGES+=(autotools-dev libmpc-dev libmpfr-dev libgmp-dev build-essential ninja-build zlib1g-dev libexpat1-dev libglib2.0-dev libslirp-dev) - QEMU_PACKAGES+=(libfdt-dev libpixman-1-dev) + GENERAL_PACKAGES+=("$PYTHON_VERSION" python3-pip "$PYTHON_VERSION"-venv pkg-config build-essential g++ ssmtp) + GNU_PACKAGES+=(autotools-dev libmpc-dev libmpfr-dev libgmp-dev zlib1g-dev libexpat1-dev libglib2.0-dev libslirp-dev) + QEMU_PACKAGES+=(libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build) SPIKE_PACKAGES+=(device-tree-compiler libboost-regex-dev libboost-system-dev) - VERILATOR_PACKAGES+=(libunwind-dev libgoogle-perftools-dev perl-doc libfl2 libfl-dev zlib1g) + SAIL_PACKAGES+=(ninja-build libgmp-dev) + VERILATOR_PACKAGES+=(libfl2 libfl-dev zlib1g-dev libunwind-dev libgoogle-perftools-dev perl-doc) BUILDROOT_PACKAGES+=(ncurses-base ncurses-bin libncurses-dev gfortran) # gfortran is only needed for compiling spec benchmarks on buildroot linux VIVADO_PACKAGES+=(libncurses*) # Vivado hangs on the third stage of installation without this ;; - suse) + suse) PYTHON_VERSION=python3.12 PYTHON_VERSION_PACKAGE=python312 PACKAGE_MANAGER="zypper -n" UPDATE_COMMAND="$PACKAGE_MANAGER update" GENERAL_PACKAGES+=("$PYTHON_VERSION_PACKAGE" "$PYTHON_VERSION_PACKAGE"-pip pkg-config) - GNU_PACKAGES+=(mpc-devel mpfr-devel gmp-devel zlib-devel libexpat-devel libslirp-devel ninja) - QEMU_PACKAGES+=(glib2-devel libpixman-1-0-devel) # maybe also need qemu itself? + GNU_PACKAGES+=(mpc-devel mpfr-devel gmp-devel zlib-devel libexpat-devel glib2-devel libslirp-devel) + QEMU_PACKAGES+=(glib2-devel libfdt-devel libpixman-1-0-devel zlib-devel ninja) SPIKE_PACKAGES+=(dtc libboost_regex1_75_0-devel libboost_system1_75_0-devel) - VERILATOR_PACKAGES+=(gperftools perl-doc) + SAIL_PACKAGES+=(ninja gmp-devel) + VERILATOR_PACKAGES+=(libfl2 libfl-devel zlib-devel gperftools-devel perl-doc) BUILDROOT_PACKAGES+=(ncurses-utils ncurses-devel ncurses5-devel gcc-fortran) # gcc-fortran is only needed for compiling spec benchmarks on buildroot linux - OTHER_PACKAGES+=(gcc13 gcc13-c++ cpp13) # Newer version of gcc needed for many tools. Default is gcc7 + GENERAL_PACKAGES+=(gcc13 gcc13-c++ cpp13) # Newer version of gcc needed for many tools. Default is gcc7 ;; esac @@ -116,18 +117,18 @@ esac if [ "${1}" == "--check" ]; then section_header "Checking Dependencies from Package Manager" if [[ "$FAMILY" == rhel || "$FAMILY" == suse ]]; then - for pack in "${GENERAL_PACKAGES[@]}" "${GNU_PACKAGES[@]}" "${QEMU_PACKAGES[@]}" "${SPIKE_PACKAGES[@]}" "${VERILATOR_PACKAGES[@]}" "${BUILDROOT_PACKAGES[@]}" "${OTHER_PACKAGES[@]}"; do + for pack in "${GENERAL_PACKAGES[@]}" "${GNU_PACKAGES[@]}" "${QEMU_PACKAGES[@]}" "${SPIKE_PACKAGES[@]}" "${SAIL_PACKAGES[@]}" "${VERILATOR_PACKAGES[@]}" "${BUILDROOT_PACKAGES[@]}"; do rpm -q "$pack" > /dev/null || (echo -e "${FAIL_COLOR}Missing packages detected (${WARNING_COLOR}$pack${FAIL_COLOR}). Run as root to auto-install or run wally-package-install.sh first.${ENDC}" && exit 1) done elif [[ "$FAMILY" == ubuntu || "$FAMILY" == debian ]]; then - for pack in "${GENERAL_PACKAGES[@]}" "${GNU_PACKAGES[@]}" "${QEMU_PACKAGES[@]}" "${SPIKE_PACKAGES[@]}" "${VERILATOR_PACKAGES[@]}" "${BUILDROOT_PACKAGES[@]}" "${OTHER_PACKAGES[@]}"; do + for pack in "${GENERAL_PACKAGES[@]}" "${GNU_PACKAGES[@]}" "${QEMU_PACKAGES[@]}" "${SPIKE_PACKAGES[@]}" "${SAIL_PACKAGES[@]}" "${VERILATOR_PACKAGES[@]}" "${BUILDROOT_PACKAGES[@]}"; do dpkg -l "$pack" | grep "ii" > /dev/null || (echo -e "${FAIL_COLOR}Missing packages detected (${WARNING_COLOR}$pack${FAIL_COLOR}). Run as root to auto-install or run wally-package-install.sh first." && exit 1) done fi echo -e "${OK_COLOR}All required packages detected.${ENDC}" else # Check if root, otherwise exit with error message - [ "${EUID:=$(id -u)}" -ne 0 ] && echo -e "\n${FAIL_COLOR}Must be run as root${ENDC}" && exit 1 + [ "$ROOT" == false ] && echo -e "\n${FAIL_COLOR}Must be run as root${ENDC}" && exit 1 section_header "Installing/Updating Dependencies from Package Manager" # Enable extra repos necessary for rhel @@ -150,7 +151,7 @@ else # Update and Upgrade tools eval "$UPDATE_COMMAND" # Install packages listed above using appropriate package manager - eval $PACKAGE_MANAGER install "${GENERAL_PACKAGES[@]}" "${GNU_PACKAGES[@]}" "${QEMU_PACKAGES[@]}" "${SPIKE_PACKAGES[@]}" "${VERILATOR_PACKAGES[@]}" "${BUILDROOT_PACKAGES[@]}" "${OTHER_PACKAGES[@]}" "${VIVADO_PACKAGES[@]}" + eval $PACKAGE_MANAGER install "${GENERAL_PACKAGES[@]}" "${GNU_PACKAGES[@]}" "${QEMU_PACKAGES[@]}" "${SPIKE_PACKAGES[@]}" "${SAIL_PACKAGES[@]}" "${VERILATOR_PACKAGES[@]}" "${BUILDROOT_PACKAGES[@]}" "${VIVADO_PACKAGES[@]}" # Post install steps # Vivado looks for ncurses5 libraries, but Ubuntu 24.04 only has ncurses6 diff --git a/bin/wally-tool-chain-install.sh b/bin/wally-tool-chain-install.sh index 4b7c47d36..fee173f92 100755 --- a/bin/wally-tool-chain-install.sh +++ b/bin/wally-tool-chain-install.sh @@ -3,11 +3,8 @@ ## Tool chain install script. ## ## Written: Rose Thompson rose@rosethompson.net -## Created: 18 January 2023 -## Modified: 22 January 2023 -## Modified: 23 March 2023 ## Modified: 30 June 2024, Jordan Carlin jcarlin@hmc.edu -## Modified: 1 September 2024 +## Modified: 30 May 2025 ## ## Purpose: Open source tool chain installation script ## @@ -30,99 +27,9 @@ ## and limitations under the License. ################################################################################################ -# Increasing NUM_THREADS will speed up parallel compilation of the tools -NUM_THREADS=$(nproc --ignore 1) # One less than the total number of threads - -# Colors -BOLD='\033[1m' -UNDERLINE='\033[4m' -SECTION_COLOR='\033[95m'$BOLD -OK_COLOR='\033[94m' -SUCCESS_COLOR='\033[92m' -WARNING_COLOR='\033[93m' -FAIL_COLOR='\033[91m' -ENDC='\033[0m' # Reset to default color - -## Helper functions -# Error handler -error() { - echo -e "${FAIL_COLOR}Error: $STATUS installation failed" - echo -e "Error on line ${BASH_LINENO[0]} with command $BASH_COMMAND${ENDC}" - if [ -e "$RISCV/logs/$STATUS.log" ]; then - echo -e "Please check the log in $RISCV/logs/$STATUS.log for more information." - fi - exit 1 -} - -# Check if a git repository exists, is up to date, and has been installed -# clones the repository if it doesn't exist -# $1: repo name -# $2: repo url to clone from -# $3: file to check if already installed -# $4: upstream branch, optional, default is master -git_check() { - local repo=$1 - local url=$2 - local check=$3 - local branch="${4:-master}" - - # Clone repo if it doesn't exist - if [[ ! -e $repo ]]; then - for ((i=1; i<=5; i++)); do - git clone "$url" && break - echo -e "${WARNING_COLOR}Failed to clone $repo. Retrying.${ENDC}" - rm -rf "$repo" - sleep $i - done - if [[ ! -e $repo ]]; then - echo -e "${ERROR_COLOR}Failed to clone $repo after 5 attempts. Exiting.${ENDC}" - exit 1 - fi - fi - - # Get the current HEAD commit hash and the remote branch commit hash - cd "$repo" - git fetch - local local_head=$(git rev-parse HEAD) - local remote_head=$(git rev-parse origin/"$branch") - - # Check if the git repository is not up to date or the specified file does not exist - if [[ "$local_head" != "$remote_head" ]]; then - echo "$repo is not up to date. Updating now." - true - elif [[ ! -e $check ]]; then - true - else - false - fi -} - -# Log output to a file and only print lines with keywords -logger() { - local log_file="$RISCV/logs/$STATUS.log" - local keyword_pattern="(\bwarning|\berror|\bfail|\bsuccess|\bstamp|\bdoesn't work)" - local exclude_pattern="(_warning|warning_|_error|error_|-warning|warning-|-error|error-|Werror|error\.o|warning flags)" - - cat < /dev/stdin | tee -a "$log_file" | \ - (grep -iE --color=never "$keyword_pattern" || true) | \ - (grep -viE --color=never "$exclude_pattern" || true) -} +# NOTE: All scripts are sourced instead of executed so that environment variables and functions are shared properly. set -e # break on error -trap error ERR # run error handler on error -STATUS="setup" # keep track of what part of the installation is running for error messages - -# Check for clean flag -if [ "$1" == "--clean" ] || [ "$2" == "--clean" ]; then - clean=true - shift -fi - -# Check for no-buildroot flag -if [ "$1" == "--no-buildroot" ] || [ "$2" == "--no-buildroot" ]; then - no_buidroot=true - shift -fi # Determine script directory to locate related scripts dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -130,382 +37,86 @@ WALLY=$(dirname "$dir") export WALLY # Get Linux distro and version -source "${dir}"/wally-distro-check.sh - -# Check if root -ROOT=$( [ "${EUID:=$(id -u)}" == 0 ] && echo true || echo false); - -# Set installation directory based on execution privileges -# If the script is run as root, the default installation path is /opt/riscv -# If the script is run as a user, the default installation path is ~/riscv -# The installation path can be overridden with an argument passed to the script. -if [ "$ROOT" == true ]; then - export RISCV="${1:-/opt/riscv}" -else - export RISCV="${1:-$HOME/riscv}" -fi - -# Set environment variables -export PATH=$PATH:$RISCV/bin:/usr/bin -export PKG_CONFIG_PATH=$RISCV/lib64/pkgconfig:$RISCV/lib/pkgconfig:$RISCV/share/pkgconfig:$RISCV/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH - -# wget retry on host error flag not available with older wget on RHEL 8 -if (( RHEL_VERSION != 8 )); then - retry_on_host_error="--retry-on-host-error" -fi - -# Check for incompatible PATH environment variable before proceeding with installation -if [[ ":$PATH:" == *::* || ":$PATH:" == *:.:* ]]; then - echo -e "${FAIL_COLOR}Error: You seem to have the current working directory in your \$PATH environment variable." - echo -e "This won't work. Please update your \$PATH and try again.${ENDC}" - exit 1 -fi - -# Check available memory -total_mem=$(grep MemTotal < /proc/meminfo | awk '{print $2}') -total_mem_gb=$((total_mem / 1024 / 1024)) - -# Print system information -echo "Running as root: $ROOT" -echo "Installation path: $RISCV" -echo "Number of cores: $(nproc)" -echo "Total memory: $total_mem_gb GB" - -# Reduce number of threads for systems with less than 8 GB of memory -if ((total_mem < 8400000 )) ; then - NUM_THREADS=1 - echo -e "${WARNING_COLOR}Detected less than or equal to 8 GB of memory. Using a single thread for compiling tools. This may take a while.${ENDC}" -fi - -# Print number of threads -echo "Using $NUM_THREADS thread(s) for compilation" - -# Create installation directory -mkdir -p "$RISCV"/logs +source "${dir}"/wally-environment-check.sh # Install/update system packages if root. Otherwise, check that packages are already installed. -STATUS="system_packages" if [ "$ROOT" == true ]; then source "${dir}"/wally-package-install.sh else source "${dir}"/wally-package-install.sh --check fi -# Older version of git defaults to protocol version incompatible with riscv-gnu-toolchain -if (( UBUNTU_VERSION == 20 )); then - git config --global protocol.version 2 -fi - -# Enable newer version of gcc for older distros (required for QEMU/Verilator) -if [ "$FAMILY" == rhel ]; then - source /opt/rh/gcc-toolset-13/enable -elif [ "$FAMILY" == suse ]; then - mkdir -p "$RISCV"/gcc-13/bin - for f in gcc cpp g++ gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool lto-dump; do - ln -vsf /usr/bin/$f-13 "$RISCV"/gcc-13/bin/$f - done - export PATH="$RISCV"/gcc-13/bin:$PATH -elif (( UBUNTU_VERSION == 20 )); then - mkdir -p "$RISCV"/gcc-10/bin - for f in gcc cpp g++ gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool lto-dump; do - ln -vsf /usr/bin/$f-10 "$RISCV"/gcc-10/bin/$f - done - export PATH="$RISCV"/gcc-10/bin:$PATH -fi - # Create python virtual environment so the python command targets desired version of python -# and installed packages are isolated from the rest of the system. -section_header "Setting up Python Environment" -STATUS="python_virtual_environment" -cd "$RISCV" -if [ ! -e "$RISCV"/riscv-python/bin/activate ]; then - "$PYTHON_VERSION" -m venv riscv-python --prompt cvw - echo -e "${OK_COLOR}Python virtual environment created!\nInstalling pip packages.${ENDC}" -else - echo -e "${OK_COLOR}Python virtual environment already exists.\nUpdating pip packages.${ENDC}" -fi - -source "$RISCV"/riscv-python/bin/activate # activate python virtual environment - -# Install python packages, including RISCOF (https://github.com/riscv-software-src/riscof.git) +# and installed packages are isolated from the rest of the system. Also installs python packages, +# including RISCOF (https://github.com/riscv-software-src/riscof.git) # RISCOF is a RISC-V compliance test framework that is used to run the RISC-V Arch Tests. -STATUS="python packages" -pip install --upgrade pip && pip install --upgrade -r "$dir"/requirements.txt +source "$WALLY"/bin/installation/python-setup.sh -source "$RISCV"/riscv-python/bin/activate # reload python virtual environment -echo -e "${SUCCESS_COLOR}Python environment successfully configured!${ENDC}" -# Extra dependencies needed for older distros that don't have new enough versions available from package manager +# Activate tools (python virtual environment and possibly newer version of gcc) +source "${WALLY}"/bin/installation/activate-tools.sh + + +# Newer version of glib required for QEMU. +# Anything newer than this won't build on red hat 8 +# Used for all installed tools becuase mixing glib versions can cause issues. if (( RHEL_VERSION == 8 )) || (( UBUNTU_VERSION == 20 )); then - # Newer version of glib required for QEMU. - # Anything newer than this won't build on red hat 8 - STATUS="glib" - if [ ! -e "$RISCV"/include/glib-2.0 ]; then - section_header "Installing glib" - pip install -U meson # Meson is needed to build glib - cd "$RISCV" - wget -nv --retry-connrefused $retry_on_host_error https://download.gnome.org/sources/glib/2.70/glib-2.70.5.tar.xz - tar -xJf glib-2.70.5.tar.xz - rm -f glib-2.70.5.tar.xz - cd glib-2.70.5 - meson setup _build --prefix="$RISCV" - meson compile -C _build -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - meson install -C _build 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - cd "$RISCV" - rm -rf glib-2.70.5 - echo -e "${SUCCESS_COLOR}glib successfully installed!${ENDC}" - fi + source "$WALLY"/bin/installation/glib-installation.sh fi -# Newer version of gmp needed for sail-riscv model -if (( RHEL_VERSION == 8 )); then - STATUS="gmp" - if [ ! -e "$RISCV"/include/gmp.h ]; then - section_header "Installing gmp" - cd "$RISCV" - wget -nv --retry-connrefused $retry_on_host_error https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz - tar -xJf gmp-6.3.0.tar.xz - rm -f gmp-6.3.0.tar.xz - cd gmp-6.3.0 - ./configure --prefix="$RISCV" - make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - cd "$RISCV" - rm -rf gmp-6.3.0 - echo -e "${SUCCESS_COLOR}gmp successfully installed!${ENDC}" - fi -fi - -# Mold needed for Verilator -if (( UBUNTU_VERSION == 20 || DEBIAN_VERSION == 11 )) || [ "$FAMILY" == suse ]; then - STATUS="mold" - if [ ! -e "$RISCV"/bin/mold ]; then - section_header "Installing mold" - cd "$RISCV" - wget -nv --retry-connrefused $retry_on_host_error --output-document=mold.tar.gz https://github.com/rui314/mold/releases/download/v2.34.1/mold-2.34.1-x86_64-linux.tar.gz - tar xz --directory="$RISCV" --strip-components=1 -f mold.tar.gz - rm -f mold.tar.gz - echo -e "${SUCCESS_COLOR}Mold successfully installed/updated!${ENDC}" - else - echo -e "${SUCCESS_COLOR}Mold already installed.${ENDC}" - fi -fi - -# Newer version of CMake needed to build sail-riscv model (at least 3.20) -if (( UBUNTU_VERSION == 20 || DEBIAN_VERSION == 11 )); then - STATUS="cmake" - if [ ! -e "$RISCV"/bin/cmake ]; then - section_header "Installing cmake" - cd "$RISCV" - wget -nv --retry-connrefused $retry_on_host_error --output-document=cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.31.5/cmake-3.31.5-linux-x86_64.tar.gz - tar xz --directory="$RISCV" --strip-components=1 -f cmake.tar.gz - rm -f cmake.tar.gz - echo -e "${SUCCESS_COLOR}CMake successfully installed/updated!${ENDC}" - else - echo -e "${SUCCESS_COLOR}CMake already installed.${ENDC}" - fi -fi # RISC-V GNU Toolchain (https://github.com/riscv-collab/riscv-gnu-toolchain) # The RISC-V GNU Toolchain includes the GNU Compiler Collection (gcc), GNU Binutils, Newlib, # and the GNU Debugger Project (gdb). It is a collection of tools used to compile RISC-V programs. # To install GCC from source can take hours to compile. -# This configuration enables multilib to target many flavors of RISC-V. -# This book is tested with GCC 13.2.0 and 14.2.0. -section_header "Installing/Updating RISC-V GNU Toolchain" -STATUS="riscv-gnu-toolchain" -cd "$RISCV" -if git_check "riscv-gnu-toolchain" "https://github.com/riscv/riscv-gnu-toolchain" "$RISCV/riscv-gnu-toolchain/stamps/build-gcc-newlib-stage2"; then - cd "$RISCV"/riscv-gnu-toolchain - git reset --hard && git clean -f && git checkout master && git pull && git submodule update - ./configure --prefix="${RISCV}" --with-multilib-generator="rv32e-ilp32e--;rv32i-ilp32--;rv32im-ilp32--;rv32iac-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32d--;rv64i-lp64--;rv64ic-lp64--;rv64iac-lp64--;rv64imac-lp64--;rv64imafdc-lp64d--;rv64im-lp64--;" - make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - if [ "$clean" ]; then - cd "$RISCV" - rm -rf riscv-gnu-toolchain - fi - echo -e "${SUCCESS_COLOR}RISC-V GNU Toolchain successfully installed/updated!${ENDC}" -else - echo -e "${SUCCESS_COLOR}RISC-V GNU Toolchain already up to date.${ENDC}" -fi +source "$WALLY"/bin/installation/riscv-gnu-toolchain-install.sh # elf2hex (https://github.com/sifive/elf2hex) # The elf2hex utility to converts executable files into hexadecimal files for Verilog simulation. # Note: The exe2hex utility that comes with Spike doesn’t work for our purposes because it doesn’t -# handle programs that start at 0x80000000. The SiFive version above is touchy to install. -# For example, if Python version 2.x is in your path, it won’t install correctly. -# Also, be sure riscv64-unknown-elf-objcopy shows up in your path in $RISCV/riscv-gnu-toolchain/bin -# at the time of compilation, or elf2hex won’t work properly. -section_header "Installing/Updating elf2hex" -STATUS="elf2hex" -cd "$RISCV" -export PATH=$RISCV/bin:$PATH -if git_check "elf2hex" "https://github.com/sifive/elf2hex.git" "$RISCV/bin/riscv64-unknown-elf-elf2bin"; then - cd "$RISCV"/elf2hex - git reset --hard && git clean -f && git checkout master && git pull - autoreconf -i - ./configure --target=riscv64-unknown-elf --prefix="$RISCV" - make 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - if [ "$clean" ]; then - cd "$RISCV" - rm -rf elf2hex - fi - echo -e "${SUCCESS_COLOR}elf2hex successfully installed/updated!${ENDC}" -else - echo -e "${SUCCESS_COLOR}elf2hex already up to date.${ENDC}" -fi +# handle programs that start at 0x80000000. +source "$WALLY"/bin/installation/elf2hex-install.sh # QEMU (https://www.qemu.org/docs/master/system/target-riscv.html) # QEMU is an open source machine emulator and virtualizer capable of emulating RISC-V -section_header "Installing/Updating QEMU" -STATUS="qemu" -cd "$RISCV" -if git_check "qemu" "https://github.com/qemu/qemu" "$RISCV/include/qemu-plugin.h"; then - cd "$RISCV"/qemu - git reset --hard && git clean -f && git checkout master && git pull - ./configure --target-list=riscv64-softmmu --prefix="$RISCV" - make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - if [ "$clean" ]; then - cd "$RISCV" - rm -rf qemu - fi - echo -e "${SUCCESS_COLOR}QEMU successfully installed/updated!${ENDC}" -else - echo -e "${SUCCESS_COLOR}QEMU already up to date.${ENDC}" -fi +source "$WALLY"/bin/installation/qemu-install.sh # Spike (https://github.com/riscv-software-src/riscv-isa-sim) # Spike is a reference model for RISC-V. It is a functional simulator that can be used to run RISC-V programs. -section_header "Installing/Updating SPIKE" -STATUS="spike" -cd "$RISCV" -if git_check "riscv-isa-sim" "https://github.com/riscv-software-src/riscv-isa-sim" "$RISCV/lib/pkgconfig/riscv-riscv.pc"; then - cd "$RISCV"/riscv-isa-sim - git reset --hard && git clean -f && git checkout master && git pull - mkdir -p build - cd build - ../configure --prefix="$RISCV" - make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - if [ "$clean" ]; then - cd "$RISCV" - rm -rf riscv-isa-sim - fi - echo -e "${SUCCESS_COLOR}Spike successfully installed/updated!${ENDC}" -else - echo -e "${SUCCESS_COLOR}Spike already up to date.${ENDC}" -fi +source "$WALLY"/bin/installation/spike-install.sh + + +# RISC-V Sail Model (https://github.com/riscv/sail-riscv) +# The RISC-V Sail Model is the golden reference model for RISC-V. It is written in Sail. +# Sail is a formal specification language designed for describing the semantics of an ISA. +# It is used to generate the RISC-V Sail Model, which is the golden reference model for RISC-V. +# The Sail Compiler is written in OCaml, which is an object-oriented extension of ML, which in turn +# is a functional programming language suited to formal verification. +source "$WALLY"/bin/installation/sail-install.sh # Verilator (https://github.com/verilator/verilator) # Verilator is a fast open-source Verilog simulator that compiles synthesizable Verilog code into C++ code. # It is used for linting and simulation of Wally. -# Verilator needs to be built from source to get the latest version (Wally needs 5.021 or later). -section_header "Installing/Updating Verilator" -STATUS="verilator" -if [ "$UBUNTU_VERSION" == 20 ] || [ "$DEBIAN_VERSION" == 11 ]; then - # On Ubuntu 20 and Debian 11, the last version of Verilator that build successfully is 5.036. - export VERILATOR_VERSION="5.036" -else - export VERILATOR_VERSION="master" -fi -cd "$RISCV" -if git_check "verilator" "https://github.com/verilator/verilator" "$RISCV/share/pkgconfig/verilator.pc"; then - unset VERILATOR_ROOT - cd "$RISCV"/verilator - git reset --hard && git clean -f && git checkout "$VERILATOR_VERSION" && (git pull || true) - autoconf - ./configure --prefix="$RISCV" - make -j "${NUM_THREADS}" 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - make install 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - if [ "$clean" ]; then - cd "$RISCV" - rm -rf verilator - fi - echo -e "${SUCCESS_COLOR}Verilator successfully installed/updated!${ENDC}" -else - echo -e "${SUCCESS_COLOR}Verilator already up to date.${ENDC}" -fi - - -# Sail Compiler (https://github.com/rems-project/sail) -# Sail is a formal specification language designed for describing the semantics of an ISA. -# It is used to generate the RISC-V Sail Model, which is the golden reference model for RISC-V. -# The Sail Compiler is written in OCaml, which is an object-oriented extension of ML, which in turn -# is a functional programming language suited to formal verification. -section_header "Installing/Updating Sail Compiler" -STATUS="sail_compiler" -cd "$RISCV" -wget -nv --retry-connrefused $retry_on_host_error --output-document=sail.tar.gz https://github.com/rems-project/sail/releases/latest/download/sail.tar.gz -tar xz --directory="$RISCV" --strip-components=1 -f sail.tar.gz -rm -f sail.tar.gz -echo -e "${SUCCESS_COLOR}Sail Compiler successfully installed/updated!${ENDC}" - -# RISC-V Sail Model (https://github.com/riscv/sail-riscv) -# The RISC-V Sail Model is the golden reference model for RISC-V. It is written in Sail (described above) -section_header "Installing/Updating RISC-V Sail Model" -STATUS="riscv-sail-model" -if git_check "sail-riscv" "https://github.com/riscv/sail-riscv.git" "$RISCV/bin/riscv_sim_rv32d"; then - cd "$RISCV"/sail-riscv - git reset --hard && git clean -f && git checkout master && git pull - cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="$RISCV" -GNinja 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - cmake --build build 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - cmake --install build 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - if [ "$clean" ]; then - cd "$RISCV" - rm -rf sail-riscv - fi - echo -e "${SUCCESS_COLOR}RISC-V Sail Model successfully installed/updated!${ENDC}" -else - echo -e "${SUCCESS_COLOR}RISC-V Sail Model already up to date.${ENDC}" -fi +source "$WALLY"/bin/installation/verilator-install.sh # OSU Skywater 130 cell library (https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_osu_sc_t12) # The OSU Skywater 130 cell library is a standard cell library that is used to synthesize Wally. -section_header "Installing/Updating OSU Skywater 130 cell library" -STATUS="osu_skywater_130_cell_library" -mkdir -p "$RISCV"/cad/lib -cd "$RISCV"/cad/lib -if git_check "sky130_osu_sc_t12" "https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_osu_sc_t12" "$RISCV/cad/lib/sky130_osu_sc_t12" "main"; then - cd "$RISCV"/sky130_osu_sc_t12 - git reset --hard && git clean -f && git checkout main && git pull - echo -e "${SUCCESS_COLOR}OSU Skywater library successfully installed!${ENDC}" -else - echo -e "${SUCCESS_COLOR}OSU Skywater library already up to date.${ENDC}" -fi +source "$WALLY"/bin/installation/skywater-lib-install.sh # Buildroot and Linux testvectors # Buildroot is used to boot a minimal version of Linux on Wally. # Testvectors are generated using QEMU. -if [ ! "$no_buidroot" ]; then - section_header "Installing Buildroot and Creating Linux testvectors" - STATUS="buildroot" - if [ -z "$LD_LIBRARY_PATH" ]; then - export LD_LIBRARY_PATH=$RISCV/lib:$RISCV/lib64:$RISCV/riscv64-unknown-elf/lib:$RISCV/lib/x86_64-linux-gnu/ - else - export LD_LIBRARY_PATH=$RISCV/lib:$RISCV/lib64:$LD_LIBRARY_PATH:$RISCV/riscv64-unknown-elf/lib:$RISCV/lib/x86_64-linux-gnu/ - fi - cd "$dir"/../linux - if [ ! -e "$RISCV"/buildroot ]; then - FORCE_UNSAFE_CONFIGURE=1 make 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] # FORCE_UNSAFE_CONFIGURE is needed to allow buildroot to compile when run as root - echo -e "${SUCCESS_COLOR}Buildroot successfully installed and Linux testvectors created!${ENDC}" - elif [ ! -e "$RISCV"/linux-testvectors ]; then - echo -e "${OK_COLOR}Buildroot already exists, but Linux testvectors are missing. Generating them now.${ENDC}" - make dumptvs 2>&1 | logger; [ "${PIPESTATUS[0]}" == 0 ] - echo -e "${SUCCESS_COLOR}Linux testvectors successfully generated!${ENDC}" - else - echo -e "${OK_COLOR}Buildroot and Linux testvectors already exist.${ENDC}" - fi -else +if [ "$no_buildroot" = true ]; then echo -e "${OK_COLOR}Skipping Buildroot and Linux testvectors.${ENDC}" +else + source "$WALLY"/bin/installation/buildroot-install.sh fi @@ -519,7 +130,7 @@ if [ ! -e "${RISCV}"/site-setup.sh ]; then wget -nv --retry-connrefused $retry_on_host_error https://raw.githubusercontent.com/openhwgroup/cvw/main/site-setup.sh wget -nv --retry-connrefused $retry_on_host_error https://raw.githubusercontent.com/openhwgroup/cvw/main/site-setup.csh echo -e "${SUCCESS_COLOR}Site setup script successfully downloaded!${ENDC}" - echo -e "${WARNING_COLOR}Make sure to edit the environment variables in $RISCV/site-setup.sh (or .csh) to point to your installation of EDA tools and licensce files.${ENDC}" + echo -e "${WARNING_COLOR}Make sure to edit the environment variables in $RISCV/site-setup.sh (or .csh) to point to your installation of EDA tools and license files.${ENDC}" else echo -e "${OK_COLOR}Site setup script already exists. Not checking for updates to avoid overwritng modifications." echo -e "You may need to manually update it if there were changes upstream.${ENDC}" diff --git a/linux/Makefile b/linux/Makefile index 58cb6c69b..5f6775bcd 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -100,8 +100,10 @@ $(DISASSEMBLY_DIR)/%.objdump: $(IMAGE_DIR)/% | $(DISASSEMBLY_DIR) $(WALLY)/bin/extractFunctionRadix.sh $@ # Disassemble binaries ending in .elf +# Add -D flag back to disassemble all sections (instead of just code sections) +# once objdump bug is fixed and the pinned version of the toolchain is updated. $(DISASSEMBLY_DIR)/%.objdump: $(IMAGE_DIR)/%.elf | $(DISASSEMBLY_DIR) - riscv64-unknown-elf-objdump -SD $< >> $@ + riscv64-unknown-elf-objdump -S $< >> $@ $(WALLY)/bin/extractFunctionRadix.sh $@ # Load wally buildroot configuration diff --git a/site-setup.sh b/site-setup.sh index 32c1913f7..aa6ae3422 100755 --- a/site-setup.sh +++ b/site-setup.sh @@ -39,12 +39,7 @@ export SYN_memory=/home/jstine/WallyMem/rv64gc/ #export osumemory=/import/yukari1/pdk/TSMC/WallyMem/rv64gc/ # GCC -if [ -z "$LD_LIBRARY_PATH" ]; then - export LD_LIBRARY_PATH=$RISCV/riscv64-unknown-elf/lib -else - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RISCV/riscv64-unknown-elf/lib -fi - +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}$RISCV/riscv64-unknown-elf/lib # RISC-V Tools export LD_LIBRARY_PATH=$RISCV/lib:$RISCV/lib64:$LD_LIBRARY_PATH:$RISCV/lib/x86_64-linux-gnu/ export PATH=$PATH:$RISCV/bin diff --git a/synthDC/extractArea.pl b/synthDC/extractArea.pl index cd795d3ff..e69cabdd5 100755 --- a/synthDC/extractArea.pl +++ b/synthDC/extractArea.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env -S perl -w +#!/usr/bin/env perl ########################################### ## extractArea.pl