Build & Install
The akr2daq3 server software is cross compiled for the ZC706 [1] or ZCU102 [2] board. Therefore a cross compiler is needed. The following sections describes all requirements and steps to install.
Requirements
The server software is build within a linux system. Since we build the software not directly on the ZC706 we have to cross-compile for the Arm [3] platform. The preferred way to do this is with Docker (see Build the server software). Alternatively you can set up a cross compiler on the host. In both cases the following is needed:
This repository
needed libraries have to be installed on the ZC706
(optional) automatic SSH access to ZC706 via public key
For Docker-based builds you additionally need:
Docker - runs the cross compiler and sysroot in a container
For a native build on the host you additionally need:
CMake [4] - build system used by the server software
GCC cross compiler
Copy of parts of the root filesystem (rootfs)
Clone repository
Clone the repository to your local machine and initialize the submodules.
git clone git@gitlab.mn.tu-dresden.de:wket/hardware/fpga-zc706/zc706-server.git
git submodule update --init
Install CMAKE
Only needed for a native build on the host. Docker-based builds include CMake in the container.
To install CMake in an Ubuntu system run the following:
apt install cmake
Install needed libraries on the ZC706
The ZC706 needs the build-essential package to be installed. Therefore SSH into the ZC706 and install the package using root rights.
ssh debian@ZC706.local
After that you can install the package.
sudo apt install build-essential
For some reasons some symbolic links of libraries are absolute. This is a problem when trying to cross compile. Therefore we need to fix it using the symlinks tool
sudo apt install symlinks
cd /usr/lib/arm-linux-gnueabihf
sudo symlinks -rc .
Another thing which needs to be done is the following:
cd /usr/lib
sudo ln -s arm-linux-gnueabihf/crt1.o crt1.o
sudo ln -s arm-linux-gnueabihf/crti.o crti.o
sudo ln -s arm-linux-gnueabihf/crtn.o crtn.o
cd arm-linux-gnueabihf
sudo ln -s libstdc++.so.6 libstdc++.so
This is needed so that all libraries are found when building the software.
The last thing to do on the ZC706 is to create the directory which should contain the server application.
mkdir -p ~/app
GCC cross compiler
Only needed for a native build on the host. Docker images provide the cross compiler (see Build the server software).
A cross compiler tool chain may be found at developer.arm.com. On the currently used system at the AKR-2 [5] the version arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-linux-gnueabihf is used. Make sure you use the arm-none-linux-gnueabihf architecture as this is the one running on the ZC706.
To install it simply download it and extract to where ever you like. I suggest
within ~/tools/arm-cross-compiler.
Copy parts of the rootfs
Only needed for a native build on the host. Docker images include a matching sysroot.
The cross compiler needs to know the libraries and includes of the ZC706 to compile and link the final binary. Therefore it is needed to copy those parts of the rootfs from the ZC706 to your system.
The tool of choice to sync your copy of the rootfs with the ZC706 is the command rsync which must be installed on both systems. The ZC706 and the host PC.
sudo apt install rsync
After sync the usr and the lib directory of the ZC706. It is assumed that
the ZC706 is reachable using the hostname nexmess.local. Additionally it is
assumed the rootfs should be installed to ~/tools/ZC706/rootfs.
mkdir ~/tools/ZC706/rootfs
rsync -rl --delete-after --safe-links debian@nexmess.local:/{lib,usr} ~/tools/ZC706/rootfs
This may take some time.
Automatic SSH access to ZC706 via public key (optional but recommend)
When using a public key it is possible to directly access the ZC706 via SSH without having to enter a password. This makes it easy for the build system to directly copy the final binary onto the ZC706.
If you have not done so already generate a key pair (without passphrase):
ssh-keygen -t ed25519 -C "your-mail@example.com"
Copy the public key to the authorized_keys file of the ZC706.
ssh -T debian@ZC706 'mkdir -p ~/.ssh'
cat ~/.ssh/id_ed25519.pub | ssh -T debian@ZC706 'cat >> ~/.ssh/authorized_keys'
Now you should be able to access the ZC706 without entering a password. You may want to try it:
ssh debian@nexmess.local
Assumptions
This page assumes that the ZC706 is completely configured and running. It is assumed the ZC706 runs a Debian [6] system.
Environment variables
This wiki pages uses environment variables to point to special directories. You don’t have to set them but it makes almost all shown code copyable.
PROJECT_DIR - directory of the local copy of the git project.
ROOTFS_DIR - directory of the the copied rootfs of the ZC706
CROSS_COMPILER_DIR - directory of the cross compiler
Here is an example on how to set the variables.
export PROJECT_DIR=~/projects/daq3zc706-server
export ROOTFS_DIR=~/tools/ZC706/rootfs
export CROSS_COMPILER_DIR=~/tools/arm-cross-compiler/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-linux-gnueabihf
Build the server software
As already mentioned the server software uses CMake to make things easy. It is also possible to directly copy the final binary onto the ZC706 in the correct directory.
Before building the software clone it from the git repository.
git clone git@gitlab.mn.tu-dresden.de:wket/hardware/fpga-zc706/zc706-server.git
git submodule update --init
Dev Container (recommended for development)
For day-to-day development, open the project in a Dev Container. The container
includes the cross compiler, sysroot, CMake, gdb, clang-tidy, and clangd.
compile_commands.json uses workspace paths, so IntelliSense and static
analysis work in the IDE without extra setup.
Requirements on the host:
VS Code or Cursor with the Dev Containers extension
Docker
SSH key access to the target board (optional, for deploy)
Setup
Open the repository in VS Code / Cursor.
Run Dev Containers: Reopen in Container.
Pick a configuration:
akr2daq3 (armv7 / ZC706) — default,
.devcontainer/devcontainer.jsonakr2daq3 (aarch64 / ZCU102) —
.devcontainer/aarch64/devcontainer.json
On first start the container copies the matching example config to
config/config.cmake and runs an initial CMake configure.
The container uses host networking (--network=host) so the board is
reachable by hostname and mDNS (.local) works as on the host. Your host
~/.ssh directory is mounted read-only for deploy; ~/nfs is mounted at
/home/vscode/nfs when using NFS copy.
Build the software
Inside the container:
Target |
Debug |
Release |
|---|---|---|
armv7 (ZC706) |
|
|
aarch64 (ZCU102) |
|
|
Or use the default build task in the IDE (Ctrl+Shift+B).
Deploy and debugging from the container work like on the host: enable
ssh_copy in config/config.cmake to copy the binary after build, or deploy
manually. For remote debugging see Debug.
Example configs: config/config.devcontainer.armv7.cmake.example,
config/config.devcontainer.aarch64.cmake.example.
Docker build (from host)
Cross-compilation runs inside Docker images that include the toolchain and sysroot. Deploy via NFS or SSH is handled on the host after the container build finishes.
Configure the project
The docker compile scripts swap in config/config.docker.aarch64.cmake or
config/config.docker.armv7.cmake for the container toolchain/sysroot.
Do not edit those files. NFS/SSH deploy after the container build is read
from config/config.cmake. Typical SSH settings for the ZC706:
set(ssh_copy TRUE)
set(ssh_auto_restart_service TRUE)
set(ssh_user debian)
set(ssh_host zc706)
set(ssh_target_dir /home/debian/app)
When setting ssh_copy to TRUE the finished binary is copied to the ZC706 after the build. To make this possible you must be able to access the ZC706 without credentials.
When setting ssh_auto_restart_service to true the service is automatically stopped before copying the software to the ZC706. After copying the service will start again automatically. To be able to do that you must configure the software as service and allow the *debian* user to restart the service without password.
Build the software
Run one of the compile scripts for your target:
Target |
Debug |
Release |
|---|---|---|
aarch64 (ZCU102) |
|
|
armv7 (ZC706) |
|
|
Docker images: git-worker.wket.ifvu.mw.tu-dresden.de/cross-aarch64:trixie, git-worker.wket.ifvu.mw.tu-dresden.de/cross-armhf:bookworm
Example for a debug build on the ZC706:
./compile_debug_docker_armv7
Native build (host toolchain)
Configure the project
The project of the server software comes with a configuration example. Copy it to set your configuration.
cd $PROJECT_DIR
cp config/config.cmake.example config/config.cmake
Now edit the file to fit your needs. The following code snippet shows an example of changed settings within the config to match this wiki page.
# .....
set(sysroot_base_path $ENV{HOME}/tools/ZC706/rootfs)
set(toolchain_path $ENV{HOME}/tools/arm-cross-compiler/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-linux-gnueabihf)
# ssh copy config
# this only works if you can log in on the target device without password (via public key)
# set ssh_copy to FALSE to turn this off
# set ssh_auto_restart to FALSE to not automatically restart the service
set(ssh_copy TRUE)
set(ssh_auto_restart_service TRUE)
set(ssh_user debian)
set(ssh_host zc706)
set(ssh_target_dir /home/debian/app)
# .....
You can see that the rootfs directory is set to sysroot_base_path, the
cross compiler directory is set to toolchain_path and that user specific
settings for the ZC706 are made. When settings ssh_copy to TRUE the
finished binary is directly copied to the ZC706 in the set directory
(/home/debian/app in this case). To make this possible you must be able to
access the ZC706 without credentials.
When setting ssh_auto_restart_service to true the service is automatically stopped before copying the software to the ZC706. After copying the service will start again automatically. To be able to do that you must configure the software as service and allow the *debian* user to restart the service without password.
Build the software
There are two simple scripts to compile the project.
compile_debug- Compiles the debug version of the server softwarecompile_release- Compiles the release version of the server software
Simply run one of the scripts and the software is build and depending on the configuration copied to the ZC706. The following snippet shows how to compile the release version.
./compile_release
Start server software automatically on boot
When actually planning to do measurements using the whole system it is wise to not bother with the board at all. So the server software should start automatically in network (server) mode. Like this the measurements may start as soon as the green LED lights up.
To do this systemd [7] is used. A .service unit must be placed
into /etc/systemd/system. The project provides example units under
scripts/systemctl/:
akr2daq3-zc706.service— ZC706 (no analog bring-up dependency)akr2daq3-zcu102.service— ZCU102 with FMC-ADC500CD; waits foradc500cd-init.servicebefore starting
On ZCU102 images built with the meta-zcu102-akr2 Yocto layer,
adc500cd-init.service runs adc500cd init at boot. Use the ZCU102 unit
there so akr2daq3 only starts after the ADC mezzanine is initialized. On
ZC706 that service does not exist and is not required — use akr2daq3-zc706.service
as-is.
On ZCU102, capture ADS54J60 interleaving-core offsets at least once before using DC coupling. Use idle, AC-coupled analog inputs:
akr2daq3 --calibrate-offset
This writes /var/lib/adc500cd/offset-corr (shared with adc500cd offset-corr
generate). Until that file exists, akr2daq3 warns and uses zeros. This
step is not used on ZC706.
Copy the appropriate unit onto the board (example hostnames below), set
ExecStart to the installed binary path, then enable the service. You need
root rights on the board.
ZC706
scp $PROJECT_DIR/scripts/systemctl/akr2daq3-zc706.service debian@ZC706.local:/tmp/akr2daq3.service
ZCU102
scp $PROJECT_DIR/scripts/systemctl/akr2daq3-zcu102.service debian@zcu102.local:/tmp/akr2daq3.service
Once the file is copied, SSH into the board and log yourself in. Then switch to
the root user using sudo su.
Edit the unit and set the correct path for ExecStart:
nano /tmp/akr2daq3.service
Save and close the file (CTRL+O -> CTRL+X).
Then:
mv /tmp/akr2daq3.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable akr2daq3.service
You may control the server software using the following commands if you feel there is a need for it:
systemctl start akr2daq3.service
systemctl stop akr2daq3.service
systemctl restart akr2daq3.service
Assuming the server software is not running you can test if everything is fine by starting the software using the start command. The green LED should turn on. It should turn off again if you use the stop command. The green LED should turn on shortly after boot once the service is enabled.
Allow user to restart service
When following the previous section it is a good idea to allow the debian user to restart the service, too. To du that login as root and run the following command:
visudo
Add the following lines at the end of the file:
debian ALL=(ALL:ALL) NOPASSWD: /bin/systemctl start akr2daq3
debian ALL=(ALL:ALL) NOPASSWD: /bin/systemctl stop akr2daq3
debian ALL=(ALL:ALL) NOPASSWD: /bin/systemctl restart akr2daq3
Like this you can simply control the server as the debian user using sudo without any password. It is possible to automatically upload and restart the service when building the server software, too.
Build the documentation
The documentation is automatically build on each push to the main branch. You can also build it manually.
The documentation requires Doxygen [8] and Python [9] to be installed on your system. To install it run the following command:
sudo apt install doxygen python3
Then you can build the documentation running the script make_doc:
./make_doc
The documentation will be available within the html directly.