Adding Custom Applications

One of the primary purposes of the cFS framework is to provide a platform for mission-specific applications. This guide outlines the basic steps required to integrate your own custom application into the cFS build and runtime system.

For a comprehensive guide on creating applications, it is highly recommended to consult the official cFE Application Developer's Guide, which can be found in the cFE submodule repository at cFE/docs/cFE Application Developers Guide.md.

The easiest way to start is by using an existing application, like sample_app or skeleton_app (from a separate repository), as a template.

Once you have created your application's source code, you need to perform two key integration steps:

1. Add the Application to the Build System

The cFS build system, driven by CMake, needs to be aware of your new application. This is done by adding it to the MISSION_GLOBAL_APPLIST in your targets.cmake file.

This file is typically located in your mission definition directory, which for this bundle is sample_defs/.

Example: Modifying sample_defs/targets.cmake

If your application is named my_app and is located in the apps/my_app directory, you would add the following line:

# In sample_defs/targets.cmake

# ... existing list of apps ...
list(APPEND MISSION_GLOBAL_APPLIST sample_app)
list(APPEND MISSION_GLOBAL_APPLIST sch_lab)

# Add your new application here
list(APPEND MISSION_GLOBAL_APPLIST my_app)

After this change, running make prep and make will compile your application along with the rest of the system.

2. Add the Application to the Startup Script

Simply compiling the application is not enough; the cFS Executive Services (ES) needs to be instructed to load and run it at startup. This is configured in the ES startup script, a .scr file.

For this bundle, the relevant file is sample_defs/cpu1_cfe_es_startup.scr.

You need to add a CFE_APP entry for your application. The format specifies the library name, entry point, application name, priority, stack size, and other parameters.

Example: Modifying sample_defs/cpu1_cfe_es_startup.scr

-- This is the cFE startup script for CPU1.

-- ... other app definitions ...
CFE_APP, sample_app, SAMPLE_AppMain, SAMPLE_APP, 81, 16384, 0x0, 0;

-- Add your new application's startup command
CFE_APP, my_app, MY_APP_Main, MY_APP, 82, 16384, 0x0, 0;

-- ... system commands ...
CFE_CMD, CFE_EVS, POKE_NOOP_CC, 2, 0, "No-op command to EVS";

With these two changes, your custom application will be fully integrated into the cFS system. When you next build and run ./core-cpu1, your application will be loaded and executed by the cFE Core.