Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
BasedOnStyle: Chromium
IndentWidth: 4
ColumnLimit: 120
AccessModifierOffset: -2
AccessModifierOffset: -2
10 changes: 8 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ on:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint
run: |
make fmt
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: |
make
make build
- name: Archive
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
build-artifacts/zephyr.uf2
build-artifacts/zephyr/fprime-zephyr-deployment/dict/ReferenceDeploymentTopologyDictionary.json

19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-added-large-files

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.8
hooks:
- id: clang-format
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ endif()
find_package(Zephyr HINTS "${CMAKE_CURRENT_LIST_DIR}/lib/zephyr-workspace")
project(fprime-zephyr-reference C CXX)

# Put in an option to force the device back into programable state for automated testing
option(FPRIME_CI_FAILSAFE_ENABLED "Cycle count before a forced reset to programable state" OFF)
# Put in an option to force the device back into programmable state for automated testing
option(FPRIME_CI_FAILSAFE_ENABLED "Cycle count before a forced reset to programmable state" OFF)
if (FPRIME_CI_FAILSAFE_ENABLED)
set(FPRIME_CI_FAILSAFE_CYCLE_COUNT 6000 CACHE STRING "Cycles before a forced reset")
add_compile_definitions(FPRIME_CI_FAILSAFE_CYCLE_COUNT=${FPRIME_CI_FAILSAFE_CYCLE_COUNT})
Expand Down
37 changes: 19 additions & 18 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"version": 4,
"configurePresets": [
{
"name": "fprime-zephyr-teensy41",
"displayName": "F´ Zephyr (teensy41)",
"description": "F´ release build using local fprime-venv",
"binaryDir": "${sourceDir}/build-fprime-automatic-zephyr",
"environment": {
"VIRTUAL_ENV": "${fileDir}/fprime-venv",
"PATH": "$env{VIRTUAL_ENV}/bin:$penv{PATH}"
},
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "teensy41"
},
"toolchainFile": "${fileDir}/lib/fprime-zephyr/cmake/toolchain/zephyr.cmake",
"generator": "Ninja"
}]
{
"binaryDir": "${sourceDir}/build-fprime-automatic-zephyr",
"cacheVariables": {
"BOARD": "teensy41",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"description": "F\u00b4 release build using local fprime-venv",
"displayName": "F\u00b4 Zephyr (teensy41)",
"environment": {
"PATH": "$env{VIRTUAL_ENV}/bin:$penv{PATH}",
"VIRTUAL_ENV": "${fileDir}/fprime-venv"
},
"generator": "Ninja",
"name": "fprime-zephyr-teensy41",
"toolchainFile": "${fileDir}/lib/fprime-zephyr/cmake/toolchain/zephyr.cmake"
}
],
"version": 4
}
59 changes: 23 additions & 36 deletions FprimeZephyrReference/Components/FatalHandler/FatalHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,39 @@
//
// ======================================================================

#include <Fw/Logger/Logger.hpp>
#include <zephyr/sys/reboot.h>
#include <FprimeZephyrReference/Components/FatalHandler/FatalHandler.hpp>
#include <Fw/FPrimeBasicTypes.hpp>
#include <zephyr/sys/reboot.h>
#include <Fw/Logger/Logger.hpp>

namespace Components {

// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

FatalHandler ::
FatalHandler(
const char *const compName
) : FatalHandlerComponentBase(compName)
{
FatalHandler ::FatalHandler(const char* const compName) : FatalHandlerComponentBase(compName) {}

}
FatalHandler ::~FatalHandler() {}

FatalHandler ::
~FatalHandler()
{

}

void FatalHandler::reboot() {
// When running in CI failsafe mode and the board is a teensy,
// then we should invoke bkpt #251 to trigger the soft reboot enabling a
// flash of new software
#if defined(FPRIME_CI_FAILSAFE_CYCLE_COUNT)
// Magic bootloader breakpoint, provided by PRJC
if (strncmp(CONFIG_BOARD, "teensy", 6) == 0) {
void FatalHandler::reboot() {
// When running in CI failsafe mode and the board is a teensy,
// then we should invoke bkpt #251 to trigger the soft reboot enabling a
// flash of new software
#if defined(FPRIME_CI_FAILSAFE_CYCLE_COUNT)
// Magic bootloader breakpoint, provided by PRJC
if (strncmp(CONFIG_BOARD, "teensy", 6) == 0) {
asm("bkpt #251");
}
#endif
}
#endif
// Otherwise, use Zephyr to reboot the system
sys_reboot(SYS_REBOOT_COLD);
}

void FatalHandler::FatalReceive_handler(
const FwIndexType portNum,
FwEventIdType Id) {
Fw::Logger::log("FATAL %" PRI_FwEventIdType "handled.\n",Id);
Os::Task::delay(Fw::TimeInterval(0, 1000)); // Delay to allow log to be processed
this->reboot(); // Reboot the system
}
}

void FatalHandler::FatalReceive_handler(const FwIndexType portNum, FwEventIdType Id) {
Fw::Logger::log("FATAL %" PRI_FwEventIdType "handled.\n", Id);
Os::Task::delay(Fw::TimeInterval(0, 1000)); // Delay to allow log to be processed
this->reboot(); // Reboot the system
}

} // end namespace Svc
} // namespace Components
71 changes: 32 additions & 39 deletions FprimeZephyrReference/Components/FatalHandler/FatalHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,37 @@

namespace Components {

class FatalHandler final :
public FatalHandlerComponentBase
{

public:

// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

//! Construct object FatalHandler
//!
FatalHandler(
const char *const compName /*!< The component name*/
);

//! Destroy object FatalHandler
//!
~FatalHandler();

//! Reboot the device
//!
void reboot();

private:

// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for FatalReceive
//!
void FatalReceive_handler(
const FwIndexType portNum, /*!< The port number*/
FwEventIdType Id /*!< The ID of the FATAL event*/
);
};

} // end namespace Svc
class FatalHandler final : public FatalHandlerComponentBase {
public:
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

//! Construct object FatalHandler
//!
FatalHandler(const char* const compName /*!< The component name*/
);

//! Destroy object FatalHandler
//!
~FatalHandler();

//! Reboot the device
//!
void reboot();

private:
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for FatalReceive
//!
void FatalReceive_handler(const FwIndexType portNum, /*!< The port number*/
FwEventIdType Id /*!< The ID of the FATAL event*/
);
};

} // namespace Components

#endif
1 change: 0 additions & 1 deletion FprimeZephyrReference/Components/Led/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ register_fprime_library(
# DEPENDS
# MyPackage_MyOtherModule
)

9 changes: 4 additions & 5 deletions FprimeZephyrReference/Components/Led/Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Led ::~Led() {}
// ----------------------------------------------------------------------

void Led ::run_handler(FwIndexType portNum, U32 context) {

U32 interval = this->m_blinkInterval; // Get the blink interval from the member variable
U32 interval = this->m_blinkInterval; // Get the blink interval from the member variable

// Only perform actions when set to blinking
if (this->m_blinking && (interval != 0)) {
Expand Down Expand Up @@ -77,12 +76,12 @@ void Led ::BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::On on
void Led ::SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U32 interval) {
// Update the member variable
this->m_blinkInterval = interval;

// Log the event
this->log_ACTIVITY_HI_BlinkIntervalSet(interval);

// Provide command response
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}

} // namespace Components
} // namespace Components
2 changes: 1 addition & 1 deletion FprimeZephyrReference/Components/Led/Led.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ module Components {
telemetry port tlmOut

}
}
}
62 changes: 29 additions & 33 deletions FprimeZephyrReference/Components/Led/Led.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,38 @@ class Led : public LedComponentBase {
//! Destroy Led object
~Led();

private :
private:
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
//! Handler implementation for run
//!
//! Port receiving calls from the rate group
void run_handler(FwIndexType portNum, //!< The port number
U32 context //!< The call order
) override;

//! Handler implementation for run
//!
//! Port receiving calls from the rate group
void
run_handler(FwIndexType portNum, //!< The port number
U32 context //!< The call order
) override;
private:
// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------

private :
// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------
//! Handler implementation for command BLINKING_ON_OFF
//!
//! Command to turn on or off the blinking LED
void BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
Fw::On onOff //!< Indicates whether the blinking should be on or off
) override;

//! Handler implementation for command BLINKING_ON_OFF
//!
//! Command to turn on or off the blinking LED
void
BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
Fw::On onOff //!< Indicates whether the blinking should be on or off
) override;

//! Handler implementation for command SET_BLINK_INTERVAL
//!
//! Command to set the LED blink interval
void
SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
U32 interval //!< Blink interval in rate group ticks
) override;
//! Handler implementation for command SET_BLINK_INTERVAL
//!
//! Command to set the LED blink interval
void SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
U32 interval //!< Blink interval in rate group ticks
) override;

Fw::On m_state = Fw::On::OFF; //! Keeps track if LED is on or off
U64 m_transitions = 0; //! The number of on/off transitions that have occurred
Expand All @@ -72,4 +68,4 @@ class Led : public LedComponentBase {

} // namespace Components

#endif
#endif
4 changes: 2 additions & 2 deletions FprimeZephyrReference/ReferenceDeployment/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#####
# 'ReferenceDeployment' Deployment:
#
# This registers the 'ReferenceDeployment' deployment to the build system.
# Custom components that have not been added at the project-level should be added to
# This registers the 'ReferenceDeployment' deployment to the build system.
# Custom components that have not been added at the project-level should be added to
# the list below.
#
#####
Expand Down
Loading