cFS Tutorial Stage 1: Celebrate the Launch of Artemis 1 by Building & Running NASA's cFS 7 (core Flight System) on Your Own Laptop

Demo / Tutorial: NASA's cFS (core Flight System)

by David Ferreira



This post is a companion to our video tutorial on YouTube. Click here to view that video as you follow the steps below.

NOTE:  Your background will vary according to your own configuration of VM.

Steps

1. Stand Up a Target Machine

If you already have a target Linux machine handy, please skip this step. If not, consider setting up a Linux VM. 

If you don't already have VirtualBox or some other VM management software installed, click here to install VirtualBox from Oracle.

 

Here are two videos that will guide you through setup of either a Ubuntu Linux VM or a Raspberry Pi VM:

2. Tools: Let's install a few things you'll need on your target machine

Boot and login to your target machine, then open the terminal (Linux command prompt). By default, you'll be at your Home directory. (You can confirm this by a command prompt that looks similar to this,

name@machine: ~/      

Most of these tools are probably already installed on your machine, but running these install commands won't harm anything and may serve to update them if they're not already at their latest version. Here are the Linux install commands:

 

sudo apt install git   

sudo apt install make  

sudo apt install cmake 

sudo apt install gcc   

sudo apt install g++   

 

3. Now let's pull the cFS project from NASA's GitHub repository

 

a. Let's create a "source" directory for our project(s).

 

mkdir src             
cd src                

 

b. Now let's clone NASA's cFS repository locally. (That's just git-speak for make a local copy.)

 

git clone https://www.github.com/nasa/cFS.git   

cd cFS                                          

git submodule init                              

git submodule update                            

 

You now should have a local copy of the entire NASA cFS repo on your local machine. The next steps will verify that you have successfully accomplished this task. 

 

4. Begin Raspberry Pi ONLY steps (Ubuntu users skips to Step 5, plz)

 

These steps will make adjustments to the cFS build environment to allow us to build properly on Pi OS.

 

cd ..                                                      

git clone https://github.com/mbr4477/install-cfs-rpi.git   

source ./install-cfs-rpi/install-cfs-rpi.sh                

cd                                                         

cd cFS                                                     


In the next 2 steps, take care to use the partially capitalized directory name, “cFE”, not “cfe”.

cp cFE/cmake/Makefile.sample Makefile          

cp -r cFE/cmake/sample_defs sample_defs        

 

End Raspberry Pi only steps.

You may now proceed to Step 6 (skip step 5).

 5. A little pre-build housekeeping

These steps will copy build instructions for the sample application into the correct location to build properly.  

cp cfe/cmake/Makefile.sample Makefile          

cp -r cfe/cmake/sample_defs sample_defs         


6. Let's do a preliminary build & run before making any changes

 

make SIMULATION=native prep          
make                                 
make install                         
cd build/exe/cpu1/                   
./core-cpu1                          

 

7. Add a couple lines of code to the sample app

 

a.    In the VM’s file manager (where you see graphical views if files and folders), browse to this path:

 

b.     Right-click on the file named, “sample_app.c” and select Text Editor from the drop-down menu. This will open the file for editing.

Now let’s search for the appropriate place to insert a print statement. Searching this document for the expression “status == CFE_SUCCESS” will bring us immediately to the sample application’s main while loop and the clause where we can insert a print statement that will display obviously when we run our program.


Let’s go ahead and insert the following print statement in the location specified in the above image:

printf(“<<<<< Go Artemis. Go Orion. To the moon! >>>>>\n”);

 

NOTE:  This is an easy place to make a mistake. The most common mistakes would be: forgetting to put a semi-colon at the end of line; missing a quotation mark; missing the ‘f’ in “printf”;

 

Now let’s go ahead and save this document and return to our terminal.

 

8. Let's go back to your terminal (home directory), rebuild and re-run

 

cd                                   
make SIMULATION=native prep          
make                                 
make install                         
cd build/exe/cpu1/                   
./core-cpu1                          

 

Carefully examine any compiler or build errors that may occur. If there are many, scroll up and examine the first error first. What file and line did it occur in? etc.


9. Expected results

 

If you’re done everything correctly, we expect you’ll see a few screens of initialization output and they, after about 10 seconds, your print statement output. This will repeat indefinitely until you kill the process. The image below shows your what to expect.

If it didn’t work out quite as expected, don’t lose heart. Use common sense to retrace the steps that went wrong.

Summary / Conclusions

In this demo / tutorial we performed the following tasks:

  • Downloaded / installed multiple tools for compiling and building C/C++ apps in Linux
  • Downloaded (cloned) NASA’s cFS codebase
  • Built and ran the cFS sample_app
  • Modified the code of the sample_app
  •  Re-built and re-ran the modified sample_app

With these steps we have demonstrated:

  • That we can build, run, and modify an application that runs as part of NASA’s core Flight System

In our next demo / tutorial we will learn how to create our own, independent application. We expect to do the following tasks:

  • Create an independent application aside from NASA’s sample_app.
  • “Subscribe” our indie application in the same build process that builds the sample_app
    • o   This is very much non-trivial
  •  Register our indie application with NASA’s cFE (core Flight Executable)
    • o   Also very much non-trivial

THANK YOU so much for reviewing our tutorial. We hope you found it useful or at least exciting.

Please feel free to send us some feedback either on YouTube or by blog comments.

Best wishes,

-        DaveFer

Comments

  1. Excited for the next tutorial! Sad about the scrub but we're not doing it because its easy!

    ReplyDelete

Post a Comment

Popular posts from this blog

cFS Tutorial Stage 2: Transform the NASA sample_app To Your Own ...

cFS Tutorial Part 3: Putting messages onto the (Local) Software Bus