mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Update ubuntu toolchain install to match new red hat form in preparation for merging of scripts.
This commit is contained in:
parent
206f52a371
commit
2862b89714
@ -6,6 +6,7 @@
|
|||||||
## Created: 18 January 2023
|
## Created: 18 January 2023
|
||||||
## Modified: 22 January 2023
|
## Modified: 22 January 2023
|
||||||
## Modified: 23 March 2023
|
## Modified: 23 March 2023
|
||||||
|
## Modified: 21 June 2024, Jordan Carlin jcarlin@hmc.edu
|
||||||
##
|
##
|
||||||
## Purpose: Open source tool chain installation script
|
## Purpose: Open source tool chain installation script
|
||||||
##
|
##
|
||||||
@ -28,8 +29,17 @@
|
|||||||
## and limitations under the License.
|
## and limitations under the License.
|
||||||
################################################################################################
|
################################################################################################
|
||||||
|
|
||||||
# Use /opt/riscv for installation - may require running script with sudo
|
# Check if root
|
||||||
export RISCV="${1:-/opt/riscv}"
|
ROOT=$( [ "${EUID:=$(id -u)}" = 0 ] && echo true || echo false);
|
||||||
|
|
||||||
|
# All tools will be installed under the $RISCV directory. By default, if run as root (with sudo)
|
||||||
|
# this is set to /opt/riscv. Otherwise, it is set to ~/riscv. This value can be changed if needed.
|
||||||
|
if [ "$ROOT" = true ]; then
|
||||||
|
export RISCV="${1:-/opt/riscv}"
|
||||||
|
else
|
||||||
|
export RISCV="${1:-$HOME/riscv}"
|
||||||
|
fi
|
||||||
|
|
||||||
export PATH=$PATH:$RISCV/bin:/usr/bin
|
export PATH=$PATH:$RISCV/bin:/usr/bin
|
||||||
|
|
||||||
set -e # break on error
|
set -e # break on error
|
||||||
@ -40,23 +50,39 @@ set -e # break on error
|
|||||||
NUM_THREADS=8 # for >= 32GiB
|
NUM_THREADS=8 # for >= 32GiB
|
||||||
#NUM_THREADS=16 # for >= 64GiB
|
#NUM_THREADS=16 # for >= 64GiB
|
||||||
|
|
||||||
sudo mkdir -p $RISCV
|
mkdir -p "$RISCV"
|
||||||
# *** need to update permissions to local user
|
|
||||||
|
|
||||||
|
echo -e "\n*************************************************************************"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "Installing Dependencies from Package Manager"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "*************************************************************************\n"
|
||||||
# Update and Upgrade tools (see https://itsfoss.com/apt-update-vs-upgrade/)
|
# Update and Upgrade tools (see https://itsfoss.com/apt-update-vs-upgrade/)
|
||||||
sudo apt update -y
|
sudo apt update -y
|
||||||
sudo apt upgrade -y
|
sudo apt upgrade -y
|
||||||
sudo apt install -y git gawk make texinfo bison flex build-essential python3 libz-dev libexpat-dev autoconf device-tree-compiler ninja-build libpixman-1-dev ncurses-base ncurses-bin libncurses5-dev dialog curl wget ftp libgmp-dev libglib2.0-dev python3-pip pkg-config opam z3 zlib1g-dev automake autotools-dev libmpc-dev libmpfr-dev gperf libtool patchutils bc mutt ssmtp
|
sudo apt install -y git gawk make texinfo bison flex build-essential python3 python3-venv libz-dev libexpat-dev autoconf device-tree-compiler ninja-build libpixman-1-dev ncurses-base ncurses-bin libncurses5-dev dialog curl wget ftp libgmp-dev libglib2.0-dev python3-pip pkg-config opam z3 zlib1g-dev automake autotools-dev libmpc-dev libmpfr-dev gperf libtool patchutils bc mutt ssmtp perl g++ ccache help2man libgoogle-perftools-dev numactl perl-doc
|
||||||
# Other python libraries used through the book.
|
|
||||||
sudo -H pip3 install sphinx sphinx_rtd_theme matplotlib scipy scikit-learn adjustText lief markdown pyyaml
|
|
||||||
sudo -H pip3 install riscv_isac # to generate new tests, such as quads with fp_dataset.py
|
|
||||||
|
|
||||||
# needed for Ubuntu 22.04, gcc cross compiler expects python not python2 or python3.
|
# 24
|
||||||
if ! command -v python &> /dev/null
|
# Note, selecting 'zlib1g-dev' instead of 'libz-dev'
|
||||||
then
|
# Note, selecting 'libexpat1-dev' instead of 'libexpat-dev'
|
||||||
echo "WARNING: python3 was installed as python3 rather than python. Creating symlink."
|
# Note, selecting 'libncurses-dev' instead of 'libncurses5-dev'
|
||||||
sudo ln -sf /usr/bin/python3 /usr/bin/python
|
|
||||||
|
|
||||||
|
echo -e "\n*************************************************************************"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "Setting up Python Environment"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "*************************************************************************\n"
|
||||||
|
# Other python libraries used through the book.
|
||||||
|
cd "$RISCV"
|
||||||
|
if [ ! -e "$RISCV"/riscv-python/bin/activate ]; then
|
||||||
|
python3 -m venv riscv-python
|
||||||
fi
|
fi
|
||||||
|
source "$RISCV"/riscv-python/bin/activate
|
||||||
|
pip install -U pip
|
||||||
|
pip install -U sphinx sphinx_rtd_theme matplotlib scipy scikit-learn adjustText lief markdown pyyaml meson testresources riscv_config
|
||||||
|
pip install -U riscv_isac # to generate new tests, such as quads with fp_dataset.py
|
||||||
|
source "$RISCV"/riscv-python/bin/activate
|
||||||
|
|
||||||
# gcc cross-compiler (https://github.com/riscv-collab/riscv-gnu-toolchain)
|
# gcc cross-compiler (https://github.com/riscv-collab/riscv-gnu-toolchain)
|
||||||
# To install GCC from source can take hours to compile.
|
# To install GCC from source can take hours to compile.
|
||||||
@ -65,11 +91,19 @@ fi
|
|||||||
# Versions newer than 2023-12-20 fail to compile the RISC-V arch test with an error:
|
# Versions newer than 2023-12-20 fail to compile the RISC-V arch test with an error:
|
||||||
# cvw/addins/riscv-arch-test/riscv-test-suite/rv32i_m/I/src/jalr-01.S:72: Error: illegal operands `la x0,5b'
|
# cvw/addins/riscv-arch-test/riscv-test-suite/rv32i_m/I/src/jalr-01.S:72: Error: illegal operands `la x0,5b'
|
||||||
# PR *** submitted to fix riscv-arch-test to be compatible with latest GCC by modifying test_macros.h for TEST_JALR_OP
|
# PR *** submitted to fix riscv-arch-test to be compatible with latest GCC by modifying test_macros.h for TEST_JALR_OP
|
||||||
cd $RISCV
|
echo -e "\n*************************************************************************"
|
||||||
git clone https://github.com/riscv/riscv-gnu-toolchain
|
echo -e "*************************************************************************"
|
||||||
cd riscv-gnu-toolchain
|
echo -e "Installing RISC-V 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--;"
|
echo -e "*************************************************************************"
|
||||||
make -j 8
|
echo -e "*************************************************************************\n"
|
||||||
|
cd "$RISCV"
|
||||||
|
if [[ ((! -e riscv-gnu-toolchain) && ($(git clone https://github.com/riscv/riscv-gnu-toolchain) || true)) || ($(cd riscv-gnu-toolchain; git fetch; git rev-parse HEAD) != $(cd riscv-gnu-toolchain; git rev-parse master)) || (! -e $RISCV/riscv-gnu-toolchain/stamps/build-gcc-newlib-stage2) ]]; then
|
||||||
|
cd riscv-gnu-toolchain
|
||||||
|
git checkout master
|
||||||
|
git pull
|
||||||
|
./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}
|
||||||
|
fi
|
||||||
|
|
||||||
# elf2hex (https://github.com/sifive/elf2hex)
|
# elf2hex (https://github.com/sifive/elf2hex)
|
||||||
#The elf2hex utility to converts executable files into hexadecimal files for Verilog simulation.
|
#The elf2hex utility to converts executable files into hexadecimal files for Verilog simulation.
|
||||||
@ -78,51 +112,77 @@ make -j 8
|
|||||||
# For example, if Python version 2.x is in your path, it won’t install correctly.
|
# 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
|
# 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.
|
# at the time of compilation, or elf2hex won’t work properly.
|
||||||
cd $RISCV
|
echo -e "\n*************************************************************************"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "Installing elf2hex"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "*************************************************************************\n"
|
||||||
|
cd "$RISCV"
|
||||||
export PATH=$RISCV/bin:$PATH
|
export PATH=$RISCV/bin:$PATH
|
||||||
git clone https://github.com/sifive/elf2hex.git
|
if [[ ((! -e elf2hex) && ($(git clone https://github.com/sifive/elf2hex.git) || true)) || ($(cd elf2hex; git fetch; git rev-parse HEAD) != $(cd elf2hex; git rev-parse master)) || (! -e $RISCV/bin/riscv64-unknown-elf-elf2bin) ]]; then
|
||||||
cd elf2hex
|
cd elf2hex
|
||||||
autoreconf -i
|
git reset --hard && git clean -f && git checkout master && git pull
|
||||||
./configure --target=riscv64-unknown-elf --prefix=$RISCV
|
autoreconf -i
|
||||||
make
|
./configure --target=riscv64-unknown-elf --prefix="$RISCV"
|
||||||
make install
|
make
|
||||||
|
make install
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# QEMU (https://www.qemu.org/docs/master/system/target-riscv.html)
|
# QEMU (https://www.qemu.org/docs/master/system/target-riscv.html)
|
||||||
cd $RISCV
|
echo -e "\n*************************************************************************"
|
||||||
git clone --recurse-submodules https://github.com/qemu/qemu
|
echo -e "*************************************************************************"
|
||||||
cd qemu
|
echo -e "Installing QEMU"
|
||||||
./configure --target-list=riscv64-softmmu --prefix=$RISCV
|
echo -e "*************************************************************************"
|
||||||
make -j 8
|
echo -e "*************************************************************************\n"
|
||||||
make install
|
cd "$RISCV"
|
||||||
|
if [[ ((! -e qemu) && ($(git clone --recurse-submodules https://github.com/qemu/qemu) || true)) || ($(cd qemu; git fetch --recurse-submodules=yes; git rev-parse HEAD) != $(cd qemu; git rev-parse master)) || (! -e $RISCV/include/qemu-plugin.h) ]]; then
|
||||||
|
cd qemu
|
||||||
|
git reset --hard && git clean -f && git checkout master && git pull --recurse-submodules
|
||||||
|
./configure --target-list=riscv64-softmmu --prefix="$RISCV"
|
||||||
|
make -j ${NUM_THREADS}
|
||||||
|
make install
|
||||||
|
fi
|
||||||
|
|
||||||
# Spike (https://github.com/riscv-software-src/riscv-isa-sim)
|
# Spike (https://github.com/riscv-software-src/riscv-isa-sim)
|
||||||
# Spike also takes a while to install and compile, but this can be done concurrently
|
# Spike also takes a while to install and compile, but this can be done concurrently
|
||||||
# with the GCC installation.
|
# with the GCC installation.
|
||||||
cd $RISCV
|
echo -e "\n*************************************************************************"
|
||||||
git clone https://github.com/riscv-software-src/riscv-isa-sim
|
echo -e "*************************************************************************"
|
||||||
mkdir -p riscv-isa-sim/build
|
echo -e "Installing SPIKE"
|
||||||
cd riscv-isa-sim/build
|
echo -e "*************************************************************************"
|
||||||
../configure --prefix=$RISCV
|
echo -e "*************************************************************************\n"
|
||||||
make -j 8
|
cd "$RISCV"
|
||||||
make install
|
if [[ ((! -e riscv-isa-sim) && ($(git clone https://github.com/riscv-software-src/riscv-isa-sim) || true)) || ($(cd riscv-isa-sim; git fetch; git rev-parse HEAD) != $(cd riscv-isa-sim; git rev-parse master)) || (! -e $RISCV/lib/pkgconfig/riscv-riscv.pc) ]]; then
|
||||||
|
cd 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}
|
||||||
|
make install
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Wally needs Verilator 5.021 or later.
|
# Wally needs Verilator 5.021 or later.
|
||||||
# Verilator needs to be built from scratch to get the latest version
|
# Verilator needs to be built from scratch to get the latest version
|
||||||
# apt-get install verilator installs version 4.028 as of 6/8/23
|
# apt-get install verilator installs version 4.028 as of 6/8/23
|
||||||
sudo apt-get install -y perl g++ ccache help2man libgoogle-perftools-dev numactl perl-doc zlib1g
|
echo -e "\n*************************************************************************"
|
||||||
cd $RISCV
|
echo -e "*************************************************************************"
|
||||||
git clone https://github.com/verilator/verilator # Only first time
|
echo -e "Installing Verilator"
|
||||||
# unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
|
echo -e "*************************************************************************"
|
||||||
unset VERILATOR_ROOT # For bash
|
echo -e "*************************************************************************\n"
|
||||||
cd verilator
|
cd "$RISCV"
|
||||||
git pull # Make sure git repository is up-to-date
|
if [[ ((! -e verilator) && ($(git clone https://github.com/verilator/verilator) || true)) || ($(cd verilator; git fetch; git rev-parse HEAD) != $(cd verilator; git rev-parse master)) || (! -e $RISCV/share/pkgconfig/verilator.pc) ]]; then
|
||||||
git checkout master
|
# unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
|
||||||
autoconf # Create ./configure script
|
unset VERILATOR_ROOT # For bash
|
||||||
./configure # Configure and create Makefile
|
cd verilator
|
||||||
make -j 8 # Build Verilator itself (if error, try just 'make')
|
git reset --hard && git clean -f && git checkout master && git pull
|
||||||
sudo make install
|
autoconf # Create ./configure script
|
||||||
|
./configure --prefix="$RISCV" # Configure and create Makefile
|
||||||
|
make -j ${NUM_THREADS} # Build Verilator itself (if error, try just 'make')
|
||||||
|
make install
|
||||||
|
fi
|
||||||
|
|
||||||
# Sail (https://github.com/riscv/sail-riscv)
|
# Sail (https://github.com/riscv/sail-riscv)
|
||||||
# Sail is the new golden reference model for RISC-V. Sail is written in OCaml, which
|
# Sail is the new golden reference model for RISC-V. Sail is written in OCaml, which
|
||||||
@ -130,63 +190,47 @@ sudo make install
|
|||||||
# language suited to formal verification. OCaml is installed with the opam OCcaml
|
# language suited to formal verification. OCaml is installed with the opam OCcaml
|
||||||
# package manager. Sail has so many dependencies that it can be difficult to install.
|
# package manager. Sail has so many dependencies that it can be difficult to install.
|
||||||
# This script works for Ubuntu.
|
# This script works for Ubuntu.
|
||||||
|
echo -e "\n*************************************************************************"
|
||||||
# Alex Solomatnikov found these commands worked to build Sail for Centos 8 on 1/12/24
|
echo -e "*************************************************************************"
|
||||||
#sudo su -
|
echo -e "Installing Sail Compiler"
|
||||||
#dnf install ocaml.x86_64
|
echo -e "*************************************************************************"
|
||||||
#pip3 install z3-solver
|
echo -e "*************************************************************************\n"
|
||||||
#wget https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh
|
cd "$RISCV"
|
||||||
#sh install.sh
|
|
||||||
#opam init
|
|
||||||
#exit
|
|
||||||
#ocaml -version
|
|
||||||
#opam switch create 5.1.0
|
|
||||||
#eval $(opam config env)
|
|
||||||
#git clone --recurse-submodules git@github.com:riscv/sail-riscv.git
|
|
||||||
#cd sail-riscv
|
|
||||||
#make
|
|
||||||
#ARCH=RV32 make
|
|
||||||
#ARCH=RV64 make
|
|
||||||
#git log -1
|
|
||||||
#cp -p c_emulator/riscv_sim_RV* /tools/sail-riscv/d7a3d8012fd579f40e53a29569141d72dd5e0c32/bin/.
|
|
||||||
|
|
||||||
|
|
||||||
# This was an earlier attemp to prepare to install Sail on RedHat 8
|
|
||||||
# Do these commands only for RedHat / Rocky 8 to build from source.
|
|
||||||
#cd $RISCV
|
|
||||||
#git clone https://github.com/Z3Prover/z3.git
|
|
||||||
#cd z3
|
|
||||||
#python scripts/mk_make.py
|
|
||||||
#cd build
|
|
||||||
#make -j 8
|
|
||||||
#make install
|
|
||||||
#cd ../..
|
|
||||||
#pip3 install chardet==3.0.4
|
|
||||||
#pip3 install urllib3==1.22
|
|
||||||
|
|
||||||
cd $RISCV
|
|
||||||
opam init -y --disable-sandboxing
|
opam init -y --disable-sandboxing
|
||||||
opam update
|
opam update -y
|
||||||
opam upgrade
|
opam upgrade -y
|
||||||
opam switch create 5.1.0
|
opam switch create 5.1.0 || opam switch set 5.1.0
|
||||||
opam install sail -y
|
opam install sail -y
|
||||||
|
|
||||||
eval $(opam config env)
|
eval $(opam config env)
|
||||||
git clone https://github.com/riscv/sail-riscv.git
|
if [[ ((! -e sail-riscv) && ($(git clone https://github.com/riscv/sail-riscv.git) || true)) || ($(cd sail-riscv; git fetch; git rev-parse HEAD) != $(cd sail-riscv; git rev-parse master)) || (! -e $RISCV/bin/riscv_sim_RV32) ]]; then
|
||||||
cd sail-riscv
|
cd sail-riscv
|
||||||
# For now, use checkout that is stable for Wally
|
git reset --hard && git clean -f && git checkout master && git pull
|
||||||
#git checkout 72b2516d10d472ac77482fd959a9401ce3487f60 # not new enough for Zicboz?
|
export OPAMCLI=2.0 # Sail is not compatible with opam 2.1 as of 4/16/24
|
||||||
export OPAMCLI=2.0 # Sail is not compatible with opam 2.1 as of 4/16/24
|
ARCH=RV64 make -j ${NUM_THREADS} c_emulator/riscv_sim_RV64
|
||||||
ARCH=RV64 make -j 8 c_emulator/riscv_sim_RV64
|
ARCH=RV32 make -j ${NUM_THREADS} c_emulator/riscv_sim_RV32
|
||||||
ARCH=RV32 make -j 8 c_emulator/riscv_sim_RV32
|
cd "$RISCV"
|
||||||
sudo ln -sf $RISCV/sail-riscv/c_emulator/riscv_sim_RV64 /usr/bin/riscv_sim_RV64
|
ln -sf ../sail-riscv/c_emulator/riscv_sim_RV64 bin/riscv_sim_RV64
|
||||||
sudo ln -sf $RISCV/sail-riscv/c_emulator/riscv_sim_RV32 /usr/bin/riscv_sim_RV32
|
ln -sf ../sail-riscv/c_emulator/riscv_sim_RV32 bin/riscv_sim_RV32
|
||||||
|
fi
|
||||||
|
|
||||||
# riscof
|
# riscof
|
||||||
sudo -H pip3 install -U testresources riscv_config
|
echo -e "\n*************************************************************************"
|
||||||
sudo -H pip3 install git+https://github.com/riscv/riscof.git
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "Installing riscof"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "*************************************************************************\n"
|
||||||
|
pip3 install git+https://github.com/riscv/riscof.git
|
||||||
|
|
||||||
# Download OSU Skywater 130 cell library
|
# Download OSU Skywater 130 cell library
|
||||||
sudo mkdir -p $RISCV/cad/lib
|
echo -e "\n*************************************************************************"
|
||||||
cd $RISCV/cad/lib
|
echo -e "*************************************************************************"
|
||||||
sudo git clone https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_osu_sc_t12
|
echo -e "Installing OSU Skywater 130 cell library"
|
||||||
|
echo -e "*************************************************************************"
|
||||||
|
echo -e "*************************************************************************\n"
|
||||||
|
mkdir -p "$RISCV"/cad/lib
|
||||||
|
cd "$RISCV"/cad/lib
|
||||||
|
if [[ ((! -e sky130_osu_sc_t12) && ($(git clone https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_osu_sc_t12) || true)) || ($(cd sky130_osu_sc_t12; git fetch; git rev-parse HEAD) != $(cd sky130_osu_sc_t12; git rev-parse master)) ]]; then
|
||||||
|
cd sky130_osu_sc_t12
|
||||||
|
git reset --hard && git clean -f && git checkout master && git pull
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user