From c431deede06be85333f85bc55ac40615e561c25a Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Wed, 4 Aug 2021 10:20:36 +0200 Subject: [PATCH] ploc udpdater wip --- bsp_q7s/memory/SdCardManager.h | 2 +- common/config/commonClassIds.h | 1 + common/config/commonObjects.h | 4 ++- linux/fsfwconfig/OBSWConfig.h.in | 1 + mission/devices/CMakeLists.txt | 1 + mission/devices/PlocUpdater.cpp | 59 ++++++++++++++++++++++++++++++++ mission/devices/PlocUpdater.h | 45 ++++++++++++++++++++++++ 7 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 mission/devices/PlocUpdater.cpp create mode 100644 mission/devices/PlocUpdater.h diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 7af57a67..d882aa8e 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -153,7 +153,7 @@ public: sd::SdCard prefSdCard = sd::SdCard::NONE); /** - * If sd::SdCard::NONE is passed as an argument, this funtion will get the currently + * If sd::SdCard::NONE is passed as an argument, this function will get the currently * preferred SD card from the scratch buffer. * @param prefSdCardPtr * @return diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 6a27c286..d35b01dc 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -19,6 +19,7 @@ enum commonClassIds: uint8_t { PLOC_SUPERVISOR_HANDLER, //PLSV SUS_HANDLER, //SUSS CCSDS_IP_CORE_BRIDGE, //IPCI + PLOC_UPDATER, //PLUD COMMON_CLASS_ID_END // [EXPORT] : [END] }; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 8c9a83b9..2a2a25b9 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -80,7 +80,9 @@ enum commonObjects: uint32_t { RW3 = 0x44120003, RW4 = 0x44120004, - START_TRACKER = 0x44130001 + START_TRACKER = 0x44130001, + + PLOC_UPDATER = 0x44300000 }; } diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 778a1611..6a83a874 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -76,6 +76,7 @@ namespace config { /* Add mission configuration flags here */ static constexpr uint32_t OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE = 50; +static constexpr uint32_t PLOC_UPDATER_QUEUE_SIZE = 50; #ifdef __cplusplus } diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index 63b417e9..5b1f5533 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -18,6 +18,7 @@ target_sources(${TARGET_NAME} PUBLIC GyroADIS16507Handler.cpp RwHandler.cpp StarTrackerHandler.cpp + PlocUpdater.cpp ) diff --git a/mission/devices/PlocUpdater.cpp b/mission/devices/PlocUpdater.cpp new file mode 100644 index 00000000..d1a44783 --- /dev/null +++ b/mission/devices/PlocUpdater.cpp @@ -0,0 +1,59 @@ +#include + +PlocUpdater::PlocUpdater() : commandActionHelper(this) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +} + +PlocUpdater::~PlocUpdater() { +} + +ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size) { + if (state == BUSY) { + return UPDATER_BUSY; + } + ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + dumpData.address = 0; + receivedDataSize = 0; + timer.resetTimer(); + switch (actionId) { + case UPDATE_NVM0_A: + break; + case UPDATE_NVM0_B: + break; + case UPDATE_NVM1_A: + break; + case UPDATE_NVM1_B: + break; + dumpData.size = STRHandler::IMAGE_HEADER_SIZE; + dumpData.memoryId = STRHandler::ASC_MID_IMAGE; + result = commandActionHelper.commandAction(objects::STR_HANDLER, + STRHandler::ASC_SEND_IMAGE_TC_ID, &dumpData); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + state = EXPECT_IMAGE_SIZE; + break; + case FETCH_MIRU_DATA: + dumpData.memoryId = STRHandler::ASC_MID_MASSMEMORY; + dumpData.size = chunkSize; + result = commandActionHelper.commandAction(objects::STR_HANDLER, + STRHandler::ASC_MIRU_DUMP_DATA_TC_ID, &dumpData); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + state = MIRU_DATA_REQUESTED; + break; + default: + return INVALID_ACTION_ID; + } + return EXECUTION_FINISHED; +} + +MessageQueueId_t PlocUpdater::getCommandQueue() const { + return commandQueue.getId(); +} + +PlocUpdater::prepare +getCurrentMountPrefix + diff --git a/mission/devices/PlocUpdater.h b/mission/devices/PlocUpdater.h new file mode 100644 index 00000000..ae3edf1f --- /dev/null +++ b/mission/devices/PlocUpdater.h @@ -0,0 +1,45 @@ +#ifndef MISSION_DEVICES_PLOCUPDATER_H_ +#define MISSION_DEVICES_PLOCUPDATER_H_ + +#include "fsfw/action/CommandActionHelper.h" + +/** + * @brief An object of this class can be used to perform the software updates of the PLOC. The + * software update will be fetched via file system messages from the SD card handler, + * split into multiple space packets and sent to the PlocSupervisorHandler. + * + * @details The MPSoC has to boot memories (NVM0 and NVM1) where each stores two images (Partition A + * and Partition B) + * + * @author J. Meier + */ +class PlocUpdater : public SystemObject, + public HasActionsIF, + public ExecutableObjectIF { +public: + + static const ActionId_t UPDATE_NVM0_A = 0; + static const ActionId_t UPDATE_NVM0_B = 0; + static const ActionId_t UPDATE_NVM1_A = 0; + static const ActionId_t UPDATE_NVM1_B = 0; + + PlocUpdater(); + virtual ~PlocUpdater(); + + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; + + //! [EXPORT] : [COMMENT] Updater is already performing an update + static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); + + static constexpr uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; + + CommandActionHelper commandActionHelper; +}; + +#endif /* MISSION_DEVICES_PLOCUPDATER_H_ */