From eccf45341509f852637d2f4ee32dcb36ccc96b4c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 29 May 2022 16:06:19 +0200 Subject: [PATCH] debugging mem exception --- README.md | 8 ++--- bsp_stm32h7_freertos/boardtest/SpiTest.cpp | 2 +- bsp_stm32h7_freertos/boardtest/SpiTest.h | 2 +- bsp_stm32h7_freertos/core/InitMission.cpp | 40 ++++++++++++--------- bsp_stm32h7_freertos/core/ObjectFactory.cpp | 4 ++- bsp_stm32h7_freertos/main.cpp | 8 ++--- fsfw | 2 +- 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ffd64a9..c73126f 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ This demo can be run on a STM32H743ZI-Nucleo board with the FreeRTOS OSAL. ## General Information -The board is flashed and debugged with OpenOCD and this README specifies on how -to make this work with the Eclipse IDE. Other IDEs or the command line can be used as well as long -as long as OpenOCD integration is given. The example demo uses newlib nano (glibc). -Some system calls were overriden so the C and C++ stdio functions work. IO is sent via the HUART3, +The board is flashed and debugged with [OpenOCD](https://openocd.org/) and this README specifies on +how to make this work with the Eclipse IDE. Other IDEs or the command line can be used as well as +long as long as OpenOCD integration is given. The example demo uses newlib nano (glibc). +Some system calls were overriden so the C and C++ `stdio` functions work. IO is sent via the HUART3, so debug output can be read directly from the USB connection to the board. ## Prerequisites diff --git a/bsp_stm32h7_freertos/boardtest/SpiTest.cpp b/bsp_stm32h7_freertos/boardtest/SpiTest.cpp index 4e9ba18..0d2b145 100644 --- a/bsp_stm32h7_freertos/boardtest/SpiTest.cpp +++ b/bsp_stm32h7_freertos/boardtest/SpiTest.cpp @@ -16,7 +16,7 @@ ReturnValue_t SpiTest::performOperation(uint8_t opCode) { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - std::array recBuf; + std::array recBuf{}; uint8_t *recPtr = recBuf.data(); size_t readLen = 0; return spiComIF.readReceivedMessage(&spiCookie, &recPtr, &readLen); diff --git a/bsp_stm32h7_freertos/boardtest/SpiTest.h b/bsp_stm32h7_freertos/boardtest/SpiTest.h index 90fe44f..ed40e65 100644 --- a/bsp_stm32h7_freertos/boardtest/SpiTest.h +++ b/bsp_stm32h7_freertos/boardtest/SpiTest.h @@ -7,7 +7,7 @@ class SpiTest { public: - SpiTest(SpiComIF &spiComIF); + explicit SpiTest(SpiComIF &spiComIF); ReturnValue_t performOperation(uint8_t opCode = 0); diff --git a/bsp_stm32h7_freertos/core/InitMission.cpp b/bsp_stm32h7_freertos/core/InitMission.cpp index 80b47ac..40f4359 100644 --- a/bsp_stm32h7_freertos/core/InitMission.cpp +++ b/bsp_stm32h7_freertos/core/InitMission.cpp @@ -17,15 +17,16 @@ #include "FreeRTOS.h" +void assemlyDemo(); + void InitMission::createTasks() { TaskFactory *taskFactory = TaskFactory::instance(); - + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if OBSW_ADD_CORE_COMPONENTS == 1 /* TMTC Distribution */ PeriodicTaskIF *distributerTask = taskFactory->createPeriodicTask("DIST", 5, 1024 * 2, 0.2, nullptr); - ReturnValue_t result = - distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR); + result = distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR); if (result != HasReturnvaluesIF::RETURN_OK) { task::printInitError("CCSDS distributor", objects::CCSDS_DISTRIBUTOR); } @@ -38,6 +39,7 @@ void InitMission::createTasks() { task::printInitError("TM funnel", objects::TM_FUNNEL); } +#if OBSW_ADD_LWIP_COMPONENTS == 1 /* UDP bridge */ PeriodicTaskIF *udpBridgeTask = TaskFactory::instance()->createPeriodicTask( "UDP_UNIX_BRIDGE", 6, 1024 * 2, 0.2, nullptr); @@ -51,6 +53,7 @@ void InitMission::createTasks() { if (result != HasReturnvaluesIF::RETURN_OK) { task::printInitError("UDP polling task", objects::UDP_POLLING_TASK); } +#endif PeriodicTaskIF *eventManagerTask = TaskFactory::instance()->createPeriodicTask("EVENT_MGMT", 4, 1024 * 2, @@ -183,8 +186,10 @@ void InitMission::createTasks() { #if OBSW_ADD_CORE_COMPONENTS == 1 distributerTask->startTask(); eventManagerTask->startTask(); +#if OBSW_ADD_LWIP_COMPONENTS == 1 udpBridgeTask->startTask(); udpPollingTask->startTask(); +#endif #endif /* OBSW_ADD_CORE_COMPONENTS == 1 */ #if OBSW_ADD_PUS_STACK == 1 @@ -221,8 +226,7 @@ void InitMission::createTasks() { #endif #if OBSW_ADD_DEVICE_HANDLER_DEMO - HasModesIF *assembly = - ObjectManager::instance()->get(objects::TEST_ASSEMBLY); + auto *assembly = ObjectManager::instance()->get(objects::TEST_ASSEMBLY); if (assembly == nullptr) { return; } @@ -236,16 +240,20 @@ void InitMission::createTasks() { #endif TaskFactory::delayTask(5000); - CommandMessage modeMessage; - ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, - DeviceHandlerIF::MODE_NORMAL, - TestAssembly::submodes::DUAL); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Commanding Test Assembly to Normal, Dual" << std::endl; -#else - sif::printInfo("Commanding Test Assembly to Normal, Dual \n"); -#endif - MessageQueueSenderIF::sendMessage(assembly->getCommandQueue(), &modeMessage, - MessageQueueIF::NO_QUEUE); + #endif /* OBSW_ADD_DEVICE_HANDLER_DEMO */ } + +void assemblyDemo(HasModesIF* assembly) { + CommandMessage modeMessage; + ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, + DeviceHandlerIF::MODE_NORMAL, + TestAssembly::submodes::DUAL); +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "Commanding Test Assembly to Normal, Dual" << std::endl; +#else + sif::printInfo("Commanding Test Assembly to Normal, Dual \n"); +#endif + MessageQueueSenderIF::sendMessage(assembly->getCommandQueue(), &modeMessage, + MessageQueueIF::NO_QUEUE); +} \ No newline at end of file diff --git a/bsp_stm32h7_freertos/core/ObjectFactory.cpp b/bsp_stm32h7_freertos/core/ObjectFactory.cpp index 9dbd224..c78ba93 100644 --- a/bsp_stm32h7_freertos/core/ObjectFactory.cpp +++ b/bsp_stm32h7_freertos/core/ObjectFactory.cpp @@ -51,17 +51,19 @@ void ObjectFactory::produce(void *args) { new PoolManager(objects::IPC_STORE, poolCfg); } +#if OBSW_ADD_LWIP_COMPONENTS == 1 /* UDP Server */ new TmTcLwIpUdpBridge(objects::UDP_BRIDGE, objects::CCSDS_DISTRIBUTOR, objects::TM_STORE, objects::TC_STORE); new UdpTcLwIpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE, &gnetif); +#endif #endif /* OBSW_ADD_CORE_COMPONENTS == 1 */ ObjectFactory::produceGenericObjects(); /* Test Device Handler */ - new STM32TestTask(objects::TEST_TASK, false, true); + new STM32TestTask(objects::TEST_TASK, true, true); #if OBSW_PERFORM_L3GD20H_TEST == 1 diff --git a/bsp_stm32h7_freertos/main.cpp b/bsp_stm32h7_freertos/main.cpp index 01af21c..dc77559 100644 --- a/bsp_stm32h7_freertos/main.cpp +++ b/bsp_stm32h7_freertos/main.cpp @@ -1,6 +1,4 @@ #include "OBSWConfig.h" -#include "OBSWVersion.h" -#include "boardconfig.h" #include "hardware_init.h" #if OBSW_ADD_LWIP_COMPONENTS == 1 @@ -16,7 +14,6 @@ #include #include -#include "FreeRTOS.h" #include "cmsis_os.h" #include "task.h" @@ -52,8 +49,7 @@ int main() { osKernelStart(); /* Should not be reached, scheduler should now be running. */ - for (;;) { - } + for (;;) {} return 0; } @@ -84,5 +80,5 @@ void initTask(void *parameters) { sif::printInfo("Creating tasks..\n\r"); #endif InitMission::createTasks(); - TaskFactory::instance()->deleteTask(nullptr); + TaskFactory::deleteTask(nullptr); } diff --git a/fsfw b/fsfw index a5245d5..4440288 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit a5245d55866af138b1f2d86d560b59f3a1bd3255 +Subproject commit 44402883b509f2116d48269edff3068a63c4c204