Hello World Example for Debian - UG1630

Kria SOM App Store Applications Developer Deployment Guide for Ubuntu (UG1630)

Document ID
UG1630
Release Date
2023-08-11
Revision
1.0 English

This example generates a Hello World binary Debian package. This example is created entirely on a Kria SOM target.

First, create a folder. This example uses amd-hello-kria_1.0.0-1+jammy_arm64/. Customize the example to a specific project: <vendor>-<package_name>-<target>_ <upstream_version>-<debian_revision>+<dist_codename>_<Architecture>.

In the folder, create the following folders and add the perspective files. In compliance with the Package File System Unpacking file system structures, the files are put into a /opt/amd/hello/ folder:

amd-hello-kria_1.0.0-1+jammy_arm64/opt/amd/hello/src/hello.c

amd-hello-kria_1.0.0-1+jammy_arm64/opt/amd/hello/src/makefile

This is the makefile:

CC      = gcc
CFLAGS  = -g
RM      = rm -f

default: all
all: hello
hello: hello.c
                $(CC) $(CFLAGS) -o hello hello.c

install: hello
        install -d $(DESTDIR)/opt/xilinx/hello/bin/
        install -m 755 hello $(DESTDIR)/opt/xilinx/hello/bin/

clean veryclean:
        $(RM) hello

In the amd-hello-kria_1.0.0-1+jammy_arm64/opt/amd/hello/src/ folder, execute the following to copy the executable to the bin/ folder:

make
mkdir ../bin
mv hello ../bin

Now you have:

amd-hello-kria_1.0.0-1+jammy_arm64/opt/amd/hello/bin/hello

Next, create the amd-hello-kria_1.0.0-1+jammy_arm64/DEBIAN/control file. Modify the fields accordingly, making sure the source, vendor, version, and architecture fields match.

Source: amd-hello-kria_1.0.0-1+jammy_arm64
Section: unknown
Priority: optional
Maintainer: <your name> <your email>
Standards-Version: 4.6.0
Homepage: <your home page>
Rules-Requires-Root: no
Package: amd-hello-kria
Version: 1.0.0-1+jammy
Vendor: amd
Architecture: arm64
Description: hello world test

In the amd-hello-kria_1.0.0-1+jammy_arm64/ folder, execute this to generate amd-hello-kria_1.0.0-1+jammy_arm64/DEBIAN/md5sums.

md5sum $(find * -type f -not -path 'DEBIAN/*') > DEBIAN/md5sums

The following files should be created:

amd-hello-kria_1.0.0-1+jammy_arm64/opt/amd/hello/bin/hello

amd-hello-kria_1.0.0-1+jammy_arm64/opt/amd/hello/src/hello.c

amd-hello-kria_1.0.0-1+jammy_arm64/opt/amd/hello/src/makefile

amd-hello-kria_1.0.0-1+jammy_arm64/DEBIAN/control

amd-hello-kria_1.0.0-1+jammy_arm64/DEBIAN/md5sums

In the top-level folder, find amd-hello-kria_1.0.0-1+jammy_arm64/, and generate a DEB file:

dpkg-deb --build --root-owner-group amd-hello-kria_1.0.0-1+jammy_arm64

This generates an amd-hello-kria_1.0.0-1+jammy_arm64.deb file. Find and test the package using the following commands, and inspect the /opt/amd/hello/ folder after installing the Debian package.

dpkg -c  amd-hello-kria_1.0.0-1+jammy_arm64.deb      # look at the content of .deb
sudo dpkg -i  amd-hello-kria_1.0.0-1+jammy_arm64.deb # install the Debian package 
sudo dpkg --remove amd-hello-kria                    # uninstall Debian package

Next, upload the DEB file into a private PPA, and add the PPA to the PPA list on the Kria SOM target. Once the PPA is visible on the target, use the following to install the package:

sudo apt install -y amd-hello-kria

After that, you should see a binary in the /opt/Xilinx/hello/bin/hello folder and be able to execute it.