Steps to Add Custom Applications - 2022.2 English

PetaLinux Tools Documentation: Reference Guide (UG1144)

Document ID
UG1144
Release Date
2022-10-19
Version
2022.2 English

The basic steps are as follows:

  1. Create a user application by running petalinux-create -t apps from inside a PetaLinux project on your workstation:
    $ cd <plnx-proj-root>
    $ petalinux-create -t apps --template <TYPE> --name <user-application-name> --enable

    For example, to create a user application called myapp in C (the default):

    $ petalinux-create -t apps --name myapp --enable

    or:

    $ petalinux-create -t apps --template c --name myapp --enable

    To create a C++ application template, pass the --template c++ option, as follows:

    $ petalinux-create -t apps --template c++ --name myapp --enable

    To create an autoconf application template, pass the --template autoconf option, as follows:

    $ petalinux-create -t apps --template autoconf --name myapp --enable

    The new application sources can be found in the <plnx-proj-root>/project-spec/meta-user/recipes-apps/myapp directory.

  2. Change to the newly created application directory.
    $ cd <plnx-proj-root>/project-spec/meta-user/recipes-apps/myapp

    You should see the following PetaLinux template-generated files:

    Table 1. Adding Custom Applications Files
    Template Description
    <plnx-proj-root>/project- spec/meta-user/conf/user-rootfsconfig Configuration file template - This file controls the integration of your application into the PetaLinux RootFS menu configuration. It also allows you select or de-select the app and its dev, dbg packages into the target root file system
    Makefile Compilation file template - This is a basic Makefile containing targets to build and install your application into the root file system. This file needs to be modified when you add additional source code files to your project.
    README A file to introduce how to build the user application.
    myapp.c for C;

    myapp.cpp for C++

    Simple application program in either C or C++, depending upon your choice.
    Note: If you want to use the build artifacts for debugging with the third party utilities, add the following line in <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf:
    RM_WORK_EXCLUDE += "myapp"
    Note: You can find all build artifacts under ${TMPDIR}/work/<arch>/myapp/1.0./r0/
    where arch can be:
    • aarch64(zynqmp and versal) - cortexa72-cortexa53-xilinx-linux
    • arm(zynq) - cortexa9t2hf-neon-xilinx-linux-gnueabi/
    • microblaze - microblazeel-v11.0-bs-cmp-re-mh-div-xilinx-linux/
    Note: Applications created using the petalinux-create -t apps command have debug symbols by default in the following path if you comment out rm_work: <plnx-proj-root>/build/conf/local.conf.<plnx-proj-root>/build/tmp/work/aarch64-xilinx-linux/<app-name>/1.0-r0/packages-split/<app-name>-dbg/usr/bin/.debug/<app-name>.
    Tip: Mapping of Make file clean with do_clean in recipe is not recommended. This is because Yocto maintains its own do_clean.
  3. myapp.c/myapp.cpp file can be edited or replaced with the real source code for your application. If you want to modify your custom user application later, this file should be edited.
CAUTION:
You can delete the app directory if it is no longer required. You must also remove the line: CONFIG_myapp from <plnx-proj-root>/project-spec/meta-user/conf/user-rootfsconfig. Deleting the directory by keeping the mentioned line throws an error.