From 5de9a812bb9c386e2c47425475285c9da36a8590 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Aug 2022 14:44:27 +0200 Subject: [PATCH 1/7] use default cross-user path for x-compiler installation --- scripts/q7s-env-em.sh | 2 +- scripts/q7s-env.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/q7s-env-em.sh b/scripts/q7s-env-em.sh index 895648a2..e8be1467 100755 --- a/scripts/q7s-env-em.sh +++ b/scripts/q7s-env-em.sh @@ -4,7 +4,7 @@ # custom cross-compiler and sysroot path setups # Adapt the following two entries to your need -CROSS_COMPILE_BIN_PATH="$HOME/EIVE/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" +CROSS_COMPILE_BIN_PATH="/opt/q7s-gcc/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" export ZYNQ_7020_SYSROOT="/opt/xiphos/sdk/ark/sysroots/cortexa9hf-neon-xiphos-linux-gnueabi" export PATH=$PATH:${CROSS_COMPILE_BIN_PATH} diff --git a/scripts/q7s-env.sh b/scripts/q7s-env.sh index c5638323..5cf608a0 100755 --- a/scripts/q7s-env.sh +++ b/scripts/q7s-env.sh @@ -4,7 +4,7 @@ # custom cross-compiler and sysroot path setups # Adapt the following two entries to your need -CROSS_COMPILE_BIN_PATH="$HOME/EIVE/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" +CROSS_COMPILE_BIN_PATH="/opt/q7s-gcc/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" export ZYNQ_7020_SYSROOT="/opt/xiphos/sdk/ark/sysroots/cortexa9hf-neon-xiphos-linux-gnueabi" export PATH=$PATH:${CROSS_COMPILE_BIN_PATH} From 208856ef52f9b347994035df783c93aec5c26ef4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 21:44:18 +0200 Subject: [PATCH 2/7] bump tmtc again --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 13256211..7dfe92be 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 1325621133158604880f9d609646dd29deb09f2a +Subproject commit 7dfe92be8c85260e5abd1d52f9b201d26dbf6dc3 From e09eaae42f1d82f41c65a1f8812df0a84d32e9c9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 22:18:14 +0200 Subject: [PATCH 3/7] update events --- generators/bsp_q7s_events.csv | 33 ++++++------ generators/events/translateEvents.cpp | 53 ++++++++++--------- generators/objects/translateObjects.cpp | 2 +- linux/devices/ploc/PlocSupervisorHandler.cpp | 2 +- linux/devices/ploc/PlocSupvHelper.h | 39 +++++++------- linux/fsfwconfig/events/translateEvents.cpp | 53 ++++++++++--------- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- tmtc | 2 +- 8 files changed, 97 insertions(+), 89 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 7d822e1d..fc8492ce 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -194,22 +194,23 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 13605;0x3525;SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL;LOW;Requesting event buffer was successful;linux/devices/ploc/PlocSupvHelper.h 13606;0x3526;SUPV_EVENT_BUFFER_REQUEST_FAILED;LOW;Requesting event buffer failed;linux/devices/ploc/PlocSupvHelper.h 13607;0x3527;SUPV_EVENT_BUFFER_REQUEST_TERMINATED;LOW;Terminated event buffer request by command P1: Number of packets read before process was terminated;linux/devices/ploc/PlocSupvHelper.h -13608;0x3528;SUPV_SENDING_COMMAND_FAILED;LOW;;linux/devices/ploc/PlocSupvHelper.h -13609;0x3529;SUPV_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h -13610;0x352a;SUPV_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h -13611;0x352b;SUPV_MISSING_ACK;LOW;Did not receive acknowledgement report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/devices/ploc/PlocSupvHelper.h -13612;0x352c;SUPV_MISSING_EXE;LOW;Supervisor did not receive execution report P1: Number of bytes missing P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h -13613;0x352d;SUPV_ACK_FAILURE_REPORT;LOW;Supervisor received acknowledgment failure report P1: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h -13614;0x352e;SUPV_EXE_FAILURE_REPORT;LOW;Execution report failure P1:;linux/devices/ploc/PlocSupvHelper.h -13615;0x352f;SUPV_ACK_INVALID_APID;LOW;Supervisor expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h -13616;0x3530;SUPV_EXE_INVALID_APID;LOW;Supervisor helper expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h -13617;0x3531;ACK_RECEPTION_FAILURE;LOW;Failed to receive acknowledgment report P1: Return value P2: Apid of command for which the reception of the acknowledgment report failed;linux/devices/ploc/PlocSupvHelper.h -13618;0x3532;EXE_RECEPTION_FAILURE;LOW;Failed to receive execution report P1: Return value P2: Apid of command for which the reception of the execution report failed;linux/devices/ploc/PlocSupvHelper.h -13619;0x3533;WRITE_MEMORY_FAILED;LOW;Update procedure failed when sending packet. P1: First byte percent, Third and Fourht bytes Sequence Count, P2: Bytes written;linux/devices/ploc/PlocSupvHelper.h -13620;0x3534;SUPV_REPLY_SIZE_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h -13621;0x3535;SUPV_REPLY_CRC_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h -13622;0x3536;SUPV_UPDATE_PROGRESS;INFO;Will be triggered every 5 percent of the update progress. P1: First byte percent, Third and Fourht bytes Sequence Count, P2: Bytes written;linux/devices/ploc/PlocSupvHelper.h -13623;0x3537;SUPV_MEM_CHECK_STATUS;INFO;;linux/devices/ploc/PlocSupvHelper.h +13608;0x3528;SUPV_MEM_CHECK_OK;INFO;;linux/devices/ploc/PlocSupvHelper.h +13609;0x3529;SUPV_MEM_CHECK_FAIL;INFO;;linux/devices/ploc/PlocSupvHelper.h +13616;0x3530;SUPV_SENDING_COMMAND_FAILED;LOW;;linux/devices/ploc/PlocSupvHelper.h +13617;0x3531;SUPV_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h +13618;0x3532;SUPV_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h +13619;0x3533;SUPV_MISSING_ACK;LOW;Did not receive acknowledgement report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/devices/ploc/PlocSupvHelper.h +13620;0x3534;SUPV_MISSING_EXE;LOW;Supervisor did not receive execution report P1: Number of bytes missing P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h +13621;0x3535;SUPV_ACK_FAILURE_REPORT;LOW;Supervisor received acknowledgment failure report P1: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h +13622;0x3536;SUPV_EXE_FAILURE_REPORT;LOW;Execution report failure P1:;linux/devices/ploc/PlocSupvHelper.h +13623;0x3537;SUPV_ACK_INVALID_APID;LOW;Supervisor expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h +13624;0x3538;SUPV_EXE_INVALID_APID;LOW;Supervisor helper expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h +13625;0x3539;ACK_RECEPTION_FAILURE;LOW;Failed to receive acknowledgment report P1: Return value P2: Apid of command for which the reception of the acknowledgment report failed;linux/devices/ploc/PlocSupvHelper.h +13626;0x353a;EXE_RECEPTION_FAILURE;LOW;Failed to receive execution report P1: Return value P2: Apid of command for which the reception of the execution report failed;linux/devices/ploc/PlocSupvHelper.h +13627;0x353b;WRITE_MEMORY_FAILED;LOW;Update procedure failed when sending packet. P1: First byte percent, Third and Fourht bytes Sequence Count, P2: Bytes written;linux/devices/ploc/PlocSupvHelper.h +13628;0x353c;SUPV_REPLY_SIZE_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h +13629;0x353d;SUPV_REPLY_CRC_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h +13630;0x353e;SUPV_UPDATE_PROGRESS;INFO;Will be triggered every 5 percent of the update progress. P1: First byte percent, Third and Fourht bytes Sequence Count, P2: Bytes written;linux/devices/ploc/PlocSupvHelper.h 13700;0x3584;ALLOC_FAILURE;MEDIUM;;bsp_q7s/core/CoreController.h 13701;0x3585;REBOOT_SW;MEDIUM; Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h 13702;0x3586;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index f9511036..d4f6f594 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 215 translations. + * @brief Auto-generated event translation file. Contains 216 translations. * @details - * Generated on: 2022-08-22 12:35:41 + * Generated on: 2022-08-22 22:17:50 */ #include "translateEvents.h" @@ -196,6 +196,8 @@ const char *TERMINATED_UPDATE_PROCEDURE_STRING = "TERMINATED_UPDATE_PROCEDURE"; const char *SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL_STRING = "SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL"; const char *SUPV_EVENT_BUFFER_REQUEST_FAILED_STRING = "SUPV_EVENT_BUFFER_REQUEST_FAILED"; const char *SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING = "SUPV_EVENT_BUFFER_REQUEST_TERMINATED"; +const char *SUPV_MEM_CHECK_OK_STRING = "SUPV_MEM_CHECK_OK"; +const char *SUPV_MEM_CHECK_FAIL_STRING = "SUPV_MEM_CHECK_FAIL"; const char *SUPV_SENDING_COMMAND_FAILED_STRING = "SUPV_SENDING_COMMAND_FAILED"; const char *SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING = "SUPV_HELPER_REQUESTING_REPLY_FAILED"; const char *SUPV_HELPER_READING_REPLY_FAILED_STRING = "SUPV_HELPER_READING_REPLY_FAILED"; @@ -211,7 +213,6 @@ const char *WRITE_MEMORY_FAILED_STRING = "WRITE_MEMORY_FAILED"; const char *SUPV_REPLY_SIZE_MISSMATCH_STRING = "SUPV_REPLY_SIZE_MISSMATCH"; const char *SUPV_REPLY_CRC_MISSMATCH_STRING = "SUPV_REPLY_CRC_MISSMATCH"; const char *SUPV_UPDATE_PROGRESS_STRING = "SUPV_UPDATE_PROGRESS"; -const char *SUPV_MEM_CHECK_STATUS_STRING = "SUPV_MEM_CHECK_STATUS"; const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; @@ -602,37 +603,39 @@ const char *translateEvents(Event event) { case (13607): return SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING; case (13608): - return SUPV_SENDING_COMMAND_FAILED_STRING; + return SUPV_MEM_CHECK_OK_STRING; case (13609): - return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING; - case (13610): - return SUPV_HELPER_READING_REPLY_FAILED_STRING; - case (13611): - return SUPV_MISSING_ACK_STRING; - case (13612): - return SUPV_MISSING_EXE_STRING; - case (13613): - return SUPV_ACK_FAILURE_REPORT_STRING; - case (13614): - return SUPV_EXE_FAILURE_REPORT_STRING; - case (13615): - return SUPV_ACK_INVALID_APID_STRING; + return SUPV_MEM_CHECK_FAIL_STRING; case (13616): - return SUPV_EXE_INVALID_APID_STRING; + return SUPV_SENDING_COMMAND_FAILED_STRING; case (13617): - return ACK_RECEPTION_FAILURE_STRING; + return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING; case (13618): - return EXE_RECEPTION_FAILURE_STRING; + return SUPV_HELPER_READING_REPLY_FAILED_STRING; case (13619): - return WRITE_MEMORY_FAILED_STRING; + return SUPV_MISSING_ACK_STRING; case (13620): - return SUPV_REPLY_SIZE_MISSMATCH_STRING; + return SUPV_MISSING_EXE_STRING; case (13621): - return SUPV_REPLY_CRC_MISSMATCH_STRING; + return SUPV_ACK_FAILURE_REPORT_STRING; case (13622): - return SUPV_UPDATE_PROGRESS_STRING; + return SUPV_EXE_FAILURE_REPORT_STRING; case (13623): - return SUPV_MEM_CHECK_STATUS_STRING; + return SUPV_ACK_INVALID_APID_STRING; + case (13624): + return SUPV_EXE_INVALID_APID_STRING; + case (13625): + return ACK_RECEPTION_FAILURE_STRING; + case (13626): + return EXE_RECEPTION_FAILURE_STRING; + case (13627): + return WRITE_MEMORY_FAILED_STRING; + case (13628): + return SUPV_REPLY_SIZE_MISSMATCH_STRING; + case (13629): + return SUPV_REPLY_CRC_MISSMATCH_STRING; + case (13630): + return SUPV_UPDATE_PROGRESS_STRING; case (13700): return ALLOC_FAILURE_STRING; case (13701): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index de55983c..b9535da0 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 133 translations. - * Generated on: 2022-08-22 12:35:41 + * Generated on: 2022-08-22 22:17:50 */ #include "translateObjects.h" diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 668264f1..b2759e53 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -2068,7 +2068,7 @@ ReturnValue_t PlocSupervisorHandler::eventSubscription() { } result = manager->subscribeToEventRange( eventQueue->getId(), event::getEventId(PlocSupvHelper::SUPV_UPDATE_FAILED), - event::getEventId(PlocSupvHelper::SUPV_EVENT_BUFFER_REQUEST_TERMINATED)); + event::getEventId(PlocSupvHelper::SUPV_MEM_CHECK_FAIL)); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "PlocSupervisorHandler::eventSubscritpion: Failed to subscribe to events from " diff --git a/linux/devices/ploc/PlocSupvHelper.h b/linux/devices/ploc/PlocSupvHelper.h index 27eaaa94..abd43187 100644 --- a/linux/devices/ploc/PlocSupvHelper.h +++ b/linux/devices/ploc/PlocSupvHelper.h @@ -42,60 +42,61 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha //! [EXPORT] : [COMMENT] Terminated event buffer request by command //! P1: Number of packets read before process was terminated static const Event SUPV_EVENT_BUFFER_REQUEST_TERMINATED = MAKE_EVENT(7, severity::LOW); + //! Status of memory check command + //! P1: Returncode, 0 for success, other value with returncode for failure + static constexpr Event SUPV_MEM_CHECK_OK = MAKE_EVENT(8, severity::INFO); + static constexpr Event SUPV_MEM_CHECK_FAIL = MAKE_EVENT(9, severity::INFO); + //! [EXPORT] : [COMMENT] Communication interface returned failure when trying to send the command //! to the supervisor //! P1: Return value returned by the communication interface sendMessage function //! P2: Internal state of supervisor helper - static const Event SUPV_SENDING_COMMAND_FAILED = MAKE_EVENT(8, severity::LOW); + static const Event SUPV_SENDING_COMMAND_FAILED = MAKE_EVENT(16, severity::LOW); //! [EXPORT] : [COMMENT] Request receive message of communication interface failed //! P1: Return value returned by the communication interface requestReceiveMessage function //! P2: Internal state of supervisor helper - static const Event SUPV_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(9, severity::LOW); + static const Event SUPV_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(17, severity::LOW); //! [EXPORT] : [COMMENT] Reading receive message of communication interface failed //! P1: Return value returned by the communication interface readingReceivedMessage function //! P2: Internal state of supervisor helper - static const Event SUPV_HELPER_READING_REPLY_FAILED = MAKE_EVENT(10, severity::LOW); + static const Event SUPV_HELPER_READING_REPLY_FAILED = MAKE_EVENT(18, severity::LOW); //! [EXPORT] : [COMMENT] Did not receive acknowledgement report //! P1: Number of bytes missing //! P2: Internal state of MPSoC helper - static const Event SUPV_MISSING_ACK = MAKE_EVENT(11, severity::LOW); + static const Event SUPV_MISSING_ACK = MAKE_EVENT(19, severity::LOW); //! [EXPORT] : [COMMENT] Supervisor did not receive execution report //! P1: Number of bytes missing //! P2: Internal state of supervisor helper - static const Event SUPV_MISSING_EXE = MAKE_EVENT(12, severity::LOW); + static const Event SUPV_MISSING_EXE = MAKE_EVENT(20, severity::LOW); //! [EXPORT] : [COMMENT] Supervisor received acknowledgment failure report //! P1: Internal state of supervisor helper - static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(13, severity::LOW); + static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(21, severity::LOW); //! [EXPORT] : [COMMENT] Execution report failure //! P1: - static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(14, severity::LOW); + static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(22, severity::LOW); //! [EXPORT] : [COMMENT] Supervisor expected acknowledgment report but received space packet with //! other apid P1: Apid of received space packet P2: Internal state of supervisor helper - static const Event SUPV_ACK_INVALID_APID = MAKE_EVENT(15, severity::LOW); + static const Event SUPV_ACK_INVALID_APID = MAKE_EVENT(23, severity::LOW); //! [EXPORT] : [COMMENT] Supervisor helper expected execution report but received space packet //! with other apid P1: Apid of received space packet P2: Internal state of supervisor helper - static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(16, severity::LOW); + static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(24, severity::LOW); //! [EXPORT] : [COMMENT] Failed to receive acknowledgment report //! P1: Return value //! P2: Apid of command for which the reception of the acknowledgment report failed - static const Event ACK_RECEPTION_FAILURE = MAKE_EVENT(17, severity::LOW); + static const Event ACK_RECEPTION_FAILURE = MAKE_EVENT(25, severity::LOW); //! [EXPORT] : [COMMENT] Failed to receive execution report //! P1: Return value //! P2: Apid of command for which the reception of the execution report failed - static const Event EXE_RECEPTION_FAILURE = MAKE_EVENT(18, severity::LOW); + static const Event EXE_RECEPTION_FAILURE = MAKE_EVENT(26, severity::LOW); //! [EXPORT] : [COMMENT] Update procedure failed when sending packet. //! P1: First byte percent, Third and Fourht bytes Sequence Count, P2: Bytes written - static const Event WRITE_MEMORY_FAILED = MAKE_EVENT(19, severity::LOW); - static const Event SUPV_REPLY_SIZE_MISSMATCH = MAKE_EVENT(20, severity::LOW); - static const Event SUPV_REPLY_CRC_MISSMATCH = MAKE_EVENT(21, severity::LOW); + static const Event WRITE_MEMORY_FAILED = MAKE_EVENT(27, severity::LOW); + static const Event SUPV_REPLY_SIZE_MISSMATCH = MAKE_EVENT(28, severity::LOW); + static const Event SUPV_REPLY_CRC_MISSMATCH = MAKE_EVENT(29, severity::LOW); //! [EXPORT] : [COMMENT] Will be triggered every 5 percent of the update progress. //! P1: First byte percent, Third and Fourht bytes Sequence Count, P2: Bytes written - static constexpr Event SUPV_UPDATE_PROGRESS = MAKE_EVENT(22, severity::INFO); - //! Status of memory check command - //! P1: Returncode, 0 for success, other value with returncode for failure - static constexpr Event SUPV_MEM_CHECK_OK = MAKE_EVENT(23, severity::INFO); - static constexpr Event SUPV_MEM_CHECK_FAIL = MAKE_EVENT(24, severity::INFO); + static constexpr Event SUPV_UPDATE_PROGRESS = MAKE_EVENT(30, severity::INFO); PlocSupvHelper(object_id_t objectId); virtual ~PlocSupvHelper(); diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index f9511036..d4f6f594 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 215 translations. + * @brief Auto-generated event translation file. Contains 216 translations. * @details - * Generated on: 2022-08-22 12:35:41 + * Generated on: 2022-08-22 22:17:50 */ #include "translateEvents.h" @@ -196,6 +196,8 @@ const char *TERMINATED_UPDATE_PROCEDURE_STRING = "TERMINATED_UPDATE_PROCEDURE"; const char *SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL_STRING = "SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL"; const char *SUPV_EVENT_BUFFER_REQUEST_FAILED_STRING = "SUPV_EVENT_BUFFER_REQUEST_FAILED"; const char *SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING = "SUPV_EVENT_BUFFER_REQUEST_TERMINATED"; +const char *SUPV_MEM_CHECK_OK_STRING = "SUPV_MEM_CHECK_OK"; +const char *SUPV_MEM_CHECK_FAIL_STRING = "SUPV_MEM_CHECK_FAIL"; const char *SUPV_SENDING_COMMAND_FAILED_STRING = "SUPV_SENDING_COMMAND_FAILED"; const char *SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING = "SUPV_HELPER_REQUESTING_REPLY_FAILED"; const char *SUPV_HELPER_READING_REPLY_FAILED_STRING = "SUPV_HELPER_READING_REPLY_FAILED"; @@ -211,7 +213,6 @@ const char *WRITE_MEMORY_FAILED_STRING = "WRITE_MEMORY_FAILED"; const char *SUPV_REPLY_SIZE_MISSMATCH_STRING = "SUPV_REPLY_SIZE_MISSMATCH"; const char *SUPV_REPLY_CRC_MISSMATCH_STRING = "SUPV_REPLY_CRC_MISSMATCH"; const char *SUPV_UPDATE_PROGRESS_STRING = "SUPV_UPDATE_PROGRESS"; -const char *SUPV_MEM_CHECK_STATUS_STRING = "SUPV_MEM_CHECK_STATUS"; const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; @@ -602,37 +603,39 @@ const char *translateEvents(Event event) { case (13607): return SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING; case (13608): - return SUPV_SENDING_COMMAND_FAILED_STRING; + return SUPV_MEM_CHECK_OK_STRING; case (13609): - return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING; - case (13610): - return SUPV_HELPER_READING_REPLY_FAILED_STRING; - case (13611): - return SUPV_MISSING_ACK_STRING; - case (13612): - return SUPV_MISSING_EXE_STRING; - case (13613): - return SUPV_ACK_FAILURE_REPORT_STRING; - case (13614): - return SUPV_EXE_FAILURE_REPORT_STRING; - case (13615): - return SUPV_ACK_INVALID_APID_STRING; + return SUPV_MEM_CHECK_FAIL_STRING; case (13616): - return SUPV_EXE_INVALID_APID_STRING; + return SUPV_SENDING_COMMAND_FAILED_STRING; case (13617): - return ACK_RECEPTION_FAILURE_STRING; + return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING; case (13618): - return EXE_RECEPTION_FAILURE_STRING; + return SUPV_HELPER_READING_REPLY_FAILED_STRING; case (13619): - return WRITE_MEMORY_FAILED_STRING; + return SUPV_MISSING_ACK_STRING; case (13620): - return SUPV_REPLY_SIZE_MISSMATCH_STRING; + return SUPV_MISSING_EXE_STRING; case (13621): - return SUPV_REPLY_CRC_MISSMATCH_STRING; + return SUPV_ACK_FAILURE_REPORT_STRING; case (13622): - return SUPV_UPDATE_PROGRESS_STRING; + return SUPV_EXE_FAILURE_REPORT_STRING; case (13623): - return SUPV_MEM_CHECK_STATUS_STRING; + return SUPV_ACK_INVALID_APID_STRING; + case (13624): + return SUPV_EXE_INVALID_APID_STRING; + case (13625): + return ACK_RECEPTION_FAILURE_STRING; + case (13626): + return EXE_RECEPTION_FAILURE_STRING; + case (13627): + return WRITE_MEMORY_FAILED_STRING; + case (13628): + return SUPV_REPLY_SIZE_MISSMATCH_STRING; + case (13629): + return SUPV_REPLY_CRC_MISSMATCH_STRING; + case (13630): + return SUPV_UPDATE_PROGRESS_STRING; case (13700): return ALLOC_FAILURE_STRING; case (13701): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index de55983c..b9535da0 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 133 translations. - * Generated on: 2022-08-22 12:35:41 + * Generated on: 2022-08-22 22:17:50 */ #include "translateObjects.h" diff --git a/tmtc b/tmtc index 7dfe92be..61375956 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 7dfe92be8c85260e5abd1d52f9b201d26dbf6dc3 +Subproject commit 613759562ed855f692936bad5b25e8e2570dca52 From d7bc35ea458f272de1da17c5319fd5dffd8d7797 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 22:25:22 +0200 Subject: [PATCH 4/7] crc check fails on mem 0 --- linux/devices/ploc/PlocSupervisorHandler.cpp | 6 +++--- linux/devices/ploc/PlocSupvHelper.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index b2759e53..b90fa721 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -2066,9 +2066,9 @@ ReturnValue_t PlocSupervisorHandler::eventSubscription() { if (result != RETURN_OK) { return result; } - result = manager->subscribeToEventRange( - eventQueue->getId(), event::getEventId(PlocSupvHelper::SUPV_UPDATE_FAILED), - event::getEventId(PlocSupvHelper::SUPV_MEM_CHECK_FAIL)); + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(PlocSupvHelper::SUPV_UPDATE_FAILED), + event::getEventId(PlocSupvHelper::SUPV_MEM_CHECK_FAIL)); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "PlocSupervisorHandler::eventSubscritpion: Failed to subscribe to events from " diff --git a/linux/devices/ploc/PlocSupvHelper.cpp b/linux/devices/ploc/PlocSupvHelper.cpp index 42464dc7..6c195865 100644 --- a/linux/devices/ploc/PlocSupvHelper.cpp +++ b/linux/devices/ploc/PlocSupvHelper.cpp @@ -194,26 +194,26 @@ void PlocSupvHelper::stopProcess() { terminate = true; } void PlocSupvHelper::executeFullCheckMemoryCommand() { ReturnValue_t result; if (update.crcShouldBeChecked) { - sif::info << "PlocSupvHelper::performUpdate: Calculating Image CRC" << std::endl; + sif::info << "PLOC SUPV Mem Check: Calculating Image CRC" << std::endl; result = calcImageCrc(); if (result != RETURN_OK) { triggerEvent(SUPV_MEM_CHECK_FAIL, result); return; } } - sif::info << "PlocSupvHelper::executeFullCheckMemoryCommand: Selecting Memory" << std::endl; + sif::info << "PLOC SUPV Mem Check: Selecting Memory" << std::endl; result = selectMemory(); if (result != RETURN_OK) { triggerEvent(SUPV_MEM_CHECK_FAIL, result); return; } - sif::info << "PlocSupvHelper::executeFullCheckMemoryCommand: Preparing Update" << std::endl; + sif::info << "PLOC SUPV Mem Check: Preparing Update" << std::endl; result = prepareUpdate(); if (result != RETURN_OK) { triggerEvent(SUPV_MEM_CHECK_FAIL, result); return; } - sif::info << "PlocSupvHelper::executeFullCheckMemoryCommand: Memory Check" << std::endl; + sif::info << "PLOC SUPV Mem Check: Memory Check" << std::endl; result = handleCheckMemoryCommand(); if (result == HasReturnvaluesIF::RETURN_OK) { triggerEvent(SUPV_MEM_CHECK_OK, result); @@ -224,22 +224,22 @@ void PlocSupvHelper::executeFullCheckMemoryCommand() { ReturnValue_t PlocSupvHelper::performUpdate() { ReturnValue_t result = RETURN_OK; - sif::info << "PlocSupvHelper::performUpdate: Calculating Image CRC" << std::endl; + sif::info << "PLOC SUPV Update MPSoC: Calculating Image CRC" << std::endl; result = calcImageCrc(); if (result != RETURN_OK) { return result; } - sif::info << "PlocSupvHelper::performUpdate: Selecting Memory" << std::endl; + sif::info << "PLOC SUPV Update MPSoC: Selecting Memory" << std::endl; result = selectMemory(); if (result != RETURN_OK) { return result; } - sif::info << "PlocSupvHelper::performUpdate: Preparing Update" << std::endl; + sif::info << "PLOC SUPV Update MPSoC: Preparing Update" << std::endl; result = prepareUpdate(); if (result != RETURN_OK) { return result; } - sif::info << "PlocSupvHelper::performUpdate: Erasing Memory" << std::endl; + sif::info << "PLOC SUPV Update MPSoC: Erasing Memory" << std::endl; result = eraseMemory(); if (result != RETURN_OK) { return result; From 1aeebcc0ee2dd049de8adc22f66a8253c8d64ff4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 Aug 2022 18:26:14 +0200 Subject: [PATCH 5/7] important bugfix for update conitnuation --- linux/devices/ploc/PlocSupvHelper.cpp | 37 +++++++++++++++++---------- linux/devices/ploc/PlocSupvHelper.h | 2 ++ tmtc | 2 +- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/linux/devices/ploc/PlocSupvHelper.cpp b/linux/devices/ploc/PlocSupvHelper.cpp index 6c195865..836e7fc0 100644 --- a/linux/devices/ploc/PlocSupvHelper.cpp +++ b/linux/devices/ploc/PlocSupvHelper.cpp @@ -135,7 +135,13 @@ ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId, } #endif update.file = file; - update.length = getFileSize(update.file); + update.fullFileSize = getFileSize(update.file); + if (startBytesWritten > update.fullFileSize) { + sif::warning << "Invalid start bytes counter " << startBytesWritten + << ", smaller than full file length" << update.fullFileSize << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + update.length = update.fullFileSize - startBytesWritten; update.memoryId = memoryId; update.startAddress = startAddress; update.progressPercent = 0; @@ -152,6 +158,7 @@ ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId, ReturnValue_t PlocSupvHelper::performMemCheck(std::string file, uint8_t memoryId, uint32_t startAddress) { update.file = file; + update.fullFileSize = getFileSize(file); return performMemCheck(memoryId, startAddress, getFileSize(update.file), true); } @@ -268,20 +275,20 @@ ReturnValue_t PlocSupvHelper::updateOperation() { ReturnValue_t PlocSupvHelper::writeUpdatePackets() { ReturnValue_t result = RETURN_OK; #if OBSW_DEBUG_PLOC_SUPERVISOR == 1 - ProgressPrinter progressPrinter("Supervisor update", update.length, + ProgressPrinter progressPrinter("Supervisor update", update.fullFileSize, ProgressPrinter::HALF_PERCENT); #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{}; std::ifstream file(update.file, std::ifstream::binary); uint16_t dataLength = 0; ccsds::SequenceFlags seqFlags; - while (update.bytesWritten < update.length) { + while (update.bytesWritten < update.fullFileSize) { if (terminate) { terminate = false; triggerEvent(TERMINATED_UPDATE_PROCEDURE); return PROCESS_TERMINATED; } - size_t remainingSize = update.length - update.bytesWritten; + size_t remainingSize = update.fullFileSize - update.bytesWritten; bool lastSegment = false; if (remainingSize > supv::WriteMemory::CHUNK_MAX) { dataLength = supv::WriteMemory::CHUNK_MAX; @@ -309,7 +316,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() { seqFlags = ccsds::SequenceFlags::CONTINUATION; } resetSpParams(); - float progress = static_cast(update.bytesWritten) / update.length; + float progress = static_cast(update.bytesWritten) / update.fullFileSize; uint8_t progPercent = std::floor(progress * 100); if (progPercent > update.progressPercent) { update.progressPercent = progPercent; @@ -410,7 +417,8 @@ ReturnValue_t PlocSupvHelper::eraseMemory() { ReturnValue_t result = RETURN_OK; resetSpParams(); supv::EraseMemory eraseMemory(spParams); - result = eraseMemory.buildPacket(update.memoryId, update.startAddress, update.length); + result = eraseMemory.buildPacket(update.memoryId, update.startAddress + update.bytesWritten, + update.length); if (result != RETURN_OK) { return result; } @@ -579,7 +587,7 @@ ReturnValue_t PlocSupvHelper::receive(uint8_t* data, size_t* readBytes, size_t r ReturnValue_t PlocSupvHelper::calcImageCrc() { ReturnValue_t result = RETURN_OK; - if (update.length == 0) { + if (update.fullFileSize == 0) { return HasReturnvaluesIF::RETURN_FAILED; } #ifdef XIPHOS_Q7S @@ -593,17 +601,19 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() { auto crc16Calcer = etl::crc16_ccitt(); std::ifstream file(update.file, std::ifstream::binary); - std::array crcBuf; + std::array crcBuf{}; #if OBSW_DEBUG_PLOC_SUPERVISOR == 1 - ProgressPrinter progress("Supervisor update crc calculation", update.length, + ProgressPrinter progress("Supervisor update crc calculation", update.fullFileSize, ProgressPrinter::ONE_PERCENT); #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ uint32_t byteCount = 0; - while (byteCount < update.length) { - size_t bytesToRead = 1024; - size_t remLen = update.length - byteCount; + size_t bytesToRead = 1024; + while (byteCount < update.fullFileSize) { + size_t remLen = update.fullFileSize - byteCount; if (remLen < 1024) { bytesToRead = remLen; + } else { + bytesToRead = 1024; } file.seekg(byteCount, file.beg); file.read(reinterpret_cast(crcBuf.data()), bytesToRead); @@ -617,7 +627,6 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() { #if OBSW_DEBUG_PLOC_SUPERVISOR == 1 progress.print(byteCount); #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ - file.close(); update.crc = crc16Calcer.value(); return result; } @@ -630,7 +639,7 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() { supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size()); // Verification of update write procedure supv::CheckMemory packet(spParams); - result = packet.buildPacket(update.memoryId, update.startAddress, update.length); + result = packet.buildPacket(update.memoryId, update.startAddress, update.fullFileSize); if (result != RETURN_OK) { return result; } diff --git a/linux/devices/ploc/PlocSupvHelper.h b/linux/devices/ploc/PlocSupvHelper.h index abd43187..3fc60145 100644 --- a/linux/devices/ploc/PlocSupvHelper.h +++ b/linux/devices/ploc/PlocSupvHelper.h @@ -167,6 +167,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha uint32_t startAddress; // Absolute name of file containing update data std::string file; + // Length of full file + size_t fullFileSize; // Size of update uint32_t length; uint32_t crc; diff --git a/tmtc b/tmtc index 61375956..aec55035 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 613759562ed855f692936bad5b25e8e2570dca52 +Subproject commit aec55035d7602226a2e61845565c94b5ed8f561c From e561805f3aa45e73360725631eb5507f94b4c574 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 12:02:16 +0200 Subject: [PATCH 6/7] update ploc supv helper --- .../PlocSupervisorDefinitions.h | 28 +++- linux/devices/ploc/PlocSupervisorHandler.cpp | 15 +- linux/devices/ploc/PlocSupervisorHandler.h | 13 +- linux/devices/ploc/PlocSupvHelper.cpp | 131 +++++++++++------- linux/devices/ploc/PlocSupvHelper.h | 9 +- tmtc | 2 +- 6 files changed, 126 insertions(+), 72 deletions(-) diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index d36e4c0c..bfe23488 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -160,6 +160,15 @@ static const size_t MAX_PACKET_SIZE = 1024; static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6; +struct UpdateParams { + std::string file; + uint8_t memId; + uint32_t startAddr; + uint32_t bytesWritten; + uint16_t seqCount; + bool deleteMemory; +}; + enum PoolIds : lp_id_t { NUM_TMS, TEMP_PS, @@ -1247,11 +1256,14 @@ class DisableAutoTm : public ploc::SpTcBase { */ class RequestLoggingData : public ploc::SpTcBase { public: + /** + * Subapid + */ enum class Sa : uint8_t { - REQUEST_COUNTERS = 1, - REQUEST_EVENT_BUFFERS = 2, - CLEAR_COUNTERS = 3, - SET_LOGGING_TOPIC = 4 + REQUEST_COUNTERS = 1, /**< REQUEST_COUNTERS */ + REQUEST_EVENT_BUFFERS = 2, /**< REQUEST_EVENT_BUFFERS */ + CLEAR_COUNTERS = 3, /**< CLEAR_COUNTERS */ + SET_LOGGING_TOPIC = 4 /**< SET_LOGGING_TOPIC */ }; RequestLoggingData(ploc::SpTcParams params) : ploc::SpTcBase(params) { @@ -1260,6 +1272,11 @@ class RequestLoggingData : public ploc::SpTcBase { spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); } + /** + * @param sa + * @param tpc Topic + * @return + */ ReturnValue_t buildPacket(Sa sa, uint8_t tpc = 0) { auto res = checkSizeAndSerializeHeader(); if (res != result::OK) { @@ -1659,7 +1676,8 @@ class ExecutionReport : public VerificationReport { } default: sif::warning << "ExecutionReport::printStatusInformation: Invalid status code: 0x" - << std::hex << static_cast(statusCode) << std::endl; + << std::hex << std::setfill('0') << std::setw(4) + << static_cast(statusCode) << std::dec << std::endl; break; } } diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index b90fa721..a5d3f3e2 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -121,8 +121,7 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId, if (result != RETURN_OK) { return result; } - result = supvHelper->performUpdate(params.file, params.memId, params.startAddr, - params.bytesWritten, params.seqCount); + result = supvHelper->performUpdate(params); if (result != RETURN_OK) { return result; } @@ -1992,7 +1991,7 @@ ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp) } ReturnValue_t PlocSupervisorHandler::extractUpdateCommand(const uint8_t* commandData, size_t size, - UpdateParams& params) { + supv::UpdateParams& params) { size_t remSize = size; if (size > (config::MAX_FILENAME_SIZE + config::MAX_PATH_SIZE + sizeof(params.memId)) + sizeof(params.startAddr) + sizeof(params.bytesWritten) + sizeof(params.seqCount)) { @@ -2017,11 +2016,19 @@ ReturnValue_t PlocSupervisorHandler::extractUpdateCommand(const uint8_t* command << std::endl; return result; } + result = SerializeAdapter::deSerialize(¶ms.deleteMemory, &commandData, &remSize, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::warning + << "PlocSupervisorHandler::extractUpdateCommand: Failed to deserialize whether to delete " + "memory" << std::endl; + return result; + } return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::extractBaseParams(const uint8_t** commandData, size_t& remSize, - UpdateParams& params) { + supv::UpdateParams& params) { bool nullTermFound = false; for (size_t idx = 0; idx < remSize; idx++) { if ((*commandData)[idx] == '\0') { diff --git a/linux/devices/ploc/PlocSupervisorHandler.h b/linux/devices/ploc/PlocSupervisorHandler.h index e410340f..bd4b0b9c 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.h +++ b/linux/devices/ploc/PlocSupervisorHandler.h @@ -367,17 +367,10 @@ class PlocSupervisorHandler : public DeviceHandlerBase { ReturnValue_t prepareSetShutdownTimeoutCmd(const uint8_t* commandData); - struct UpdateParams { - std::string file; - uint8_t memId; - uint32_t startAddr; - uint32_t bytesWritten; - uint16_t seqCount; - }; - - ReturnValue_t extractUpdateCommand(const uint8_t* commandData, size_t size, UpdateParams& params); + ReturnValue_t extractUpdateCommand(const uint8_t* commandData, size_t size, + supv::UpdateParams& params); ReturnValue_t extractBaseParams(const uint8_t** commandData, size_t& remSize, - UpdateParams& params); + supv::UpdateParams& params); ReturnValue_t eventSubscription(); ReturnValue_t handleExecutionSuccessReport(const uint8_t* data); diff --git a/linux/devices/ploc/PlocSupvHelper.cpp b/linux/devices/ploc/PlocSupvHelper.cpp index 836e7fc0..a33765b5 100644 --- a/linux/devices/ploc/PlocSupvHelper.cpp +++ b/linux/devices/ploc/PlocSupvHelper.cpp @@ -46,7 +46,7 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) { break; } case InternalState::UPDATE: { - result = performUpdate(); + result = executeUpdate(); if (result == RETURN_OK) { triggerEvent(SUPV_UPDATE_SUCCESSFUL, result); } else if (result == PROCESS_TERMINATED) { @@ -107,22 +107,28 @@ void PlocSupvHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_ ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId, uint32_t startAddress) { - return performUpdate(file, memoryId, startAddress, 0, 1); + supv::UpdateParams params; + params.file = file; + params.memId = memoryId; + params.startAddr = startAddress; + params.bytesWritten = 0; + params.seqCount = 1; + params.deleteMemory = true; + return performUpdate(params); } -ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId, - uint32_t startAddress, size_t startBytesWritten, - uint16_t initSeqCount) { +ReturnValue_t PlocSupvHelper::performUpdate(const supv::UpdateParams& params) { ReturnValue_t result = RETURN_OK; #ifdef XIPHOS_Q7S - result = FilesystemHelper::checkPath(file); + result = FilesystemHelper::checkPath(params.file); if (result != RETURN_OK) { - sif::warning << "PlocSupvHelper::startUpdate: File " << file << " does not exist" << std::endl; + sif::warning << "PlocSupvHelper::startUpdate: File " << params.file << " does not exist" + << std::endl; return result; } - result = FilesystemHelper::fileExists(file); + result = FilesystemHelper::fileExists(params.file); if (result != RETURN_OK) { - sif::warning << "PlocSupvHelper::startUpdate: The file " << file << " does not exist" + sif::warning << "PlocSupvHelper::startUpdate: The file " << params.file << " does not exist" << std::endl; return result; } @@ -134,21 +140,22 @@ ReturnValue_t PlocSupvHelper::performUpdate(std::string file, uint8_t memoryId, return RETURN_FAILED; } #endif - update.file = file; + update.file = params.file; update.fullFileSize = getFileSize(update.file); - if (startBytesWritten > update.fullFileSize) { - sif::warning << "Invalid start bytes counter " << startBytesWritten + if (params.bytesWritten > update.fullFileSize) { + sif::warning << "Invalid start bytes counter " << params.bytesWritten << ", smaller than full file length" << update.fullFileSize << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } - update.length = update.fullFileSize - startBytesWritten; - update.memoryId = memoryId; - update.startAddress = startAddress; + update.length = update.fullFileSize - params.bytesWritten; + update.memoryId = params.memId; + update.startAddress = params.startAddr; update.progressPercent = 0; - update.bytesWritten = startBytesWritten; + update.bytesWritten = params.bytesWritten; update.crcShouldBeChecked = true; update.packetNum = 1; - update.sequenceCount = initSeqCount; + update.deleteMemory = params.deleteMemory; + update.sequenceCount = params.seqCount; internalState = InternalState::UPDATE; uartComIF->flushUartTxAndRxBuf(comCookie); semaphore.release(); @@ -229,7 +236,7 @@ void PlocSupvHelper::executeFullCheckMemoryCommand() { } } -ReturnValue_t PlocSupvHelper::performUpdate() { +ReturnValue_t PlocSupvHelper::executeUpdate() { ReturnValue_t result = RETURN_OK; sif::info << "PLOC SUPV Update MPSoC: Calculating Image CRC" << std::endl; result = calcImageCrc(); @@ -246,10 +253,12 @@ ReturnValue_t PlocSupvHelper::performUpdate() { if (result != RETURN_OK) { return result; } - sif::info << "PLOC SUPV Update MPSoC: Erasing Memory" << std::endl; - result = eraseMemory(); - if (result != RETURN_OK) { - return result; + if(update.deleteMemory) { + sif::info << "PLOC SUPV Update MPSoC: Erasing Memory" << std::endl; + result = eraseMemory(); + if (result != RETURN_OK) { + return result; + } } return updateOperation(); } @@ -372,13 +381,38 @@ ReturnValue_t PlocSupvHelper::performEventBufferRequest() { if (result != RETURN_OK) { return result; } - result = handleEventBufferReception(); + result = + handleTmReception(ccsds::HEADER_LEN, tmBuf.data(), supv::recv_timeout::UPDATE_STATUS_REPORT); if (result != RETURN_OK) { return result; } - result = handleExe(); - if (result != RETURN_OK) { - return result; + ploc::SpTmReader spReader(tmBuf.data(), tmBuf.size()); + bool exeAlreadyReceived = false; + if (spReader.getApid() == supv::APID_EXE_FAILURE) { + exeAlreadyReceived = true; + result = handleRemainingExeReport(spReader); + } else if (spReader.getApid() == supv::APID_MRAM_DUMP_TM) { + result = handleEventBufferReception(spReader); + } + + if (not exeAlreadyReceived) { + result = handleExe(); + if (result != RETURN_OK) { + return result; + } + } + return result; +} + +ReturnValue_t PlocSupvHelper::handleRemainingExeReport(ploc::SpTmReader& reader) { + size_t remBytes = reader.getPacketDataLen() + 1; + ReturnValue_t result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading exe failure report failed" << std::endl; + } + result = exeReportHandling(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Handling exe report failed" << std::endl; } return result; } @@ -652,22 +686,17 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() { return result; } - result = - handleTmReception(ccsds::HEADER_LEN, tmBuf.data(), supv::recv_timeout::UPDATE_STATUS_REPORT); - SpacePacketReader spReader(tmBuf.data(), tmBuf.size()); + bool exeAlreadyHandled = false; + uint32_t timeout = std::max(CRC_EXECUTION_TIMEOUT, supv::recv_timeout::UPDATE_STATUS_REPORT); + result = handleTmReception(ccsds::HEADER_LEN, tmBuf.data(), timeout); + ploc::SpTmReader spReader(tmBuf.data(), tmBuf.size()); if (spReader.getApid() == supv::APID_EXE_FAILURE) { - size_t remBytes = spReader.getPacketDataLen() + 1; - result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading exe failure report failed" << std::endl; - } - result = exeReportHandling(); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Handling exe report failed" << std::endl; - } + exeAlreadyHandled = true; + result = handleRemainingExeReport(spReader); } else if (spReader.getApid() == supv::APID_UPDATE_STATUS_REPORT) { size_t remBytes = spReader.getPacketDataLen() + 1; - result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN); + result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN, + supv::recv_timeout::UPDATE_STATUS_REPORT); if (result != RETURN_OK) { sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report" @@ -683,9 +712,11 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() { std::memcpy(statusReportBuf.data(), tmBuf.data(), updateStatusReport.getNominalSize()); } - result = handleExe(CRC_EXECUTION_TIMEOUT); - if (result != RETURN_OK) { - return result; + if (not exeAlreadyHandled) { + result = handleExe(CRC_EXECUTION_TIMEOUT); + if (result != RETURN_OK) { + return result; + } } // Now process the status report @@ -715,14 +746,14 @@ uint32_t PlocSupvHelper::getFileSize(std::string filename) { return size; } -ReturnValue_t PlocSupvHelper::handleEventBufferReception() { +ReturnValue_t PlocSupvHelper::handleEventBufferReception(ploc::SpTmReader& reader) { ReturnValue_t result = RETURN_OK; std::string filename = Filenaming::generateAbsoluteFilename( eventBufferReq.path, eventBufferReq.filename, timestamping); std::ofstream file(filename, std::ios_base::app | std::ios_base::out); uint32_t packetsRead = 0; size_t requestLen = 0; - ploc::SpTmReader tmReader(tmBuf.data(), tmBuf.size()); + bool firstPacket = true; for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS; packetsRead++) { if (terminate) { triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1); @@ -734,6 +765,10 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() { } else { requestLen = SIZE_EVENT_BUFFER_FULL_PACKET; } + if (firstPacket) { + firstPacket = false; + requestLen -= 6; + } result = handleTmReception(requestLen); if (result != RETURN_OK) { sif::debug << "PlocSupvHelper::handleEventBufferReception: Failed while trying to read packet" @@ -741,20 +776,20 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() { file.close(); return result; } - ReturnValue_t result = tmReader.checkCrc(); + ReturnValue_t result = reader.checkCrc(); if (result != RETURN_OK) { triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid); return result; } - uint16_t apid = tmReader.getApid(); + uint16_t apid = reader.getApid(); if (apid != supv::APID_MRAM_DUMP_TM) { sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet " << "with APID 0x" << std::hex << apid << std::endl; file.close(); return EVENT_BUFFER_REPLY_INVALID_APID; } - file.write(reinterpret_cast(tmReader.getPacketData()), - tmReader.getPayloadDataLength()); + file.write(reinterpret_cast(reader.getPacketData()), + reader.getPayloadDataLength()); } return result; } diff --git a/linux/devices/ploc/PlocSupvHelper.h b/linux/devices/ploc/PlocSupvHelper.h index 3fc60145..c79af01f 100644 --- a/linux/devices/ploc/PlocSupvHelper.h +++ b/linux/devices/ploc/PlocSupvHelper.h @@ -116,8 +116,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha * * @return RETURN_OK if successful, otherwise error return value */ - ReturnValue_t performUpdate(std::string file, uint8_t memoryId, uint32_t startAddress, - size_t startBytesWritten, uint16_t initSeqCount); + ReturnValue_t performUpdate(const supv::UpdateParams& params); ReturnValue_t startUpdate(std::string file, uint8_t memoryId, uint32_t startAddress); ReturnValue_t performMemCheck(uint8_t memoryId, uint32_t startAddress, size_t sizeToCheck, @@ -177,6 +176,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha uint32_t packetNum; uint16_t sequenceCount; uint8_t progressPercent; + bool deleteMemory = false; }; struct Update update; @@ -220,7 +220,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha void executeFullCheckMemoryCommand(); - ReturnValue_t performUpdate(); + ReturnValue_t executeUpdate(); ReturnValue_t continueUpdate(); ReturnValue_t updateOperation(); ReturnValue_t writeUpdatePackets(); @@ -268,7 +268,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha * @return The size of the file */ uint32_t getFileSize(std::string filename); - ReturnValue_t handleEventBufferReception(); + ReturnValue_t handleEventBufferReception(ploc::SpTmReader& reader); + ReturnValue_t handleRemainingExeReport(ploc::SpTmReader& reader); void resetSpParams(); }; diff --git a/tmtc b/tmtc index aec55035..ac782157 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit aec55035d7602226a2e61845565c94b5ed8f561c +Subproject commit ac7821575c16b2c08740722f8d9ae0b456c60ece From ef92673e4ed69635d87dda45c65fff7c929de02e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 12:07:55 +0200 Subject: [PATCH 7/7] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index ac782157..7885b29d 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ac7821575c16b2c08740722f8d9ae0b456c60ece +Subproject commit 7885b29d22f23f0e4432126dd6c1d22b592428cc