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 1/5] 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. */ From 124abf02137ff4588f65259c64d2c719b81ae2e7 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Wed, 18 Aug 2021 08:26:31 +0200 Subject: [PATCH 2/5] crc for ploc update --- README.md | 2 +- bsp_q7s/devices/PlocUpdater.cpp | 28 +++++++++++++++---- bsp_q7s/devices/PlocUpdater.h | 7 ++++- .../PlocSupervisorDefinitions.h | 2 +- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d75c535b..cb2f9f53 100644 --- a/README.md +++ b/README.md @@ -926,7 +926,7 @@ candump can0 ## Dump content of file in hex ```` -cat file.bin | hexdump +cat file.bin | hexdump -C ```` ## Preparation of a fresh rootfs and SD card diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 0e4ea77d..c37855a4 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -292,7 +292,7 @@ void PlocUpdater::commandUpdateAvailable() { remainingPackets = numOfUpdatePackets; packetsSent = 0; - uint32_t imageCrc = makeCrc(); + calcImageCrc(); PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(updateMemory), static_cast(updatePartition), imageSize, imageCrc, numOfUpdatePackets); @@ -338,7 +338,7 @@ void PlocUpdater::commandUpdatePacket() { file.close(); // sequence count of first packet is 1 packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); - if (numOfUpdatePackets > 0) { + if (numOfUpdatePackets > 1) { adjustSequenceFlags(packet); } packet.makeCrc(); @@ -383,9 +383,27 @@ void PlocUpdater::commandUpdateVerify() { return; } -ReturnValue_t PlocUpdater::makeCrc() { - //TODO: Waiting on input from TAS about the CRC to use - return 0; +void PlocUpdater::calcImageCrc() { + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + uint32_t count; + uint32_t bit; + uint32_t remainder = INITIAL_REMAINDER_32; + char input; + for (count = 0; count < imageSize; count++) { + file.seekg(count, file.beg); + file.read(&input, 1); + remainder ^= (input << 16); + for (bit = 8; bit > 0; --bit) { + if (remainder & TOPBIT_32) { + remainder = (remainder << 1) ^ POLYNOMIAL_32; + } else { + remainder = (remainder << 1); + } + } + } + file.close(); + imageCrc = (remainder ^ FINAL_XOR_VALUE_32); } void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) { diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index 8d7d9e30..c8a2b67b 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -92,6 +92,11 @@ private: // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) static const size_t MAX_SP_DATA = 1016; + static const uint32_t TOPBIT_32 = (1 << 31); + static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; + static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; + static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; + MessageQueueIF* commandQueue = nullptr; #if BOARD_TE0720 == 0 @@ -168,7 +173,7 @@ private: bool isSdCardMounted(sd::SdCard sdCard); #endif - ReturnValue_t makeCrc(); + void calcImageCrc(); void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); }; diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 909379df..26d44272 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1453,7 +1453,7 @@ public: UpdateInfo(uint16_t apid, uint8_t memory, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, uint32_t numPackets) : SupvTcSpacePacket(PAYLOAD_LENGTH, apid), memory(memory), partition(partition), imageSize( - imageSize), numPackets(numPackets) { + imageSize), imageCrc(imageCrc), numPackets(numPackets) { initPacket(); makeCrc(); } From 3acb61959a9ef558aa6bf0e23941dade46944769 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Fri, 20 Aug 2021 06:56:29 +0200 Subject: [PATCH 3/5] mram dump standalone packet --- README.md | 4 ++ bsp_q7s/devices/PlocSupervisorHandler.cpp | 13 ++++- bsp_q7s/devices/PlocUpdater.cpp | 48 ++++++++++++------- bsp_q7s/devices/PlocUpdater.h | 34 ++++++++----- .../PlocSupervisorDefinitions.h | 21 ++++---- tmtc | 2 +- 6 files changed, 81 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index cb2f9f53..d690a3a1 100644 --- a/README.md +++ b/README.md @@ -928,6 +928,10 @@ candump can0 ```` cat file.bin | hexdump -C ```` +All content will be printed with +```` +cat file.bin | hexdump -v +```` ## Preparation of a fresh rootfs and SD card diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index 5bbcf1ef..3a0eb141 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -467,6 +467,7 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry( { 0 })); localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry( { 0 })); localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry( { 0 })); return HasReturnvaluesIF::RETURN_OK; } @@ -557,6 +558,7 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR: case PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR: case PLOC_SPV::REQUEST_LOGGING_DATA: + case PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION: enabledReplies = 2; break; default: @@ -867,6 +869,9 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | *(data + offset + 3); offset += 4; + latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; nextReplyId = PLOC_SPV::EXE_REPORT; @@ -901,6 +906,8 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da << latchupStatusReport.timeYear << std::endl; sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " << latchupStatusReport.timeMsec << std::endl; + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" + << std::hex << latchupStatusReport.timeMsec << std::dec << std::endl; #endif return result; @@ -1400,7 +1407,8 @@ void PlocSupervisorHandler::increaseExpectedMramReplies() { return; } uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; - if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)) { + if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) + && (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { // Command expects at least one MRAM packet more and the execution report info->expectedReplies = 2; // Wait maximum of 2 cycles for next MRAM packet @@ -1428,7 +1436,8 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile() { ReturnValue_t result = RETURN_OK; uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)) { + if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) + || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { result = createMramDumpFile(); if (result != RETURN_OK) { return result; diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index c37855a4..5a94495b 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -52,21 +52,37 @@ ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, } switch (actionId) { - case UPDATE_NVM0_A: - updatePartition = Partition::A; - updateMemory = Memory::NVM0; + case UPDATE_A_UBOOT: + image = Image::A; + partition = Partition::UBOOT; break; - case UPDATE_NVM0_B: - updatePartition = Partition::B; - updateMemory = Memory::NVM0; + case UPDATE_A_BITSTREAM: + image = Image::A; + partition = Partition::BITSTREAM; break; - case UPDATE_NVM1_A: - updatePartition = Partition::A; - updateMemory = Memory::NVM1; + case UPDATE_A_LINUX: + image = Image::A; + partition = Partition::LINUX_OS; break; - case UPDATE_NVM1_B: - updatePartition = Partition::B; - updateMemory = Memory::NVM1; + case UPDATE_A_APP_SW: + image = Image::A; + partition = Partition::APP_SW; + break; + case UPDATE_B_UBOOT: + image = Image::B; + partition = Partition::UBOOT; + break; + case UPDATE_B_BITSTREAM: + image = Image::B; + partition = Partition::BITSTREAM; + break; + case UPDATE_B_LINUX: + image = Image::B; + partition = Partition::LINUX_OS; + break; + case UPDATE_B_APP_SW: + image = Image::B; + partition = Partition::APP_SW; break; default: return INVALID_ACTION_ID; @@ -294,8 +310,8 @@ void PlocUpdater::commandUpdateAvailable() { calcImageCrc(); - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(updateMemory), - static_cast(updatePartition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), + static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize()); @@ -365,8 +381,8 @@ void PlocUpdater::commandUpdatePacket() { void PlocUpdater::commandUpdateVerify() { ReturnValue_t result = RETURN_OK; - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(updateMemory), - static_cast(updatePartition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), + static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize()); diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index c8a2b67b..50404d14 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -33,10 +33,14 @@ class PlocUpdater : public SystemObject, public CommandsActionsIF { public: - static const ActionId_t UPDATE_NVM0_A = 0; - static const ActionId_t UPDATE_NVM0_B = 1; - static const ActionId_t UPDATE_NVM1_A = 2; - static const ActionId_t UPDATE_NVM1_B = 3; + static const ActionId_t UPDATE_A_UBOOT = 0; + static const ActionId_t UPDATE_A_BITSTREAM = 1; + static const ActionId_t UPDATE_A_LINUX = 2; + static const ActionId_t UPDATE_A_APP_SW = 3; + static const ActionId_t UPDATE_B_UBOOT = 4; + static const ActionId_t UPDATE_B_BITSTREAM = 5; + static const ActionId_t UPDATE_B_LINUX = 6; + static const ActionId_t UPDATE_B_APP_SW = 7; PlocUpdater(object_id_t objectId); virtual ~PlocUpdater(); @@ -118,19 +122,23 @@ private: ActionId_t pendingCommand = PLOC_SPV::NONE; - enum class Memory: uint8_t { - NVM0, - NVM1 - }; - - Memory updateMemory = Memory::NVM0; - - enum class Partition: uint8_t { + enum class Image: uint8_t { + NONE, A, B }; - Partition updatePartition = Partition::A; + Image image = Image::NONE; + + enum class Partition: uint8_t { + NONE, + UBOOT, + BITSTREAM, + LINUX_OS, + APP_SW + }; + + Partition partition = Partition::NONE; uint32_t packetsSent = 0; uint32_t remainingPackets = 0; diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 26d44272..a28418e7 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -67,7 +67,7 @@ static const uint16_t SIZE_ACK_REPORT = 14; static const uint16_t SIZE_EXE_REPORT = 14; static const uint16_t SIZE_HK_REPORT = 48; static const uint16_t SIZE_BOOT_STATUS_REPORT = 22; -static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 51; +static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 55; /** * SpacePacket apids of telemetry packets @@ -196,11 +196,12 @@ enum PoolIds LATCHUP_RPT_TIME_YEAR, LATCHUP_RPT_TIME_MSEC, LATCHUP_RPT_TIME_USEC, + LATCHUP_RPT_TIME_IS_SET, }; static const uint8_t HK_SET_ENTRIES = 13; static const uint8_t BOOT_REPORT_SET_ENTRIES = 8; -static const uint8_t LATCHUP_RPT_SET_ENTRIES = 15; +static const uint8_t LATCHUP_RPT_SET_ENTRIES = 16; static const uint32_t HK_SET_ID = HK_REPORT; static const uint32_t BOOT_REPORT_SET_ID = BOOT_STATUS_REPORT; @@ -1445,14 +1446,15 @@ public: * * @param apid Packet can be used to generate the update available and the update verify * packet. Thus the APID must be specified here. - * @param memory The memory to apply the update (NVM0 - 0, NVM1 - 1) - * @param partition The partition to update (A - 0, B - 1) + * @param image The image to update on a NVM (A - 0, B - 1) + * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, + * application - 4 * @param imageSize The size of the update image * param numPackets The number of space packets required to transfer all data. */ - UpdateInfo(uint16_t apid, uint8_t memory, uint8_t partition, uint32_t imageSize, + UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, uint32_t numPackets) : - SupvTcSpacePacket(PAYLOAD_LENGTH, apid), memory(memory), partition(partition), imageSize( + SupvTcSpacePacket(PAYLOAD_LENGTH, apid), image(image), partition(partition), imageSize( imageSize), imageCrc(imageCrc), numPackets(numPackets) { initPacket(); makeCrc(); @@ -1462,7 +1464,7 @@ private: static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field - uint8_t memory = 0; + uint8_t image = 0; uint8_t partition = 0; uint32_t imageSize = 0; uint32_t imageCrc = 0; @@ -1471,8 +1473,8 @@ private: void initPacket() { size_t serializedSize = 0; uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&memory, &data_field_ptr, &serializedSize, - sizeof(memory), SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, + sizeof(image), SerializeIF::Endianness::BIG); serializedSize = 0; SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, sizeof(partition), SerializeIF::Endianness::BIG); @@ -1599,6 +1601,7 @@ public: lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); lp_var_t timeYear = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); lp_var_t timeMsec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); + lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); }; } diff --git a/tmtc b/tmtc index 5b2ff495..c125a626 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5b2ff49555f0cfee51cd53c7772a147575a825a3 +Subproject commit c125a6261201930c25ebdcdeb0ef69a53ab588b0 From 5789e2a3b5229f9a66b6102a9dfb53f089d9848d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 20 Aug 2021 10:01:37 +0200 Subject: [PATCH 4/5] added LICENSE and NOTICE file --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NOTICE | 13 ++++ 2 files changed, 215 insertions(+) create mode 100644 LICENSE create mode 100644 NOTICE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..86a797ad --- /dev/null +++ b/NOTICE @@ -0,0 +1,13 @@ +Copyright 2021 Institute of Space Systems (IRS), University of Stuttgart + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file From 95b49ca49dbd3e2ce7a1dec49b0f1c28ce592c22 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Fri, 20 Aug 2021 13:56:43 +0200 Subject: [PATCH 5/5] update tmtc and arcsec submodule --- README.md | 4 ++++ linux/fsfwconfig/OBSWConfig.h.in | 2 +- thirdparty/arcsec_star_tracker | 2 +- tmtc | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d690a3a1..77263fd2 100644 --- a/README.md +++ b/README.md @@ -932,6 +932,10 @@ All content will be printed with ```` cat file.bin | hexdump -v ```` +To print only the first X bytes of a file +```` +cat file.bin | hexdump -v -n X +```` ## Preparation of a fresh rootfs and SD card diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index e848fc6e..e2693430 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 1 +#define BOARD_TE0720 0 #define TE0720_HEATER_TEST 0 #define P60DOCK_DEBUG 0 diff --git a/thirdparty/arcsec_star_tracker b/thirdparty/arcsec_star_tracker index c468400a..657c06e4 160000 --- a/thirdparty/arcsec_star_tracker +++ b/thirdparty/arcsec_star_tracker @@ -1 +1 @@ -Subproject commit c468400aaf8470a31e393f53c858d2bf2c361273 +Subproject commit 657c06e4a6e4c460e897c4a5b4eaefe7c6d1085e diff --git a/tmtc b/tmtc index c125a626..ce5596f5 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c125a6261201930c25ebdcdeb0ef69a53ab588b0 +Subproject commit ce5596f5669b8df44df418da6adff123941a395d