blob: c64eb47ca17732c302c11c341fe6e06174d14927 [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
lowRISC Contributors802543a2019-08-31 12:12:56 +010011# The RISCV toolchain version should match the release tag used in GitHub.
Philipp Wagnerca403532021-04-13 09:15:28 +010012ARG RISCV_TOOLCHAIN_TAR_VERSION=20210412-1
Chris Frantzc4273942021-09-20 14:19:45 -070013ARG RUST_VERSION=1.55.0
lowRISC Contributors802543a2019-08-31 12:12:56 +010014
lowRISC Contributors802543a2019-08-31 12:12:56 +010015# Main container image.
Philipp Wagner3c8a73f2020-10-06 12:35:49 +010016FROM ubuntu:18.04 AS opentitan
lowRISC Contributors802543a2019-08-31 12:12:56 +010017ARG VERILATOR_VERSION
Rupert Swarbrickdf237122021-04-20 14:43:48 +010018ARG OPENOCD_VERSION
lowRISC Contributors802543a2019-08-31 12:12:56 +010019ARG RISCV_TOOLCHAIN_TAR_VERSION
Alphan Ulusoye2205892021-05-13 09:36:17 -040020ARG RUST_VERSION
lowRISC Contributors802543a2019-08-31 12:12:56 +010021
22LABEL version="1.0"
Philipp Wagner854a6f02021-09-28 16:41:50 +010023LABEL description="OpenTitan development container."
24LABEL maintainer="opentitan-dev@opentitan.org"
lowRISC Contributors802543a2019-08-31 12:12:56 +010025
Philipp Wagner854a6f02021-09-28 16:41:50 +010026# Use bash as default shell.
27RUN ln -sf /bin/bash /bin/sh
Rupert Swarbrickdf237122021-04-20 14:43:48 +010028
Philipp Wagner854a6f02021-09-28 16:41:50 +010029# Add OBS repository to apt sources.
Rupert Swarbrickdf237122021-04-20 14:43:48 +010030RUN OBS_URL="https://download.opensuse.org/repositories"; \
31 OBS_PATH="/home:/phiwag:/edatools/xUbuntu_18.04"; \
32 REPO_URL="${OBS_URL}${OBS_PATH}"; \
33 \
34 EDATOOLS_REPO_KEY="${REPO_URL}/Release.key"; \
35 EDATOOLS_REPO="deb ${REPO_URL}/ /"; \
36 \
37 apt-get update && \
38 apt-get install -y curl && \
39 \
40 curl -f -sL -o "$TMPDIR/obs.asc" "$EDATOOLS_REPO_KEY" || { \
41 error "Failed to download repository key from ${REPO_URL}"; \
42 } && \
43 echo "$EDATOOLS_REPO" > "$TMPDIR/obs.list" && \
44 mv "$TMPDIR/obs.asc" /etc/apt/trusted.gpg.d/obs.asc && \
Philipp Wagner854a6f02021-09-28 16:41:50 +010045 mv "$TMPDIR/obs.list" /etc/apt/sources.list.d/edatools.list
lowRISC Contributors802543a2019-08-31 12:12:56 +010046
Philipp Wagner854a6f02021-09-28 16:41:50 +010047# Install system packages
Sam Elliott155b5ab2020-09-10 10:27:24 +010048#
Philipp Wagner854a6f02021-09-28 16:41:50 +010049# Install (and cleanup) required packages (from apt-requirements.txt).
50# Also add some additional packages for the use within this container and for
51# developer convenience:
52# - gosu and sudo are used by the scripting to make the image more convenient
53# to use.
54# - locales and locales-all are required to set the locale.
55# - minicom and screen are useful to see UART communication.
56# - dc and time are requirements of Synopsys VCS.
Sam Elliott00881552020-05-04 16:46:55 +010057COPY apt-requirements.txt /tmp/apt-requirements.txt
Philipp Wagner854a6f02021-09-28 16:41:50 +010058RUN echo "verilator-${VERILATOR_VERSION}" >>/tmp/apt-requirements.txt \
59 && echo "openocd-${OPENOCD_VERSION}" >>/tmp/apt-requirements.txt \
60 && sed -i -e '/^$/d' -e '/^#/d' -e 's/#.*//' /tmp/apt-requirements.txt \
61 && apt-get update \
62 && xargs apt-get install -y </tmp/apt-requirements.txt \
63 && apt-get install -y \
64 sudo \
65 gosu \
Sam Elliott155b5ab2020-09-10 10:27:24 +010066 locales \
67 locales-all \
Sam Elliott00881552020-05-04 16:46:55 +010068 minicom \
Philipp Wagner854a6f02021-09-28 16:41:50 +010069 screen \
70 dc \
71 time \
72 && apt-get clean; \
Sam Elliott00881552020-05-04 16:46:55 +010073 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
lowRISC Contributors802543a2019-08-31 12:12:56 +010074
Philipp Wagner854a6f02021-09-28 16:41:50 +010075# RISC-V device toolchain
76COPY util/get-toolchain.py /tmp/get-toolchain.py
77RUN /tmp/get-toolchain.py -r ${RISCV_TOOLCHAIN_TAR_VERSION} \
78 && rm -f /tmp/get-toolchain.py
79
Sam Elliott155b5ab2020-09-10 10:27:24 +010080# Set Locale to utf-8 everywhere
81ENV LC_ALL en_US.UTF-8
82ENV LANG en_US.UTF-8
83ENV LANGUAGE en_US:en
84
Philipp Wagner854a6f02021-09-28 16:41:50 +010085# Scripting for use within this container.
86COPY util/container/start.sh /start.sh
87COPY util/container/sudoconf /etc/sudoers.d/dev
88
89# Add the development user (UID/GID to be replaced).
90RUN groupadd dev \
91 && useradd --create-home -g dev dev \
92 && usermod -p '*' dev \
93 && passwd -u dev
94
95# All subsequent steps are performed as user.
96USER dev
97
Philipp Wagner48fe27a2021-09-29 15:08:58 +010098# Install Rust plus packages.
99COPY sw/vendor/rustup/rustup-init.sh /tmp/rustup-init.sh
100RUN /tmp/rustup-init.sh -y --default-toolchain ${RUST_VERSION}
101
Philipp Wagner854a6f02021-09-28 16:41:50 +0100102# Install Python plus packages.
103#
Alex Bradburybef0c8c2021-08-27 07:02:05 +0100104# Explicitly updating pip and setuptools is required to have these tools
105# properly parse Python-version metadata, which some packages uses to
106# specify that an older version of a package must be used for a certain
107# Python version. If that information is not read, pip installs the latest
108# version, which then fails to run.
Philipp Wagner854a6f02021-09-28 16:41:50 +0100109ENV PATH "/home/dev/.local/bin:${PATH}"
lowRISC Contributors802543a2019-08-31 12:12:56 +0100110COPY python-requirements.txt /tmp/python-requirements.txt
Philipp Wagner854a6f02021-09-28 16:41:50 +0100111RUN python3 -m pip install --user -U pip setuptools \
112 && python3 -m pip install --user -r /tmp/python-requirements.txt \
113 --no-warn-script-location
lowRISC Contributors802543a2019-08-31 12:12:56 +0100114
Philipp Wagner854a6f02021-09-28 16:41:50 +0100115USER root
lowRISC Contributors802543a2019-08-31 12:12:56 +0100116
Philipp Wagner854a6f02021-09-28 16:41:50 +0100117ENTRYPOINT [ "/start.sh" ]