diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df99041 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +buildroot.tar.gz +buildroot/ +f4pga/ +litex/ +opensbi/ +upsilon/ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5429719..0000000 --- a/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM debian:bookworm -# FIXME: Very large User IDs cause ADD to not work properly. Use RUN -# instead. - -ENV FPGA_FAM=xc7 -ENV F4PGA_INSTALL_DIR=/home/user/f4pga - -# Install base system and system user. -RUN apt-get update \ - && apt-get install -y git sudo wget xz-utils \ - && adduser --quiet --disabled-password user -USER user:user -WORKDIR /home/user - -# Install F4PGA. -# FIXME: We need to either enable passwordless sudo for user (not good) -# or disable all instances of sudo. This hack works for this commit but -# might break in the future. -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 - -# Install LiteX. TODO: put in litex directory. -COPY --chown=user:user litex/litex_setup.py /home/user -WORKDIR /home/user -RUN chmod +x litex_setup.py \ - && bash -c '\ -source ~/f4pga/xc7/conda/etc/profile.d/conda.sh; \ -conda run -n xc7 ./litex_setup.py --init --install --user --tag=2023.04' - -# Install Buildroot. -WORKDIR /home/user -COPY --chown=user:user buildroot.tar.gz /home/user -RUN tar -xvf buildroot.tar.gz && rm buildroot.tar.gz -USER root:root -RUN apt-get -y install build-essential gcc g++ sed make binutils diffutils bash patch gzip bzip2 perl tar cpio unzip rsync bc findutils wget diff --git a/Dockerfile.buildroot b/Dockerfile.buildroot new file mode 100644 index 0000000..0a41262 --- /dev/null +++ b/Dockerfile.buildroot @@ -0,0 +1,11 @@ +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 \ + && adduser --quiet --disabled-password user + +USER user:user +WORKDIR /home/user +COPY --chown=user:user buildroot.tar.gz /home/user +RUN tar -xvf buildroot.tar.gz && rm buildroot.tar.gz diff --git a/Dockerfile.hardware b/Dockerfile.hardware new file mode 100644 index 0000000..b76a3fd --- /dev/null +++ b/Dockerfile.hardware @@ -0,0 +1,26 @@ +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/Makefile b/Makefile index 6df30e4..837c76e 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,9 @@ -.PHONY: image f4pga buildroot litex clone help container attach -ADDED_FILES=f4pga/scripts/prepare_environment.sh litex/litex_setup.py buildroot.tar.gz +.PHONY: images f4pga buildroot litex clone help container attach hardware-image buildroot-image help: @echo 'compile commands (run in order)' @echo 'make clone: clone repositories' - @echo 'make image: build docker image' + @echo 'make images: build docker images' @echo 'make container: create docker container' @echo @echo 'run commands' @@ -13,8 +12,13 @@ help: @echo 'clean commands' @echo 'make clean-container: delete docker container' -image: ${ADDED_FILES} - docker build -t "upsilon-buildenv" . +hardware-image: f4pga/scripts/prepare_environment.sh litex/litex_setup.py + docker build -f Dockerfile.hardware -t "upsilon-hardware-env" . + +buildroot-image: buildroot.tar.gz + docker build -f Dockerfile.buildroot -t "upsilon-buildroot-env" . + +images: hardware-image buildroot-image container: docker run --name upsilon-container --volume .:/home/user/outside -it upsilon-buildenv /bin/bash -l diff --git a/environment_setup.md b/environment_setup.md index c0dbd5a..0b8eb2f 100644 --- a/environment_setup.md +++ b/environment_setup.md @@ -1,16 +1,13 @@ -MagLab Upsilon development environment setup. +Upsilon development environment setup. Written by Peter McGoron. -Preqreuisites -============= +# Preqreuisites -Rebinding Caps Lock to Escape ------------------------------ +## Rebinding Caps Lock to Escape gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']" -Installing OpenFPGALoader -------------------------- +## Installing OpenFPGALoader Then install [openFPGALoader][1]. This utility entered the Ubuntu repositories in 23.04. Install and compile it if you do not have it. Install the udev rule @@ -18,8 +15,7 @@ so that admin access is not required to load FPGA bitstreams. [1]: https://trabucayre.github.io/openFPGALoader/index.html -Setup Rootless Docker ---------------------- +## Setup Rootless Docker Docker allows you to run programs in containers, which are isolated environments. Upsilon development (at the Maglab) uses Docker for @@ -33,12 +29,10 @@ If you have issues with docker, try adding to `~/.config/docker/daemon.json` } -Download and Install Python3 ----------------------------- +## Download and Install Python3 Install `python3-venv` (or `python3-virtualenv`) and `python3-pip`. -Setup Build Environment -======================= - +# Setup Build Environment +Run `make image container attach`.