added first CMakeLists and fsfwconfig

This commit is contained in:
Robin Müller 2021-07-16 11:10:39 +02:00
parent f8d969d7b4
commit 8bcae41e7e
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
14 changed files with 446 additions and 0 deletions

159
CMakeLists.txt Normal file
View File

@ -0,0 +1,159 @@
################################################################################
# CMake support for the Flight Software Framework
# Author: R. Mueller
################################################################################
################################################################################
# Pre-Project preparation
################################################################################
cmake_minimum_required(VERSION 3.13)
# set(CMAKE_VERBOSE TRUE)
set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(RTEMS_CMAKE_PATH "${CMAKE_SCRIPT_PATH}/rtems-cmake")
set(FSFW_OSAL rtems CACHE STRING "OS for the FSFW")
# Set off, networking code is part of RTEMS BSP
set(STM32_ADD_NETWORKING_CODE OFF)
set(FSFW_HAL_ADD_STM32H7 ON)
# This call has to come before the project call
set(CMAKE_TOOLCHAIN_FILE ${STM32_CMAKE_PATH}/cmake/stm32_gcc.cmake)
# Project Name
project(fsfw-example-stm32h7-freertos ASM C CXX)
################################################################################
# Pre-Sources preparation
################################################################################
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(TGT_BSP "arm/stm32h743zi-nucleo")
# Set names and variables
set(TARGET_NAME ${CMAKE_PROJECT_NAME})
set(LIB_FSFW_NAME fsfw)
# Set path names
set(FSFW_PATH fsfw)
set(COMMON_PATH example_common)
set(BSP_PATH "bsp_stm32h7_freertos")
set(COMMON_CONFIG_PATH "${COMMON_PATH}/config")
set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig")
set(BSP_NUCLEO_PATH "${BSP_PATH}/NUCLEO-H743ZI")
set(BSP_NUCLEO_INC_PATH "${BSP_NUCLEO_PATH}/Inc")
set(FSFW_HAL_ADDITIONAL_INC_PATHS ${BSP_NUCLEO_INC_PATH})
set(FSFW_ADDITIONAL_INC_PATHS
"${COMMON_CONFIG_PATH}"
"${CMAKE_CURRENT_BINARY_DIR}"
CACHE STRING
"FSFW configuration paths"
)
configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h)
configure_file(${FSFW_CONFIG_PATH}/FSFWConfig.h.in FSFWConfig.h)
configure_file(${FSFW_CONFIG_PATH}/OBSWConfig.h.in OBSWConfig.h)
configure_file(${BSP_NUCLEO_PATH}/Inc/lwipopts.h.in lwipopts.h)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(WARNING_FLAGS
-Wall
-Wextra
-Wimplicit-fallthrough=1
-Wno-unused-parameter
-Wno-psabi
)
set(FSFW_WARNING_FLAGS ${WARNING_FLAGS})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/permissive- /d2SSAOptimizer-)
# To avoid nameclashes with min and max macro
add_compile_definitions(NOMINMAX)
endif()
################################################################################
# Executable and Sources
################################################################################
# Add executable
add_executable(${TARGET_NAME})
# Add subdirectories
add_subdirectory(${BSP_PATH})
add_subdirectory(${FSFW_PATH})
add_subdirectory(${COMMON_PATH})
################################################################################
# Post-Sources preparation
################################################################################
# Add libraries for all sources.
target_link_libraries(${TARGET_NAME} PRIVATE
${LIB_FSFW_NAME}
)
# Add include paths for all sources.
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${FSFW_CONFIG_PATH}
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(${TARGET_NAME} PRIVATE
"-Wl,-Map=${TARGET_NAME}.map"
)
# Remove unused sections.
target_compile_options(${TARGET_NAME} PRIVATE
"-ffunction-sections"
"-fdata-sections"
)
# Removed unused sections.
if(NOT FSFW_OSAL MATCHES rtems)
target_link_options(${TARGET_NAME} PRIVATE
"-Wl,--gc-sections"
)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif()
if(CMAKE_VERBOSE)
message(STATUS "Warning flags: ${WARNING_FLAGS}")
endif()
# Compile options for all sources.
target_compile_options(${TARGET_NAME} PRIVATE
${WARNING_FLAGS}
)
if(TGT_BSP)
set(TARGET_STRING "Target BSP: ${TGT_BSP}")
else()
set(TARGET_STRING "Target BSP: Hosted")
endif()
string(CONCAT POST_BUILD_COMMENT
"Build directory: ${CMAKE_BINARY_DIR}\n"
"Target OSAL: ${FSFW_OSAL}\n"
"Target Build Type: ${CMAKE_BUILD_TYPE}\n"
"${TARGET_STRING}"
)
include("${RTEMS_CONFIG_DIR}/BuildType.cmake")
set_build_type()
################################################################################
# Load RTEMS post-project configuration and checks
################################################################################
include("${RTEMS_CONFIG_DIR}/RTEMSPostProjectConfig.cmake")
rtems_post_project_config(${TARGET_NAME})

View File

@ -0,0 +1,11 @@
target_sources(${TARGET_NAME}
PRIVATE
ipc/missionMessageTypes.cpp
pollingsequence/pollingSequenceFactory.cpp
)
# Add include paths for the executable
target_include_directories(${TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@ -0,0 +1,75 @@
#ifndef CONFIG_FSFWCONFIG_H_
#define CONFIG_FSFWCONFIG_H_
#include <cstddef>
#include <cstdint>
//! Used to determine whether C++ ostreams are used which can increase
//! the binary size significantly. If this is disabled,
//! the C stdio functions can be used alternatively
#define FSFW_CPP_OSTREAM_ENABLED 0
//! More FSFW related printouts depending on level. Useful for development.
#define FSFW_VERBOSE_LEVEL 1
//! Can be used to completely disable printouts, even the C stdio ones.
#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_VERBOSE_LEVEL == 0
#define FSFW_DISABLE_PRINTOUT 0
#endif
#define FSFW_USE_PUS_C_TELEMETRY 1
#define FSFW_USE_PUS_C_TELECOMMANDS 1
//! Can be used to disable the ANSI color sequences for C stdio.
#define FSFW_COLORED_OUTPUT 1
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
//! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiled source files)
#define FSFW_OBJ_EVENT_TRANSLATION 0
#if FSFW_OBJ_EVENT_TRANSLATION == 1
//! Specify whether info events are printed too.
#define FSFW_DEBUG_INFO 1
#include "objects/translateObjects.h"
#include "events/translateEvents.h"
#else
#endif
//! When using the newlib nano library, C99 support for stdio facilities
//! will not be provided. This define should be set to 1 if this is the case.
#define FSFW_NO_C99_IO 1
//! Specify whether a special mode store is used for Subsystem components.
#define FSFW_USE_MODESTORE 0
//! Defines if the real time scheduler for linux should be used.
//! If set to 0, this will also disable priority settings for linux
//! as most systems will not allow to set nice values without privileges
//! For embedded linux system set this to 1.
//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run
#define FSFW_USE_REALTIME_FOR_LINUX 1
namespace fsfwconfig {
//! Default timestamp size. The default timestamp will be an seven byte CDC short timestamp.
static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 7;
//! Configure the allocated pool sizes for the event manager.
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
//! Defines the FIFO depth of each commanding service base which
//! also determines how many commands a CSB service can handle in one cycle
//! simultaneously. This will increase the required RAM for
//! each CSB service !
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
}
#endif /* CONFIG_FSFWCONFIG_H_ */

View File

@ -0,0 +1,48 @@
/**
* @brief This file can be used to add preprocessor define for conditional
* code inclusion exclusion or various other project constants and
* properties in one place.
*/
#ifndef FSFWCONFIG_OBSWCONFIG_H_
#define FSFWCONFIG_OBSWCONFIG_H_
#define STM_USE_PERIPHERAL_TX_BUFFER_MPU_PROTECTION 1
//! Specify whether lwIP components are added. These are necessary for TMTC commanding
#define OBSW_ADD_LWIP_COMPONENTS 1
//! Specify whether TMTC commanding via Ethernet is possible
#define OBSW_ETHERNET_TMTC_COMMANDING 1
//! Only applies if TMTC commanding is enabled.
//! Specify whether LEDs are used to display Ethernet connection status.
#define OBSW_ETHERNET_USE_LED1_LED2 0
#define OBSW_ATTEMPT_DHCP_CONN 1
#define OBSW_PERIPHERAL_PST 0
#define OBSW_PERFORM_SPI_TEST 0
#define OBSW_PERFORM_L3GD20H_TEST 0
#if OBSW_ATTEMPT_DHCP_CONN == 0
#define MAX_DHCP_TRIES 0
#else
#define MAX_DHCP_TRIES 3
#endif
#ifdef __cplusplus
#include "events/subsystemIdRanges.h"
#include "objects/systemObjectList.h"
#include <commonConfig.h>
namespace config {
#endif
/* Add mission configuration flags here */
#ifdef __cplusplus
}
#endif
#endif /* FSFWCONFIG_OBSWCONFIG_H_ */

View File

@ -0,0 +1,14 @@
#ifndef BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_
#define BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_
#include <cstdint>
namespace devaddress {
enum devaddress: uint32_t {
L3GD20H = 1
};
}
#endif /* BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_ */

View File

@ -0,0 +1,11 @@
#ifndef FSFWCONFIG_TMTC_SUBSYSTEMIDRANGES_H_
#define FSFWCONFIG_TMTC_SUBSYSTEMIDRANGES_H_
#include "commonSubsystemIds.h"
namespace SUBSYSTEM_ID {
enum subsystemId: uint8_t {
};
}
#endif /* FSFWCONFIG_TMTC_SUBSYSTEMIDRANGES_H_ */

View File

@ -0,0 +1,11 @@
#include "missionMessageTypes.h"
#include <fsfw/ipc/CommandMessage.h>
#include <fsfw/ipc/CommandMessageCleaner.h>
void messagetypes::clearMissionMessage(CommandMessage* message) {
switch((message->getMessageType())) {
default:
message->setCommand(CommandMessage::CMD_NONE);
break;
}
}

View File

@ -0,0 +1,19 @@
#ifndef FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_
#define FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_
#include <fsfw/ipc/FwMessageTypes.h>
class CommandMessage;
namespace messagetypes {
/* First type must have number MESSAGE_TYPE::FW_MESSAGES_COUNT! */
/* Remember to add new message types to the clearMissionMessage function below! */
enum MISSION_MESSAGE_TYPE {
COSTUM_MESSAGE = FW_MESSAGES_COUNT,
};
void clearMissionMessage(CommandMessage* message);
}
#endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */

View File

@ -0,0 +1,20 @@
#ifndef FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#define FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#include <commonSystemObjects.h>
namespace objects {
enum mission_objects {
/* 0x62 ('b') Board and mission specific objects */
UDP_BRIDGE = 0x62000300,
UDP_POLLING_TASK = 0x62000400,
SPI_COM_IF = 0x63001000,
SPI_DEVICE_TEST = 0x74001000,
/* Generic name for FSFW static ID setter */
DOWNLINK_DESTINATION = UDP_BRIDGE
};
}
#endif /* FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */

View File

@ -0,0 +1,33 @@
/**
* Add polling sequence initialization which are not common to every BSP here.
*/
#include "pollingSequenceFactory.h"
#include "OBSWConfig.h"
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
ReturnValue_t pst::pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence) {
uint32_t length = thisSequence->getPeriodMs();
static_cast<void>(length);
#if OBSW_PERFORM_L3GD20H_TEST == 1
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.3, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.45 * length,
DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.6 * length, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.8 * length, DeviceHandlerIF::GET_READ);
#endif
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
#else
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -0,0 +1,15 @@
#ifndef POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_
#define POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_
#include "OBSWConfig.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
class FixedTimeslotTaskIF;
namespace pst {
ReturnValue_t pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence);
ReturnValue_t pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence);
ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF* thisSequence);
}
#endif /* POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_ */

View File

@ -0,0 +1,12 @@
#ifndef FSFWCONFIG_RETURNVALUES_CLASSIDS_H_
#define FSFWCONFIG_RETURNVALUES_CLASSIDS_H_
#include <commonConfig.h>
namespace CLASS_ID {
enum classIds: uint8_t {
};
}
#endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */

View File

@ -0,0 +1,11 @@
#ifndef FSFWCONFIG_TMTC_APID_H_
#define FSFWCONFIG_TMTC_APID_H_
#include <cstdint>
#include <commonConfig.h>
namespace apid {
static const uint16_t APID = COMMON_APID;
};
#endif /* FSFWCONFIG_TMTC_APID_H_ */

View File

@ -0,0 +1,7 @@
#ifndef FSFWCONFIG_TMTC_PUSIDS_H_
#define FSFWCONFIG_TMTC_PUSIDS_H_
#include <commonConfig.h>
#endif /* FSFWCONFIG_TMTC_PUSIDS_H_ */