blob: ccad687b113633c65d5f7c3863bd117df34b5e48 [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 Wagnere8ade052020-11-16 11:18:49 +00009ARG VERILATOR_VERSION=4.104
lowRISC Contributors802543a2019-08-31 12:12:56 +010010
11# The RISCV toolchain version should match the release tag used in GitHub.
Philipp Wagner1500b402020-10-14 11:50:24 +020012ARG RISCV_TOOLCHAIN_TAR_VERSION=20200904-1
lowRISC Contributors802543a2019-08-31 12:12:56 +010013
14# Build OpenOCD
15# OpenOCD is a tool to connect with the target chip over JTAG and similar
16# transports.
Philipp Wagner3c8a73f2020-10-06 12:35:49 +010017FROM ubuntu:18.04 AS openocd
lowRISC Contributors802543a2019-08-31 12:12:56 +010018RUN apt-get update && apt-get install -y \
Adam H. Leventhal1b2141b2020-01-15 16:45:41 -080019 autoconf \
lowRISC Contributors802543a2019-08-31 12:12:56 +010020 git \
21 libftdi1-dev \
22 libtool \
23 libusb-1.0.0-dev \
24 pkg-config \
25 texinfo
26RUN git clone --depth=1 https://github.com/riscv/riscv-openocd.git /usr/local/src/openocd
27RUN 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 Wagner3c8a73f2020-10-06 12:35:49 +010033FROM ubuntu:18.04 as verilator
lowRISC Contributors802543a2019-08-31 12:12:56 +010034ARG VERILATOR_VERSION
35RUN apt-get update && apt-get install -y \
36 autoconf \
37 automake \
38 autotools-dev \
39 bison \
40 build-essential \
41 flex \
42 git
43RUN git clone --depth=1 -b v${VERILATOR_VERSION} \
Philipp Wagnerc16764a2020-10-06 16:06:04 +010044 https://github.com/verilator/verilator.git /usr/local/src/verilator
lowRISC Contributors802543a2019-08-31 12:12:56 +010045RUN 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 Wagner3c8a73f2020-10-06 12:35:49 +010051FROM ubuntu:18.04 AS opentitan
lowRISC Contributors802543a2019-08-31 12:12:56 +010052ARG VERILATOR_VERSION
53ARG RISCV_TOOLCHAIN_TAR_VERSION
54
55LABEL version="1.0"
56LABEL description="OpenTitan container for hardware development."
57LABEL maintainer="miguelosorio@google.com"
58
59# Copy tools from previous build stages
60WORKDIR /tools
61COPY --from=openocd /tools/openocd openocd
62COPY --from=verilator /tools/verilator/${VERILATOR_VERSION} verilator/${VERILATOR_VERSION}
63
Sam Elliott00881552020-05-04 16:46:55 +010064# 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 Elliott155b5ab2020-09-10 10:27:24 +010067#
68# This also adds `locales` and `locales-all` so we can set the locale to utf-8
Sam Elliott00881552020-05-04 16:46:55 +010069COPY apt-requirements.txt /tmp/apt-requirements.txt
70RUN apt-get update && \
71 sed 's/#.*//' /tmp/apt-requirements.txt \
72 | xargs apt-get install -y && \
73 apt-get install -y \
Sam Elliott155b5ab2020-09-10 10:27:24 +010074 locales \
75 locales-all \
Sam Elliott00881552020-05-04 16:46:55 +010076 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 Contributors802543a2019-08-31 12:12:56 +010083
Sam Elliott155b5ab2020-09-10 10:27:24 +010084# Set Locale to utf-8 everywhere
85ENV LC_ALL en_US.UTF-8
86ENV LANG en_US.UTF-8
87ENV LANGUAGE en_US:en
88
Philipp Wagner14a3fee2019-11-21 10:07:02 +000089# Copy repository into tmp directory to execute additional install steps.
lowRISC Contributors802543a2019-08-31 12:12:56 +010090COPY python-requirements.txt /tmp/python-requirements.txt
91RUN pip3 install -r /tmp/python-requirements.txt
92
93COPY util/get-toolchain.py /tmp/get-toolchain.py
94RUN /tmp/get-toolchain.py -r ${RISCV_TOOLCHAIN_TAR_VERSION}
95RUN rm /tmp/python-requirements.txt /tmp/get-toolchain.py
96
97# Use bash as default shell
98RUN ln -sf /bin/bash /bin/sh
99
100# Include tools in PATH.
101ENV PATH "/tools/verilator/${VERILATOR_VERSION}/bin:${PATH}"
102
103# Configures default container user.
104ENV USER ot
105
106ENTRYPOINT /bin/bash