Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 44 additions & 49 deletions quartus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Quartus is a part of [Intel Quartus Prime Lite](https://www.intel.de/content/www
## Tags
| Tag | Quartus Version | Device Support | Note |
|---|---|---|---|
| `18.1-cycloneiv` | 18.1.0 | Cyclone IV | Quartus GUI non functional with WSLg (only window borders), use [`VcXsrv`](https://github.com/marchaesen/vcxsrv). |
| `22.1-cycloneiv` | 22.1.2 | Cyclone IV | - |
| `23.1-cycloneiv` | 23.1.1 | Cyclone IV | - |
| `24.1-cycloneiv` | 24.1.0 | Cyclone IV | Very slow. ~2x slowdown compared to older versions. Regardless if GUI or scripts are used. |
| `25.1-cycloneiv` | 25.1.0 | Cyclone IV | - |
| `18.1` | 18.1.0 | Cyclone IV | Quartus GUI non functional with WSLg (only window borders), use [`VcXsrv`](https://github.com/marchaesen/vcxsrv). |
| `22.1` | 22.1.2 | Cyclone IV | - |
| `23.1` | 23.1.1 | Cyclone IV | - |
| `24.1` | 24.1.0 | Cyclone IV | Very slow. ~2x slowdown compared to older versions. Regardless if GUI or scripts are used. |
| `25.1` | 25.1.0 | Cyclone IV | - |

Feel free to open an issue to request other versions or additional device support.

Expand All @@ -24,15 +24,15 @@ Feel free to open an issue to request other versions or additional device suppor

The image has `quartus_sh` set as `ENTRYPOINT`. Simply running a container without arguments will invoke `quartus_sh` with the default `CMD` argument `-version` and print the Quartus version:
```
$ docker run ghcr.io/nikleberg/quartus:24.1-cycloneiv
$ docker run ghcr.io/nikleberg/quartus:24.1
> Quartus Prime Shell
Version 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
Copyright (C) 2025 Altera Corporation. All rights reserved.
```

For an actual usage you want to override the `CMD` by giving additional arguments to the `docker run` command. For example to run a tcl script you could run:
```
$ docker run ghcr.io/nikleberg/quartus:24.1-cycloneiv -t <script>.tcl
$ docker run ghcr.io/nikleberg/quartus:24.1 -t <script>.tcl
> Info: *******************************************************************
Info: Running Quartus Prime Shell
Info: Version 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
Expand All @@ -52,51 +52,46 @@ Quartus knows many CLI programs, `quartus_sh` is just the common entrypoint to r

To use them you can simply set `--entrypoint quartus_<xxx>` to the desired program when starting the container with `docker run`.

### Device Support
To keep the base image lean, it does not ship with any deviceinfo files. To allow quartus to actually build a bitfile for your device you must use one (or multiple) of the provided _data-only_ device docker images. The device images are a bit special to handle but allow for a minimal setup while keeping everything well separeted.

First, just _create_ a named container from the data-only image by running:
```
$ docker create --name quartus-devinfo -v <path to devinfo files> ghcr.io/nikleberg/quartus:<quartus version>-<device type>
```

For _quartus version_ choose one of the table above. For _path to devinfo files_ and _device type_ see the following table. Note that you can also just use one of the given _volume paths_ if there are multiple listed. E.g. if you only use Cyclone IV E (and not GX) products, you can omit the _cycloneivgx_ path.

| Tag | Device Support | Volume Path(s) |
|---|---|---|
| `<quartus version>-cycloneiv` | Cyclone IV (E / GX) | `-v /opt/quartus_lite/quartus/common/devinfo/cycloneive` and `-v /opt/quartus_lite/quartus/common/devinfo/cycloneivgx` |
| `<quartus version>-cyclonev` | Cyclone V (E / GX / GT / SX / SE / ST) | `-v /opt/quartus_lite/quartus/common/devinfo/cyclonev` |

Now, you can start an actual quartus image and include the data from the listed volume paths of the other named container with:
```
$ docker run --volumes-from quartus-devinfo ghcr.io/nikleberg/quartus:24.1
```

To support multiple devices at the same time you may use multiple `--volumes-from` like so:
```
$ docker create --name devinfo-cycloneive -v /opt/quartus_lite/quartus/common/devinfo/cycloneive ghcr.io/nikleberg/quartus:24.1-cycloneiv
$ docker create --name devinfo-cyclonev -v /opt/quartus_lite/quartus/common/devinfo/cyclonev ghcr.io/nikleberg/quartus:24.1-cyclonev
$ docker run --volumes-from devinfo-cycloneive --volumes-from devinfo-cyclonev ghcr.io/nikleberg/quartus:24.1
```

### Software Add-Ons
To use a image with a pre-installed version of optional software, see following table for available options:

| Tag | Add-On | Note |
|---|---|---|
| `<quartus version>-riscfree` | Ashling RiscFree IDE for FPGAs | Currently only packaged for Quartus versions `23.1` through `25.1`. |

Feel free to open an issue to request other add-ons or additional versions.

### Additional `docker run` Arguments
For improved functionality and ease-of-use you may want to add some of these arguments to the `docker run` command stated above:
- `--hostname quartus`: Make the shells in the container display a human readable machine name.
- `--interactive --tty`: This makes the started container interactive and not run in the background.
- `--rm`: Removes the container after the command is finished, your disk will thank you.
- `--workdir $(pwd)`: Sets the working directory inside the container to the current shell path.
- `--volumes-from $(cat /proc/self/cgroup | head -n 1 | cut -d '/' -f3)`: If the container is started in the DooD environment provided by [`dev-base`](../dev-base/README.md) in Devcontainers, then this forwards the required volumes from the base container to the _quartus_ tool container. This is required to access any path in `/workspaces`.
- Anything mentioned in [`dev-base`](../dev-base/README.md)
- `--volume=/dev:/dev --privileged`: Allows USB/JTAG access to FPGAs for programming.
- `--env=DISPLAY=:0 --volume=/tmp/.X11-unix/:/tmp/.X11-unix/`: Forwards your X11 configuration (this works in WSLg!). With this, starting the GUI with the command `quartus` opens the GUI on your docker host.

### Alias
To release your fingers from the pain of entering these commands and arguments all the time, use an alias function.

Put the below functions in a script and `source <script>` it in whatever shell you need the `quartus_*` commands. After this, having Quartus installed locally is almost identical as having it isolated in this self-contained docker image.

```bash
function get_common_args () {
common_vols="--volumes-from $(cat /proc/self/cgroup | head -n 1 | cut -d '/' -f3)"
common_disp="--env=DISPLAY=:0 --volume=/tmp/.X11-unix/:/tmp/.X11-unix/"
common_misc="--workdir $(pwd) --interactive --tty --rm"
common_args="$common_vols $common_disp $common_misc"
echo $common_args
}
export -f get_common_args

function command_not_found_handle () {
if [[ $1 =~ ^quartus.*$ ]]; then
quartus_args="--hostname quartus --entrypoint $1 $(get_common_args)"
shift
docker run $quartus_args ghcr.io/nikleberg/quartus:24.1-cycloneiv $*
return
fi
return 127 # not a quartus command
}
export -f command_not_found_handle
function quartus_bash () {
quartus_args="--hostname quartus --entrypoint bash $(get_common_args)"
docker run $quartus_args ghcr.io/nikleberg/quartus:24.1-cycloneiv $*
}
export -f quartus_bash
```

Note:
- The `command_not_found_handle` is not a classical function-like alias but a general handler that gets called by BASH (versions >= 4) to look for unknown commands. With a regex compare we test if the unknown commands starts with `quartus` and will redirect all such commands to a freshly started docker container.
- The additional `quartus_bash` alias is for debugging. It overwrites the entrypoint in the image and lets you more easily debug problems by dropping you into a bash shell inside the container.

## License
[MIT](../LICENSE) © [NikLeberg](https://github.com/NikLeberg).
19 changes: 19 additions & 0 deletions quartus/addon.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Extend base quartus image with optional add-ons.
ARG QUARTUS_VERSION=25.1
FROM ghcr.io/nikleberg/quartus:${QUARTUS_VERSION}-staging

ARG QUARTUS_ROOTDIR="/opt/quartus_lite"
ARG ADDON_URL=https://downloads.intel.com/akdlm/software/acdsinst/25.1std/1129/ib_installers/RiscFreeSetup-25.1std.0.1129-linux.run
ARG ADDON_SHA=2d457bd18bfbf32f8f4037266b6c04853caed8e8
ARG ADDON_FILE=RiscFreeSetup-25.1std.0.1129-linux.run

# Install Add-On package.
RUN <<EOF
set -e
wget --progress=dot:giga $ADDON_URL -O $ADDON_FILE
echo "$ADDON_SHA *${ADDON_FILE}" | sha1sum --check --strict -
chmod +x $ADDON_FILE
./$ADDON_FILE \
--mode unattended --accept_eula 1 --installdir $QUARTUS_ROOTDIR
rm -r $ADDON_FILE $QUARTUS_ROOTDIR/uninstall $QUARTUS_ROOTDIR/logs
EOF
8 changes: 5 additions & 3 deletions quartus/base.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@

ARG UBUNTU_VERSION=24.04
ARG QUARTUS_VERSION=25.1
ARG QUARTUS_URL=https://downloads.intel.com/akdlm/software/acdsinst/24.1std/1129/ib_installers/QuartusLiteSetup-25.1std.0.1129-linux.run
ARG QUARTUS_URL=https://downloads.intel.com/akdlm/software/acdsinst/25.1std/1129/ib_installers/QuartusLiteSetup-25.1std.0.1129-linux.run
ARG QUARTUS_SHA=ce0773469eacab5b7035c175484625f4ec3737d1
ARG SHIZZOLATOR_NAME=i3q6bSoc4a0
ARG SHIZZOLATOR_DATA=e37e9f21a65ee0df
ARG QUARTUS_ROOTDIR="/opt/quartus_lite"

FROM ubuntu:$UBUNTU_VERSION AS builder

ARG QUARTUS_VERSION
ARG QUARTUS_URL
ARG QUARTUS_SHA
ARG QUARTUS_ROOTDIR

ARG DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8 \
Expand All @@ -39,7 +41,6 @@ EOF
# Install Quartus (without device support files) for Intel FPGAs from:
# https://www.intel.de/content/www/de/de/products/details/fpga/development-tools/quartus-prime/resource.html
# This also post-processes the install dir to remove duplicates.
ENV QUARTUS_ROOTDIR="/opt/intelFPGA_lite/$QUARTUS_VERSION"
RUN <<EOF
set -e
wget --progress=dot:giga $QUARTUS_URL -O QuartusLiteSetup-linux.run
Expand Down Expand Up @@ -99,6 +100,7 @@ FROM ubuntu:$UBUNTU_VERSION AS base
ARG QUARTUS_VERSION
ARG SHIZZOLATOR_NAME
ARG SHIZZOLATOR_DATA
ARG QUARTUS_ROOTDIR

ARG DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8 \
Expand Down Expand Up @@ -126,7 +128,7 @@ RUN <<EOF
EOF

# Add Quartus to path
ENV QUARTUS_ROOTDIR="/opt/intelFPGA_lite/$QUARTUS_VERSION"
ENV QUARTUS_ROOTDIR=$QUARTUS_ROOTDIR
ENV PATH="$QUARTUS_ROOTDIR/quartus/bin:${PATH}"

# Fixup Quartus quirks in version 18.1 that prevent loading the executables
Expand Down
Loading