lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | # Copyright lowRISC contributors. |
| 2 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | # Docker container containing various hardware and software development tools |
| 6 | # for OpenTitan. |
| 7 | |
| 8 | # Global configuration options. |
Philipp Wagner | e8ade05 | 2020-11-16 11:18:49 +0000 | [diff] [blame] | 9 | ARG VERILATOR_VERSION=4.104 |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 10 | |
| 11 | # The RISCV toolchain version should match the release tag used in GitHub. |
Philipp Wagner | 1500b40 | 2020-10-14 11:50:24 +0200 | [diff] [blame] | 12 | ARG RISCV_TOOLCHAIN_TAR_VERSION=20200904-1 |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 13 | |
| 14 | # Build OpenOCD |
| 15 | # OpenOCD is a tool to connect with the target chip over JTAG and similar |
| 16 | # transports. |
Philipp Wagner | 3c8a73f | 2020-10-06 12:35:49 +0100 | [diff] [blame] | 17 | FROM ubuntu:18.04 AS openocd |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 18 | RUN apt-get update && apt-get install -y \ |
Adam H. Leventhal | 1b2141b | 2020-01-15 16:45:41 -0800 | [diff] [blame] | 19 | autoconf \ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 20 | git \ |
| 21 | libftdi1-dev \ |
| 22 | libtool \ |
| 23 | libusb-1.0.0-dev \ |
| 24 | pkg-config \ |
| 25 | texinfo |
| 26 | RUN git clone --depth=1 https://github.com/riscv/riscv-openocd.git /usr/local/src/openocd |
| 27 | RUN cd /usr/local/src/openocd && ./bootstrap && mkdir build && cd build && \ |
| 28 | ../configure --enable-ftdi --enable-verbose-jtag-io --disable-vsllink \ |
| 29 | --enable-remote-bitbang --prefix=/tools/openocd && \ |
| 30 | make -j$(nproc) && make install |
| 31 | |
| 32 | # Build Verilator. |
Philipp Wagner | 3c8a73f | 2020-10-06 12:35:49 +0100 | [diff] [blame] | 33 | FROM ubuntu:18.04 as verilator |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 34 | ARG VERILATOR_VERSION |
| 35 | RUN apt-get update && apt-get install -y \ |
| 36 | autoconf \ |
| 37 | automake \ |
| 38 | autotools-dev \ |
| 39 | bison \ |
| 40 | build-essential \ |
| 41 | flex \ |
| 42 | git |
| 43 | RUN git clone --depth=1 -b v${VERILATOR_VERSION} \ |
Philipp Wagner | c16764a | 2020-10-06 16:06:04 +0100 | [diff] [blame] | 44 | https://github.com/verilator/verilator.git /usr/local/src/verilator |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 45 | RUN cd /usr/local/src/verilator && \ |
| 46 | autoconf && ./configure --prefix=/tools/verilator/${VERILATOR_VERSION} && \ |
| 47 | make -j$(nproc) && make install |
| 48 | |
| 49 | |
| 50 | # Main container image. |
Philipp Wagner | 3c8a73f | 2020-10-06 12:35:49 +0100 | [diff] [blame] | 51 | FROM ubuntu:18.04 AS opentitan |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 52 | ARG VERILATOR_VERSION |
| 53 | ARG RISCV_TOOLCHAIN_TAR_VERSION |
| 54 | |
| 55 | LABEL version="1.0" |
| 56 | LABEL description="OpenTitan container for hardware development." |
| 57 | LABEL maintainer="miguelosorio@google.com" |
| 58 | |
| 59 | # Copy tools from previous build stages |
| 60 | WORKDIR /tools |
| 61 | COPY --from=openocd /tools/openocd openocd |
| 62 | COPY --from=verilator /tools/verilator/${VERILATOR_VERSION} verilator/${VERILATOR_VERSION} |
| 63 | |
Sam Elliott | 0088155 | 2020-05-04 16:46:55 +0100 | [diff] [blame] | 64 | # Install (and cleanup) required packages (from apt-requirements.txt) |
| 65 | # The list of extra packages is leftover from before this Dockerfile used |
| 66 | # apt-requirements.txt |
Sam Elliott | 155b5ab | 2020-09-10 10:27:24 +0100 | [diff] [blame] | 67 | # |
| 68 | # This also adds `locales` and `locales-all` so we can set the locale to utf-8 |
Sam Elliott | 0088155 | 2020-05-04 16:46:55 +0100 | [diff] [blame] | 69 | COPY apt-requirements.txt /tmp/apt-requirements.txt |
| 70 | RUN apt-get update && \ |
| 71 | sed 's/#.*//' /tmp/apt-requirements.txt \ |
| 72 | | xargs apt-get install -y && \ |
| 73 | apt-get install -y \ |
Sam Elliott | 155b5ab | 2020-09-10 10:27:24 +0100 | [diff] [blame] | 74 | locales \ |
| 75 | locales-all \ |
Sam Elliott | 0088155 | 2020-05-04 16:46:55 +0100 | [diff] [blame] | 76 | gnupg2 \ |
| 77 | libc6-i386 \ |
| 78 | libtool \ |
| 79 | minicom \ |
| 80 | screen && \ |
| 81 | apt-get clean ; \ |
| 82 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 83 | |
Sam Elliott | 155b5ab | 2020-09-10 10:27:24 +0100 | [diff] [blame] | 84 | # Set Locale to utf-8 everywhere |
| 85 | ENV LC_ALL en_US.UTF-8 |
| 86 | ENV LANG en_US.UTF-8 |
| 87 | ENV LANGUAGE en_US:en |
| 88 | |
Philipp Wagner | 14a3fee | 2019-11-21 10:07:02 +0000 | [diff] [blame] | 89 | # Copy repository into tmp directory to execute additional install steps. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 90 | COPY python-requirements.txt /tmp/python-requirements.txt |
| 91 | RUN pip3 install -r /tmp/python-requirements.txt |
| 92 | |
| 93 | COPY util/get-toolchain.py /tmp/get-toolchain.py |
| 94 | RUN /tmp/get-toolchain.py -r ${RISCV_TOOLCHAIN_TAR_VERSION} |
| 95 | RUN rm /tmp/python-requirements.txt /tmp/get-toolchain.py |
| 96 | |
| 97 | # Use bash as default shell |
| 98 | RUN ln -sf /bin/bash /bin/sh |
| 99 | |
| 100 | # Include tools in PATH. |
| 101 | ENV PATH "/tools/verilator/${VERILATOR_VERSION}/bin:${PATH}" |
| 102 | |
| 103 | # Configures default container user. |
| 104 | ENV USER ot |
| 105 | |
| 106 | ENTRYPOINT /bin/bash |