Philipp Wagner | c120b18 | 2020-09-17 11:53:03 +0100 | [diff] [blame] | 1 | --- |
| 2 | title: Install Build Requirements |
| 3 | --- |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 4 | |
Philipp Wagner | 5a11f5b | 2019-10-03 14:02:49 +0100 | [diff] [blame] | 5 | ## System requirements |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 6 | |
Philipp Wagner | 5a11f5b | 2019-10-03 14:02:49 +0100 | [diff] [blame] | 7 | This guide makes assumes the following system setup. |
| 8 | |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 9 | * A reasonably powerful PC. |
Philipp Wagner | 5a11f5b | 2019-10-03 14:02:49 +0100 | [diff] [blame] | 10 | Using a virtual machine can work, but will slow down builds considerably. |
| 11 | 8 GB of RAM or more are highly recommended. |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 12 | * Physical access to that machine, root permissions and a graphical environment are assumed in this guide. |
| 13 | However, with an appropriate setup, none of these things are strictly needed. |
| 14 | * 60 GB or more of disk space, depending on the EDA tools used. |
| 15 | (EDA tools like Xilinx Vivado can easily take up 40 GB each.) |
| 16 | * Linux |
Philipp Wagner | dbe7a74 | 2020-10-06 12:36:11 +0100 | [diff] [blame] | 17 | * Ubuntu 18.04 LTS is the recommended reference platform. |
| 18 | Our continuous integration setup runs on Ubuntu 18.04 LTS, which gives us the most confidence that this distribution works out of the box. |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 19 | * We do our best to support other Linux distributions. |
| 20 | However, we cannot guarantee they can be used "out of the box" and might require updates of packages. |
| 21 | Please file a [GitHub issue](https://github.com/lowRISC/opentitan/issues) if you need help or would like to propose a change to increase compatibility with other distributions. |
| 22 | * RedHat Enterprise Linux (RHEL)/CentOS. |
Philipp Wagner | 5a11f5b | 2019-10-03 14:02:49 +0100 | [diff] [blame] | 23 | |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 24 | On RHEL/CentOS not all required packages are part of the base distribution; however, they can be installed easily. |
| 25 | All required packages except for a C/C++ compiler can be obtained by enabling the [EPEL repository](https://fedoraproject.org/wiki/EPEL). |
| 26 | A sufficiently recent version of GCC or LLVM (clang) can be obtained through [Red Hat Software Collections](https://www.softwarecollections.org/en/). |
| 27 | SCLs can also be used to obtain newer version of Python if needed. |
| 28 | |
| 29 | * Many of our contributors use rolling release distributions, which generally include the latest stable releases of all software packages, such as Debian unstable, openSUSE Tumbleweed, or Arch Linux. |
| 30 | |
| 31 | The following software packages are required to build and use the software, hardware, and tools in the OpenTitan repository. |
| 32 | Not every interaction with the repository requires all tools -- however, we recommend users installing all dependencies listed below for a seamless development experience. |
| 33 | |
| 34 | Note: Version numbers given below indicate a minimum version, newer versions are generally expected to work, unless explicitly stated. |
| 35 | For packages listed below without a version number we have not determined a minimum version. |
| 36 | |
| 37 | * git |
Philipp Wagner | dbe7a74 | 2020-10-06 12:36:11 +0100 | [diff] [blame] | 38 | * Python 3.6 with pip. |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 39 | Additional Python dependencies are installed through pip. |
| 40 | * A C++14 capable compiler. |
| 41 | GCC 5 or Clang 3.5 should meet this requirement. |
| 42 | * clang-format. |
Philipp Wagner | dbe7a74 | 2020-10-06 12:36:11 +0100 | [diff] [blame] | 43 | The use of clang-format 6.0 is recommended to match the formatting enforced when submitting a pull request. |
Rupert Swarbrick | 9ab407e | 2021-01-25 11:40:17 +0000 | [diff] [blame] | 44 | * [ninja](https://ninja-build.org/) {{< tool_version "ninja" >}} |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 45 | * Bash |
| 46 | * curl |
| 47 | * xz tools |
| 48 | * LSB core packages (only the `lsb_release` tool must be available) |
| 49 | * srecord |
| 50 | * GNU make |
| 51 | * pkg-config or pkgconf |
| 52 | * libelf with development headers |
| 53 | * libftdi with development headers |
| 54 | * OpenSSL 1.0 or 1.1 with development headers |
| 55 | * libusb 1.0 (called libusbx in older distributions) |
Philipp Wagner | 4a7b5a0 | 2021-03-17 15:06:56 +0000 | [diff] [blame] | 56 | * OpenOCD 0.11.0 |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 57 | * [Verible](https://github.com/google/verible) {{< tool_version "verible" >}} |
Philipp Wagner | 04ed12f | 2021-05-31 21:01:17 +0100 | [diff] [blame] | 58 | * Cmake 3.3 |
Alphan Ulusoy | e220589 | 2021-05-13 09:36:17 -0400 | [diff] [blame] | 59 | * Perl 5.6.1 |
Philipp Wagner | 04ed12f | 2021-05-31 21:01:17 +0100 | [diff] [blame] | 60 | * [Go](https://golang.org/) 1.11 |
Alphan Ulusoy | b91333a | 2021-05-13 09:45:14 -0400 | [diff] [blame] | 61 | * [Rust](https://www.rust-lang.org/) {{< tool_version "rust" >}} (x86_64-unknown-linux-gnu) |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 62 | |
| 63 | To synthesize and simulate the hardware components of OpenTitan multiple EDA tools are supported. |
| 64 | Depending on how you interact with the OpenTitan hardware code, one of more of the following tools need to be available. |
| 65 | |
| 66 | * [Verilator](https://verilator.org) {{< tool_version "verilator" >}} |
Pirmin Vogel | 37ee04a | 2021-05-25 13:38:27 +0200 | [diff] [blame] | 67 | * Xilinx Vivado {{< tool_version "vivado" >}} |
Philipp Wagner | b8b053f | 2021-05-25 09:26:34 +0100 | [diff] [blame] | 68 | (Do not use versions earlier than 2020.2 due to a [critical synthesis bug](https://forums.xilinx.com/t5/Synthesis/Simulation-Synthesis-Mismatch-with-Vivado-2018-3/m-p/1065923#M33849).) |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 69 | * Synopsys VCS |
| 70 | * Cadence Xcelium |
| 71 | * Cadence JasperGold |
| 72 | * RealIntent Ascent Lint |
| 73 | * Synopsys Design Compiler (DC) |
| 74 | |
| 75 | To build our documentation the following additional sofware packages are required. |
| 76 | |
| 77 | * [Hugo extended](https://gohugo.io/) {{< tool_version "hugo_extended" >}}. |
| 78 | A supported binary build of Hugo is installed when building the documentation. |
| 79 | However, the binaries do not run on very old distributions, such as RHEL 6. |
| 80 | In this case, Hugo must be installed separately (e.g. by building it from source). |
Philipp Wagner | dbe7a74 | 2020-10-06 12:36:11 +0100 | [diff] [blame] | 81 | * [doxygen](https://www.doxygen.nl/) 1.8 |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 82 | * xsltproc |
Philipp Wagner | 5a11f5b | 2019-10-03 14:02:49 +0100 | [diff] [blame] | 83 | |
| 84 | ## System preparation |
| 85 | |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 86 | <div class="bd-callout bd-callout-warning"> |
| 87 | <h5>Note</h5> |
| 88 | |
Philipp Wagner | dbe7a74 | 2020-10-06 12:36:11 +0100 | [diff] [blame] | 89 | This documentation and the following steps in general assume our reference distribution, Ubuntu 18.04. |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 90 | Users inexperienced with Linux and OpenTitan are strongly encouraged to use this distribution for a seamless development experience. |
| 91 | |
| 92 | Users of other Linux distributions should use these steps as guidance, but will need to adjust them as necessary. |
| 93 | Please file [GitHub issues](https://github.com/opentitan/issues/new) if you have questions. |
| 94 | </div> |
| 95 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 96 | By convention tools which are not provided through a package manager will be installed into `/tools`. |
| 97 | This directory can be replaced by any sufficiently large directory without spaces in the directory name. |
| 98 | It is assumed that the user executing the build instructions has full write permissions to this directory; the following commands ensure that. |
| 99 | |
| 100 | ```console |
| 101 | $ sudo mkdir /tools |
| 102 | $ sudo chown $(id -un) /tools |
| 103 | ``` |
| 104 | |
Greg Chadwick | 567cfd6 | 2019-10-31 16:15:33 +0000 | [diff] [blame] | 105 | ### Clone repository |
| 106 | |
Tobias Wölfel | dfff26f | 2020-02-25 12:35:23 +0100 | [diff] [blame] | 107 | If you intend to contribute back to OpenTitan you will want your own fork of the repository on GitHub and to work using that, see the [notes for using GitHub]({{< relref "doc/ug/github_notes.md" >}}). |
Greg Chadwick | 567cfd6 | 2019-10-31 16:15:33 +0000 | [diff] [blame] | 108 | Otherwise make a simple clone of the main OpenTitan repository. |
| 109 | |
| 110 | ```console |
| 111 | $ cd <working-area> |
| 112 | $ git clone https://github.com/lowRISC/opentitan.git |
| 113 | ``` |
| 114 | |
Philipp Wagner | 6f1abb9 | 2020-10-09 12:24:01 +0200 | [diff] [blame] | 115 | The repository will be checked out into `<working-area>/opentitan` (this is the `$REPO_TOP` path). |
Greg Chadwick | 567cfd6 | 2019-10-31 16:15:33 +0000 | [diff] [blame] | 116 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 117 | ### Install required software |
| 118 | |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 119 | A number of software packages from the distribution's package manager are required. |
| 120 | On Ubuntu 18.04, the required packages can be installed with the following command. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 121 | |
Pirmin Vogel | 3ff52be | 2021-01-20 18:20:25 +0100 | [diff] [blame] | 122 | {{< pkgmgr_cmd "apt" >}} |
| 123 | |
| 124 | Our recommended reference platform is Ubuntu 18.04, but the command can be adjusted as necessary for other Linux distributions. |
| 125 | |
| 126 | For example, for Red Hat Enterprise Linux (RHEL) 7 and derivatives (such as CentOS 7) the following packages are required. |
| 127 | Note that we don't have the possibilities to actively verify that our instructions continue work on RHEL/CentOS and hence also can't test anything on these distributions. |
| 128 | The following instructions are effectively community contributed and we encourage users to raise pull requests if they find the package requirements to be outdated. |
| 129 | First of all, the [EPEL repository](https://fedoraproject.org/wiki/EPEL) has to be enabled. |
| 130 | A sufficiently recent version of GCC or LLVM (clang) can be obtained through [Red Hat Software Collections](https://www.softwarecollections.org/en/). |
| 131 | Then run the following command to install the required package dependencies on RHEL/CentOS 7. |
| 132 | |
| 133 | {{< pkgmgr_cmd "yum" >}} |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 134 | |
Philipp Wagner | 4120040 | 2019-10-30 14:52:59 +0000 | [diff] [blame] | 135 | Some tools in this repository are written in Python 3 and require Python dependencies to be installed through `pip`. |
Alex Bradbury | 37ff22a | 2021-08-27 10:18:18 +0100 | [diff] [blame] | 136 | We recommend installing the latest version of `pip` and `setuptools` (especially if on older systems such as Ubuntu 18.04) using: |
| 137 | |
| 138 | ```console |
| 139 | python3 -m pip install --user -U pip setuptools |
| 140 | ``` |
| 141 | |
| 142 | The `pip` installation instructions use the `--user` flag to install without root permissions. |
| 143 | Binaries are installed to `~/.local/bin`; check that this directory is listed in your `PATH` by running `which pip3`, which should show `~/.local/bin/pip3`. |
| 144 | If it doesn't, add `~/.local/bin` to your `PATH`, e.g. by modifying your `~/.bashrc` file. |
| 145 | |
| 146 | Now install additional Python dependencies: |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 147 | |
| 148 | ```console |
| 149 | $ cd $REPO_TOP |
| 150 | $ pip3 install --user -r python-requirements.txt |
| 151 | ``` |
| 152 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 153 | |
| 154 | ## Software development |
| 155 | |
Philipp Wagner | ac73258 | 2019-10-30 14:53:17 +0000 | [diff] [blame] | 156 | ### Device compiler toolchain (RV32IMC) |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 157 | |
Philipp Wagner | ac73258 | 2019-10-30 14:53:17 +0000 | [diff] [blame] | 158 | To build device software you need a baremetal RV32IMC compiler toolchain. |
Luís Marques | 5849cd1 | 2020-06-26 10:33:55 +0100 | [diff] [blame] | 159 | We recommend using a prebuilt toolchain provided by lowRISC. |
| 160 | Alternatively, you can build your own. |
| 161 | Whichever option you choose, we recommend installing the toolchain to `/tools/riscv`. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 162 | |
Luís Marques | 5849cd1 | 2020-06-26 10:33:55 +0100 | [diff] [blame] | 163 | #### Option 1 (recommended): Use the lowRISC-provided prebuilt toolchain |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 164 | |
Luís Marques | 5849cd1 | 2020-06-26 10:33:55 +0100 | [diff] [blame] | 165 | lowRISC provides a prebuilt toolchain for the OpenTitan project. |
| 166 | This toolchain contains both GCC and Clang, targeting RISC-V. |
| 167 | By default the device software is built with Clang. |
| 168 | We recommend using the `util/get-toolchain.py` tool to download and install the latest version of this toolchain. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 169 | |
| 170 | ```cmd |
| 171 | $ cd $REPO_TOP |
| 172 | $ ./util/get-toolchain.py |
| 173 | ``` |
| 174 | |
Srikrishna Iyer | 98333ba | 2020-11-16 23:12:29 -0800 | [diff] [blame] | 175 | This tool will automatically adjust the toolchain configuration if you override the installation directory (by using the `--install-dir` option). |
| 176 | It also provides the ability to perform a staged installation (by supplying a `--dest-dir` option), if the toolchain needs to be unpacked first at a temporary staging directory, before it can be moved to the final installation directory. |
| 177 | Alternatively, manually download the file starting with `lowrisc-toolchain-rv32imc-` from [GitHub releases](https://github.com/lowRISC/lowrisc-toolchains/releases/latest) and unpack it to the desired installation directory. |
Luís Marques | 5849cd1 | 2020-06-26 10:33:55 +0100 | [diff] [blame] | 178 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 179 | #### Option 2: Compile your own GCC toolchain |
| 180 | |
| 181 | 1. Install all build prerequisites listed [in the documentation](https://github.com/riscv/riscv-gnu-toolchain/#prerequisites). |
| 182 | |
Sam Elliott | 685449b | 2019-11-12 12:36:13 +0000 | [diff] [blame] | 183 | 2. Build the toolchain (this should be done outside the `$REPO_TOP` directory): |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 184 | ```console |
| 185 | $ git clone --recursive https://github.com/riscv/riscv-gnu-toolchain |
| 186 | $ cd riscv-gnu-toolchain |
| 187 | $ ./configure --prefix=/tools/riscv --with-abi=ilp32 --with-arch=rv32imc --with-cmodel=medany |
| 188 | $ make |
| 189 | ``` |
| 190 | |
Sam Elliott | 4cac9ec | 2020-06-03 11:53:04 +0100 | [diff] [blame] | 191 | The `make` command installs the toolchain to `/tools/riscv`, no additional `make install` step is needed. |
| 192 | |
| 193 | 3. Write a [meson toolchain configuration file](https://mesonbuild.com/Cross-compilation.html#defining-the-environment) for your toolchain. |
| 194 | It should look like the following (though your paths may be different): |
| 195 | ```ini |
| 196 | [binaries] |
| 197 | c = '/tools/riscv/bin/riscv32-unknown-elf-gcc' |
| 198 | cpp = '/tools/riscv/bin/riscv32-unknown-elf-g++' |
| 199 | ar = '/tools/riscv/bin/riscv32-unknown-elf-ar' |
| 200 | ld = '/tools/riscv/bin/riscv32-unknown-elf-ld' |
| 201 | objdump = '/tools/riscv/bin/riscv32-unknown-elf-objdump' |
| 202 | objcopy = '/tools/riscv/bin/riscv32-unknown-elf-objcopy' |
| 203 | strip = '/tools/riscv/bin/riscv32-unknown-elf-strip' |
Philipp Wagner | a889e7c | 2020-08-31 22:48:27 +0100 | [diff] [blame] | 204 | as = '/tools/riscv/bin/riscv32-unknown-elf-as' |
Sam Elliott | 4cac9ec | 2020-06-03 11:53:04 +0100 | [diff] [blame] | 205 | |
| 206 | [properties] |
| 207 | needs_exe_wrapper = true |
| 208 | has_function_printf = false |
| 209 | c_args = ['-march=rv32imc', '-mabi=ilp32', '-mcmodel=medany'] |
Luís Marques | 5849cd1 | 2020-06-26 10:33:55 +0100 | [diff] [blame] | 210 | c_link_args = ['-march=rv32imc', '-mabi=ilp32', '-mcmodel=medany'] |
Sam Elliott | 4cac9ec | 2020-06-03 11:53:04 +0100 | [diff] [blame] | 211 | cpp_args = ['-march=rv32imc', '-mabi=ilp32', '-mcmodel=medany'] |
Luís Marques | 5849cd1 | 2020-06-26 10:33:55 +0100 | [diff] [blame] | 212 | cpp_link_args = ['-march=rv32imc', '-mabi=ilp32', '-mcmodel=medany'] |
Sam Elliott | 4cac9ec | 2020-06-03 11:53:04 +0100 | [diff] [blame] | 213 | |
| 214 | [host_machine] |
| 215 | system = 'bare metal' |
| 216 | cpu_family = 'riscv32' |
| 217 | cpu = 'ibex' |
| 218 | endian = 'little' |
| 219 | ``` |
| 220 | |
| 221 | You will need to pass the path to this file to `./meson_init.sh` using the `-t FILE` option. |
| 222 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 223 | |
| 224 | ### OpenOCD |
| 225 | |
| 226 | OpenOCD is a tool to connect with the target chip over JTAG and similar transports. |
| 227 | It also provides a GDB server which is an "intermediate" when debugging software on the chip with GDB. |
| 228 | |
Philipp Wagner | 4a7b5a0 | 2021-03-17 15:06:56 +0000 | [diff] [blame] | 229 | At least OpenOCD 0.11.0 is required. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 230 | |
Philipp Wagner | 4a7b5a0 | 2021-03-17 15:06:56 +0000 | [diff] [blame] | 231 | It is recommended to use the regular upstream version of OpenOCD instead of the [RISC-V downstream fork](https://github.com/riscv/riscv-openocd). |
| 232 | |
| 233 | As most distributions do not yet include OpenOCD 0.11 in its package repositories building from source is likely to be required. |
| 234 | The following steps build OpenOCD (this should be done outside the `$REPO_TOP` directory): |
Sam Elliott | 685449b | 2019-11-12 12:36:13 +0000 | [diff] [blame] | 235 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 236 | ```console |
Philipp Wagner | 4a7b5a0 | 2021-03-17 15:06:56 +0000 | [diff] [blame] | 237 | $ wget https://downloads.sourceforge.net/project/openocd/openocd/0.11.0/openocd-0.11.0.tar.bz2 |
| 238 | $ tar -xf openocd-0.11.0.tar.bz2 |
| 239 | $ cd openocd-0.11.0/ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 240 | $ mkdir build |
| 241 | $ cd build |
| 242 | $ ../configure --enable-ftdi --enable-verbose-jtag-io --disable-vsllink --enable-remote-bitbang --prefix=/tools/openocd |
| 243 | $ make -j4 |
| 244 | $ sudo make install |
| 245 | ``` |
| 246 | |
| 247 | ## Verilator |
| 248 | |
| 249 | Even though Verilator is packaged for most Linux distributions these versions tend to be too old to be usable. |
| 250 | We recommend compiling Verilator from source, as outlined here. |
| 251 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 252 | ### Install Verilator |
| 253 | |
Sam Elliott | 685449b | 2019-11-12 12:36:13 +0000 | [diff] [blame] | 254 | Then you can fetch, build and install Verilator itself (this should be done outside the `$REPO_TOP` directory). |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 255 | |
| 256 | ```console |
Pirmin Vogel | 0761f1c | 2020-03-09 17:47:45 +0100 | [diff] [blame] | 257 | $ export VERILATOR_VERSION={{< tool_version "verilator" >}} |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 258 | |
Philipp Wagner | c16764a | 2020-10-06 16:06:04 +0100 | [diff] [blame] | 259 | $ git clone https://github.com/verilator/verilator.git |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 260 | $ cd verilator |
| 261 | $ git checkout v$VERILATOR_VERSION |
| 262 | |
| 263 | $ autoconf |
| 264 | $ ./configure --prefix=/tools/verilator/$VERILATOR_VERSION |
| 265 | $ make |
| 266 | $ make install |
| 267 | ``` |
| 268 | |
| 269 | After installation you need to add `/tools/verilator/$VERILATOR_VERSION/bin` to your `PATH` environment variable. |
| 270 | |
Michael Schaffner | 29553ae | 2020-04-17 15:44:56 -0700 | [diff] [blame] | 271 | ## Verible |
| 272 | |
| 273 | Verible is an open source SystemVerilog style linter and formatting tool. |
| 274 | The style linter is relatively mature and we use it as part of our [RTL design flow]({{< relref "doc/ug/design" >}}). |
| 275 | The formatter is still under active development, and hence its usage is more experimental in OpenTitan. |
| 276 | |
| 277 | You can download and build Verible from scratch as explained on the [Verible GitHub page](https://github.com/google/verible/). |
| 278 | But since this requires the Bazel build system the recommendation is to download and install a pre-built binary as described below. |
| 279 | |
| 280 | ### Install Verible |
| 281 | |
| 282 | Go to [this page](https://github.com/google/verible/releases) and download the correct binary archive for your machine. |
Philipp Wagner | dbe7a74 | 2020-10-06 12:36:11 +0100 | [diff] [blame] | 283 | The example below is for Ubuntu 18.04: |
Michael Schaffner | 29553ae | 2020-04-17 15:44:56 -0700 | [diff] [blame] | 284 | |
| 285 | ```console |
| 286 | $ export VERIBLE_VERSION={{< tool_version "verible" >}} |
| 287 | |
Robert Schilling | b1f58aa | 2021-02-26 16:01:54 +0100 | [diff] [blame] | 288 | $ wget https://github.com/google/verible/releases/download/${VERIBLE_VERSION}/verible-${VERIBLE_VERSION}-Ubuntu-18.04-bionic-x86_64.tar.gz |
Michael Schaffner | aa193f9 | 2020-12-16 11:16:17 -0800 | [diff] [blame] | 289 | $ tar -xf verible-${VERIBLE_VERSION}-Ubuntu-18.04-bionic-x86_64.tar.gz |
Michael Schaffner | 29553ae | 2020-04-17 15:44:56 -0700 | [diff] [blame] | 290 | |
| 291 | $ sudo mkdir -p /tools/verible/${VERIBLE_VERSION}/ |
Michael Schaffner | aa193f9 | 2020-12-16 11:16:17 -0800 | [diff] [blame] | 292 | $ sudo mv verible-${VERIBLE_VERSION}/* /tools/verible/${VERIBLE_VERSION}/ |
Michael Schaffner | 29553ae | 2020-04-17 15:44:56 -0700 | [diff] [blame] | 293 | ``` |
| 294 | |
| 295 | After installation you need to add `/tools/verible/$VERIBLE_VERSION/bin` to your `PATH` environment variable. |
| 296 | |
| 297 | Note that we currently use version {{< tool_version "verible" >}}, but it is expected that this version is going to be updated frequently, since the tool is under active develpment. |
| 298 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 299 | ## Xilinx Vivado |
| 300 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 301 | ### About Xilinx Vivado |
| 302 | |
| 303 | To generate a bitstream for Xilinx devices a software called Vivado is required. |
| 304 | Vivado is provided by Xilinx, it is freeware for certain (smaller) FPGA devices but requires a commercial license for larger FPGAs. |
| 305 | The free version is called "WebPACK", the commercial version "Design Edition". |
| 306 | The installation instructions below are valid for both installation methods. |
| 307 | |
| 308 | Most lowRISC designs support at least one FPGA board which works with a free WebPACK license. |
| 309 | |
| 310 | ### Install Xilinx Vivado |
| 311 | |
Pirmin Vogel | 37ee04a | 2021-05-25 13:38:27 +0200 | [diff] [blame] | 312 | _**Vivado Version:** The recommendation is to use Vivado {{< tool_version "vivado" >}}. |
Jade Philipoom | 03ad3e4 | 2021-11-08 10:20:44 +0000 | [diff] [blame] | 313 | The following instructions have been tested with Vivado 2020.2. |
| 314 | Some screenshots are generated from Vivado 2020.1, but the installation process has not changed. |
Pirmin Vogel | 37ee04a | 2021-05-25 13:38:27 +0200 | [diff] [blame] | 315 | Vivado 2019.1 and all its minor updates are not compatible with this project._ |
Tobias Wölfel | 1ac6d4a | 2019-10-08 08:27:10 +0200 | [diff] [blame] | 316 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 317 | Vivado can be installed in two ways: either through an "All OS installer Single-File Download", or via the "Linux Self Extracting Web Installer". |
| 318 | Neither option is great: |
| 319 | the "All OS installer" is a huge download of around 20 GB (and the Xilinx download servers seem to be overloaded regularly), but it supports an unattended installation. |
| 320 | The web installer downloads only necessary subsets of the software, which significantly reduces the download size. |
| 321 | But unfortunately it doesn't support the batch mode for unattended installations, requiring users to click through the GUI and select the right options. |
| 322 | |
| 323 | To get started faster we use the web installer in the following. |
| 324 | |
Jade Philipoom | 03ad3e4 | 2021-11-08 10:20:44 +0000 | [diff] [blame] | 325 | 1. Go to the [Xilinx download page](https://www.xilinx.com/support/download.html). Select Vivado {{< tool_version "vivado" >}} from the left-hand side and download two files: |
| 326 | 1. The file "Xilinx Unified Installer {{< tool_version "vivado" >}}: Linux Self Extracting Web Installer". |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 327 | 2. The "Digests" file below the download. |
| 328 | |
| 329 |  |
| 330 | |
| 331 | You need to register for a free Xilinx account to download the software, and you'll need it again later to install the software. |
| 332 | Create a new account if you don't have one yet. |
| 333 | |
| 334 | 2. Before you proceed ensure that the download didn't get corrupted by verifying the checksum. |
| 335 | |
| 336 | ```console |
Jade Philipoom | 03ad3e4 | 2021-11-08 10:20:44 +0000 | [diff] [blame] | 337 | $ sha512sum --check Xilinx_Unified_2020.2_1118_1232_Lin64.bin.digests |
| 338 | Xilinx_Unified_2020.2_1118_1232_Lin64.bin: OK |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 339 | sha512sum: WARNING: 22 lines are improperly formatted |
| 340 | ``` |
| 341 | |
| 342 | If you see an "OK" after the downloaded file proceed to the next step. Otherwise delete the download and start over. (You can ignore the warning produced by `sha512sum`.) |
Jade Philipoom | 03ad3e4 | 2021-11-08 10:20:44 +0000 | [diff] [blame] | 343 | 3. Run the graphical installer. It may warn you that a newer version is available; you can ignore the warning. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 344 | |
| 345 | ```console |
Jade Philipoom | 03ad3e4 | 2021-11-08 10:20:44 +0000 | [diff] [blame] | 346 | $ sh Xilinx_Unified_2020.2_1118_1232_Lin64.bin |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 347 | ``` |
| 348 | |
| 349 | 4. Now you need to click through the installer. |
| 350 | Click "Next" on the first screen. |
| 351 | |
| 352 |  |
| 353 | |
| 354 | 5. Type in your Xilinx User ID (your email address) and the associated password. |
| 355 | Choose the "Download and Install Now" option. |
| 356 | Click "Next" to continue. |
| 357 | |
| 358 |  |
| 359 | |
| 360 | 6. Click all "I Agree" checkboxes, and click on "Next" to continue. |
| 361 | |
| 362 |  |
| 363 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 364 | 7. Choose "Vivado", and click on "Next" to continue. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 365 | |
| 366 |  |
| 367 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 368 | 8. Choose "Vivado HL Design Edition". |
| 369 | This is required to enable support for the Xilinx Kintex 7 XC7K410T FPGA device found on the ChipWhisperer CW310 board. |
| 370 | You'll need a commercial Vivado license for this FPGA device. |
Philipp Wagner | 04ed12f | 2021-05-31 21:01:17 +0100 | [diff] [blame] | 371 | Without a valid license, you are still able to install the Vivado HL Design Edition but you'll only be able to work with devices supported by the free WebPACK license. |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 372 | If you don't have a valid license and if you're only planning to work with devices supported by the free WebPACK license, you can also choose "Vivado HL WebPACK" instead. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 373 | |
| 374 |  |
| 375 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 376 | 9. Choose the features to install. |
| 377 | You can restrict the features to the ones shown in the screenshot below. |
| 378 | Click "Next" to continue. |
| 379 | |
| 380 |  |
| 381 | |
| 382 | 10. Choose an installation location. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 383 | Any location which doesn't have a whitespace in its path and enough free space is fine. |
| 384 | We use `/tools` in our example, but a path in `/opt` or within the home directory works equally well. |
| 385 | Click "Next" to continue. |
| 386 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 387 |  |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 388 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 389 | 11. Double-check the installation summary and click on "Install" to start the installation process. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 390 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 391 |  |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 392 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 393 | 12. Now Vivado is downloaded and installed, a process which can easily take multiple hours. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 394 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 395 |  |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 396 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 397 | 13. As soon as the installation has completed close the installer and you're now ready to use Vivado! |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 398 | |
| 399 | ### Device permissions: udev rules |
| 400 | |
| 401 | To program FPGAs user using Vivado typically needs to have permission to USB devices connected to the PC. |
| 402 | Depending on your security policy you can take different steps to enable this access. |
| 403 | One way of doing so is given in the udev rule outlined below. |
| 404 | |
| 405 | To do so, create a file named `/etc/udev/rules.d/90-lowrisc.rules` and add the following content to it: |
| 406 | |
| 407 | ``` |
| 408 | # Grant access to board peripherals connected over USB: |
| 409 | # - The USB devices itself (used e.g. by Vivado to program the FPGA) |
| 410 | # - Virtual UART at /dev/tty/XXX |
| 411 | |
Pirmin Vogel | 95c7678 | 2021-05-17 13:30:38 +0200 | [diff] [blame] | 412 | # NewAE Technology Inc. ChipWhisperer boards e.g. CW310, CW305, CW-Lite, CW-Husky |
| 413 | ACTION=="add|change", SUBSYSTEM=="usb|tty", ATTRS{idVendor}=="2b3e", ATTRS{idProduct}=="ace[0-9]|c[3-6][0-9][0-9]", MODE="0666" |
| 414 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 415 | # Future Technology Devices International, Ltd FT2232C/D/H Dual UART/FIFO IC |
| 416 | # used on Digilent boards |
| 417 | ACTION=="add|change", SUBSYSTEM=="usb|tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ATTRS{manufacturer}=="Digilent", MODE="0666" |
| 418 | |
| 419 | # Future Technology Devices International, Ltd FT232 Serial (UART) IC |
| 420 | ACTION=="add|change", SUBSYSTEM=="usb|tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666" |
| 421 | ``` |
| 422 | |
| 423 | You then need to reload the udev rules: |
| 424 | |
| 425 | ```console |
Tobias Wölfel | 7f570bd | 2019-11-04 11:10:22 +0100 | [diff] [blame] | 426 | $ sudo udevadm control --reload |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 427 | ``` |