6. Script and configuration index¶
6.1. build_tools¶
6.1.1. install_everything.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jul. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="libraries/library.sh"
CONFIG="config.cfg"
BUILDFOLDER="build_and_install_quantumrisc_tools"
VERSIONFILE="installed_version.txt"
SUCCESS_FILE_TOOLS="latest_success_tools.txt"
SUCCESS_FILE_PROJECTS="latest_success_projects.txt"
DIALOUT_USERS=default
VERSION_FILE_USERS=default
CLEANUP=false
VERBOSE=false
SCRIPTS="YOSYS TRELLIS ICESTORM NEXTPNR_ICE40 NEXTPNR_ECP5 UJPROG OPENOCD \
OPENOCD_VEXRISCV VERILATOR GTKTERM GTKWAVE RISCV_NEWLIB RISCV_LINUX FUJPROG \
SPINALHDL ICARUSVERILOG SPIKE GHDL COCOTB RUST_RISCV"
PROJECTS="PQRISCV_VEXRISCV DEMO_PROJECT_ICE40"
# parse arguments
USAGE="$(basename "$0") [-c] [-h] [-o] [-p] [-v] [-d dir] -- Build and install QuantumRisc toolchain.
where:
-c cleanup, delete everything after successful execution
-h show this help text
-o space seperated list of users who shall be added to dialout
(default: every logged in user)
-p space seperated list of users for whom the version file shall
be copied to the desktop (default: every logged in user)
-v be verbose (spams the terminal)
-d dir build files in \"dir\" (default: ${BUILDFOLDER})"
while getopts ':chopvd:' OPTION; do
case "$OPTION" in
c) echo "-c set: Cleaning up everything in the end"
CLEANUP=true
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
h) echo "$USAGE"
exit
;;
o) echo "-o set: Adding users \"${OPTARG}\" to dialout"
DIALOUT_USERS="$OPTARG"
;;
p) echo "-o set: Copying version file to desktop of \"${OPTARG}\""
VERSION_FILE_USERS="$OPTARG"
;;
v) echo "-v set: Being verbose"
VERBOSE=true
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# load shared functions
source $LIBRARY
# Read config
echo_verbose "Loading configuration file"
source config.cfg
# create and cd into buildfolder
if [ ! -d $BUILDFOLDER ]; then
echo_verbose "Creating build folder \"${BUILDFOLDER}\""
mkdir $BUILDFOLDER
fi
cp -r install_build_essentials.sh $BUILDFOLDER
pushd $BUILDFOLDER > /dev/null
ERROR_FILE="$(pwd -P)/errors.log"
# Potentially create and empty errors.log file
echo '' > errors.log
echo "Executing: ./install_build_essentials.sh"
exec_verbose "./install_build_essentials.sh" "$ERROR_FILE"
# Cleanup files if the programm was shutdown unexpectedly
# trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
echo -e "\n--- Installing tools ---\n"
get_latest "$SCRIPTS" "$SUCCESS_FILE_TOOLS" "tool" "SCRIPTS"
# Process scripts
for SCRIPT in $SCRIPTS; do
# Should the tool be build/installed?
if [ "${!SCRIPT}" = true ]; then
echo "Installing $SCRIPT"
PARAMETERS=""
parameters_tool "$SCRIPT" "PARAMETERS"
COMMAND_INSTALL_ESSENTIALS=""
COMMAND_INSTALL=""
find_script "$SCRIPT" "COMMAND_INSTALL_ESSENTIALS" "COMMAND_INSTALL"
# Execute any file that is available
# build essentials
if [ -f "$COMMAND_INSTALL_ESSENTIALS" ]; then
echo "Executing: $COMMAND_INSTALL_ESSENTIALS"
exec_verbose "$COMMAND_INSTALL_ESSENTIALS" "$ERROR_FILE"
else
echo -e "Warning: ${COMMAND_INSTALL_ESSENTIALS##*/} not found"
fi
# tool install script
if [ -f "$COMMAND_INSTALL" ]; then
echo "Executing: ${COMMAND_INSTALL} ${PARAMETERS}"
exec_verbose "${COMMAND_INSTALL} ${PARAMETERS}" "$ERROR_FILE"
echo "$SCRIPT" > $SUCCESS_FILE_TOOLS
else
echo -e "Warning: ${COMMAND_INSTALL##*/} not found"
fi
fi
done
echo -e "\n--- Setting up projects ---\n"
get_latest "$PROJECTS" "$SUCCESS_FILE_PROJECTS" "project" "PROJECTS"
for PROJECT in $PROJECTS; do
if [ "${!PROJECT}" = true ]; then
echo "Setting up $PROJECT"
install_project "$PROJECT"
echo "$PROJECT" > $SUCCESS_FILE_PROJECTS
fi
done
# secure version file before it gets deleted (-c)
pushd -0 > /dev/null
if [ -f "${BUILDFOLDER}/${VERSIONFILE}" ]; then
cp "${BUILDFOLDER}/${VERSIONFILE}" .
fi
# add users to dialout
if [ "$DIALOUT_USERS" == "default" ]; then
for DIALOUT_USER in `who | cut -d' ' -f1`; do
usermod -a -G dialout "$DIALOUT_USER"
done
else
for DIALOUT_USER in "$DIALOUT_USERS"; do
usermod -a -G dialout "$DIALOUT_USER"
done
fi
# copy version file to users desktop
if [ "$VERSION_FILE_USERS" == "default" ]; then
copy_version_file "$(pwd -P)/${VERSIONFILE}" `who | cut -d' ' -f1`
else
copy_version_file "$(pwd -P)/${VERSIONFILE}" "$VERSION_FILE_USERS"
fi
# cleanup
if [ $CLEANUP = true ]; then
echo_verbose "Cleaning up files"
rm -rf $BUILDFOLDER
fi
echo "Script finished successfully."
|
6.1.2. install_build_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git clang gcc meson ninja-build g++ python3-dev \
make flex bison libc6 binutils gzip bzip2 tar perl autoconf m4 \
automake gettext gperf dejagnu expect tcl"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.1.3. config.cfg¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | ### Configure tools
## Yosys
# Build and (if desired) install Yosys?
YOSYS=true
# Build AND install yosys?
YOSYS_INSTALL=true
# Install path (default = default path)
YOSYS_INSTALL_PATH=default
# Remove build directory after successful install?
YOSYS_CLEANUP=true
# Folder name in which the project is built
YOSYS_DIR=default
# Compiler (gcc or clang)
YOSYS_COMPILER=clang
# Specify project version to pull (default/latest, stable, tag, branch, hash)
YOSYS_TAG=default
## Project Trellis
# Build and (if desired) install Project Trellis?
TRELLIS=true
# Build AND install Project Trellis?
TRELLIS_INSTALL=true
# Install path (default = default path)
TRELLIS_INSTALL_PATH=default
# Remove build directory after successful install?
TRELLIS_CLEANUP=true
# Folder name in which the project is built
TRELLIS_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
TRELLIS_TAG=default
## Icestorm
# Build and (if desired) install Icestorm?
ICESTORM=true
# Build AND install Icestorm?
ICESTORM_INSTALL=true
# Install path (default = default path)
ICESTORM_INSTALL_PATH=default
# Remove build directory after successful install?
ICESTORM_CLEANUP=true
# Folder name in which the project is built
ICESTORM_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
ICESTORM_TAG=default
## NextPNR-Ice40
# Build and (if desired) install NextPNR-ice40?
NEXTPNR_ICE40=true
# Build AND install NextPNR-ice40?
NEXTPNR_ICE40_INSTALL=true
# Install path (default = default path)
NEXTPNR_ICE40_INSTALL_PATH=default
# Remove build directory after successful install?
NEXTPNR_ICE40_CLEANUP=false
# Folder name in which the project is built
NEXTPNR_ICE40_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
NEXTPNR_ICE40_TAG=default
# Use chip dbs from the following path (default = fetch latest chip dbs)
NEXTPNR_ICE40_CHIPDB_PATH=default
## NextPNR-Ecp5
# Build and (if desired) install NextPNR-Ecp5?
NEXTPNR_ECP5=true
# Build AND install NextPNR-NextPNR-Ecp5?
NEXTPNR_ECP5_INSTALL=true
# Install path (default = default path)
NEXTPNR_ECP5_INSTALL_PATH=default
# Remove build directory after successful install?
NEXTPNR_ECP5_CLEANUP=true
# Folder name in which the project is built
NEXTPNR_ECP5_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
NEXTPNR_ECP5_TAG=default
# Use chip dbs from the following path (default = fetch latest chip dbs)
NEXTPNR_ECP5_CHIPDB_PATH=default
## Fujprog
# Build and (if desired) install Fujprog?
FUJPROG=true
# Build AND install Fujprog?
FUJPROG_INSTALL=true
# Install path (default = default path)
FUJPROG_INSTALL_PATH=default
# Remove build directory after successful install?
FUJPROG_CLEANUP=true
# Folder name in which the project is built
FUJPROG_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
FUJPROG_TAG=default
## Ujprog
# Build and (if desired) install Ujprog?
UJPROG=true
# Build AND install Ujprog?
UJPROG_INSTALL=true
# Install path (default = default path)
UJPROG_INSTALL_PATH=default
# Remove build directory after successful install?
UJPROG_CLEANUP=true
# Folder name in which the project is built
UJPROG_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
UJPROG_TAG=default
## OpenOCD
# Build and (if desired) install OpenOCD?
OPENOCD=true
# Build AND install OpenOCD?
OPENOCD_INSTALL=true
# Install path (default = default path)
OPENOCD_INSTALL_PATH=default
# Remove build directory after successful install?
OPENOCD_CLEANUP=true
# Folder name in which the project is built
OPENOCD_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
OPENOCD_TAG=default
## OpenOCD-VexRiscV
# Build and (if desired) install OpenOCD-VexRiscV?
OPENOCD_VEXRISCV=true
# Build AND install OpenOCD-VexRiscV?
OPENOCD_VEXRISCV_INSTALL=true
# Install path (default = default path)
OPENOCD_VEXRISCV_INSTALL_PATH=default
# Remove build directory after successful install?
OPENOCD_VEXRISCV_CLEANUP=true
# Folder name in which the project is built
OPENOCD_VEXRISCV_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
OPENOCD_VEXRISCV_TAG=default
## Verilator
# Build and (if desired) install Verilator?
VERILATOR=true
# Build AND install Verilator?
VERILATOR_INSTALL=true
# Install path (default = default path)
VERILATOR_INSTALL_PATH=default
# Remove build directory after successful install?
VERILATOR_CLEANUP=true
# Folder name in which the project is built
VERILATOR_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
VERILATOR_TAG=default
## GTKTerm
# Build and (if desired) install GTKTerm?
GTKTERM=true
# Build AND install GTKTerm?
GTKTERM_INSTALL=true
# Install path (default = default path)
GTKTERM_INSTALL_PATH=default
# Remove build directory after successful install?
GTKTERM_CLEANUP=true
# Folder name in which the project is built
GTKTERM_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
GTKTERM_TAG=default
## GTKWave
# Build and (if desired) install GTKWave?
GTKWAVE=true
# Build AND install GTKWave?
GTKWAVE_INSTALL=true
# Install path (default = default path)
GTKWAVE_INSTALL_PATH=default
# Remove build directory after successful install?
GTKWAVE_CLEANUP=true
# Folder name in which the project is built
GTKWAVE_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
GTKWAVE_TAG=default
## RiscV-GNU-Toolchain Newlib Multilib
# build and install RiscV-GNU-Toolchain?
RISCV_NEWLIB=true
# Remove build directory after successful install?
RISCV_NEWLIB_CLEANUP=false
# Folder name in which the project is built
RISCV_NEWLIB_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
# Note: You can specify the version of every single tool of this toolchain in
# ./riscv_tools/versions.cfg
RISCV_NEWLIB_TAG=default
# Extend PATH by RiscV-GNU-Toolchain path?
RISCV_NEWLIB_EXTEND_PATH=true
# Specify user to install the toolchain for (default = everybody)
# Note: this only makes sense if PATH is extended (RISCV_NEWLIB_EXTEND_PATH)
RISCV_NEWLIB_USER=default
# Specify install path (default: /opt/riscv)
RISCV_NEWLIB_INSTALL_PATH=default
## RiscV-GNU-Toolchain Linux Multilib
# build and install RiscV-GNU-Toolchain?
RISCV_LINUX=true
# Remove build directory after successful install?
RISCV_LINUX_CLEANUP=true
# Folder name in which the project is built
RISCV_LINUX_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
# Note: You can specify the version of every single tool of this toolchain in
# ./riscv_tools/versions.cfg
RISCV_LINUX_TAG=default
# Extend PATH by RiscV-GNU-Toolchain path?
RISCV_LINUX_EXTEND_PATH=true
# Specify user to install the toolchain for (default = everybody)
# Note: this only makes sense if PATH is extended (RISCV_LINUX_EXTEND_PATH)
RISCV_LINUX_USER=default
# Specify install path (default: /opt/riscv)
RISCV_LINUX_INSTALL_PATH=default
## SpinalHDL
# install SpinalHDL scala libraries?
SPINALHDL=true
## Cocotb
# install Cocotb python package?
COCOTB=true
## Rust and RiscV targets
# install Rust and RiscV targets?
RUST_RISCV=true
## Spike
# Build and (if desired) install Spike?
SPIKE=true
# Build AND install Spike?
SPIKE_INSTALL=true
# Install path (default = default path)
SPIKE_INSTALL_PATH=default
# Remove build directory after successful install?
SPIKE_CLEANUP=true
# Folder name in which the project is built
SPIKE_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
SPIKE_TAG=default
## Icarusverilog
# Build and (if desired) install Icarusverilog?
ICARUSVERILOG=true
# Build AND install Icarusverilog?
ICARUSVERILOG_INSTALL=true
# Install path (default = default path)
ICARUSVERILOG_INSTALL_PATH=default
# Remove build directory after successful install?
ICARUSVERILOG_CLEANUP=true
# Folder name in which the project is built
ICARUSVERILOG_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
ICARUSVERILOG_TAG=default
## Ghdl
# Build and (if desired) install Ghdl?
GHDL=true
# Build AND install Ghdl?
GHDL_INSTALL=true
# Install path (default = default path)
GHDL_INSTALL_PATH=default
# Remove build directory after successful install?
GHDL_CLEANUP=true
# Folder name in which the project is built
GHDL_DIR=default
# Specify project version to pull (default/latest, stable, tag, branch, hash)
GHDL_TAG=default
# Note: At least one of the following three backends must be build
# Build mcode backend?
GHDL_MCODE=true
# Build LLVM backend?
GHDL_LLVM=true
# Build GCC backend?
GHDL_GCC=true
### Configure projects
## Pqvexriscv project
# Download git repository
PQRISCV_VEXRISCV=false
# Git URL
PQRISCV_VEXRISCV_URL="https://github.com/mupq/pqriscv-vexriscv.git"
# Specify project version to pull (default/latest, stable, tag, branch, hash)
PQRISCV_VEXRISCV_TAG=default
# If default is selected, the project is stored in the documents folder
# of each user listed in the variable PQRISCV_VEXRISCV_USER
PQRISCV_VEXRISCV_LOCATION=default
# Space separated list of users (in quotation marks) to install the project for
# in /home/$user/Documents (if PQRISCV_VEXRISCV_LOCATION=default).
# default = all logged in users. Linking to desktop is also based on this list.
PQRISCV_VEXRISCV_USER=default
# Symbolic link to /home/$user/Desktop
PQRISCV_VEXRISCV_LINK_TO_DESKTOP=true
## Hello world demo application
# Download git repository
DEMO_PROJECT_ICE40=false
# Git URL
DEMO_PROJECT_ICE40_URL="https://github.com/ThorKn/icebreaker-vexriscv-helloworld.git"
# Specify project version to pull (default/latest, stable, tag, branch, hash)
DEMO_PROJECT_ICE40_TAG=default
# If default is selected, the project is stored in the documents folder
# of each user listed in the variable DEMO_PROJECT_ICE40_USER
DEMO_PROJECT_ICE40_LOCATION=default
# Space separated list of users (in quotation marks) to install the project for
# in /home/$user/Documents (if DEMO_PROJECT_ICE40_LOCATION=default).
# default = all logged in users. Linking to desktop is also based on this list.
DEMO_PROJECT_ICE40_USER=default
# Symbolic link to /home/$user/Desktop
DEMO_PROJECT_ICE40_LINK_TO_DESKTOP=true
|
6.2. gtkwave¶
6.2.1. install_gtkwave.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/gtkwave/gtkwave.git"
PROJ="gtkwave/gtkwave3-gtk3"
BUILDFOLDER="build_and_install_gtkwave"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
if [ "$INSTALL_PREFIX" == "default" ]; then
./configure
else
./configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.2.2. install_gtkwave_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git gcc make debhelper libgtk2.0-dev zlib1g-dev \
libbz2-dev flex gperf tcl-dev tk-dev liblzma-dev libjudy-dev \
libgconf2-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.3. openocd¶
6.3.1. install_openocd.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://git.code.sf.net/p/openocd/code"
PROJ="openocd"
BUILDFOLDER="build_and_install_openocd"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
# avoid version 10.0 when stable is selected (majorly outdated)
if [ "$TAG" == "stable" ]; then
TAGLIST=`git rev-list --tags --max-count=1`
if [ -n "$TAGLIST" ] && [ `git describe --tags $TAGLIST` == "v0.10.0" ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
else
select_and_get_project_version "$TAG" "COMMIT_HASH"
fi
else
select_and_get_project_version "$TAG" "COMMIT_HASH"
fi
echo "selected TAG: $COMMIT_HASH"
# build and install if wanted
./bootstrap
if [ "$INSTALL_PREFIX" == "default" ]; then
./configure
else
./configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.3.2. install_openocd_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git gcc make libtool pkg-config autoconf automake \
texinfo libftdi-dev libusb-1.0-0-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.4. gtkterm¶
6.4.1. install_gtkterm_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="libgtk-3-dev libvte-2.91-dev intltool libgudev-1.0 meson ninja-build"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.4.2. install_gtkterm.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 08 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/Jeija/gtkterm"
PROJ="gtkterm"
BUILDFOLDER="build_and_install_gtkterm"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
if [ "$INSTALL_PREFIX" == "default" ]; then
meson build
else
meson build -Dprefix="$INSTALL_PREFIX"
fi
if [ $INSTALL = true ]; then
ninja -C build install
else
ninja -C build
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.5. openocd_vexriscv¶
6.5.1. install_openocd_vexriscv.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/SpinalHDL/openocd_riscv.git"
PROJ="openocd_vexriscv"
BUILDFOLDER="build_and_install_openocd_vexriscv"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
CONFIGURE_STRING="--prefix=/usr/local --program-suffix=-vexriscv
--datarootdir=/usr/local/share/vexriscv --enable-maintainer-mode
--disable-werror --enable-ft232r --enable-ftdi --enable-jtag_vpi"
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
# Adjust configure string
if [ "$OPTARG" != 'default' ]; then
CONFIGURE_STRING="${CONFIGURE_STRING//"/usr/local"/"$OPTARG"}"
fi
# INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $OPTARG"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "${PROJ%%/*}" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
./bootstrap
./configure $CONFIGURE_STRING
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.5.2. install_openocd_vexriscv_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git gcc make libtool pkg-config autoconf automake \
texinfo libftdi-dev libusb-1.0-0-dev libyaml-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.6. icestorm¶
6.6.1. install_icestorm_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang bison flex libreadline-dev \
gawk tcl-dev libffi-dev git mercurial graphviz \
xdot pkg-config python python3 libftdi-dev \
qt5-default python3-dev libboost-all-dev cmake libeigen3-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.6.2. install_icestorm.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/cliffordwolf/icestorm.git"
PROJ="icestorm"
BUILDFOLDER="build_and_install_icestorm"
VERSIONFILE="installed_version.txt"
RULE_FILE="/etc/udev/rules.d/53-lattice-ftdi.rules"
# space separate multiple rules
RULES=('ACTION=="add", ATTR{idVendor}=="0403", ATTR{idProduct}=="6010", MODE:="666"')
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
make -j$(nproc)
if [ $INSTALL = true ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
make install
else
make install PREFIX="$INSTALL_PREFIX"
fi
fi
# allow any user to access ice fpgas (no sudo)
touch "$RULE_FILE"
for RULE in "${RULES[@]}"; do
if ! grep -q "$RULE" "$RULE_FILE"; then
echo -e "$RULE" >> "$RULE_FILE"
fi
done
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.7. ujprog¶
6.7.1. install_ujprog_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang make"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.7.2. install_ujprog.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/f32c/tools.git"
PROJ="tools/ujprog"
BUILDFOLDER="build_and_install_ujprog"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
cp Makefile.linux Makefile
# Adjust path if required
if [ "$INSTALL_PREFIX" != "default" ]; then
mkdir -p "${INSTALL_PREFIX}/bin"
sed -i "s /usr/local ${INSTALL_PREFIX} g" Makefile
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.8. trellis¶
6.8.1. install_trellis_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang cmake python3 python3-dev libboost-all-dev git"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.8.2. install_trellis.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/SymbiFlow/prjtrellis"
PROJ="prjtrellis/libtrellis"
BUILDFOLDER="build_and_install_trellis"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -DCMAKE_INSTALL_PREFIX=/usr .
else
cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.9. spike¶
6.9.1. install_spike_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="device-tree-compiler"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.9.2. install_spike.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/riscv/riscv-isa-sim.git"
PROJ="spike"
BUILDFOLDER="build_and_install_spike"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
mkdir -p 'build'
pushd 'build' > /dev/null
if [ "$INSTALL_PREFIX" == "default" ]; then
../configure
else
../configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.10. fujprog¶
6.10.1. install_fujprog.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/kost/fujprog.git"
PROJ="fujprog"
BUILDFOLDER="build_and_install_fujprog"
VERSIONFILE="installed_version.txt"
RULE_FILE="/etc/udev/rules.d/80-fpga-ulx3s.rules"
# space separate multiple rules
RULES=(
'SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE="664", GROUP="dialout"'
'ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", GROUP="dialout", MODE="666"'
)
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake .
else
cmake -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" .
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# allow any user to access ulx3s fpgas (no sudo)
touch "$RULE_FILE"
for RULE in "${RULES[@]}"; do
if ! grep -q "$RULE" "$RULE_FILE"; then
echo -e "$RULE" >> "$RULE_FILE"
fi
done
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.10.2. install_fujprog_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="libftdi1-dev libusb-dev cmake make build-essential"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.11. verilator¶
6.11.1. install_verilator_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="git perl python3 make g++ libfl2 libfl-dev zlibc zlib1g zlib1g-dev \
ccache libgoogle-perftools-dev numactl git autoconf flex bison"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.11.2. install_verilator.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/verilator/verilator.git"
PROJ="verilator"
BUILDFOLDER="build_and_install_verilator"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
# unset var
if [ -n "$BASH" ]; then
unset VERILATOR_ROOT
else
unsetenv VERILATOR_ROOT
fi
autoconf
if [ "$INSTALL_PREFIX" == "default" ]; then
./configure
else
./configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.12. rust_riscv¶
6.12.1. install_rust_riscv.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
BUILDFOLDER="install_rust_riscv"
VERSIONFILE="installed_version.txt"
LIBRARY="../libraries/library.sh"
# required tools
TOOLS="curl"
# available rust targets
DEFAULT_TARGETS="riscv32i-unknown-none-elf riscv32imac-unknown-none-elf \
riscv32imc-unknown-none-elf riscv64gc-unknown-linux-gnu \
riscv64gc-unknown-none-elf riscv64imac-unknown-none-elf"
source $LIBRARY
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
# install rust
mkdir -p $BUILDFOLDER
pushd $BUILDFOLDER > /dev/null
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > 'rustup_installer.sh'
chmod +x './rustup_installer.sh'
# Install rust in the context of every logged in user
for RUST_USER in `who | cut -d' ' -f1`; do
# check if rustup is installed
RUSTUP_SCRIPT="$(pwd -P)/rustup_installer.sh"
if ! runuser -l $RUST_USER -c "command -v rustup" &> /dev/null; then
runuser -l $RUST_USER -c "$RUSTUP_SCRIPT -y"
RUSTUP="\$HOME/.cargo/bin/rustup"
else
RUSTUP=`runuser -l $RUST_USER -c "command -v rustup"`
fi
# update rust
runuser -l $RUST_USER -c "$RUSTUP install stable"
runuser -l $RUST_USER -c "$RUSTUP install nightly"
runuser -l $RUST_USER -c "$RUSTUP update"
runuser -l $RUST_USER -c "$RUSTUP update nightly"
# add riscv target
# scan for available targets first, if it fails use DEFAULT_TARGETS
PRRT=`runuser -l $RUST_USER -c "$RUSTUP target list | grep riscv"`
DEFAULT_TC=`runuser -l $RUST_USER -c "rustup default"`
DEFAULT_TC="${DEFAULT_TC// (default)}"
if [ -n "$PRRT" ]; then
DEFAULT_TARGETS=`echo $PRRT`
fi
runuser -l $RUST_USER -c "$RUSTUP target add --toolchain ${DEFAULT_TC} ${DEFAULT_TARGETS// (installed)}"
runuser -l $RUST_USER -c "$RUSTUP target add --toolchain nightly ${DEFAULT_TARGETS// (installed)}"
# add some useful dev components
runuser -l $RUST_USER -c "$RUSTUP component add --toolchain ${DEFAULT_TC} rls rustfmt rust-analysis clippy"
runuser -l $RUST_USER -c "$RUSTUP component add --toolchain nightly rls rustfmt rust-analysis clippy"
done
# cleanup
popd > /dev/null
rm -r $BUILDFOLDER
VER_DEFAULT=`runuser -l $RUST_USER -c "$RUSTUP run ${DEFAULT_TC} rustc --version"`
VER_DEFAULT="${VER_DEFAULT//(*)}"
VER_DEFAULT="${VER_DEFAULT#rustc }"
VER_NIGHTLY=`runuser -l $RUST_USER -c "$RUSTUP run nightly rustc --version"`
VER_NIGHTLY="${VER_NIGHTLY//(*)}"
VER_NIGHTLY="${VER_NIGHTLY#rustc }"
echo -e "rustc (${DEFAULT_TC}, with riscv targets): ${VER_DEFAULT}\nrustc (nightly, with riscv targets): ${VER_NIGHTLY}" >> "$VERSIONFILE"
|
6.13. libraries¶
6.13.1. library.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 22 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# This file contains functions that are shared by the build and install scripts.
# constants
RED='\033[1;31m'
NC='\033[0m'
# This function does checkout the correct version and return the commit hash or tag name
# Parameter 1: Branch name, commit hash, tag or one of the special keywords default/latest/stable
# Parameter 2: Return variable name (commit hash or tag name)
# Parameter 3: (OPTIONAL) glob string filter for stable tag list
function select_and_get_project_version {
# Stable selected: Choose latest tag if available, otherwise use default branch
if [ "$1" == "stable" ]; then
if [ -n "$3" ]; then
local L_TAGLIST=`git rev-list --tags="$3" --max-count=1`
else
local L_TAGLIST=`git rev-list --tags --max-count=1`
fi
# tags found?
if [ -n "$L_TAGLIST" ]; then
local L_COMMIT_HASH="`git describe --tags $L_TAGLIST`"
git checkout --recurse-submodules "$L_COMMIT_HASH"
return 0
else
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
local L_COMMIT_HASH="$(git rev-parse HEAD)"
>&2 echo -e "${RED}WARNING: No git tags found, using default branch${NC}"
fi
else
# Either checkout default/stable branch or use custom commit hash, tag or branch name
if [ "$1" == 'default' ] || [ "$1" == 'latest' ]; then
git checkout --recurse-submodules $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
else
# Check if $1 contains a valid tag and use it as the version if it does
git checkout --recurse-submodules "$1"
fi
local L_COMMIT_HASH="$(git rev-parse HEAD)"
fi
# Set return value to tag name if available
local L_POSSIBLE_TAGS=`git tag --points-at $L_COMMIT_HASH`
if [ -n "$L_POSSIBLE_TAGS" ] && [ "$L_POSSIBLE_TAGS" != "nightly" ]; then
L_COMMIT_HASH="${L_POSSIBLE_TAGS%%[$'\n']*}"
fi
# Apply return value
eval "$2=\"$L_COMMIT_HASH\""
}
# Prints only if verbose is set
function echo_verbose {
if [ $VERBOSE = true ]; then
echo "$1"
fi
}
# Prints only errors from executed commands if verbose is set
# Parameter $1: Command to execute
# Parameter $2: Path to error file
function exec_verbose {
if [ $VERBOSE = false ]; then
$1 > /dev/null 2>> "$2"
else
$1 2>> "$2"
fi
}
# Read latest executed tool/project/etc.
# Parameter $1: tool/project/etc. list
# Parameter $2: success file
# Parameter $3: string containing list element type (tool/project/etc.)
# Parameter $4: Return variable name
function get_latest {
if [ ! -f "$2" ]; then
return 0
fi
local LATEST_SCRIPT=`cat $2`
local SCRIPTS_ADAPTED=`echo "$1" | sed "s/.*${LATEST_SCRIPT} //"`
if [ "$SCRIPTS_ADAPTED" == "$1" ]; then
local AT_END=true
echo -e "\nThe script detected a checkpoint after the last ${3}. This means that all ${3}s already have been checked and installed if configured that way. Do you want to check every ${3} and install them again if configured that way (y/n)?"
else
local AT_END=false
echo -e "\nThe script detected a checkpoint. Do you want to install every ${3} from the checkpoint onwards (y) if configured that way or do you want to start over from the beginning (n)?"
echo "${3}s yet to be check for installation after the checkpoint: $SCRIPTS_ADAPTED"
fi
local DECISION="z"
while [ $DECISION != "n" ] && [ $DECISION != "y" ]; do
read -p "Decision(y/n): " DECISION
if [ -z $DECISION ]; then
DECISION="z"
fi
done
echo -e "\n"
if [ $DECISION == "n" ]; then
if [ $AT_END = true ]; then
eval "$4=\"\""
fi
else
eval "$4=\"$SCRIPTS_ADAPTED\""
fi
}
# Process riscv_gnu_toolchain script parameters
# Parameter $1: Script name
# Parameter $2: Variable to store the parameters in
function parameters_tool_riscv {
# set -n flag
if [ "${1:6}" == "NEWLIB" ]; then
eval "$2=\"${!2} -n\""
fi
# Set "e" parameter
if [ "$(eval "echo $`echo $1`_EXTEND_PATH")" = true ]; then
eval "$2=\"${!2} -e\""
fi
# set "u" parameter
local L_BUILD_USER="$(eval "echo $`echo $1`_USER")"
if [ -n "$L_BUILD_USER" ] && [ "$L_BUILD_USER" != "default" ]; then
eval "$2=\"${!2} -u \"$L_BUILD_USER\"\""
fi
# set "p" parameter
local L_BUILD_INSTALL_PATH="$(eval "echo $`echo $1`_INSTALL_PATH")"
if [ -n "$L_BUILD_INSTALL_PATH" ] && [ "$L_BUILD_INSTALL_PATH" != "default" ]; then
eval "$2=\"${!2} -p \"$L_BUILD_INSTALL_PATH\"\""
fi
}
# Process nextpnr script parameters
# Parameter $1: Script name
# Parameter $2: Variable to store the parameters in
function parameters_tool_nextpnr {
# set -e flag
if [ "${1:8}" == "ECP5" ]; then
eval "$2=\"${!2} -e\""
fi
local L_BUILD_CHIPDB="$(eval "echo $`echo $1`_CHIPDB_PATH")"
if [ -n "$L_BUILD_CHIPDB" ] && [ "$L_BUILD_CHIPDB" != "default" ]; then
eval "$2=\"${!2} -l \"$L_BUILD_CHIPDB\"\""
fi
}
# Process ghdl script parameters
# Parameter $1: Script name
# Parameter $2: Variable to store the parameters in
function parameters_tool_ghdl {
# Set "g" flag
if [ "$(eval "echo $`echo $1`_GCC")" = true ]; then
eval "$2=\"${!2} -g\""
fi
# Set "l" flag
if [ "$(eval "echo $`echo $1`_LLVM")" = true ]; then
eval "$2=\"${!2} -l\""
fi
# Set "m" flag
if [ "$(eval "echo $`echo $1`_MCODE")" = true ]; then
eval "$2=\"${!2} -m\""
fi
}
# Process common script parameters
# Parameter $1: Script name
# Parameter $2: Variable to store the parameters in
function parameters_tool {
# Set "i" parameter
if [ "$(eval "echo $`echo $1`_INSTALL")" = true ]; then
eval "$2=\"${!2} -i $(eval "echo $`echo $1`_INSTALL_PATH")\""
fi
# Set "c" parameter
if [ "$(eval "echo $`echo $1`_CLEANUP")" = true ]; then
eval "$2=\"${!2} -c\""
fi
# Set "d" parameter
local L_BUILD_DIR="$(eval "echo $`echo $1`_DIR")"
if [ -n "$L_BUILD_DIR" ] && [ "$L_BUILD_DIR" != "default" ]; then
eval "$2=\"${!2} -d \"$L_BUILD_DIR\"\""
fi
# Set "t" parameter
local L_BUILD_TAG="$(eval "echo $`echo $1`_TAG")"
if [ -n "$L_BUILD_TAG" ] && [ "$L_BUILD_TAG" != "default" ]; then
eval "$2=\"${!2} -t \"$L_BUILD_TAG\"\""
fi
# Set "b" for Yosys only
if [ $1 == "YOSYS" ]; then
local L_BUILD_COMPILER="$(eval "echo $`echo $1`_COMPILER")"
if [ -n "$L_BUILD_COMPILER" ]; then
eval "$2=\"${!2} -b \"$L_BUILD_COMPILER\"\""
fi
fi
# Append special parameters
if [ "${1::5}" == "RISCV" ]; then
parameters_tool_riscv "$1" "$2"
elif [ "${1::7}" == "NEXTPNR" ]; then
parameters_tool_nextpnr "$1" "$2"
elif [ "$1" == "GHDL" ]; then
parameters_tool_ghdl "$1" "$2"
fi
}
# Copies the project to documents and creates a symbolic link if desired
# Parameter $1: Project name
# Parameter $2: User name
# Parameter $3: Create symbolic link (bool)
# Parameter $4: Project directory (where to copy it)
function install_project_for_user {
local L_USER_HOME=$(getent passwd "$2" | cut -d: -f6)
# User not found (link to desktop impossible)
if [ $3 = true ] || [ "$4" == "default" ]; then
if [ -z "$L_USER_HOME" ]; then
echo -e "${RED}ERROR: User ${L_USER} does not exist (home directory not found).${NC}"
exit 1;
fi
fi
# Lookup Documents and Desktop and create if not existant
if [ "$4" == "default" ]; then
local L_DESTINATION="${L_USER_HOME}/Documents"
else
# Strip last possible "/" path
if [ "${4: -1}" == "/" ]; then
local L_DESTINATION="${4:: -1}"
else
local L_DESTINATION="$4"
fi
fi
local L_PROJECT="$1"
local L_USER="$2"
# TODO: Improve for multiple languages (Documents / Desktop only in en)
if [ ! -d "${L_DESTINATION}" ]; then
mkdir "$L_DESTINATION"
chown -R "${L_USER}:${L_USER}" "$L_DESTINATION"
fi
# Copy project
cp -r "$L_PROJECT" "$L_DESTINATION"
chown -R "${L_USER}:${L_USER}" "${L_DESTINATION}/${L_PROJECT}"
# Create symbolic link to desktop if desired
if [ $3 = true ]; then
local L_USER_DESKTOP="${L_USER_HOME}/Desktop"
if [ ! -d "${L_USER_DESKTOP}" ]; then
mkdir "$L_USER_DESKTOP"
chown -R "${L_USER}:${L_USER}" "$L_USER_DESKTOP"
fi
ln -s "${L_DESTINATION}/${L_PROJECT}" "${L_USER_DESKTOP}/${L_PROJECT}"
fi
}
# Install project ("configure projects" section in config.cfg)
# Parameter $1: Project name
function install_project {
if [ "${!1}" = false ]; then
return 0
fi
local L_NAME_LOWER=`echo "$1" | tr [A-Z] [a-z]`
# Clone
if [ ! -d "$L_NAME_LOWER" ]; then
exec_verbose "git clone --recurse-submodules ""$(eval "echo $`echo $1`_URL")"" ""$L_NAME_LOWER""" "$ERROR_FILE"
fi
# Checkout specified version
local L_TAG="$(eval "echo $`echo $1`_TAG")"
if [ "$L_TAG" != "default" ]; then
pushd $L_NAME_LOWER > /dev/null
exec_verbose "select_and_get_project_version ""$L_TAG"" ""L_COMMIT_HASH""" "$ERROR_FILE"
popd > /dev/null
fi
local L_LINK="$(eval "echo $`echo $1`_LINK_TO_DESKTOP")"
# Get users to install the projects for
local L_USERLIST="$(eval "echo $`echo $1`_USER")"
# Get project install location
local L_INST_LOC="$(eval "echo $`echo $1`_LOCATION")"
if [ "$L_USERLIST" == "default" ]; then
for L_USER in `who | cut -d' ' -f1`; do
install_project_for_user "$L_NAME_LOWER" "$L_USER" $L_LINK "$L_INST_LOC"
done
else
for L_USER in "$L_USERLIST"; do
install_project_for_user "$L_NAME_LOWER" "$L_USER" $L_LINK "$L_INST_LOC"
done
fi
rm -rf "$L_NAME_LOWER"
}
# Moves script folder into build folder and returns script path
# Parameter $1: Script name
# Parameter $2: Variable to store the script path for requirements script in
# Parameter $3: Variable to store the script path for installation script in
function find_script {
if [ "${SCRIPT::5}" == "RISCV" ]; then
cp -r ../riscv_tools .
eval "$2=\"$(pwd -P)/riscv_tools/install_riscv_essentials.sh\""
eval "$3=\"$(pwd -P)/riscv_tools/install_riscv.sh\""
cp "$(pwd -P)/riscv_tools/versions.cfg" .
elif [ "${SCRIPT::7}" == "NEXTPNR" ]; then
cp -r ../nextpnr .
eval "$2=\"$(pwd -P)/nextpnr/install_nextpnr_essentials.sh\""
eval "$3=\"$(pwd -P)/nextpnr/install_nextpnr.sh\""
else
local L_NAME_LOWER=`echo "$1" | tr [A-Z] [a-z]`
cp -r ../${L_NAME_LOWER} .
eval "$2=\"$(pwd -P)/${L_NAME_LOWER}/install_${L_NAME_LOWER}_essentials.sh\""
eval "$3=\"$(pwd -P)/${L_NAME_LOWER}/install_${L_NAME_LOWER}.sh\""
local L_CFG_FILES=`find "$(pwd -P)/${L_NAME_LOWER}" -iname "*.cfg"`
for CFG_FILE in $L_CFG_FILES; do
cp "$CFG_FILE" .
done
fi
}
# Copies version file $1 to the desktop of the users specified in $2
# Parameter $1: Version file path
# Parameter $2: User list
function copy_version_file {
if [ ! -f "$1" ]; then
return
fi
for L_USER in "$2"; do
local L_VERSION_USER_DESKTOP="$(getent passwd "$L_USER" | cut -d: -f6)/Desktop"
# TODO: add multiple language support
if [ ! -d "$L_VERSION_USER_DESKTOP" ]; then
mkdir "$L_VERSION_USER_DESKTOP"
fi
cp "$1" "$L_VERSION_USER_DESKTOP"
done
}
|
6.14. spinalhdl¶
6.14.1. install_spinalhdl_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="openjdk-8-jdk scala sbt"
# install and upgrade tools
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.15. yosys¶
6.15.1. install_yosys.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/YosysHQ/yosys.git"
PROJ="yosys"
BUILDFOLDER="build_and_install_yosys"
VERSIONFILE="installed_version.txt"
COMPILER="clang"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-b buildtool] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select compiler (buildtool), build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-b compiler specify compiler (default: ${COMPILER}, alternative: gcc)
-t tag specify version (git tag or commit hash) to pull (default: default branch)"
while getopts ':hi:cd:b:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:b:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
b) echo "-b set: Using compiler $OPTARG"
COMPILER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
make config-$COMPILER
make -j$(nproc)
if [ $INSTALL = true ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
make install
else
make install PREFIX="$INSTALL_PREFIX"
fi
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.15.2. install_yosys_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential clang bison flex libreadline-dev gawk tcl-dev \
libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev \
libboost-python-dev libboost-filesystem-dev zlib1g-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.16. icarusverilog¶
6.16.1. install_icarusverilog.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/steveicarus/iverilog.git"
PROJ="iverilog"
BUILDFOLDER="build_and_install_iverilog"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:t:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:t:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
autoconf
if [ "$INSTALL_PREFIX" == "default" ]; then
./configure
else
./configure --prefix="$INSTALL_PREFIX"
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.16.2. install_icarusverilog_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="make g++ autoconf flex bison gperf autoconf libbz2-1.0 libc6 libgcc-s1 \
libreadline8 libstdc++6 zlib1g"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.17. ghdl¶
6.17.1. install_ghdl.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/ghdl/ghdl.git"
REPO_LIBBACKTRACE="https://github.com/ianlancetaylor/libbacktrace.git"
REPO_GCC="https://gcc.gnu.org/git/gcc.git"
PROJ="ghdl"
BUILDFOLDER="build_and_install_ghdl"
VERSIONFILE="installed_version.txt"
TAG="latest"
INSTALL=false
INSTALL_PREFIX="default"
CLEANUP=false
BUILD_MCODE=false
BUILD_LLVM=false
BUILD_GCC=false
DEFAULT_PREFIX='/usr/local'
GHDL_GCC_SUFFIX='-ghdl'
BUILD_GCC_DEFAULT_CONFIG="--enable-languages=c,vhdl --disable-bootstrap \
--disable-lto --disable-multilib --disable-libssp --program-suffix=${GHDL_GCC_SUFFIX}"
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-m] [-l] [-g] [-d dir] [-i path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-g build GCC backend
-l build LLVM backend
-m build mcode backend
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ':hi:cd:glmt:' OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
esac
done
OPTIND=1
while getopts ':hi:cd:glmt:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
g) echo "-g set: Building GCC backend for GHDL"
BUILD_GCC=true
;;
l) echo "-l set: Building LLVM backend for GHDL"
BUILD_LLVM=true
;;
m) echo "-m set: Building MCODE backend for GHDL"
BUILD_MCODE=true
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
function build_mcode {
mkdir -p 'build_mcode'
pushd 'build_mcode' > /dev/null
local L_FAKE_PREFIX="$(pwd -P)/adjust_filename"
../configure --prefix="$L_FAKE_PREFIX"
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
# Add suffix (why does configure not offer it anyways?)
pushd $L_FAKE_PREFIX > /dev/null
for L_FILE in `find . -iname ghdl -type f`; do
mv $L_FILE ${L_FILE}-mcode
done
if [ "$INSTALL_PREFIX" != "default" ]; then
mkdir -p $INSTALL_PREFIX
cp -r ./* $INSTALL_PREFIX
else
mkdir -p $DEFAULT_PREFIX
cp -r ./* $DEFAULT_PREFIX
fi
popd > /dev/null
rm -r $L_FAKE_PREFIX
fi
popd > /dev/null
}
function build_llvm {
mkdir -p 'build_llvm'
pushd 'build_llvm' > /dev/null
local L_FAKE_PREFIX="$(pwd -P)/adjust_filename"
# compile latest libbacktrace.a to compile ghdl-llvm with stack backtrace support
if [ ! -d './libbacktrace' ]; then
git clone --recursive "$REPO_LIBBACKTRACE" 'libbacktrace'
fi
pushd 'libbacktrace' > /dev/null
./configure
make -j$(nproc)
local L_LIBBACKTRACE_PATH="$(pwd -P)/.libs/libbacktrace.a"
popd > /dev/null
../configure --with-llvm-config --with-backtrace-lib="$L_LIBBACKTRACE_PATH" --prefix="$L_FAKE_PREFIX"
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
# Add suffix (why does configure not offer it anyways?)
pushd $L_FAKE_PREFIX > /dev/null
for L_FILE in `find . -iname ghdl -type f`; do
mv $L_FILE ${L_FILE}-llvm
done
if [ "$INSTALL_PREFIX" != "default" ]; then
mkdir -p $INSTALL_PREFIX
cp -r ./* $INSTALL_PREFIX
else
mkdir -p $DEFAULT_PREFIX
cp -r ./* $DEFAULT_PREFIX
fi
popd > /dev/null
rm -r $L_FAKE_PREFIX
fi
popd > /dev/null
}
function build_gcc {
# download GCC sources
if [ ! -d 'gcc' ]; then
git clone --recursive "$REPO_GCC" 'gcc'
fi
# checkout latest release and buld prerequisites
pushd 'gcc' > /dev/null
local L_GCC_SRC_PATH=`pwd -P`
select_and_get_project_version 'stable' 'THROWAWAY_VAR' 'releases/*'
./contrib/download_prerequisites
popd > /dev/null
# configure ghdl-gcc
mkdir -p 'build_gcc'
pushd 'build_gcc' > /dev/null
if [ "$INSTALL_PREFIX" != 'default' ]; then
../configure --with-gcc="$L_GCC_SRC_PATH" --prefix="$INSTALL_PREFIX"
local L_GCC_CONFIG="--prefix=${INSTALL_PREFIX}"
else
../configure --with-gcc="$L_GCC_SRC_PATH"
local L_GCC_CONFIG=''
fi
make -j$(nproc) copy-sources
mkdir -p 'gcc-objs'
pushd 'gcc-objs' > /dev/null
# Check if the gcc used to compile ghdl-gcc uses default pie
if [ `gcc -v 2>&1 | grep -c -- "--enable-default-pie"` -gt 0 ]; then
L_GCC_CONFIG="${L_GCC_CONFIG} --enable-default-pie"
fi
$L_GCC_SRC_PATH/configure $L_GCC_CONFIG $BUILD_GCC_DEFAULT_CONFIG
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
popd > /dev/null
make -j$(nproc) ghdllib
if [ $INSTALL = true ]; then
make install
fi
popd > /dev/null
}
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# invalid configuration
if [ $BUILD_MCODE = false ] && [ $BUILD_LLVM = false ] && [ $BUILD_GCC = false ]; then
echo -e "${RED}ERROR: Invalid configuration (at least one of -m, -l and -g must be specified)${NC}"
exit 2
fi
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
if [ $BUILD_MCODE = true ]; then
build_mcode
fi
if [ $BUILD_LLVM = true ]; then
build_llvm
fi
if [ $BUILD_GCC = true ]; then
build_gcc
fi
# return to first folder and store version
pushd -0 > /dev/null
echo "${PROJ##*/}: $COMMIT_HASH" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.17.2. install_ghdl_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 23 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="build-essential git make gcc gnat llvm clang flex libc6 binutils gzip \
bzip2 tar perl autoconf m4 automake gettext gperf dejagnu expect tcl \
autogen guile-3.0 ssh texinfo"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.18. riscv_tools¶
6.18.1. install_riscv.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jul. 02 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/riscv/riscv-gnu-toolchain.git"
PROJ="riscv-gnu-toolchain"
BUILDFOLDER="build_and_install_riscv_gnu_toolchain"
VERSIONFILE="installed_version.txt"
TOOLCHAIN_SUFFIX="linux-multilib"
TAG="latest"
NEWLIB=false
# INSTALL=false
INSTALL_PATH="/opt/riscv"
PROFILE_PATH="/etc/profile"
CLEANUP=false
EXPORTPATH=false
VERSION_FILE_NAME="versions.cfg"
VERSION_FILE='## Define sourcecode branch
# default = use predefined versions from current riscv-gnu-toolchain branch
# or any arbitrary git tag or commit hash
# note that in most projects there is no master branch
QEMU=default
RISCV_BINUTILS=default
RISCV_DEJAGNU=default
RISCV_GCC=default
RISCV_GDB=default
RISCV_GLIBC=default
RISCV_NEWLIB=default
## Define which RiscV architectures and ABIs are supported (space seperated list "arch-abi")
# Taken from Sifive:
# https://github.com/sifive/freedom-tools/blob/120fa4d48815fc9e87c59374c499849934f2ce10/Makefile
NEWLIB_MULTILIBS_GEN="\
rv32e-ilp32e--c \
rv32ea-ilp32e--m \
rv32em-ilp32e--c \
rv32eac-ilp32e-- \
rv32emac-ilp32e-- \
rv32i-ilp32--c,f,fc,fd,fdc \
rv32ia-ilp32-rv32ima,rv32iaf,rv32imaf,rv32iafd,rv32imafd- \
rv32im-ilp32--c,f,fc,fd,fdc \
rv32iac-ilp32--f,fd \
rv32imac-ilp32-rv32imafc,rv32imafdc- \
rv32if-ilp32f--c,d,dc \
rv32iaf-ilp32f--c,d,dc \
rv32imf-ilp32f--d \
rv32imaf-ilp32f-rv32imafd- \
rv32imfc-ilp32f--d \
rv32imafc-ilp32f-rv32imafdc- \
rv32ifd-ilp32d--c \
rv32imfd-ilp32d--c \
rv32iafd-ilp32d-rv32imafd,rv32iafdc- \
rv32imafdc-ilp32d-- \
rv64i-lp64--c,f,fc,fd,fdc \
rv64ia-lp64-rv64ima,rv64iaf,rv64imaf,rv64iafd,rv64imafd- \
rv64im-lp64--c,f,fc,fd,fdc \
rv64iac-lp64--f,fd \
rv64imac-lp64-rv64imafc,rv64imafdc- \
rv64if-lp64f--c,d,dc \
rv64iaf-lp64f--c,d,dc \
rv64imf-lp64f--d \
rv64imaf-lp64f-rv64imafd- \
rv64imfc-lp64f--d \
rv64imafc-lp64f-rv64imafdc- \
rv64ifd-lp64d--c \
rv64imfd-lp64d--c \
rv64iafd-lp64d-rv64imafd,rv64iafdc- \
rv64imafdc-lp64d--"
# Linux install (cross-compile for linux)
# Default value from riscv-gcc repository
GLIBC_MULTILIBS_GEN="\
rv32imac-ilp32-rv32ima,rv32imaf,rv32imafd,rv32imafc,rv32imafdc- \
rv32imafdc-ilp32d-rv32imafd- \
rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- \
rv64imafdc-lp64d-rv64imafd-"'
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-n] [-d dir] [-t tag] [-u user] [-p path] -- Clone latested ${PROJ} version and build it. Optionally select compiler (buildtool), build directory and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-n use \"newlib multilib\" instead of \"linux multilib\" cross-compiler
-e extend PATH in by RiscV binary path (default: /etc/profile)
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-t tag specify version (git tag or commit hash) to pull (default: default branch)
-u user install RiscV tools for user \"user\". (default: install globally)
-p path choose install path (default: /opt/riscv)"
while getopts ':hcend:t:u:p:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
e) EXPORTPATH=true
echo "-e set: Extending PATH by RiscV binary path"
;;
n) echo "-n set: Using newlib cross-compiler"
NEWLIB=true
TOOLCHAIN_SUFFIX="newlib-multilib"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
p) echo "-p set: Using install path $OPTARG"
INSTALL_PATH="$OPTARG"
;;
u) echo "-u set: Installing for user $OPTARG"
PROFILE_PATH="$(grep $OPTARG /etc/passwd | cut -d ":" -f6)/.profile"
if [ ! -f "$PROFILE_PATH" ]; then
echo -e "${RED}ERROR: No .profile file found for user \"${OPTARG}\"${NC}" >&2
exit 1;
fi
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." >&2 && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# does the config exist?
if [ ! -f "$VERSION_FILE_NAME" ]; then
echo -e "${RED}Warning: No version.cfg file found. Generating file and using default versions${NC}";
echo "$VERSION_FILE" > "$VERSION_FILE_NAME"
fi
source "$VERSION_FILE_NAME"
CFG_LOCATION=`pwd -P`
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
VERSIONLIST="RiscV-GNU-Toolchain-${TOOLCHAIN_SUFFIX}: $COMMIT_HASH"
# fetch versions for all subrepos (as specified in versions.cfg)
while read LINE; do
if [ -n "$LINE" ] && [ "${LINE:0:1}" != "#" ]; then
SUBREPO=`echo "$LINE" | sed "s/[=].*$//"`
if [ -n "${!SUBREPO}" ]; then
SUBREPO_LOWER=`echo "$SUBREPO" | tr [A-Z,_] [a-z,-]`
if [ -d "$SUBREPO_LOWER" ]; then
pushd $SUBREPO_LOWER > /dev/null
if [ "${!SUBREPO}" != "default" ]; then
git checkout --recurse-submodules ${!SUBREPO}
fi
SUBREPO_COMMIT_HASH="$(git rev-parse HEAD)"
# set return value to tag name if available
# we have to cheat here: Since riscv-collaborators used branch names instead
# of tag names (why?!), we have to check both and hack the version a bit to
# indicate that.
POSSIBLE_TAGS=`git tag --points-at $SUBREPO_COMMIT_HASH`
if [ -n "$POSSIBLE_TAGS" ]; then
SUBREPO_COMMIT_HASH="${POSSIBLE_TAGS%%[$'\n']*}"
else
# check branches
POSSIBLE_BRANCHES=`git branch -r --points-at $SUBREPO_COMMIT_HASH`
if [ -n "$POSSIBLE_BRANCHES" ]; then
ONE_BRANCH="${POSSIBLE_BRANCHES%%[$'\n']*}"
# this is hacky. Extracts the number and anything after the number
# matching the the pattern d.d, where d is an arbitrary long number
SUBREPO_COMMIT_HASH="$(echo "$ONE_BRANCH" | grep -Po '\d+\.\d+.*') (${SUBREPO_COMMIT_HASH})"
fi
fi
popd > /dev/null
VERSIONLIST="${VERSIONLIST}\n${SUBREPO_LOWER}-${TOOLCHAIN_SUFFIX}: ${SUBREPO_COMMIT_HASH}"
fi
fi
fi
done < "${CFG_LOCATION}/${VERSION_FILE_NAME}"
# build and install if wanted
PATH="${INSTALL_PATH}:${PATH}"
if [ $NEWLIB = true ]; then
./configure --prefix=$INSTALL_PATH --enable-multilib --disable-linux
# activate custom multilibs
pushd "riscv-gcc/gcc/config/riscv" > /dev/null
chmod +x ./multilib-generator
./multilib-generator $NEWLIB_MULTILIBS_GEN > t-elf-multilib
popd > /dev/null
NEWLIB_MULTILIB_NAMES=`echo $NEWLIB_MULTILIBS_GEN | sed "s/-\(rv\(32\|64\)[a-zA-Z]*,*\)*-\([a-zA-Z]*,*\)*//g"`
echo "Building newlib-multilib for \"$NEWLIB_MULTILIB_NAMES\""
# build
make -j$(nproc) NEWLIB_MULTILIB_NAMES="$NEWLIB_MULTILIB_NAMES"
else
./configure --prefix=$INSTALL_PATH --enable-multilib --enable-linux
# activate custom multilibs
pushd "riscv-gcc/gcc/config/riscv" > /dev/null
chmod +x ./multilib-generator
./multilib-generator $GLIBC_MULTILIBS_GEN > t-linux-multilib
popd > /dev/null
GLIBC_MULTILIB_NAMES=`echo $GLIBC_MULTILIBS_GEN | sed "s/-\(rv\(32\|64\)[a-zA-Z]*,*\)*-\([a-zA-Z]*,*\)*//g"`
echo "Building linux-multilib for \"$GLIBC_MULTILIB_NAMES\""
# build
make -j$(nproc) GLIBC_MULTILIB_NAMES="$GLIBC_MULTILIB_NAMES" linux
fi
# extend path
if [ $EXPORTPATH = true ]; then
PATH_STRING="\n# Add RiscV tools to path
if [ -d \"${INSTALL_PATH}/bin\" ]; then
PATH=\"${INSTALL_PATH}/bin:\$PATH\"
fi"
if ! grep -q "PATH=\"${INSTALL_PATH}/bin:\$PATH\"" "$PROFILE_PATH"; then
echo -e "$PATH_STRING" >> "$PROFILE_PATH"
fi
fi
# return to first folder and store version
pushd -0 > /dev/null
echo -e "$VERSIONLIST" >> "$VERSIONFILE"
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.18.2. install_riscv_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jul. 02 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev \
libgmp-dev gawk build-essential bison flex texinfo gperf libtool \
patchutils bc zlib1g-dev libexpat-dev"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|
6.18.3. versions.cfg¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ## Define sourcecode branch
# default = use predefined versions from current riscv-gnu-toolchain branch
# or any arbitrary git tag or commit hash
# note that in most projects there is no master branch
QEMU=default
RISCV_BINUTILS=default
RISCV_DEJAGNU=default
RISCV_GCC=default
RISCV_GDB=default
RISCV_GLIBC=default
RISCV_NEWLIB=default
## Define which RiscV architectures and ABIs are supported (space seperated list "arch-abi")
# Taken from Sifive:
# https://github.com/sifive/freedom-tools/blob/120fa4d48815fc9e87c59374c499849934f2ce10/Makefile
NEWLIB_MULTILIBS_GEN="\
rv32e-ilp32e--c \
rv32ea-ilp32e--m \
rv32em-ilp32e--c \
rv32eac-ilp32e-- \
rv32emac-ilp32e-- \
rv32i-ilp32--c,f,fc,fd,fdc \
rv32ia-ilp32-rv32ima,rv32iaf,rv32imaf,rv32iafd,rv32imafd- \
rv32im-ilp32--c,f,fc,fd,fdc \
rv32iac-ilp32--f,fd \
rv32imac-ilp32-rv32imafc,rv32imafdc- \
rv32if-ilp32f--c,d,dc \
rv32iaf-ilp32f--c,d,dc \
rv32imf-ilp32f--d \
rv32imaf-ilp32f-rv32imafd- \
rv32imfc-ilp32f--d \
rv32imafc-ilp32f-rv32imafdc- \
rv32ifd-ilp32d--c \
rv32imfd-ilp32d--c \
rv32iafd-ilp32d-rv32imafd,rv32iafdc- \
rv32imafdc-ilp32d-- \
rv64i-lp64--c,f,fc,fd,fdc \
rv64ia-lp64-rv64ima,rv64iaf,rv64imaf,rv64iafd,rv64imafd- \
rv64im-lp64--c,f,fc,fd,fdc \
rv64iac-lp64--f,fd \
rv64imac-lp64-rv64imafc,rv64imafdc- \
rv64if-lp64f--c,d,dc \
rv64iaf-lp64f--c,d,dc \
rv64imf-lp64f--d \
rv64imaf-lp64f-rv64imafd- \
rv64imfc-lp64f--d \
rv64imafc-lp64f-rv64imafdc- \
rv64ifd-lp64d--c \
rv64imfd-lp64d--c \
rv64iafd-lp64d-rv64imafd,rv64iafdc- \
rv64imafdc-lp64d--"
# Linux install (cross-compile for linux)
# Default value from riscv-gcc repository
GLIBC_MULTILIBS_GEN="\
rv32imac-ilp32-rv32ima,rv32imaf,rv32imafd,rv32imafc,rv32imafdc- \
rv32imafdc-ilp32d-rv32imafd- \
rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- \
rv64imafdc-lp64d-rv64imafd-"
|
6.19. cocotb¶
6.19.1. install_cocotb_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Oct. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="g++ python3 python3-pip"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
# install cocotb
python3 -m pip install --upgrade pip
python3 -m pip install cocotb
|
6.20. nextpnr¶
6.20.1. install_nextpnr.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 25 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# constants
RED='\033[1;31m'
NC='\033[0m'
LIBRARY="../libraries/library.sh"
REPO="https://github.com/YosysHQ/nextpnr.git"
PROJ="nextpnr"
CHIP="ice40"
BUILDFOLDER="build_and_install_nextpnr"
VERSIONFILE="installed_version.txt"
TAG="latest"
LIBPATH=""
INSTALL=false
CLEANUP=false
# trellis config
TRELLIS_LIB="/usr"
TRELLIS_REPO="https://github.com/SymbiFlow/prjtrellis"
TRELLIS_PROJ="prjtrellis"
# icestorm config
ICESTORM_REPO="https://github.com/cliffordwolf/icestorm.git"
ICESTORM_PROJ="icestorm"
ICESTORM_LIB="/usr/local/share/icebox"
ICESTORM_ICEBOX_DIR="icestorm"
# parse arguments
USAGE="$(basename "$0") [-h] [-c] [-e] [-d dir] [-i path] [-l path] [-t tag] -- Clone latested tagged ${PROJ} version and build it. Optionally select the build directory, chip files, chipset and version, install binaries and cleanup setup files.
where:
-h show this help text
-c cleanup project
-e install NextPNR for ecp5 chips (default: ice40)
-d dir build files in \"dir\" (default: ${BUILDFOLDER})
-i path install binaries to path (use \"default\" to use default path)
-l path use local chip files for ice40 or ecp5 from \"path\" (use empty string for default path in ubuntu)
-t tag specify version (git tag or commit hash) to pull (default: Latest tag)"
while getopts ":hecd:i:t:l:" OPTION; do
case $OPTION in
i) INSTALL=true
INSTALL_PREFIX="$OPTARG"
echo "-i set: Installing built binaries to $INSTALL_PREFIX"
;;
e) echo "-e set: Installing NextPNR for ecp5 chipset"
CHIP="ecp5"
;;
esac
done
OPTIND=1
while getopts ':hecd:i:t:l:' OPTION; do
case "$OPTION" in
h) echo "$USAGE"
exit
;;
c) if [ $INSTALL = false ]; then
>&2 echo -e "${RED}ERROR: -c only makes sense if the built binaries were installed before (-i)"
exit 1
fi
CLEANUP=true
echo "-c set: Removing build directory"
;;
d) echo "-d set: Using folder $OPTARG"
BUILDFOLDER="$OPTARG"
;;
t) echo "-t set: Using version $OPTARG"
TAG="$OPTARG"
;;
l) echo "-l set: Using local chip data"
if [ -z "$OPTARG" ]; then
if [ "$CHIP" = "ice40" ]; then
LIBPATH="$ICESTORM_LIB"
else
LIBPATH="$TRELLIS_LIB"
fi
else
if [ ! -d "$OPTARG" ]; then
echo -e "${RED}ERROR: Invalid path \"${OPTARG}\""
exit 1
fi
LIBPATH="$OPTARG"
fi
;;
:) echo -e "${RED}ERROR: missing argument for -${OPTARG}\n${NC}" >&2
echo "$USAGE" >&2
exit 1
;;
\?) echo -e "${RED}ERROR: illegal option: -${OPTARG}\n${NC}" "$OPTARG" >&2
echo "$USAGE" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# exit when any command fails
set -e
# require sudo
if [[ $UID != 0 ]]; then
echo -e "${RED}Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# cleanup files if the programm was shutdown unexpectedly
trap 'echo -e "${RED}ERROR: Script was terminated unexpectedly, cleaning up files..." && pushd -0 > /dev/null && rm -rf $BUILDFOLDER' INT TERM
# load shared functions
source $LIBRARY
# fetch specified version
if [ ! -d $BUILDFOLDER ]; then
mkdir $BUILDFOLDER
fi
pushd $BUILDFOLDER > /dev/null
if [ ! -d "$PROJ" ]; then
git clone --recursive "$REPO" "${PROJ%%/*}"
fi
pushd $PROJ > /dev/null
select_and_get_project_version "$TAG" "COMMIT_HASH"
# build and install if wanted
# chip ice40?
if [ "$CHIP" = "ice40" ]; then
# is icestorm installed?
if [ -n "$LIBPATH" ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -DARCH=ice40 -DICEBOX_ROOT=${LIBPATH} .
else
cmake -DARCH=ice40 -DICEBOX_ROOT=${LIBPATH} -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
else
echo "Note: Pulling Icestorm from Github."
if [ ! -d "$ICESTORM_PROJ" ]; then
git clone $ICESTORM_REPO "$ICESTORM_ICEBOX_DIR"
fi
NEXTPNR_FOLDER=`pwd -P`
# build icebox (chipdbs)
pushd "${ICESTORM_ICEBOX_DIR}/icebox" > /dev/null
make -j$(nproc)
make install DESTDIR=$NEXTPNR_FOLDER PREFIX=''
popd +0 > /dev/null
# build icetime (timing)
pushd "${ICESTORM_ICEBOX_DIR}/icetime" > /dev/null
make -j$(nproc) PREFIX=$NEXTPNR_FOLDER
make install DESTDIR=$NEXTPNR_FOLDER PREFIX=''
popd +0 > /dev/null
# build nextpnr-ice40 next
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -j$(nproc) -DARCH=ice40 -DICEBOX_ROOT="${NEXTPNR_FOLDER}/share/icebox" .
else
cmake -j$(nproc) -DARCH=ice40 -DICEBOX_ROOT="${NEXTPNR_FOLDER}/share/icebox" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
fi
# chip ecp5?
else
# is project trellis installed?
if [ -d "$LIBPATH" ]; then
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX=${LIBPATH} .
else
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX=${LIBPATH} -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
else
echo "Note: Pulling Trellis from Github."
if [ ! -d "$TRELLIS_PROJ" ]; then
git clone --recursive $TRELLIS_REPO
fi
TRELLIS_MAKE_PATH="$(pwd -P)/${TRELLIS_PROJ}/libtrellis"
pushd "$TRELLIS_MAKE_PATH" > /dev/null
cmake -j$(nproc) -DCMAKE_INSTALL_PREFIX="$TRELLIS_MAKE_PATH" .
make -j$(nproc)
make install
popd +0 > /dev/null
if [ "$INSTALL_PREFIX" == "default" ]; then
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX="$TRELLIS_MAKE_PATH" .
else
cmake -j$(nproc) -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX="$TRELLIS_MAKE_PATH" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" .
fi
fi
fi
make -j$(nproc)
if [ $INSTALL = true ]; then
make install
fi
# return to first folder and store version
pushd -0 > /dev/null
if [ "$CHIP" == "ice40" ]; then
echo "${PROJ##*/}-ice40: $COMMIT_HASH" >> "$VERSIONFILE"
else
echo "${PROJ##*/}-ecp5: $COMMIT_HASH" >> "$VERSIONFILE"
fi
# cleanup if wanted
if [ $CLEANUP = true ]; then
rm -rf $BUILDFOLDER
fi
|
6.20.2. install_nextpnr_essentials.sh¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/bash
# Author: Harald Heckmann <mail@haraldheckmann.de>
# Date: Jun. 24 2020
# Project: QuantumRisc (RheinMain University) <Steffen.Reith@hs-rm.de>
# require sudo
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
# exit when any command fails
set -e
# required tools
TOOLS="clang-format qt5-default libboost-dev libboost-filesystem-dev \
libboost-thread-dev libboost-program-options-dev libboost-python-dev \
libboost-iostreams-dev libboost-dev libeigen3-dev python3-dev cmake"
# install and upgrade tools
apt-get update
apt-get install -y $TOOLS
apt-get install --only-upgrade -y $TOOLS
|