Steps to Test User Libraries - 2021.1 English

PetaLinux Tools Documentation Reference Guide (UG1144)

Document ID
UG1144
Release Date
2021-06-16
Version
2021.1 English
  1. Create an application using following command.
    petalinux-create -t apps --template c -n sampleapp --enable
  2. Modify the file <plnx-proj-root>/project-spec/meta-user/recipes-apps/sampleapp/sampleapp.bb as below:
    #
    # This file is the sampleapp recipe.
    #
    
    SUMMARY = "Simple sampleapp application"
    SECTION = "PETALINUX/apps"
    LICENSE = "MIT"
    LIC_FILES_CHKSUM = 
    "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
    
    SRC_URI = "file://sampleapp.c \
                      "
    S = "${WORKDIR}"
    
    DEPENDS = " sample"
    
    do_compile() {
            ${CC} ${CFLAGS} ${LDFLAGS} -o testsamplelib testsamplelib.c -lsample
    }
    
    do_install() {
                 install -d ${D}${bindir}
                 install -m 0755 sampleapp ${D}${bindir}
    }
    FILES_${PN} += "sampleapp"
  3. Edit the file project-spec/meta-user/recipes-apps/sampleapp/files/sampleapp.c.
    #include <stdio.h>
    #include <SAMPLE/libsample.h>
    
    int main(int argc, char **argv)
    {
        printf("Hello World!\n");
        samplelib();
        return 0;
    }
  4. Build the application using the following command:
    petalinux-build -c sampleapp
  5. Boot the newly created system image.
  6. Run your user application on the target system console. For example, to run user application sampleapp:
    # sampleapp
  7. Confirm that the result of the application is as expected.