Creating New Applications

Most embedded Linux systems include some specific user software programs that executes in the Linux operating system environment. These applications often include it's own set of build rules that are architecture specifics and are built independantly of the Linux kernel. This section describes the process of adding or creating a new user application into PetaLinux.

The 'user-apps' Directory

PetaLinux includes the '$PETALINUX/software/user-apps' directory to house all user-land application programs. Any new application can be added into this directory.

Using 'petalinux-new-app' Script

The 'petalinux-new-app' script automates the creation of a new application environment, including the directory structure and template Makefile and 'C' source file for building the new application. The created application environment can also be used to house existing application. The usage information of the 'pertalinux-new-app' script can be found in the PetaLinux Tools Section.

$ cd $PETALINUX/software/user-apps
$ petalinux-new-app my_new_app
New application template successfully created in software/user-apps/my_new_app
See my_new_app/README for what to do next.

The above example will create an application directory called 'my_new_app' along with a Makefile, C source file and a README file.

The user can now start developing their application.

Adding an Existing Application

Adding an existing application is just as straight forward.

Create a directory for the application

Use the 'petalinux-new-app' script to create a directory structure within '$PETALINUX/software/user-apps' for your existing application.

$ cd $PETALINUX/software/user-apps
$ petelinux-new-app my_existing_app
New application template successfully created in software/user-apps/my_existing_app
See my_existing_app/README for what to do next.

Copy source files to the new application directory

Copy the source files of the application into the new application directory created in the previous step.

Note: Ensure that the Makefile in the new application directory is not overwritten.

Edit the Makefile

Edit the Makefile to include the build rules for your existing application.

Installing Application into Root Filesystem

The application executable must be installed into the romfs of the target system before it can be used. This romfs directory is compile into the kernel image during the kernel image build process.

To install the application program simply use the 'make romfs' command.

$ cd $PETALINUX/software/user-apps/my_existing_app
$ make romfs