Objectives
In this project you will connect an LED to a Raspberry Pi’s General-Purpose Input/Output (GPIO) header and control the LED using a cFS app. It helps cFS developers gain experience with using a library and an app to interface and control an external hardware component using low-cost materials.
The slides used in the videos are contained in Raspberry Pi Project Slides
What you will need
- A Raspberry Pi (RPI) with an internet connection and a keyboard, mouse and terminal attached. Or the means to SSH with the “-X’ option into an RPI that has an internet connection. The “-X” option allows graphic displays on the host.
- A solderless breadboard, (2) wires with male and female connectors, (1) LED, (1) 220 Ohm resister (red, red, brown)
What you will learn
- How to connect an LED to a Raspberry Pi.
- How to create and run a cFS target that includes the Raspberry Pi I/O Library (PI_IOLIB) and GPIO Demo (GPIO_DEMO) app.
- How a library and app can be used to interface and control an external interface.
Raspberry Pi Setup
- If you’re new to the Raspberry Pi, please see the following website to get started, https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up
- Connect the LED as shown below. Note physical pin 12 is logical GPIO pin 18 which is the identifier used by the FSW.

cFS Basecamp Setup
- Install cFS Basecamp. You must build the default cFS target to generate the Python libraries before you run the Basecamp to perform step 4.
- Make the following changes in cfs-basecamp/cfe-eds-framework/basecamp_defs/toolchain-cpu1.cmake:
- Change CMAKE_SYSTEM_PROCESSOR from i686 to arm
- If your are using a 32 bit RPI operating system add SET(CMAKE_C_FLAGS_INIT “-m32”
- If you your are using a 32 bit RPI operating systemthen comment out the -Wcast-align compiler option in
- cfs-basecamp\cfe-eds-framework\basecamp_defs\arch_build_custom.cmake
- cfs-basecamp\cfe-eds-framework\basecamp_defs\mission_build_custom.cmake
- Make the following changes to cfs-basecamp/ gnd-sys/app/basecamp.ini:
- [CFS_TARGET] SUDO_START_CFS = True
- [APP] PASSWORD = Your user account password
- Download and add PI_IOLIB and GPIO_DEMO. PI_IOLIB must be added to the cFS target before GPIO_DEMO is added. This ensures when the cFS is started that the library will be loaded prior to the apps that depend on the library. Refer to Basecamp’s built-in App Exchange Tutorial for guidance.
- Edit pi_iolib/config.h and select the Broadcom chip for your Pi.
Operations
When you start the new cFS target with the LED connected you should see the LED turn on and off for the “CTRL_ON_TIME” and “CTRL_OFF_TIME” durations defined in gpio_demo_ini.json. You should also event messages reporting when the LED is turned on and off. These events have an event filter so only the first 4 events are reported. If you send a GPIO_DEMO Reset command, it will reset the event filter and you should see 4 more events.
The GPIO_DEMO “Set On Time” and “Set Off Time” commands can be used to change the direction of the duration of the on and off times respectively. Note the command times are in milliseconds.
Design
Code Exercises
Coming soon…

