Skip to content

Commit

Permalink
Update to FPrime v3.5.0 (#19)
Browse files Browse the repository at this point in the history
* Bump to FPrime v3.5.0

* Readd USE_BASIC_TIMER rateDriver cycle

* Cleanup

* Reduce config sizes to decrease memory usage on baremetal

* Use fprime-baremetal OSAL implementations

* Update fprime-arduino and fprime-baremetal

* Update READMEs

* Switch from StaticMemory to BufferManager

* submodule updates

* track main fprime-arduino

* Update/cleanup documentation files
  • Loading branch information
ethancheez authored Nov 1, 2024
1 parent 292ceb9 commit 395b290
Show file tree
Hide file tree
Showing 43 changed files with 478 additions and 459 deletions.
21 changes: 15 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
.vscode
.idea
# fprime items
logs/
cmake-build-*
build-artifacts/
build-fprime-*
*-template
*.template.cpp
*.template.hpp

# Misc
/venv/
/fprime-venv/
/.idea/
/.vscode/
.DS_Store
venv
**/logs
**/build-artifacts
**/build-fprime-*
*.gcov
4 changes: 3 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
[submodule "fprime-arduino"]
path = fprime-arduino
url = https://github.com/fprime-community/fprime-arduino.git
branch = devel
[submodule "fprime-baremetal"]
path = fprime-baremetal
url = https://github.com/fprime-community/fprime-baremetal.git
2 changes: 1 addition & 1 deletion Components/Led/Led.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Components {
format "Invalid Blinking Argument: {}"

@ Reports the state we set to blinking.
event SetBlinkingState(state: Fw.On) \
event SetBlinkingState($state: Fw.On) \
severity activity high \
format "Set blinking state to {}."

Expand Down
31 changes: 14 additions & 17 deletions LedBlinker/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
// ======================================================================
// \title Main.cpp
// \brief main program for the F' application. Intended for CLI-based systems (Linux, macOS)
// \brief main program for the F' application. Intended for Arduino-based systems
//
// ======================================================================
// Used to access topology functions
#include <LedBlinker/Top/LedBlinkerTopology.hpp>
#include <LedBlinker/Top/LedBlinkerTopologyAc.hpp>
// Used for Task Runner
#include <Os/Baremetal/TaskRunner/TaskRunner.hpp>

// Used for logging
#include <Arduino/Os/StreamLog.hpp>
#include <Os/Log.hpp>

// Instantiate a system logger that will handle Fw::Logger::logMsg calls
Os::Log logger;
// Used for TaskRunner
#include <fprime-baremetal/Os/TaskRunner/TaskRunner.hpp>

// Task Runner
Os::TaskRunner taskrunner;
// Used for logging
#include <Arduino/Os/Console.hpp>

/**
* \brief setup the program
Expand All @@ -26,11 +20,12 @@ Os::TaskRunner taskrunner;
*
*/
void setup() {
// Setup Serial
// Initialize OSAL
Os::init();

// Setup Serial and Logging
Serial.begin(115200);
Os::setArduinoStreamLogHandler(&Serial);
delay(1000);
Fw::Logger::logMsg("Program Started\n");
static_cast<Os::Arduino::StreamConsoleHandle*>(Os::Console::getSingleton().getHandle())->setStreamHandler(Serial);

// Object for communicating state to the reference topology
LedBlinker::TopologyState inputs;
Expand All @@ -39,6 +34,8 @@ void setup() {

// Setup topology
LedBlinker::setupTopology(inputs);

Fw::Logger::log("Program Started\n");
}

/**
Expand All @@ -51,5 +48,5 @@ void loop() {
#ifdef USE_BASIC_TIMER
rateDriver.cycle();
#endif
taskrunner.run();
}
Os::Baremetal::TaskRunner::getSingleton().run();
}
6 changes: 4 additions & 2 deletions LedBlinker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ fprime-util build
The following command will spin up the F' GDS as well as run the application binary and the components necessary for the GDS and application to communicate.

```
fprime-gds -n --dictionary ./build-artifacts/<build name>/LedBlinker/dict/LedBlinkerTopologyAppDictionary.xml --comm-adapter uart --uart-device /dev/ttyACM0 --uart-baud 115200
fprime-gds -n --dictionary ./build-artifacts/<build name>/LedBlinker/dict/LedBlinkerTopologyAppDictionary.xml --communication-selection uart --uart-device /dev/ttyACM0 --uart-baud 115200
```
> Change `<build name>` to the build of your deployment (i.e. `teensy41`, `featherM0`, etc.).
Change `<build name>` to the build of your deployment (i.e. `teensy41`, `featherM0`, etc.).
> `/dev/ttyACM0` may vary for your system/device. It may also be `/dev/ttyUSB0`. For MacOS, it will be along the lines of `/dev/tty.usbmodem12345`. Change accordingly.
> To view the list of your connected devices, run: `ls /dev/tty*`.
4 changes: 1 addition & 3 deletions LedBlinker/Top/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/instances.fpp"
"${CMAKE_CURRENT_LIST_DIR}/LedBlinkerPackets.xml"
"${CMAKE_CURRENT_LIST_DIR}/topology.fpp"
"${CMAKE_CURRENT_LIST_DIR}/LedBlinkerTopology.cpp"
)
set(MOD_DEPS
Fw/Logger
Arduino/ArduinoTime
Arduino/Drv/StreamDriver
Os/Baremetal/TaskRunner
fprime-baremetal/Os/TaskRunner
)

register_fprime_module()
5 changes: 0 additions & 5 deletions LedBlinker/Top/LedBlinkerPackets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
<channel name="systemResources.NON_VOLATILE_FREE"/>
</packet>

<packet name="SystemRes2" id="6" level="2">
<channel name="systemResources.FRAMEWORK_VERSION"/>
<channel name="systemResources.PROJECT_VERSION"/>
</packet>

<packet name="SystemRes3" id="7" level="2">
<channel name="systemResources.CPU"/>
<channel name="systemResources.CPU_00"/>
Expand Down
17 changes: 16 additions & 1 deletion LedBlinker/Top/LedBlinkerTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//
// ======================================================================
// Provides access to autocoded functions
#include <LedBlinker/Top/LedBlinkerPacketsAc.hpp>
#include <LedBlinker/Top/LedBlinkerTopologyAc.hpp>
#include <config/FppConstantsAc.hpp>

Expand All @@ -31,6 +30,13 @@ Svc::RateGroupDriver::DividerSet rateGroupDivisors{{{100, 0}, {200, 0}, {1000, 0
// reference topology sets each token to zero as these contexts are unused in this project.
NATIVE_INT_TYPE rateGroup1Context[FppConstant_PassiveRateGroupOutputPorts::PassiveRateGroupOutputPorts] = {};

// A number of constants are needed for construction of the topology. These are specified here.
enum TopologyConstants {
COM_BUFFER_SIZE = 140,
COM_BUFFER_COUNT = 3,
BUFFER_MANAGER_ID = 200
};

/**
* \brief configure/setup components in project-specific way
*
Expand All @@ -45,9 +51,18 @@ void configureTopology() {
// Rate groups require context arrays.
rateGroup1.configure(rateGroup1Context, FW_NUM_ARRAY_ELEMENTS(rateGroup1Context));

// Set up BufferManager
Svc::BufferManager::BufferBins buffMgrBins;
memset(&buffMgrBins, 0, sizeof(buffMgrBins));
buffMgrBins.bins[0].bufferSize = COM_BUFFER_SIZE;
buffMgrBins.bins[0].numBuffers = COM_BUFFER_COUNT;
bufferManager.setup(BUFFER_MANAGER_ID, 0, mallocator, buffMgrBins);

// Framer and Deframer components need to be passed a protocol handler
framer.setup(framing);
deframer.setup(deframing);

// Configure built-in LED GPIO if available
#ifndef NO_ONBOARD_LED
gpioDriver.open(Arduino::DEF_LED_BUILTIN, Arduino::GpioDriver::GpioDirection::OUT);
#endif
Expand Down
22 changes: 10 additions & 12 deletions LedBlinker/Top/instances.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,28 @@ module LedBlinker {

instance rateGroup1: Svc.PassiveRateGroup base id 0x0200

instance bufferManager: Svc.BufferManager base id 0x1000

instance commDriver: Arduino.StreamDriver base id 0x4000

instance framer: Svc.Framer base id 0x4100

instance fatalAdapter: Svc.AssertFatalAdapter base id 0x4200

instance fatalHandler: Svc.FatalHandler base id 0x4300
instance fatalHandler: Baremetal.FatalHandler base id 0x4300

instance timeHandler: Arduino.ArduinoTime base id 0x4400 \
instance timeHandler: Arduino.ArduinoTime base id 0x4400

instance rateGroupDriver: Svc.RateGroupDriver base id 0x4500

instance staticMemory: Svc.StaticMemory base id 0x4600

instance textLogger: Svc.PassiveTextLogger base id 0x4700
instance textLogger: Svc.PassiveTextLogger base id 0x4600

instance deframer: Svc.Deframer base id 0x4800
instance deframer: Svc.Deframer base id 0x4700

instance systemResources: Svc.SystemResources base id 0x4900
instance systemResources: Svc.SystemResources base id 0x4800

instance rateDriver: Arduino.HardwareRateDriver base id 0x4A00
instance rateDriver: Arduino.HardwareRateDriver base id 0x4900

instance gpioDriver: Arduino.GpioDriver base id 0x4C00
instance gpioDriver: Arduino.GpioDriver base id 0x5000

instance led: Components.Led base id 0x10000 \
instance led: Components.Led base id 0x10000

}
21 changes: 7 additions & 14 deletions LedBlinker/Top/topology.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,24 @@ module LedBlinker {
rateGroup1
}

enum Ports_StaticMemory {
framer
deframer
deframing
}

topology LedBlinker {

# ----------------------------------------------------------------------
# Instances used in the topology
# ----------------------------------------------------------------------

instance bufferManager
instance cmdDisp
instance commDriver
instance deframer
instance eventLogger
instance fatalAdapter
instance fatalHandler
instance framer
instance gpioDriver
instance led
instance rateDriver
instance rateGroup1
instance rateGroupDriver
instance staticMemory
instance systemResources
instance timeHandler
instance textLogger
Expand Down Expand Up @@ -61,10 +54,10 @@ module LedBlinker {
tlmSend.PktSend -> framer.comIn
eventLogger.PktSend -> framer.comIn

framer.framedAllocate -> staticMemory.bufferAllocate[Ports_StaticMemory.framer]
framer.framedAllocate -> bufferManager.bufferGetCallee
framer.framedOut -> commDriver.$send

commDriver.deallocate -> staticMemory.bufferDeallocate[Ports_StaticMemory.framer]
commDriver.deallocate -> bufferManager.bufferSendIn

}

Expand All @@ -87,15 +80,15 @@ module LedBlinker {
connections Uplink {
commDriver.allocate -> staticMemory.bufferAllocate[Ports_StaticMemory.deframer]
commDriver.allocate -> bufferManager.bufferGetCallee
commDriver.$recv -> deframer.framedIn
deframer.framedDeallocate -> staticMemory.bufferDeallocate[Ports_StaticMemory.deframer]
deframer.framedDeallocate -> bufferManager.bufferSendIn
deframer.comOut -> cmdDisp.seqCmdBuff
cmdDisp.seqCmdStatus -> deframer.cmdResponseIn
deframer.bufferAllocate -> staticMemory.bufferAllocate[Ports_StaticMemory.deframing]
deframer.bufferDeallocate -> staticMemory.bufferDeallocate[Ports_StaticMemory.deframing]
deframer.bufferAllocate -> bufferManager.bufferGetCallee
deframer.bufferDeallocate -> bufferManager.bufferSendIn
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In order to run through this tutorial, users should first do the following:
1. Follow the [Hello World Tutorial](https://fprime-community.github.io/fprime-tutorial-hello-world/)
2. Ensure F´ tools have been [bootstrapped](https://fprime-community.github.io/fprime-tutorial-hello-world/docs/NewProject.html#bootstrapping-f)
3. Acquire and set up the appropriate [hardware](docs/hardware.md) for this tutorial
4. Follow the [arduino-cli installation guide](docs/arduino-cli-install.md)
4. Follow the [arduino-cli installation guide](https://github.com/fprime-community/fprime-arduino/blob/main/docs/arduino-cli-install.md)

## Tutorial Steps

Expand Down
25 changes: 20 additions & 5 deletions config/AcConstants.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ constant CmdDispatcherComponentCommandPorts = 5
@ Used for uplink/sequencer buffer/response ports
constant CmdDispatcherSequencePorts = 1

@ Used for dispatching sequences to command sequencers
constant SeqDispatcherSequencerPorts = 2

@ Used for sizing the command splitter input arrays
constant CmdSplitterPorts = CmdDispatcherSequencePorts

@ Number of static memory allocations
constant StaticMemoryAllocations = 3
constant StaticMemoryAllocations = 4

@ Used to ping active components
constant HealthPingPorts = 1
Expand All @@ -45,11 +48,23 @@ constant DpManagerNumPorts = 5
@ Size of processing port array for DpWriter
constant DpWriterNumProcPorts = 5

@ The size of a file name string
constant FileNameStringSize = 200

@ The size of an assert text string
constant FwAssertTextSize = 256

@ The size of a file name in an AssertFatalAdapter event
@ Note: File names in assertion failures are also truncated by
@ the constants FW_ASSERT_TEXT_SIZE and FW_LOG_STRING_MAX_SIZE, set
@ in FpConfig.h.
constant AssertFatalAdapterEventFileSize = FileNameStringSize

# ----------------------------------------------------------------------
# Hub connections. Connections on all deployments should mirror these settings.
# ----------------------------------------------------------------------

constant GenericHubInputPorts = 5
constant GenericHubOutputPorts = 5
constant GenericHubInputBuffers = 5
constant GenericHubOutputBuffers = 5
constant GenericHubInputPorts = 10
constant GenericHubOutputPorts = 10
constant GenericHubInputBuffers = 10
constant GenericHubOutputBuffers = 10
20 changes: 0 additions & 20 deletions config/AcConstants.ini

This file was deleted.

2 changes: 2 additions & 0 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/AcConstants.fpp"
"${CMAKE_CURRENT_LIST_DIR}/DpCfg.fpp"
"${CMAKE_CURRENT_LIST_DIR}/FpConfig.fpp"
"${CMAKE_CURRENT_LIST_DIR}/PolyDbCfg.fpp"
"${CMAKE_CURRENT_LIST_DIR}/VersionCfg.fpp"
)
register_fprime_module(config)
19 changes: 0 additions & 19 deletions config/CmdSplitterCfg.hpp

This file was deleted.

Loading

0 comments on commit 395b290

Please sign in to comment.