blob: 17d69fbbbb4502af3a2daef252328e5ad8cebf7d [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001# 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 Wagnerb27f72d2021-07-23 14:41:20 +01009ARG VERILATOR_VERSION=4.210
Rupert Swarbrickdf237122021-04-20 14:43:48 +010010ARG OPENOCD_VERSION=0.11.0
Philipp Wagnera3fe55d2021-10-01 16:49:21 +010011ARG VERIBLE_VERSION=v0.0-1213-g9e5c085
lowRISC Contributors802543a2019-08-31 12:12:56 +010012# The RISCV toolchain version should match the release tag used in GitHub.
Philipp Wagnerca403532021-04-13 09:15:28 +010013ARG RISCV_TOOLCHAIN_TAR_VERSION=20210412-1
Chris Frantzc4273942021-09-20 14:19:45 -070014ARG RUST_VERSION=1.55.0
lowRISC Contributors802543a2019-08-31 12:12:56 +010015
lowRISC Contributors802543a2019-08-31 12:12:56 +010016# Main container image.
Philipp Wagner3c8a73f2020-10-06 12:35:49 +010017FROM ubuntu:18.04 AS opentitan
lowRISC Contributors802543a2019-08-31 12:12:56 +010018ARG VERILATOR_VERSION
Rupert Swarbrickdf237122021-04-20 14:43:48 +010019ARG OPENOCD_VERSION
Philipp Wagnera3fe55d2021-10-01 16:49:21 +010020ARG VERIBLE_VERSION
lowRISC Contributors802543a2019-08-31 12:12:56 +010021ARG RISCV_TOOLCHAIN_TAR_VERSION
Alphan Ulusoye2205892021-05-13 09:36:17 -040022ARG RUST_VERSION
lowRISC Contributors802543a2019-08-31 12:12:56 +010023
24LABEL version="1.0"
Philipp Wagner854a6f02021-09-28 16:41:50 +010025LABEL description="OpenTitan development container."
26LABEL maintainer="opentitan-dev@opentitan.org"
lowRISC Contributors802543a2019-08-31 12:12:56 +010027
Philipp Wagner854a6f02021-09-28 16:41:50 +010028# Use bash as default shell.
29RUN ln -sf /bin/bash /bin/sh
Rupert Swarbrickdf237122021-04-20 14:43:48 +010030
Philipp Wagner854a6f02021-09-28 16:41:50 +010031# Add OBS repository to apt sources.
Rupert Swarbrickdf237122021-04-20 14:43:48 +010032RUN 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 Wagner854a6f02021-09-28 16:41:50 +010047 mv "$TMPDIR/obs.list" /etc/apt/sources.list.d/edatools.list
lowRISC Contributors802543a2019-08-31 12:12:56 +010048
Philipp Wagner854a6f02021-09-28 16:41:50 +010049# Install system packages
Sam Elliott155b5ab2020-09-10 10:27:24 +010050#
Philipp Wagner854a6f02021-09-28 16:41:50 +010051# 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 Elliott00881552020-05-04 16:46:55 +010059COPY apt-requirements.txt /tmp/apt-requirements.txt
Philipp Wagner854a6f02021-09-28 16:41:50 +010060RUN 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 Elliott155b5ab2020-09-10 10:27:24 +010068 locales \
69 locales-all \
Sam Elliott00881552020-05-04 16:46:55 +010070 minicom \
Philipp Wagner854a6f02021-09-28 16:41:50 +010071 screen \
72 dc \
73 time \
74 && apt-get clean; \
Sam Elliott00881552020-05-04 16:46:55 +010075 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
lowRISC Contributors802543a2019-08-31 12:12:56 +010076
Philipp Wagner854a6f02021-09-28 16:41:50 +010077# RISC-V device toolchain
78COPY util/get-toolchain.py /tmp/get-toolchain.py
79RUN /tmp/get-toolchain.py -r ${RISCV_TOOLCHAIN_TAR_VERSION} \
80 && rm -f /tmp/get-toolchain.py
81
Philipp Wagnera3fe55d2021-10-01 16:49:21 +010082# Install Verible
83RUN 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
87ENV PATH "/tools/verible/bin:${PATH}"
88
Sam Elliott155b5ab2020-09-10 10:27:24 +010089# Set Locale to utf-8 everywhere
90ENV LC_ALL en_US.UTF-8
91ENV LANG en_US.UTF-8
92ENV LANGUAGE en_US:en
93
Philipp Wagner854a6f02021-09-28 16:41:50 +010094# Scripting for use within this container.
95COPY util/container/start.sh /start.sh
96COPY util/container/sudoconf /etc/sudoers.d/dev
97
98# Add the development user (UID/GID to be replaced).
99RUN 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 Wagner63249322021-10-11 13:51:36 +0100105USER dev:dev
Philipp Wagner854a6f02021-09-28 16:41:50 +0100106
Philipp Wagner48fe27a2021-09-29 15:08:58 +0100107# Install Rust plus packages.
Philipp Wagner63249322021-10-11 13:51:36 +0100108COPY --chown=dev:dev sw/vendor/rustup/rustup-init.sh /tmp/rustup-init.sh
109RUN /tmp/rustup-init.sh -y --default-toolchain ${RUST_VERSION} \
110 && rm -f /tmp/rustup-init.sh
Philipp Wagner48fe27a2021-09-29 15:08:58 +0100111
Philipp Wagner854a6f02021-09-28 16:41:50 +0100112# Install Python plus packages.
113#
Alex Bradburybef0c8c2021-08-27 07:02:05 +0100114# 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 Wagner854a6f02021-09-28 16:41:50 +0100119ENV PATH "/home/dev/.local/bin:${PATH}"
Philipp Wagner63249322021-10-11 13:51:36 +0100120COPY --chown=dev:dev python-requirements.txt /tmp/python-requirements.txt
Philipp Wagner854a6f02021-09-28 16:41:50 +0100121RUN python3 -m pip install --user -U pip setuptools \
122 && python3 -m pip install --user -r /tmp/python-requirements.txt \
Philipp Wagner63249322021-10-11 13:51:36 +0100123 --no-warn-script-location \
124 && rm -f /tmp/python-requirements.txt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100125
Philipp Wagner63249322021-10-11 13:51:36 +0100126USER root:root
lowRISC Contributors802543a2019-08-31 12:12:56 +0100127
Philipp Wagner854a6f02021-09-28 16:41:50 +0100128ENTRYPOINT [ "/start.sh" ]