Software Setup

Outline

  1. Virtual Machine and F´ setup
  2. Arduino CLI Installation
  3. F´ demo
  4. Raspberry Pi Pico

Virtual Machine and F´ setup

For any troubleshooting refer to official fprime installation guide

F´ depends on several items before the user should attempt to install it. One of them is, that it runs in Linux-based systems.

If you are a Windows 10 (or above) user, you can install Windows Subsystem for Linux or run Ubuntu in a Virtual Manager like VirtualBox.

After installing it you need to update your system and download the following packages using:

sudo apt update && sudo apt upgrade -y
sudo apt install git cmake python3 python3-pip ipython3 python-is-python3 python3-venv build-essential unzip

Now setup your python virtual environment using:

python3 -m venv fprime
source fprime/bin/activate

By activating the fprime you can now install the fprime bootstrap tool:

pip install fprime-bootstrap

Now we are ready to start an fprime project!


Virtual environment setup

Get in the directory and activate the project's python virtual environment:

code cubex # or cd cubex
python -m venv "fprime-venv"
. fprime-venv/bin/activate
                

This allows you to use the various tools that fprime provides.

⚠️: Make sure to use the right virtual environment every time you open a new shell!

Arduino CLI Installation

After the setup, you will have to setup arduino-cli with the following command:

mkdir -p /home/$USER/bin
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/home/$USER/bin sh

where BINDIR is the path that arduino-cli command will be installed. After that, restart your terminal session and arduino-cli command should be available.

Install arduino-cli-wrapper

python -m pip install --upgrade pip
pip install arduino-cli-cmake-wrapper

And then restart the bash session.

Setup arduino-cli for Arduino boards

We will be doing this exercise using a Raspberry Pi Pico (RP2040), so we need to setup the BSP of the RP2040 using arduino-cli.

Initialize the arduino-cli configuration file:

arduino-cli config init

Board manager URL:

arduino-cli config add board_manager.additional_urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

Install the new board packages:

arduino-cli core update-index
arduino-cli core install rp2040:rp2040@3.9.5

For other development boards follow this link.

Adding MPU6050 library

Now we are ready to use fprime with the Arduino Framework Support.

Next we need to install the FastIMU library which we need for MPU6050:

arduino-cli lib install FastIMU

Inspect and run the examples from FastIMU github repository in order to develop later your own code.


Fprime demo

Configuration

In this project we will work with v3.4.1 of fprime. Run the following commands in terminal in order to setup:

chmod +x setup.sh
./setup.sh
pip install -r ./fprime/requirements.txt

This will download fprime from the archive of the fprime repo, unzip it and rename it as fprime in your directory. Lastly, it will download the python packages required to begin developing an fprime project.

Build template code

Build demo

fprime-util generate rpipico

After build-cache generation we need to create the project's Deployment using fprime-util new --deployment:

fprime-util new --deployment

Next, you will need to name your topology. The output will look like below:

⚠️: It is recommended to use only latin characters e.g. MissionDeployment.
[INFO] Cookiecutter source: fprime-arduino-deployment-cookiecutter
  [1/1] deployment_name (fprime-arduino-deployment): MissionDeployment
[INFO] Found CMake file at 'fprime-space-sw-exercise-ast/project.cmake'
Add MissionDeployment to fprime-space-sw-exercise-ast/project.cmake at end of file? (yes/no) [yes]: 
[INFO] New deployment successfully created: /home/<username>/path/to/fprime-space-sw-exercise-ast/MissionDeployment
fprime-util build rpipico # if not specified in settings.ini
You can add in settings.ini file the default_toolchain and add the proper toolchain. Example:
[fprime]
project_root: .
framework_path: ./fprime
library_locations: ./fprime-arduino
default_toolchain: rpipico
deployment_cookiecutter: fprime-arduino-deployment-cookiecutter
    
default_cmake_options:  FPRIME_ENABLE_FRAMEWORK_UTS=OFF
                        FPRIME_ENABLE_AUTOCODER_UTS=OFF

Raspberry Pi Pico

Upload binary to RPI Pico

Hold the BOOTSEL Button and plug in the USB connector. The file system of the RPI should be mounted.

Inside you will probably see 2 files named INDEX.HTM and INFO_UF2.TXT. The binary of the RPI Pico should have the extension name <bin_name>.uf2. After a successful build this file can be found in path build-artifacts/<platform>/<Deployment>/bin/<bin_name>.uf2.

⚠️: For WSL users, first check the section below.

In our case this is build-artifacts/<toolchain>/<Deployment>/bin/<Deployment>.uf2. Copy this file in the RPI's storage. After that, RPI Pico will be ejected from your filesystem and it will boot with your software.

Run GDS

fprime-gds -n --dictionary ./build-artifacts/<toolchain>/<deployment>/dict/<deployment>TopologyAppDictionary.xml --comm-adapter uart --uart-device /dev/ttyACM0 --uart-baud 115200

where /dev/ttyACM0 is the path of the Serial port of the Raspberry Pi Pico. In mnemonics you can find an example deployment with the LedControl commands.


WSL Only to run GDS

For WSL you will have to install and use USBIPD. You will need to use the attach command, whenever the USB is removed from your computer.

⚠️: Those commands need to be run in Powershell (not Bash!!)
usbipd list
usbipd bind --busid <busid>
usbipd attach --wsl --busid <busid>
usbipd detach --busid <busid>

When GDS opens in your default browser, try the Led commands.

If connection can't be established make sure that you have no firewall enabled.

Back to the main page