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
dependsnames them.
Sources
nextpnr-0.11.1.tar.gz(3.4 MiB)
sha2562af682d94abf3f3e116f2fad36dc7db314fa93bfbb185e63619f2ec4f5fe40dc
upstream: https://github.com/YosysHQ/nextpnr/archive/refs/tags/nextpnr-0.11.1.tar.gz
archive copy: sources-2/eda--nextpnr-0.11.1.tar.gz
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:
-Wl,--strip-debug— Drop debug sections at the link. nextpnr’sCMakeLists.txtsets its ownCMAKE_CXX_FLAGS_RELEASEto-O3 -g, so a release build compiles every object with DWARF; no port ships it (see What kpkg does around build.sh).-DCMAKE_POLICY_DEFAULT_CMP0167=NEW— Makefind_package(Boost)read theBoostConfig.cmakepackage that boost installs instead of CMake’s old FindBoost module. FindBoost looks for alibboost_systemlibrary file; the boost port installs Boost.System as headers only, so the module reports the component missing.-DCURRENT_GIT_VERSION="nextpnr-$version"— The version string the programs print. Unset,common/CMakeLists.txtrunsgit describein the source tree, which is no checkout here.-DARCH="ice40;ecp5;machxo2;generic"— The families to build. The cache variable is empty upstream, and configure stops until it names at least one.ice40reads icestorm’s database andecp5andmachxo2read prjtrellis’s. nexus, mistral and himbaechel are left out: nexus’s database comes from prjoxide, mistral’s from the mistral source tree, and each himbaechel micro-architecture’s from its own project (apicula for Gowin, Project Peppercorn for GateMate, prjbeyond for NG-Ultra, prjxray for Xilinx), none of which is a port.-DMACHXO2_DEVICES="1200;6900"— The MachXO2 and MachXO3 parts whose chip database is compiled in, which is upstream’s default pair. A design for any other part of that family finds no database.-DBUILD_GUI=ON— Build the Qt 6 floorplan viewer,nextpnr-<arch> --gui: the design drawn over the fabric as it is packed, placed and routed. Off by default upstream. It needsBUILD_PYTHON, and configure stops without it.-DBUILD_PYTHON=ON— Embed Python, through pybind11, for the--pre-pack,--post-routeand--runscripts. It is upstream’s default, and the GUI requires it.-Dpybind11_DIR="$(python3 -m pybind11 --cmakedir)"— Pointfind_package(pybind11 CONFIG)at the python3-pybind11 port, which keeps its CMake package insidesite-packages. Without it the search finds nothing and configure falls back to the copy in3rdparty/pybind11with only a status line.-DBUILD_RUST=OFF— No Rust integration. It is upstream’s default.-DUSE_OPENMP=ON— Parallelise the analytic placer with OpenMP (gcc’s libgomp). Off by default upstream.-DICESTORM_INSTALL_PREFIX=/usr— Where icestorm’s chip database is read from at build time. The default is the install prefix, which is also/usr, unless anICESTORM_INSTALL_PREFIXvariable is in the environment; naming it makes the environment irrelevant.-DTRELLIS_INSTALL_PREFIX=/usr— The same for prjtrellis’s database and its Python library.
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.