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 | b27f72d | 2021-07-23 14:41:20 +0100 | [diff] [blame] | 9 | ARG VERILATOR_VERSION=4.210 |
Rupert Swarbrick | df23712 | 2021-04-20 14:43:48 +0100 | [diff] [blame] | 10 | ARG OPENOCD_VERSION=0.11.0 |
Philipp Wagner | a3fe55d | 2021-10-01 16:49:21 +0100 | [diff] [blame] | 11 | ARG VERIBLE_VERSION=v0.0-1213-g9e5c085 |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 12 | # The RISCV toolchain version should match the release tag used in GitHub. |
Philipp Wagner | ca40353 | 2021-04-13 09:15:28 +0100 | [diff] [blame] | 13 | ARG RISCV_TOOLCHAIN_TAR_VERSION=20210412-1 |
Chris Frantz | c427394 | 2021-09-20 14:19:45 -0700 | [diff] [blame] | 14 | ARG RUST_VERSION=1.55.0 |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 15 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 16 | # Main container image. |
Philipp Wagner | 3c8a73f | 2020-10-06 12:35:49 +0100 | [diff] [blame] | 17 | FROM ubuntu:18.04 AS opentitan |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 18 | ARG VERILATOR_VERSION |
Rupert Swarbrick | df23712 | 2021-04-20 14:43:48 +0100 | [diff] [blame] | 19 | ARG OPENOCD_VERSION |
Philipp Wagner | a3fe55d | 2021-10-01 16:49:21 +0100 | [diff] [blame] | 20 | ARG VERIBLE_VERSION |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 21 | ARG RISCV_TOOLCHAIN_TAR_VERSION |
Alphan Ulusoy | e220589 | 2021-05-13 09:36:17 -0400 | [diff] [blame] | 22 | ARG RUST_VERSION |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 23 | |
| 24 | LABEL version="1.0" |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 25 | LABEL description="OpenTitan development container." |
| 26 | LABEL maintainer="opentitan-dev@opentitan.org" |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 27 | |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 28 | # Use bash as default shell. |
| 29 | RUN ln -sf /bin/bash /bin/sh |
Rupert Swarbrick | df23712 | 2021-04-20 14:43:48 +0100 | [diff] [blame] | 30 | |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 31 | # Add OBS repository to apt sources. |
Rupert Swarbrick | df23712 | 2021-04-20 14:43:48 +0100 | [diff] [blame] | 32 | RUN OBS_URL="https://download.opensuse.org/repositories"; \ |
| 33 | OBS_PATH="/home:/phiwag:/edatools/xUbuntu_18.04"; \ |
| 34 | REPO_URL="${OBS_URL}${OBS_PATH}"; \ |
| 35 | \ |
| 36 | EDATOOLS_REPO_KEY="${REPO_URL}/Release.key"; \ |
| 37 | EDATOOLS_REPO="deb ${REPO_URL}/ /"; \ |
| 38 | \ |
| 39 | apt-get update && \ |
| 40 | apt-get install -y curl && \ |
| 41 | \ |
| 42 | curl -f -sL -o "$TMPDIR/obs.asc" "$EDATOOLS_REPO_KEY" || { \ |
| 43 | error "Failed to download repository key from ${REPO_URL}"; \ |
| 44 | } && \ |
| 45 | echo "$EDATOOLS_REPO" > "$TMPDIR/obs.list" && \ |
| 46 | mv "$TMPDIR/obs.asc" /etc/apt/trusted.gpg.d/obs.asc && \ |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 47 | mv "$TMPDIR/obs.list" /etc/apt/sources.list.d/edatools.list |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 48 | |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 49 | # Install system packages |
Sam Elliott | 155b5ab | 2020-09-10 10:27:24 +0100 | [diff] [blame] | 50 | # |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 51 | # Install (and cleanup) required packages (from apt-requirements.txt). |
| 52 | # Also add some additional packages for the use within this container and for |
| 53 | # developer convenience: |
| 54 | # - gosu and sudo are used by the scripting to make the image more convenient |
| 55 | # to use. |
| 56 | # - locales and locales-all are required to set the locale. |
| 57 | # - minicom and screen are useful to see UART communication. |
| 58 | # - dc and time are requirements of Synopsys VCS. |
Sam Elliott | 0088155 | 2020-05-04 16:46:55 +0100 | [diff] [blame] | 59 | COPY apt-requirements.txt /tmp/apt-requirements.txt |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 60 | RUN echo "verilator-${VERILATOR_VERSION}" >>/tmp/apt-requirements.txt \ |
| 61 | && echo "openocd-${OPENOCD_VERSION}" >>/tmp/apt-requirements.txt \ |
| 62 | && sed -i -e '/^$/d' -e '/^#/d' -e 's/#.*//' /tmp/apt-requirements.txt \ |
| 63 | && apt-get update \ |
| 64 | && xargs apt-get install -y </tmp/apt-requirements.txt \ |
| 65 | && apt-get install -y \ |
| 66 | sudo \ |
| 67 | gosu \ |
Sam Elliott | 155b5ab | 2020-09-10 10:27:24 +0100 | [diff] [blame] | 68 | locales \ |
| 69 | locales-all \ |
Sam Elliott | 0088155 | 2020-05-04 16:46:55 +0100 | [diff] [blame] | 70 | minicom \ |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 71 | screen \ |
| 72 | dc \ |
| 73 | time \ |
| 74 | && apt-get clean; \ |
Sam Elliott | 0088155 | 2020-05-04 16:46:55 +0100 | [diff] [blame] | 75 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 76 | |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 77 | # RISC-V device toolchain |
| 78 | COPY util/get-toolchain.py /tmp/get-toolchain.py |
| 79 | RUN /tmp/get-toolchain.py -r ${RISCV_TOOLCHAIN_TAR_VERSION} \ |
| 80 | && rm -f /tmp/get-toolchain.py |
| 81 | |
Philipp Wagner | a3fe55d | 2021-10-01 16:49:21 +0100 | [diff] [blame] | 82 | # Install Verible |
| 83 | RUN curl -f -Ls -o verible.tar.gz \ |
| 84 | https://github.com/chipsalliance/verible/releases/download/${VERIBLE_VERSION}/verible-${VERIBLE_VERSION}-Ubuntu-18.04-bionic-x86_64.tar.gz \ |
| 85 | && mkdir -p /tools/verible \ |
| 86 | && tar -C /tools/verible -xf verible.tar.gz --strip-components=1 |
| 87 | ENV PATH "/tools/verible/bin:${PATH}" |
| 88 | |
Sam Elliott | 155b5ab | 2020-09-10 10:27:24 +0100 | [diff] [blame] | 89 | # Set Locale to utf-8 everywhere |
| 90 | ENV LC_ALL en_US.UTF-8 |
| 91 | ENV LANG en_US.UTF-8 |
| 92 | ENV LANGUAGE en_US:en |
| 93 | |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 94 | # Scripting for use within this container. |
| 95 | COPY util/container/start.sh /start.sh |
| 96 | COPY util/container/sudoconf /etc/sudoers.d/dev |
| 97 | |
| 98 | # Add the development user (UID/GID to be replaced). |
| 99 | RUN groupadd dev \ |
| 100 | && useradd --create-home -g dev dev \ |
| 101 | && usermod -p '*' dev \ |
| 102 | && passwd -u dev |
| 103 | |
| 104 | # All subsequent steps are performed as user. |
Philipp Wagner | 6324932 | 2021-10-11 13:51:36 +0100 | [diff] [blame] | 105 | USER dev:dev |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 106 | |
Philipp Wagner | 48fe27a | 2021-09-29 15:08:58 +0100 | [diff] [blame] | 107 | # Install Rust plus packages. |
Philipp Wagner | 6324932 | 2021-10-11 13:51:36 +0100 | [diff] [blame] | 108 | COPY --chown=dev:dev sw/vendor/rustup/rustup-init.sh /tmp/rustup-init.sh |
| 109 | RUN /tmp/rustup-init.sh -y --default-toolchain ${RUST_VERSION} \ |
| 110 | && rm -f /tmp/rustup-init.sh |
Philipp Wagner | 48fe27a | 2021-09-29 15:08:58 +0100 | [diff] [blame] | 111 | |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 112 | # Install Python plus packages. |
| 113 | # |
Alex Bradbury | bef0c8c | 2021-08-27 07:02:05 +0100 | [diff] [blame] | 114 | # Explicitly updating pip and setuptools is required to have these tools |
| 115 | # properly parse Python-version metadata, which some packages uses to |
| 116 | # specify that an older version of a package must be used for a certain |
| 117 | # Python version. If that information is not read, pip installs the latest |
| 118 | # version, which then fails to run. |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 119 | ENV PATH "/home/dev/.local/bin:${PATH}" |
Philipp Wagner | 6324932 | 2021-10-11 13:51:36 +0100 | [diff] [blame] | 120 | COPY --chown=dev:dev python-requirements.txt /tmp/python-requirements.txt |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 121 | RUN python3 -m pip install --user -U pip setuptools \ |
| 122 | && python3 -m pip install --user -r /tmp/python-requirements.txt \ |
Philipp Wagner | 6324932 | 2021-10-11 13:51:36 +0100 | [diff] [blame] | 123 | --no-warn-script-location \ |
| 124 | && rm -f /tmp/python-requirements.txt |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 125 | |
Philipp Wagner | 6324932 | 2021-10-11 13:51:36 +0100 | [diff] [blame] | 126 | USER root:root |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 127 | |
Philipp Wagner | 854a6f0 | 2021-09-28 16:41:50 +0100 | [diff] [blame] | 128 | ENTRYPOINT [ "/start.sh" ] |