diff --git a/Dockerfile.buildroot b/Dockerfile.buildroot index 0a41262..b093119 100644 --- a/Dockerfile.buildroot +++ b/Dockerfile.buildroot @@ -2,7 +2,10 @@ FROM debian:bookworm RUN apt-get update \ && apt-get -y upgrade \ - && apt-get install -y git wget xz-utils build-essential gcc g++ sed make binutils diffutils bash patch gzip bzip2 perl tar cpio unzip rsync bc findutils wget python3 libncurses5-dev libncurses-dev file which \ + && apt-get install -y git wget xz-utils build-essential gcc g++ sed \ + make binutils diffutils bash patch gzip bzip2 perl tar cpio unzip \ + rsync bc findutils wget python3 libncurses5-dev libncurses-dev file \ + which \ && adduser --quiet --disabled-password user USER user:user diff --git a/Dockerfile.hardware b/Dockerfile.hardware deleted file mode 100644 index b76a3fd..0000000 --- a/Dockerfile.hardware +++ /dev/null @@ -1,26 +0,0 @@ -FROM debian:bookworm - -ENV FPGA_FAM=xc7 -ENV F4PGA_INSTALL_DIR=/home/user/f4pga - -RUN apt-get update \ - && apt-get -y upgrade \ - && apt-get install -y git wget python3 xz-utils bash verilator m4 \ - && adduser --quiet --disabled-password user - -USER user:user -WORKDIR /home/user - -COPY --chown=user:user f4pga/scripts/prepare_environment.sh /home/user -RUN sed -i 's/sudo/#sudo/g' ./prepare_environment.sh \ - && ./prepare_environment.sh \ - && rm ./prepare_environment.sh - -COPY --chown=user:user litex/litex_setup.py /home/user -RUN mkdir /home/user/litex \ - && chmod +x litex_setup.py \ - && cd litex/ \ - && bash -c '\ -source ~/f4pga/xc7/conda/etc/profile.d/conda.sh; \ -conda run -n xc7 ../litex_setup.py --init --install --user --tag=2023.04' \ - && rm ../litex_setup.py diff --git a/Dockerfile.litex_f4pga b/Dockerfile.litex_f4pga new file mode 100644 index 0000000..b9225c4 --- /dev/null +++ b/Dockerfile.litex_f4pga @@ -0,0 +1,33 @@ +FROM debian:bookworm + +ENV FPGA_FAM=xc7 +ENV F4PGA_INSTALL_DIR=/home/user/conda + +RUN apt-get update \ + && apt-get -y upgrade \ + && apt-get install -y git wget python3 xz-utils bash verilator \ + m4 device-tree-compiler make gcc-riscv64-unknown-elf \ + && adduser --quiet --disabled-password user +EXPOSE 22 + +USER user:user +WORKDIR /home/user + +COPY --chown=user:user f4pga.tar.gz /home/user +COPY --chown=user:user install_f4pga_defs.sh /home/user +RUN tar -xvf f4pga.tar.gz \ + && rm f4pga.tar.gz +RUN cd f4pga/scripts/ \ + && sed -i 's/sudo/#sudo/g' ./prepare_environment.sh \ + && ./prepare_environment.sh \ + && echo 'source ~/conda/xc7/conda/etc/profile.d/conda.sh' >> /home/user/.bashrc \ + && echo 'conda activate xc7' >> /home/user/.bashrc +RUN cd f4pga/f4pga && bash -c 'source ~/conda/xc7/conda/etc/profile.d/conda.sh; conda activate xc7; pip install . ninja meson' + +COPY --chown=user:user litex/litex_setup.py /home/user +RUN mkdir /home/user/litex \ + && chmod +x litex_setup.py \ + && cd litex/ \ + && bash -c 'source ~/conda/xc7/conda/etc/profile.d/conda.sh; conda activate xc7; ../litex_setup.py --init --install --user --tag=2023.04' \ + && rm ../litex_setup.py + diff --git a/Dockerfile.opensbi b/Dockerfile.opensbi new file mode 100644 index 0000000..1efb9f1 --- /dev/null +++ b/Dockerfile.opensbi @@ -0,0 +1,16 @@ +FROM debian:bookworm + +RUN apt-get update \ + && apt-get -y upgrade \ + && apt-get install -y make device-tree-compiler python3 gcc-riscv64-linux-gnu \ + && adduser --quiet --disabled-password user + +USER user:user +WORKDIR /home/user + +COPY --chown=user:user opensbi.tar.gz /home/user +COPY --chown=user:user opensbi-platform.tar.gz /home/user +RUN tar -xvf opensbi.tar.gz \ + && cd opensbi/platforms \ + && tar -xvf ~/opensbi-platform.tar.gz \ + && rm ~/opensbi.tar.gz ~/opensbi-platform.tar.gz diff --git a/Makefile b/Makefile index 837c76e..9f5234a 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,36 @@ -.PHONY: images f4pga buildroot litex clone help container attach hardware-image buildroot-image +.PHONY: images f4pga buildroot litex clone help attach hardware-image \ + buildroot-image litex-f4pga-image hardware-container \ + upsilon.tar.gz help: @echo 'compile commands (run in order)' @echo 'make clone: clone repositories' @echo 'make images: build docker images' - @echo 'make container: create docker container' - @echo - @echo 'run commands' - @echo 'make attach: open docker container' - @echo - @echo 'clean commands' - @echo 'make clean-container: delete docker container' + +###### Images + +images: hardware-image buildroot-image hardware-image: f4pga/scripts/prepare_environment.sh litex/litex_setup.py - docker build -f Dockerfile.hardware -t "upsilon-hardware-env" . + docker build -f Dockerfile.litex_f4pga -t "upsilon-litex-f4pga-env" . buildroot-image: buildroot.tar.gz docker build -f Dockerfile.buildroot -t "upsilon-buildroot-env" . -images: hardware-image buildroot-image +###### Containers -container: - docker run --name upsilon-container --volume .:/home/user/outside -it upsilon-buildenv /bin/bash -l +hardware-container: + docker run -d --name upsilon-hardware-container upsilon-litex-f4pga-env /bin/sh -c 'while true; do sleep 2; done' +hardware-container-copy: upsilon.tar.gz + docker cp upsilon.tar.gz upsilon-hardware-container:/home/user/upsilon.tar.gz +hardware-container-shell: + docker exec -ti upsilon-hardware-container /bin/bash -l +hardware-container-clean: + -docker container stop upsilon-hardware-container + -docker container rm upsilon-hardware-container -clean-container: - -docker stop upsilon-container - docker rm upsilon-container +###### External projects -attach: - -docker start upsilon-container - docker attach upsilon-container - -## Download external projects clone: f4pga buildroot litex f4pga: @@ -39,7 +38,8 @@ f4pga: git clone https://github.com/chipsalliance/f4pga; \ fi cd f4pga && git checkout main && git pull && \ - git checkout -B upsilon_stable 835a40534f9efd70770d74f56f25fef6cfc6ebc6 + git checkout -B upsilon_stable 835a40534f9efd70770d74f56f25fef6cfc6ebc6 \ + tar -czvf f4pga.tar.gz f4pga buildroot: if [ ! -d 'buildroot' ]; then \ @@ -55,3 +55,6 @@ litex: fi cd litex && git checkout master && git pull && \ git checkout -B upsilon_stable c6ccb626e88168045edacced3743f6bd98746742 + +upsilon.tar.gz: + tar -czvf upsilon.tar.gz upsilon/ diff --git a/scripts/install_f4pga_defs.sh b/scripts/install_f4pga_defs.sh new file mode 100644 index 0000000..282de6a --- /dev/null +++ b/scripts/install_f4pga_defs.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Copyright (C) 2020-2022 F4PGA Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +FPGA_FAM="${FPGA_FAM:=xc7}" +F4PGA_INSTALL_DIR="${F4PGA_INSTALL_DIR:=/opt/f4pga}" +F4PGA_INSTALL_DIR_FAM="${F4PGA_INSTALL_DIR}/${FPGA_FAM}" + +wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O conda_installer.sh + +bash conda_installer.sh -u -b -p "${F4PGA_INSTALL_DIR_FAM}"/conda +rm conda_installer.sh +source "${F4PGA_INSTALL_DIR_FAM}"/conda/etc/profile.d/conda.sh +mkdir -p "$F4PGA_INSTALL_DIR_FAM" + +F4PGA_TIMESTAMP='20220907-210059' +F4PGA_HASH='66a976d' + +# Only Arty supported +case "$FPGA_FAM" in + xc7) PACKAGES='install-xc7 xc7a50t_test xc7a100t_test';; + *) + echo "Unknowd FPGA_FAM <${FPGA_FAM}>!" + exit 1 +esac + +for PKG in $PACKAGES; do + wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/${F4PGA_TIMESTAMP}/symbiflow-arch-defs-${PKG}-${F4PGA_HASH}.tar.xz \ + | tar -xJC $F4PGA_INSTALL_DIR_FAM +done + +rm -vrf $F4PGA_INSTALL_DIR_FAM/share/f4pga/scripts +conda env create -f $F4PGA_INSTALL_DIR_FAM/"$FPGA_FAM"_env/"$FPGA_FAM"_environment.yml