diff --git a/bin/wally-tool-chain-install.sh b/bin/wally-tool-chain-install.sh index 3e20a05fe..3ba192249 100755 --- a/bin/wally-tool-chain-install.sh +++ b/bin/wally-tool-chain-install.sh @@ -6,7 +6,7 @@ ## Created: 18 January 2023 ## Modified: 22 January 2023 ## Modified: 23 March 2023 -## Modified for Red Hat: June 20 2024, Jordan Carlin jcarlin@hmc.edu +## Modified: 30 June 2024, Jordan Carlin jcarlin@hmc.edu ## ## Purpose: Open source tool chain installation script ## @@ -35,11 +35,21 @@ NUM_THREADS=8 # for >= 32GiB #NUM_THREADS=16 # for >= 64GiB -echo -e "\n*************************************************************************" +# 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' + +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Checking Distro and Permissions and Setting Installation Directory" +echo -e "Checking System Requirements and Configuring Installation" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" set -e # break on error @@ -51,31 +61,31 @@ source "$os_release" if [[ "$ID" = rhel || "$ID_LIKE" = *rhel* ]]; then FAMILY=rhel if [ "$ID" != rhel ] && [ "$ID" != rocky ] && [ "$ID" != almalinux ]; then - printf "%s\n" "For Red Hat family distros, the Wally install script has only been tested on RHEL, Rocky Linux, and AlmaLinux. Your distro " \ - "is $PRETTY_NAME. The regular Red Hat install will be attempted, but there will likely be issues." + printf "${WARNING_COLOR}%s\n${ENDC}" "For Red Hat family distros, the Wally install script has only been tested on RHEL, Rocky Linux," \ + " and AlmaLinux. Your distro is $PRETTY_NAME. The regular Red Hat install will be attempted, but there will likely be issues." fi if [ "${VERSION_ID:0:1}" = 8 ]; then RHEL_VERSION=8 elif [ "${VERSION_ID:0:1}" = 9 ]; then RHEL_VERSION=9 else - echo "The Wally install script is only compatible with versions 8 and 9 of RHEL, Rocky Linux, and AlmaLinux. You have version $VERSION." + echo "${FAIL_COLOR}The Wally install script is only compatible with versions 8 and 9 of RHEL, Rocky Linux, and AlmaLinux. You have version $VERSION.${ENDC}" exit 1 fi elif [[ "$ID" = ubuntu || "$ID_LIKE" = *ubuntu* ]]; then FAMILY=ubuntu if [ "$ID" != ubuntu ]; then - printf "%s\n" "For Ubuntu family distros, the Wally install script has only been tested on standard Ubuntu. Your distro " \ + printf "${WARNING_COLOR}%s\n${ENDC}" "For Ubuntu family distros, the Wally install script has only been tested on standard Ubuntu. Your distro " \ "is $PRETTY_NAME. The regular Ubuntu install will be attempted, but there may be issues." else UBUNTU_VERSION="${VERSION_ID:0:2}" if (( UBUNTU_VERSION < 20 )); then - echo "The Wally install script is only compatible with versions 20.04, 22.04, and 24.04 of Ubuntu. You have version $VERSION." + echo "${FAIL_COLOR}The Wally install script is only compatible with versions 20.04, 22.04, and 24.04 of Ubuntu. You have version $VERSION.${ENDC}" exit 1 fi fi else - printf "%s\n" "The Wally install script is currently only compatible with Ubuntu and Red Hat family " \ + printf "${FAIL_COLOR}%s\n${ENDC}" "The Wally install script is currently only compatible with Ubuntu and Red Hat family " \ "(RHEL, Rocky Linux, or AlmaLinux) distros. Your detected distro is $PRETTY_NAME. You may try manually running the " \ "commands in this script, but it is likely that some will need to be altered." exit 1 @@ -96,17 +106,17 @@ 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 mkdir -p "$RISCV" -echo "Detected information" +echo "${OK_COLOR}${UNDERLINE}Detected information${ENDC}" echo "Distribution: $PRETTY_NAME" echo "Version: $VERSION" echo "Running as root: $ROOT" echo "Installation path: $RISCV" -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing Dependencies from Package Manager" +echo -e "Installing/Updating Dependencies from Package Manager" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" # Installs appropriate packages for red hat or ubuntu distros, picking apt or dnf appropriately if [ "$FAMILY" = rhel ]; then # Enable extra package repos @@ -130,12 +140,12 @@ if [ "$FAMILY" = rhel ]; then # Packages are grouped by which tool requires them, split by line. # If mutltipole tools need a package, it is included in the first tool only # General/Wally specific, riscv-gnu-toolchain, qemu, spike, verilator, buildroot - sudo dnf install -y git make cmake python3.12 python3-pip curl wget ftp tar pkgconfig dialog mutt ssmtp gcc-gfortran \ + sudo dnf install -y git make cmake python3.12 python3-pip curl wget ftp tar pkgconfig dialog mutt ssmtp \ autoconf automake libmpc-devel mpfr-devel gmp-devel gawk bison flex texinfo gperf libtool patchutils bc gcc gcc-c++ zlib-devel expat-devel libslirp-devel \ glib2-devel libfdt-devel pixman-devel bzip2 ninja-build \ dtc boost-regex boost-system \ help2man perl clang ccache gperftools numactl mold \ - ncurses-base ncurses ncurses-libs ncurses-devel + ncurses-base ncurses ncurses-libs ncurses-devel gcc-gfortran # Extra packages not availale in rhel8, nice for verialtor and needed for sail respectively if [ "$RHEL_VERSION" = 9 ]; then sudo dnf install -y perl-doc z3 @@ -152,13 +162,13 @@ elif [ "$FAMILY" = ubuntu ]; then # Packages are grouped by which tool requires them, split by line. # If mutltipole tools need a package, it is included in the first tool only # General/Wally specific, riscv-gnu-toolchain, qemu, spike, verilator, sail, buildroot - sudo apt install -y git make cmake python3 python3-pip python3-venv curl wget ftp tar pkg-config dialog mutt ssmtp gfortran \ + sudo apt install -y git make cmake python3 python3-pip python3-venv curl wget ftp tar pkg-config dialog mutt ssmtp \ autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat1-dev ninja-build libglib2.0-dev libslirp-dev \ libfdt-dev libpixman-1-dev \ device-tree-compiler libboost-regex-dev libboost-system-dev \ help2man perl g++ clang ccache libgoogle-perftools-dev numactl perl-doc libfl2 libfl-dev zlib1g \ opam z3 \ - ncurses-base ncurses-bin libncurses-dev + ncurses-base ncurses-bin libncurses-dev gfortran # Extra packages not availale in Ubuntu 20.04, nice for verialtor if (( UBUNTU_VERSION >= 22 )); then sudo apt install -y mold @@ -174,11 +184,13 @@ elif [ "$FAMILY" = ubuntu ]; then fi fi -echo -e "\n*************************************************************************" +echo -e "${SUCCESS_COLOR}Packages successfully installed.${ENDC}" + +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" echo -e "Setting up Python Environment" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" # Create python virtual environment so the python command targets our desired version of python # and installed packages are isolated from the rest of the system. cd "$RISCV" @@ -189,6 +201,9 @@ if [ ! -e "$RISCV"/riscv-python/bin/activate ]; then else python3 -m venv riscv-python fi + echo -e "${OK_COLOR}Python virtual environment created.\nInstalling pip packages.${ENDC}" +else + echo -e "${OK_COLOR}Python virtual environment already exists.\Updating pip packages.${ENDC}" fi source "$RISCV"/riscv-python/bin/activate # activate python virtual environment @@ -202,17 +217,18 @@ if [ "$RHEL_VERSION" = 8 ]; then pip install -U z3-solver fi source "$RISCV"/riscv-python/bin/activate # reload python virtual environment +echo -e "${SUCCESS_COLOR}Python environment successfully configured.${ENDC}" # Extra dependecies needed for older distros that don't have new enough versions available from package manager if [ "$RHEL_VERSION" = 8 ] || [ "$UBUNTU_VERSION" = 20 ]; then # Newer versin of glib required for Qemu. # Anything newer than this won't build on red hat 8 if [ ! -e "$RISCV"/include/glib-2.0 ]; then - echo -e "\n*************************************************************************" + echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" echo -e "Installing glib" echo -e "*************************************************************************" - echo -e "*************************************************************************\n" + echo -e "*************************************************************************\n${ENDC}" # Meson is needed to build glib pip install -U meson cd "$RISCV" @@ -225,17 +241,18 @@ if [ "$RHEL_VERSION" = 8 ] || [ "$UBUNTU_VERSION" = 20 ]; then meson install -C _build cd "$RISCV" rm -rf glib-2.70.5 + echo -e "${SUCCESS_COLOR}glib successfully installed${ENDC}" fi fi # Newer version of gmp needed for sail-riscv model if [ "$RHEL_VERSION" = 8 ]; then if [ ! -e "$RISCV"/include/gmp.h ]; then - echo -e "\n*************************************************************************" + echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" echo -e "Installing gmp" echo -e "*************************************************************************" - echo -e "*************************************************************************\n" + echo -e "*************************************************************************\n${ENDC}" cd "$RISCV" wget https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz tar -xJf gmp-6.3.0.tar.xz @@ -246,6 +263,7 @@ if [ "$RHEL_VERSION" = 8 ]; then make install cd "$RISCV" rm -rf gmp-6.3.0 + echo -e "${SUCCESS_COLOR}gmp successfully installed${ENDC}" fi fi @@ -253,11 +271,11 @@ fi # 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 -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing RISC-V GNU Toolchain" +echo -e "Installing/Updating RISC-V GNU Toolchain" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" 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 origin/master)) || (! -e $RISCV/riscv-gnu-toolchain/stamps/build-gcc-newlib-stage2) ]]; then cd riscv-gnu-toolchain @@ -265,6 +283,9 @@ if [[ ((! -e riscv-gnu-toolchain) && ($(git clone https://github.com/riscv/riscv 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} + echo -e "${SUCCESS_COLOR}RISC-V GNU Toolchain successfully installed${ENDC}" +else + echo -e "${SUCCESS_COLOR}RISC-V GNU Toolchain already up to date${ENDC}" fi # elf2hex (https://github.com/sifive/elf2hex) @@ -274,11 +295,11 @@ fi # 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. -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing elf2hex" +echo -e "Installing/Updating elf2hex" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" cd "$RISCV" export PATH=$RISCV/bin:$PATH 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 origin/master)) || (! -e $RISCV/bin/riscv64-unknown-elf-elf2bin) ]]; then @@ -288,14 +309,17 @@ if [[ ((! -e elf2hex) && ($(git clone https://github.com/sifive/elf2hex.git) || ./configure --target=riscv64-unknown-elf --prefix="$RISCV" make make install + echo -e "${SUCCESS_COLOR}elf2hex successfully installed${ENDC}" +else + echo -e "${SUCCESS_COLOR}elf2hex already up to date${ENDC}" fi # QEMU (https://www.qemu.org/docs/master/system/target-riscv.html) -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing QEMU" +echo -e "Installing/Updating QEMU" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" cd "$RISCV" if [[ ((! -e qemu) && ($(git clone --recurse-submodules https://github.com/qemu/qemu) || true)) || ($(cd qemu; git fetch; git rev-parse HEAD) != $(cd qemu; git rev-parse origin/master)) || (! -e $RISCV/include/qemu-plugin.h) ]]; then cd qemu @@ -303,16 +327,19 @@ if [[ ((! -e qemu) && ($(git clone --recurse-submodules https://github.com/qemu/ ./configure --target-list=riscv64-softmmu --prefix="$RISCV" make -j ${NUM_THREADS} make install + echo -e "${SUCCESS_COLOR}QEMU successfully installed${ENDC}" +else + echo -e "${SUCCESS_COLOR}QEMU already up to date${ENDC}" fi # 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 # with the GCC installation. -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing SPIKE" +echo -e "Installing/Updating SPIKE" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" cd "$RISCV" 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 origin/master)) || (! -e $RISCV/lib/pkgconfig/riscv-riscv.pc) ]]; then cd riscv-isa-sim @@ -322,15 +349,18 @@ if [[ ((! -e riscv-isa-sim) && ($(git clone https://github.com/riscv-software-sr ../configure --prefix="$RISCV" make -j ${NUM_THREADS} make install + echo -e "${SUCCESS_COLOR}Spike successfully installed${ENDC}" +else + echo -e "${SUCCESS_COLOR}Spike already up to date${ENDC}" fi # Wally needs Verilator 5.021 or later. # Verilator needs to be built from source to get the latest version -echo -e "\n*************************************************************************" +echo -e "\n${SECTION_COLOR}*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing Verilator" +echo -e "Installing/Updating Verilator" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" cd "$RISCV" if [[ ((! -e verilator) && ($(git clone https://github.com/verilator/verilator) || true)) || ($(cd verilator; git fetch; git rev-parse HEAD) != $(cd verilator; git rev-parse origin/master)) || (! -e $RISCV/share/pkgconfig/verilator.pc) ]]; then # unsetenv VERILATOR_ROOT # For csh; ignore error if on bash @@ -341,6 +371,9 @@ if [[ ((! -e verilator) && ($(git clone https://github.com/verilator/verilator) ./configure --prefix="$RISCV" # Configure and create Makefile make -j ${NUM_THREADS} # Build Verilator itself (if error, try just 'make') make install + echo -e "${SUCCESS_COLOR}Verilator successfully installed${ENDC}" +else + echo -e "${SUCCESS_COLOR}Verilator already up to date${ENDC}" fi # RISC-V Sail Model (https://github.com/riscv/sail-riscv) @@ -352,36 +385,38 @@ fi # but a binary release of it should be available soon, removing the need to use opam. cd "$RISCV" if [ "$FAMILY" = rhel ]; then - echo -e "\n*************************************************************************" + echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" - echo -e "Installing Opam" + echo -e "Installing/Updating Opam" echo -e "*************************************************************************" - echo -e "*************************************************************************\n" + echo -e "*************************************************************************\n${ENDC}" mkdir -p opam cd opam wget https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh printf '%s\n' "$RISCV"/bin Y | sh install.sh # the print command provides $RISCV/bin as the installation path when prompted cd "$RISCV" rm -rf opam + echo -e "${SUCCESS_COLOR}Opam successfully installed/updated${ENDC}" fi -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing Sail Compiler" +echo -e "Installing/Updating Sail Compiler" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" cd "$RISCV" opam init -y --disable-sandboxing opam update -y opam upgrade -y opam switch create 5.1.0 || opam switch set 5.1.0 opam install sail -y +echo -e "${SUCCESS_COLOR}Sail Compiler successfully installed/updated${ENDC}" -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing RISC-V Sail Model" +echo -e "Installing/Updating RISC-V Sail Model" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" 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 origin/master)) || (! -e $RISCV/bin/riscv_sim_RV32) ]]; then eval $(opam config env) cd sail-riscv @@ -392,35 +427,41 @@ if [[ ((! -e sail-riscv) && ($(git clone https://github.com/riscv/sail-riscv.git cd "$RISCV" ln -sf ../sail-riscv/c_emulator/riscv_sim_RV64 bin/riscv_sim_RV64 ln -sf ../sail-riscv/c_emulator/riscv_sim_RV32 bin/riscv_sim_RV32 + echo -e "${SUCCESS_COLOR}RISC-V Sail Model successfully installed${ENDC}" +else + echo -e "${SUCCESS_COLOR}RISC-V Sail Model already up to date${ENDC}" fi # riscof -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing Riscof" +echo -e "Installing/Updating RISCOF" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" pip3 install git+https://github.com/riscv/riscof.git # Download OSU Skywater 130 cell library -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" -echo -e "Installing OSU Skywater 130 cell library" +echo -e "Installing/Updating OSU Skywater 130 cell library" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" 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 origin/main)) ]]; then cd 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 # site-setup script -echo -e "\n*************************************************************************" +echo -e "${SECTION_COLOR}\n*************************************************************************" echo -e "*************************************************************************" echo -e "Downloading Site Setup Script" echo -e "*************************************************************************" -echo -e "*************************************************************************\n" +echo -e "*************************************************************************\n${ENDC}" cd "$RISCV" if [ ! -e "${RISCV}"/site-setup.sh ]; then wget https://raw.githubusercontent.com/openhwgroup/cvw/main/site-setup.sh @@ -431,4 +472,9 @@ if [ ! -e "${RISCV}"/site-setup.sh ]; then echo "export PATH=\$RISCV/gcc-10/bin:\$PATH" >> site-setup.sh echo "prepend PATH \$RISCV/gcc-10/bin" >> site-setup.csh fi + echo -e "${SUCCESS_COLOR}Site setup script successfully downloaded${ENDC}" +else + echo -e "${OK_COLOR}Site setup script already exists. Not checking for updates to avoid overwritng modifications${ENDC}" fi + +echo -e "${SUCCESS_COLOR}${BOLD}\n\nINSTALLATION SUCCESSFUL\n\n${ENDC}"