Tuesday, October 2, 2018

How to dockerize Intel Quartus 18.01

I've been working with the Domesday Duplicator lately and one of the pieces of hardware that they use is the DE0-Nano board.  Domesday documentation focuses on linux tools so I booted into my Ubuntu and got the DE0-Nano IDE software (called 'Quartus') working.  While I was successful, I found it a bit of a pain to figure out which components of the software to download, and would've preferred a pre-built VM or a Docker image.  The Quartus license likely does not allow distribution of pre-built Docker images, so I have outlined the steps to create one from scratch here.

The benefits to running this program from a docker container are:
  • The docker image, once created, will likely work on many more platforms than what the native installation option offers.
  • Building and running the Docker image is relatively easy.
  • Installing and uninstalling is simple and clear.
So here are my instructions to Docker-ize Quartus v18.01:
  • Be using some linux flavor (I am on Ubuntu 18.04).
  • Install Docker and configure it so that normal users can access it (beyond scope of this blog post).
  • Create a file called /etc/udev/rules.d/51-usbblater.rules which has the following contents: (this file is necessary to allow non-root access to the USB device)

    SUBSYSTEM=="usb", ATTRS{idVendor}=="09fb", ATTRS{idProduct}=="6001", MODE="0666"
  • Run "sudo udevadm control --reload-rules" to make the change take effect
  • Download Quartus 18.1 Lite for linux, including the Cyclone 4 package.  The filenames I downloaded are called QuartusLiteSetup-18.1.0.625-linux.run and cyclone-18.1.0.625.qdz .
  • Create a new subdirectory and copy QuartusLiteSetup-18.1.0.625-linux.run and cyclone-18.1.0.625.qdz into it.
  • Inside this subdirectory, create a file called Dockerfile and paste this into it:

     # ubuntu 18.04 is officially supported by this version of quartus
    # libpng12 included in 16.04 but not in 18.04, so we use 16.04 for convenience
    FROM ubuntu:16.04

    ENV DEBIAN_FRONTEND noninteractive

    ARG QUARTUS=QuartusLiteSetup-18.1.0.625-linux.run
    ARG CYCLONE=cyclone-18.1.0.625.qdz

    COPY $QUARTUS /$QUARTUS
    COPY $CYCLONE /$CYCLONE

    RUN apt-get update && \
        apt-get -y -qq install apt-utils sudo && \
            apt-get -y -qq install locales && locale-gen en_US.UTF-8 && \
        apt-get -y -qq install software-properties-common \
                               libglib2.0-0:amd64 \
                               libfreetype6:amd64 \
                               libsm6:amd64 \
                               libxrender1:amd64 \
                               libfontconfig1:amd64 \
                               libxext6:amd64 \
                                    libpng12-0:amd64 \
                               xterm:amd64 && \
        chmod 755 /$QUARTUS

    # create a normal user so we're not running as root
    RUN export uid=1000 gid=1000 && \
        mkdir -p /home/developer && \
        echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
        echo "developer:x:${uid}:" >> /etc/group && \
        echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
        chmod 0440 /etc/sudoers.d/developer && \
        chown ${uid}:${gid} -R /home/developer

    # switch to user so it installs from the user's context
    USER developer
    ENV HOME /home/developer
    # install quartus as the user (not root)
    RUN    /$QUARTUS --mode unattended --unattendedmodeui none --installdir /home/developer/altera_lite --accept_eula 1 && \
        sudo rm -f /$QUARTUS && \
        sudo rm -f /$CYCLONE

    # run from xterm to capture any stdio logging (not sure there is any, but can't hurt)
    CMD xterm -e "/home/developer/altera_lite/quartus/bin/quartus --64bit"
  • From within this subdirectory (which contains the three files), run this command:
    "docker build -t quartus18 ."
  • It will take ~15 mins depending on the speed of your system.  When it finishes, your Docker image will be generated and will be called "quartus18".  You may now optionally delete the sub-directory that you created to generate the docker image.
  • Plug in your DE0-Nano to a USB port.  Be sure to unplug any other sources of power (for example, the FX3 board, if you have a DdD 'stack' ) or you will get unexplained errors.
  • From a desktop session, run the following command:

    docker run --rm -v /sys:/sys:ro -v $HOME:/shared -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY -e "QT_X11_NO_MITSHM=1" --privileged -v /dev/bus/usb:/dev/bus/usb quartus18
  • If all goes well, the Quartus app will launch inside of the container.  Your host's home folder will be accessible as /shared in the root.  Follow the instructions from DdD site.  You may also find this youtube video helpful.
  • When you exit the program, the container will automatically delete/uninstall itself.
The only thing left on your host system once you exit the container will be the file you put inside of /etc/udev/rules.d and the docker image that you created.  Uninstalling is as easy as removing this file and deleting the docker image.  Simply re-execute the "docker run" command above in the future to reprogram.

No comments:

Post a Comment