From be6056aadbe08269ca913739a09f204502a0b7e3 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Tue, 17 Aug 2021 16:14:23 +0200 Subject: [PATCH] adaptions to build software for Trenz TE0720 --- README.md | 5 ++ bsp_q7s/core/InitMission.cpp | 13 +++-- bsp_q7s/core/ObjectFactory.cpp | 50 ++++++++++--------- bsp_q7s/devices/PlocSupervisorHandler.cpp | 7 +++ bsp_q7s/devices/PlocSupervisorHandler.h | 2 + bsp_q7s/devices/PlocUpdater.cpp | 7 ++- bsp_q7s/devices/PlocUpdater.h | 5 +- linux/fsfwconfig/OBSWConfig.h.in | 2 +- .../pollingSequenceFactory.cpp | 4 +- .../pollingsequence/pollingSequenceFactory.h | 2 +- 10 files changed, 65 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index def12cf0..d75c535b 100644 --- a/README.md +++ b/README.md @@ -924,6 +924,11 @@ Reading data from CAN: candump can0 ```` +## Dump content of file in hex +```` +cat file.bin | hexdump +```` + ## Preparation of a fresh rootfs and SD card This section summarizes important changes between a fresh rootfs and the current diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 2ee4d374..051f7f3c 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -57,13 +57,14 @@ void initmission::initTasks() { void (*missedDeadlineFunc) (void) = nullptr; #endif +#if BOARD_TE0720 == 0 PeriodicTaskIF* coreController = factory->createPeriodicTask( "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); result = coreController->addComponent(objects::CORE_CONTROLLER); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); - } +#endif /* TMTC Distribution */ PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( @@ -102,7 +103,7 @@ void initmission::initTasks() { initmission::printAddObjectError("PLOC_UPDATER_TASK", objects::PLOC_UPDATER); } - +# if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task PeriodicTaskIF* fsTask = factory->createPeriodicTask( @@ -111,6 +112,7 @@ void initmission::initTasks() { if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); } +#endif /* BOARD_TE0720 */ #if TEST_CCSDS_BRIDGE == 1 PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( @@ -143,7 +145,9 @@ void initmission::initTasks() { tmTcDistributor->startTask(); tmtcBridgeTask->startTask(); tmtcPollingTask->startTask(); +#if BOARD_TE0720 == 0 coreController->startTask(); +#endif plocUpdaterTask->startTask(); taskStarter(pstTasks, "PST task vector"); @@ -155,7 +159,10 @@ void initmission::initTasks() { #if TEST_CCSDS_BRIDGE == 1 ptmeTestTask->startTask(); #endif + +#if BOARD_TE0720 == 0 fsTask->startTask(); +#endif sif::info << "Tasks started.." << std::endl; } @@ -205,7 +212,7 @@ void initmission::createPstTasks(TaskFactory& factory, } taskVec.push_back(gomSpacePstTask); #else /* BOARD_TE7020 == 0 */ - FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory->createFixedTimeslotTask( + FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, missedDeadlineFunc); result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 4e836f2e..59399f67 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -103,11 +103,11 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::produce(void* args){ ObjectFactory::setStatics(); ObjectFactory::produceGenericObjects(); - new CoreController(objects::CORE_CONTROLLER); LinuxLibgpioIF* gpioComIF = nullptr; createCommunicationInterfaces(&gpioComIF); createTmpComponents(); #if BOARD_TE0720 == 0 + new CoreController(objects::CORE_CONTROLLER); createPcduComponents(); createRadSensorComponent(gpioComIF); @@ -136,26 +136,6 @@ void ObjectFactory::produce(void* args){ #endif /* ADD_PLOC_MPSOC */ createReactionWheelComponents(gpioComIF); -#endif /* TE7020 != 0 */ - -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 - auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; -#else - new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created TCP server for TMTC commanding with listener port " << - tcpServer->getTcpPort() << std::endl; -#endif - - /* Test Task */ -#if OBSW_ADD_TEST_CODE == 1 - createTestComponents(); -#endif /* OBSW_ADD_TEST_CODE == 1 */ - - new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); #if ADD_PLOC_MPSOC == 1 UartCookie* plocMpsocCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"), @@ -178,9 +158,29 @@ void ObjectFactory::produce(void* args){ PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); plocSupervisor->setStartUpImmediately(); - #endif + new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); + +#endif /* TE7020 != 0 */ + +#if OBSW_USE_TMTC_TCP_BRIDGE == 0 + auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " << + udpBridge->getUdpPort() << std::endl; +#else + new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created TCP server for TMTC commanding with listener port " << + tcpServer->getTcpPort() << std::endl; +#endif + + /* Test Task */ +#if OBSW_ADD_TEST_CODE == 1 + createTestComponents(); +#endif /* OBSW_ADD_TEST_CODE == 1 */ + new PlocUpdater(objects::PLOC_UPDATER); } @@ -222,8 +222,11 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF) { #if Q7S_ADD_SPI_TEST == 0 new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST == 0 */ + +#if BOARD_TE0720 == 0 /* Adding gpios for chip select decoding to the gpioComIf */ gpioCallbacks::initSpiCsDecoder(*gpioComIF); +#endif } void ObjectFactory::createPcduComponents() { @@ -824,7 +827,8 @@ void ObjectFactory::createTestComponents() { /* Configuration for MIO0 on TE0720-03-1CFA */ UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200, - PLOC_SPV::MAX_REPLY_SIZE); + PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); plocSupervisor->setStartUpImmediately(); diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index de50955f..5bbcf1ef 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -34,7 +34,9 @@ ReturnValue_t PlocSupervisorHandler::initialize() { return INVALID_UART_COM_IF; } +#if BOARD_TE0720 == 0 sdcMan = SdCardManager::instance(); +#endif /* BOARD_TE0720 == 0 */ return result; } @@ -1462,7 +1464,12 @@ ReturnValue_t PlocSupervisorHandler::createMramDumpFile() { } std::string filename = "mram-dump--" + timeStamp + ".bin"; + +#if BOARD_TE0720 == 0 std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); +#else + std::string currentMountPrefix("/mnt/sd0"); +#endif /* BOARD_TE0720 == 0 */ // Check if path to PLOC directory exists if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { diff --git a/bsp_q7s/devices/PlocSupervisorHandler.h b/bsp_q7s/devices/PlocSupervisorHandler.h index 176578e4..c0c09eae 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.h +++ b/bsp_q7s/devices/PlocSupervisorHandler.h @@ -125,7 +125,9 @@ private: /** This buffer is used to concatenate space packets received in two different read steps */ uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; +#if BOARD_TE0720 == 0 SdCardManager* sdcMan = nullptr; +#endif /* BOARD_TE0720 == 0 */ /** Path to PLOC specific files on SD card */ std::string plocFilePath = "ploc"; diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 4a6085a2..0e4ea77d 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -14,8 +14,9 @@ PlocUpdater::~PlocUpdater() { } ReturnValue_t PlocUpdater::initialize() { +#if BOARD_TE0720 == 0 sdcMan = SdCardManager::instance(); - +#endif ReturnValue_t result = SystemObject::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -148,6 +149,7 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { return result; } +#if BOARD_TE0720 == 0 // Check if file is stored on SD card and if associated SD card is mounted if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { if (!isSdCardMounted(sd::SLOT_0)) { @@ -164,6 +166,7 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { else { //update image not stored on SD card } +#endif /* BOARD_TE0720 == 0 */ updateFile = std::string(reinterpret_cast(data), size); @@ -174,6 +177,7 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { return RETURN_OK; } +#if BOARD_TE0720 == 0 bool PlocUpdater::isSdCardMounted(sd::SdCard sdCard) { SdCardManager::SdStatePair active; ReturnValue_t result = sdcMan->getSdCardActiveStatus(active); @@ -202,6 +206,7 @@ bool PlocUpdater::isSdCardMounted(sd::SdCard sdCard) { } return false; } +#endif /* #if BOARD_TE0720 == 0 */ void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index fac8b7c2..8d7d9e30 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -94,8 +94,9 @@ private: MessageQueueIF* commandQueue = nullptr; +#if BOARD_TE0720 == 0 SdCardManager* sdcMan = nullptr; - +#endif CommandActionHelper commandActionHelper; ActionHelper actionHelper; @@ -160,10 +161,12 @@ private: */ void commandUpdateVerify(); +#if BOARD_TE0720 == 0 /** * @brief Checks whether the SD card to read from is mounted or not. */ bool isSdCardMounted(sd::SdCard sdCard); +#endif ReturnValue_t makeCrc(); diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index e2693430..e848fc6e 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -41,7 +41,7 @@ debugging. */ #define ADD_PLOC_SUPERVISOR 1 #define ADD_PLOC_MPSOC 0 -#define BOARD_TE0720 0 +#define BOARD_TE0720 1 #define TE0720_HEATER_TEST 0 #define P60DOCK_DEBUG 0 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 7153ac81..8d05181a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -710,7 +710,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { return HasReturnvaluesIF::RETURN_OK; } -#if BOARD_TE7020 == 1 +#if BOARD_TE0720 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { uint32_t length = thisSequence->getPeriodMs(); @@ -767,4 +767,4 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { } return HasReturnvaluesIF::RETURN_OK; } -#endif /* BOARD_TE7020 == 1 */ +#endif /* BOARD_TE0720 == 1 */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 4ce1619c..5bb5ff2a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -55,7 +55,7 @@ ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence); */ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); -#if TE0720 == 1 +#if BOARD_TE0720 == 1 /** * @brief This polling sequence will be created when the software is compiled for the TE0720. */