Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

338.3. nextpnr-0.11.1

Place and route — the second stage of the open FPGA flow

Version 0.11.1, release 1
Shelf eda — Electronics: schematic and PCB, circuit simulation, antenna modelling, FPGA synthesis and simulation, logic analysers and bench instruments
Phase 44_apps (Applications), 70 of 422 in build order
Licence ISC
Homepage https://github.com/YosysHQ/nextpnr
Build time 16.5 SBU
Installed size 481.9 MiB in 7 files
Recipe ports/core/eda/nextpnr/kpkgbuild

About

nextpnr is the place-and-route tool of the open FPGA flow: it takes the netlist that yosys synthesises and fits it onto the cells and wires of one chip, writing the configuration that icestorm or prjtrellis then packs into a bitstream. Each chip family is its own program, nextpnr-ice40, nextpnr-ecp5, nextpnr-machxo2 and nextpnr-generic, and each carries its family’s chip database compiled into the binary.

Why it is in KDOS

The comment above it in script/phases/44_apps/packages.d/eda.txt:

nextpnr compiles each fabric description INTO its binary, so both chip databases, icestorm and prjtrellis, must be installed before it is built; its depends names them.

Sources

Dependencies

Depends on: cmake, ninja, pkgconf, boost, eigen, python3, python3-pybind11, icestorm, prjtrellis, qt6-qtbase, libunwind-nongnu.

Required by: no port names it.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/44_apps/phase.env && kpkg install nextpnr'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/eda/nextpnr.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/eda/nextpnr
echo '2af682d94abf3f3e116f2fad36dc7db314fa93bfbb185e63619f2ec4f5fe40dc  nextpnr-0.11.1.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/nextpnr
SRC=$SRC_ROOT/nextpnr-0.11.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf nextpnr-0.11.1.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

export LDFLAGS="$LDFLAGS -Wl,--strip-debug"
mkdir -p build && cd build
cmake .. -G Ninja \
	-DCMAKE_POLICY_DEFAULT_CMP0167=NEW \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCURRENT_GIT_VERSION="nextpnr-$version" \
	-DARCH="ice40;ecp5;machxo2;generic" \
	-DMACHXO2_DEVICES="1200;6900" \
	-DBUILD_GUI=ON \
	-DBUILD_PYTHON=ON \
	-Dpybind11_DIR="$(python3 -m pybind11 --cmakedir)" \
	-DBUILD_RUST=OFF \
	-DBUILD_TESTS=OFF \
	-DUSE_OPENMP=ON \
	-DICESTORM_INSTALL_PREFIX=/usr \
	-DTRELLIS_INSTALL_PREFIX=/usr
ninja
DESTDIR=$PKG ninja install

install -d "$PKG/usr/share/applications"
for arch in ice40:iCE40 ecp5:ECP5; do
	cat > "$PKG/usr/share/applications/nextpnr-${arch%%:*}.desktop" <<DESKTOP
[Desktop Entry]
Type=Application
Name=nextpnr (${arch#*:})
GenericName=FPGA Place and Route
Comment=Place and route a design on a Lattice ${arch#*:} FPGA and view the floorplan
Exec=nextpnr-${arch%%:*} --gui
TryExec=nextpnr-${arch%%:*}
Icon=cpu
Terminal=false
StartupWMClass=nextpnr-${arch%%:*}
Categories=Qt;Development;Electronics;
Keywords=fpga;place;route;floorplan;lattice;${arch%%:*};
DESKTOP
	chmod 644 "$PKG/usr/share/applications/nextpnr-${arch%%:*}.desktop"
done

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/nextpnr, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf nextpnr-0.11.1-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/nextpnr, and runs the triggers its paths call for.

Contents

Installed programs: nextpnr-ecp5, nextpnr-generic, nextpnr-ice40, nextpnr-machxo2.

Installed directories: /usr/share/licenses/nextpnr.

Notes

The chip databases are read when nextpnr is built, not when it runs, so icestorm and prjtrellis are in depends of a program that links neither. A database that changes after nextpnr is built reaches it only through a rebuild of nextpnr.

On a C library other than glibc, configure stops when libunwind is missing, GUI or not. The libunwind-nongnu port is in depends for that.

nextpnr installs no menu entries, so build.sh writes two, for ice40 and ecp5, each running nextpnr-<arch> --gui. machxo2 and generic have none: machxo2 needs a --device, and generic has no device until a Python script describes one.