External Code Interface (ECI)
 All Data Structures Files Functions Variables Typedefs Groups Pages
Building the ECI sample apps.

This page provide a tutorial on how to build and run the included ECI sample apps using both CFE 6.5 and 6.6. For conciseness, we will refer to the built CFS directory as cfs_dir and the location of the ECI files as eci_dir in this section.

Requirements

ECI doesn't have any additional depedencies beyond the requirements of the CFS. For the purposes of this tutorial, we'll be using the CFE targeted for linux and so we assume the following are available on your machine:

Building CFS 6.5 ECI

The older CFE 6.5 utilizes a make-based build system, and so requires some tweaks to integrate the apps. If you're intending to just demo the ECI, we recommend using the build scripts located in the /ci directory of the ECI repo.

  1. Clone the CFE repository from GitHub. If you have a working version of CFE 6.5 available feel free to try it, but errors caused by modifications in personal working versions are outside the scope of this tutorial.
  2. Due to recent updates, CFE 6.5 is no longer the master branch. We recommend using commit SHA f26967b80cf3654575c35164b73004c3fc9d84ff as it's the last commit before the transition (and is the commit the ci scripts are tested with). From git we can reset to this hash via:
    git reset --hard f26967b80cf3654575c35164b73004c3fc9d84ff
  3. With the repository set to our 6.5 revision, we need to fetch the git submodules using:

    git submodule update --init --recursive

    If you'd like to run the UT Assert tests, you will probably also need to apply a fix to this version of UT Assert. We use the stream editor sed to modify these files while in the cloned CFS directory but if you've modified any of these files, the line numbers will most likely be incorrect.

      sed -i '481s/.*/int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size)/' tools/ut_assert/src/ut_cfe_es_stubs.c
      sed -i '489s/.*/return(Ut_CFE_ES_HookTable.CFE_ES_PoolCreate((uint32*)HandlePtr, MemPtr, Size));/' tools/ut_assert/src/ut_cfe_es_stubs.c
      sed -i '494s/.*/int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size, uint32 NumBlockSizes, uint32 *BlockSizes, uint16 UseMutex)/' tools/ut_assert/src/ut_cfe_es_stubs.c
      sed -i '502s/.*/return(Ut_CFE_ES_HookTable.CFE_ES_PoolCreateEx((uint32*)HandlePtr, MemPtr, Size, NumBlockSizes, BlockSizes, UseMutex));/' tools/ut_assert/src/ut_cfe_es_stubs.c
    
      sed -i '91s/.*/export CFS_PROM_APPS:=$(CFS_PROM)/' ./build/cpu1/Makefile
      sed -i '871s/.*/#define CFE_ES_NONVOL_STARTUP_FILE "\/cf\/cfe_es_startup.scr"/' ./cfe/fsw/platform_inc/cpu1/cfe_platform_cfg.h
      sed -i 's/\/cf\/apps/\/cf/' build/cpu1/exe/cfe_es_startup.scr

    This should give us a working version of CFE 6.5. Now we add our simple app.

  4. Copy the app files from the ECI repository into our new CFE directory:
      mkdir <cfs_dir>/apps/simpleECIApp
      cp -r <eci_dir>/examples/simpleECIApp/* <cfs_dir>/apps/simpleECIApp/
    
      mkdir -p <cfs_dir>/apps/eci/fsw
      cp -r <eci_dir>/fsw/* <cfs_dir>/apps/eci/fsw
  5. Add our apps build instructions to the CFS Makefile.
      sed -i '44a THE_APPS += simpleECIApp' <cfs_dir>/build/cpu1/Makefile
      sed -i '50a THE_TBLS += simpleECIApp' <cfs_dir>/build/cpu1/Makefile
  6. Modify the startup script to include our app and the scheduler to send the tick message at 4 Hz.
      sed -i '5a CFE_APP, /cf/simpleECIApp.so,          sa_AppMain,     SA_APP,       90,   8192, 0x0, 0;' <cfs_dir>/build/cpu1/exe/cfe_es_startup.scr
      sed -i '26a #include "simpleECI_app_msgids.h"' <cfs_dir>/apps/sch_lab/fsw/platform_inc/sch_lab_sched_tab.h
      sed -i '74a      { SIMPLE_ECI_TICK_MID,   4, 0 },' <cfs_dir>/apps/sch_lab/fsw/platform_inc/sch_lab_sched_tab.h
  7. Now that all the pieces are in place, we can change directory into our CFS directory and run the setvars script to set our build path. Afterwards, we can run make to build our binary.
      cd <cfs_dir>
      . ./setvars.sh
    
      make config
      make
  8. Navigate to the build directory and execute the CFS.

      cd <cfs_dir>/build/cpu1/exe/
      sudo ./core-linux.bin

    You should see a message indicating that the CFS has loaded our simple app.

Building CFS 6.6 ECI

Building the CFE 6.6 has an additional dependency on cmake3, which must be availabe on your system. We use cmake to build/install our unit tests for 6.6 but this tutorial was meant to illustrate how to build to an arbitrary directory. If you're just interesting in building a fresh CFS with the simple eci app, look to the next section.

  1. Clone the premade CFS repository.
    git clone --recursive https://github.com/nasa/cFS.git
  2. Copy the build configuration into the root of the CFS repository.
      cp -r <eci_dir>/ci/simple_app/simpleECIApp_defs <cfs_dir>/
      cp <eci_dir>/ci/common_defs <cfs_dir>/simpleECIApp_defs
  3. Copy our modified to_lab and sch_lab files into their respective locations.
      cp <eci_dir>/ci/simple_app/to_lab/to_lab_sub_table.h <cfs_dir>/apps/to_lab/fsw/platform_inc
      cp <eci_dir>/ci/simple_app/sch_lab/CMakeLists.txt <cfs_dir>/apps/sch_lab/
      cp <eci_dir>/ci/simple_app/sch_lab/sch_lab_sched_tab.h <cfs_dir>/apps/sch_lab/fsw/platform_inc
      mv <cfs_dir>/cfe/cmake/Makefile.sample <cfs_dir>/Makefile
  4. Add our ECI source to the CFS.
      mkdir -p <cfs_dir>/apps/eci/fsw
      cp <eci_dir>/fsw/* <cfs_dir>/apps/eci/fsw/
  5. Add our simple app source code.
      cp -r <eci_dir>/examples/simpleECIApp/ <cfs_dir>/apps/
  6. Compile our CFS binaries
      cd <cfs_dir>
      make install
  7. Run our built CFS

      cd <cfs_dir>/build/exe/cpu1/
      sudo ./core-cpu1

    You should see a message indicating the CFS has started the simple app.

Building the CFS examples using the ECI 6.6 CMake

Even though the instructions for building and running our examples with cmake is much easier, we prefer to automate these steps for fast development/testing. We've included a CMakeLists file in each of the apps ci directories for convenience. To build a functioning CFS ecosystem using these directives...

  1. Make a temporary directory to use for the cmake out of source build. This is a common practice for cmake so we can leverage it's functionality for organization.
    mkdir <any_dir>/build 
  2. Run cmake targeting the example app you wish to build. We'll use the simple ECI app for consistancy with the above examples.
    cmake <eci_dir>/ci/simple_app 
  3. Change directory into our new cfs directory and run their make file.
     cd ./cfs
     make install
  4. We can now run our CFS binary. (We assume the working directory is the built CFS)
     cd ./build/exe/cpu1/
     sudo ./core-cpu1