From 6be211bdd962497bd66812143207edbcf53ec43e Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Fri, 26 May 2023 15:00:46 -0400 Subject: [PATCH] init --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ Makefile | 35 +++++++++++++++++++++++++++++++++++ environment_setup.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 environment_setup.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a687cd8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +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. +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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2a87886 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +.PHONY: image f4pga buildroot litex clone help +ADDED_FILES=f4pga/scripts/prepare_environment.sh litex/litex_setup.py buildroot.tar.gz + +help: + @echo 'make image: build docker image' + @echo 'make open: open docker image' + @echo 'make clone: clone repositories' + +image: ${ADDED_FILES} + docker build -t "upsilon-buildenv" . + +## Download external projects +clone: f4pga buildroot litex + +f4pga: + if [ ! -d 'f4pga' ]; then \ + git clone https://github.com/chipsalliance/f4pga; \ + fi + cd f4pga && git checkout main && git pull && \ + git checkout -B upsilon_stable 835a40534f9efd70770d74f56f25fef6cfc6ebc6 + +buildroot: + if [ ! -d 'buildroot' ]; then \ + git clone https://git.buildroot.org/buildroot; \ + fi + cd buildroot && git checkout master && git pull && \ + git checkout -B upsilon_stable 2023.02.1 + tar -czvf buildroot.tar.gz buildroot/ + +litex: + if [ ! -d 'litex' ]; then \ + git clone https://github.com/enjoy-digital/litex; \ + fi + cd litex && git checkout master && git pull && \ + git checkout -B upsilon_stable c6ccb626e88168045edacced3743f6bd98746742 diff --git a/environment_setup.md b/environment_setup.md new file mode 100644 index 0000000..c0dbd5a --- /dev/null +++ b/environment_setup.md @@ -0,0 +1,44 @@ +MagLab Upsilon development environment setup. +Written by Peter McGoron. + +Preqreuisites +============= + +Rebinding Caps Lock to Escape +----------------------------- + + gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']" + +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 +so that admin access is not required to load FPGA bitstreams. + +[1]: https://trabucayre.github.io/openFPGALoader/index.html + +Setup Rootless Docker +--------------------- + +Docker allows you to run programs in containers, which are isolated +environments. Upsilon development (at the Maglab) uses Docker for +reproducibility: the environment can be set up automatically, and re-setup +whenever needed. + +If you have issues with docker, try adding to `~/.config/docker/daemon.json` + + { + "storage-driver": "fuse-overlayfs" + } + + +Download and Install Python3 +---------------------------- + +Install `python3-venv` (or `python3-virtualenv`) and `python3-pip`. + +Setup Build Environment +======================= + +