Tweaks for MPSoC startup and shutdown code #796

Merged
meggert merged 12 commits from mpsoc-tweaks into main 2023-09-27 11:32:31 +02:00
14 changed files with 179 additions and 85 deletions

View File

@ -16,6 +16,16 @@ will consitute of a breaking change warranting a new major release:
# [unreleased] # [unreleased]
## Changed
- Changed internals for MPSoC boot process to make the code more understandable and some
parameters better configurable. This should not affect the behaviour of the OBSW, but might
make it more reliable and fix some corner cases.
## Fixed
- Missing `nullptr` checks for PLOC Supervisor handler, which could lead to crashes.
# [v6.6.0] 2023-09-18 # [v6.6.0] 2023-09-18
## Changed ## Changed

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 306 translations. * @brief Auto-generated event translation file. Contains 308 translations.
* @details * @details
* Generated on: 2023-09-12 10:05:17 * Generated on: 2023-09-25 17:49:54
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -128,6 +128,8 @@ const char *EXE_FAILURE_STRING = "EXE_FAILURE";
const char *MPSOC_HANDLER_CRC_FAILURE_STRING = "MPSOC_HANDLER_CRC_FAILURE"; const char *MPSOC_HANDLER_CRC_FAILURE_STRING = "MPSOC_HANDLER_CRC_FAILURE";
const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH"; const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH";
const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED";
const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT";
const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE";
const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE";
const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE";
@ -560,6 +562,10 @@ const char *translateEvents(Event event) {
return MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING; return MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING;
case (11606): case (11606):
return MPSOC_SHUTDOWN_FAILED_STRING; return MPSOC_SHUTDOWN_FAILED_STRING;
case (11607):
return SUPV_NOT_ON_STRING;
case (11608):
return SUPV_REPLY_TIMEOUT_STRING;
case (11701): case (11701):
return SELF_TEST_I2C_FAILURE_STRING; return SELF_TEST_I2C_FAILURE_STRING;
case (11702): case (11702):

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 171 translations. * Contains 171 translations.
* Generated on: 2023-09-12 10:05:17 * Generated on: 2023-09-25 17:49:54
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -122,6 +122,8 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
11604;0x2d54;MPSOC_HANDLER_CRC_FAILURE;LOW;PLOC reply has invalid crc;linux/payload/PlocMpsocHandler.h 11604;0x2d54;MPSOC_HANDLER_CRC_FAILURE;LOW;PLOC reply has invalid crc;linux/payload/PlocMpsocHandler.h
11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHandler.h 11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHandler.h
11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/PlocMpsocHandler.h 11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/PlocMpsocHandler.h
11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/PlocMpsocHandler.h
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;linux/payload/PlocMpsocHandler.h
11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h

1 Event ID (dec) Event ID (hex) Name Severity Description File Path
122 11604 0x2d54 MPSOC_HANDLER_CRC_FAILURE LOW PLOC reply has invalid crc linux/payload/PlocMpsocHandler.h
123 11605 0x2d55 MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH LOW Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count linux/payload/PlocMpsocHandler.h
124 11606 0x2d56 MPSOC_SHUTDOWN_FAILED HIGH Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor. linux/payload/PlocMpsocHandler.h
125 11607 0x2d57 SUPV_NOT_ON LOW SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition. linux/payload/PlocMpsocHandler.h
126 11608 0x2d58 SUPV_REPLY_TIMEOUT LOW No description linux/payload/PlocMpsocHandler.h
127 11701 0x2db5 SELF_TEST_I2C_FAILURE LOW Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
128 11702 0x2db6 SELF_TEST_SPI_FAILURE LOW Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
129 11703 0x2db7 SELF_TEST_ADC_FAILURE LOW Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h

View File

@ -122,6 +122,8 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
11604;0x2d54;MPSOC_HANDLER_CRC_FAILURE;LOW;PLOC reply has invalid crc;linux/payload/PlocMpsocHandler.h 11604;0x2d54;MPSOC_HANDLER_CRC_FAILURE;LOW;PLOC reply has invalid crc;linux/payload/PlocMpsocHandler.h
11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHandler.h 11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHandler.h
11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/PlocMpsocHandler.h 11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/PlocMpsocHandler.h
11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/PlocMpsocHandler.h
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;linux/payload/PlocMpsocHandler.h
11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h

1 Event ID (dec) Event ID (hex) Name Severity Description File Path
122 11604 0x2d54 MPSOC_HANDLER_CRC_FAILURE LOW PLOC reply has invalid crc linux/payload/PlocMpsocHandler.h
123 11605 0x2d55 MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH LOW Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count linux/payload/PlocMpsocHandler.h
124 11606 0x2d56 MPSOC_SHUTDOWN_FAILED HIGH Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor. linux/payload/PlocMpsocHandler.h
125 11607 0x2d57 SUPV_NOT_ON LOW SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition. linux/payload/PlocMpsocHandler.h
126 11608 0x2d58 SUPV_REPLY_TIMEOUT LOW No description linux/payload/PlocMpsocHandler.h
127 11701 0x2db5 SELF_TEST_I2C_FAILURE LOW Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
128 11702 0x2db6 SELF_TEST_SPI_FAILURE LOW Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
129 11703 0x2db7 SELF_TEST_ADC_FAILURE LOW Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 306 translations. * @brief Auto-generated event translation file. Contains 308 translations.
* @details * @details
* Generated on: 2023-09-12 10:05:17 * Generated on: 2023-09-25 17:49:54
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -128,6 +128,8 @@ const char *EXE_FAILURE_STRING = "EXE_FAILURE";
const char *MPSOC_HANDLER_CRC_FAILURE_STRING = "MPSOC_HANDLER_CRC_FAILURE"; const char *MPSOC_HANDLER_CRC_FAILURE_STRING = "MPSOC_HANDLER_CRC_FAILURE";
const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH"; const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH";
const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED";
const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT";
const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE";
const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE";
const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE";
@ -560,6 +562,10 @@ const char *translateEvents(Event event) {
return MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING; return MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING;
case (11606): case (11606):
return MPSOC_SHUTDOWN_FAILED_STRING; return MPSOC_SHUTDOWN_FAILED_STRING;
case (11607):
return SUPV_NOT_ON_STRING;
case (11608):
return SUPV_REPLY_TIMEOUT_STRING;
case (11701): case (11701):
return SELF_TEST_I2C_FAILURE_STRING; return SELF_TEST_I2C_FAILURE_STRING;
case (11702): case (11702):

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 175 translations. * Contains 175 translations.
* Generated on: 2023-09-12 10:05:17 * Generated on: 2023-09-25 17:49:54
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 306 translations. * @brief Auto-generated event translation file. Contains 308 translations.
* @details * @details
* Generated on: 2023-09-12 10:05:17 * Generated on: 2023-09-25 17:49:54
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -128,6 +128,8 @@ const char *EXE_FAILURE_STRING = "EXE_FAILURE";
const char *MPSOC_HANDLER_CRC_FAILURE_STRING = "MPSOC_HANDLER_CRC_FAILURE"; const char *MPSOC_HANDLER_CRC_FAILURE_STRING = "MPSOC_HANDLER_CRC_FAILURE";
const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH"; const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH";
const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED";
const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT";
const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE";
const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE";
const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE";
@ -560,6 +562,10 @@ const char *translateEvents(Event event) {
return MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING; return MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING;
case (11606): case (11606):
return MPSOC_SHUTDOWN_FAILED_STRING; return MPSOC_SHUTDOWN_FAILED_STRING;
case (11607):
return SUPV_NOT_ON_STRING;
case (11608):
return SUPV_REPLY_TIMEOUT_STRING;
case (11701): case (11701):
return SELF_TEST_I2C_FAILURE_STRING; return SELF_TEST_I2C_FAILURE_STRING;
case (11702): case (11702):

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 175 translations. * Contains 175 translations.
* Generated on: 2023-09-12 10:05:17 * Generated on: 2023-09-25 17:49:54
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -188,73 +188,28 @@ void PlocMpsocHandler::doStartUp() {
startupState = StartupState::HW_INIT; startupState = StartupState::HW_INIT;
} }
if (startupState == StartupState::HW_INIT) { if (startupState == StartupState::HW_INIT) {
#ifdef XIPHOS_Q7S if (handleHwStartup()) {
#if not OBSW_MPSOC_JTAG_BOOT == 1
switch (powerState) {
case PowerState::OFF:
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
powerState = PowerState::BOOTING;
return;
case PowerState::ON:
uartIsolatorSwitch.pullHigh();
startupState = StartupState::WAIT_CYCLES;
break;
default:
return;
}
#else
uartIsolatorSwitch.pullHigh();
startupState = StartupState::WAIT_CYCLES;
#endif /* not MSPOC_JTAG_BOOT == 1 */
#else
startupState = StartupState::WAIT_CYCLES;
powerState = PowerState::ON;
#endif /* XIPHOS_Q7S */
}
// Need to wait, MPSoC still not booted properly, requesting HK without these wait cycles does
// not work, no replies..
if (startupState == StartupState::WAIT_CYCLES) {
waitCycles++;
if (waitCycles >= 8) {
startupState = StartupState::DONE; startupState = StartupState::DONE;
waitCycles = 0;
} }
} }
if (startupState == StartupState::DONE) { if (startupState == StartupState::DONE) {
setMode(_MODE_TO_ON); setMode(_MODE_TO_ON);
hkReport.setReportingEnabled(true); hkReport.setReportingEnabled(true);
powerState = PowerState::IDLE;
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
} }
} }
void PlocMpsocHandler::doShutDown() { void PlocMpsocHandler::doShutDown() {
#ifdef XIPHOS_Q7S if (handleHwShutdown()) {
#if not OBSW_MPSOC_JTAG_BOOT == 1
if (powerState == PowerState::ON) {
uartIsolatorSwitch.pullLow();
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
powerState = PowerState::SHUTDOWN;
return;
} else if (powerState == PowerState::SHUTDOWN) {
// Wait till power state is OFF.
return;
}
#else
uartIsolatorSwitch.pullLow();
powerState = PowerState::OFF;
#endif
#endif
if (specialComHelper != nullptr) {
specialComHelper->stopProcess();
}
hkReport.setReportingEnabled(false); hkReport.setReportingEnabled(false);
setMode(_MODE_POWER_DOWN); setMode(_MODE_POWER_DOWN);
commandIsPending = false; commandIsPending = false;
sequenceCount = 0; sequenceCount = 0;
specialComHelperExecuting = false; powerState = PowerState::IDLE;
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
} }
}
ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
if (not commandIsPending and not specialComHelperExecuting) { if (not commandIsPending and not specialComHelperExecuting) {
@ -1247,15 +1202,11 @@ void PlocMpsocHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
switch (actionId) { switch (actionId) {
case supv::START_MPSOC: { case supv::START_MPSOC: {
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" << std::endl; sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" << std::endl;
// This usually happens when the supervisor handler is in off mode
powerState = PowerState::OFF;
setMode(MODE_OFF);
break; break;
} }
case supv::SHUTDOWN_MPSOC: { case supv::SHUTDOWN_MPSOC: {
triggerEvent(MPSOC_SHUTDOWN_FAILED); triggerEvent(MPSOC_SHUTDOWN_FAILED);
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" << std::endl; sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" << std::endl;
powerState = PowerState::OFF;
break; break;
} }
default: default:
@ -1263,6 +1214,7 @@ void PlocMpsocHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
<< std::endl; << std::endl;
break; break;
} }
powerState = PowerState::SUPV_FAILED;
} }
void PlocMpsocHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { void PlocMpsocHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
@ -1270,18 +1222,24 @@ void PlocMpsocHandler::dataReceived(ActionId_t actionId, const uint8_t* data, ui
} }
void PlocMpsocHandler::completionSuccessfulReceived(ActionId_t actionId) { void PlocMpsocHandler::completionSuccessfulReceived(ActionId_t actionId) {
if (actionId != supv::EXE_REPORT) { if (actionId == supv::ACK_REPORT) {
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action " sif::warning
<< "ID" << std::endl; << "PlocMpsocHandler::completionSuccessfulReceived: Only received ACK report. Consider "
"increasing the MPSoC boot timer."
<< std::endl;
} else if (actionId != supv::EXE_REPORT) {
sif::warning << "PlocMpsocHandler::completionSuccessfulReceived: Did not expect the action "
<< "ID " << actionId << std::endl;
return; return;
} }
switch (powerState) { switch (powerState) {
case PowerState::BOOTING: { case PowerState::PENDING_STARTUP: {
powerState = PowerState::ON; mpsocBootTransitionCd.resetTimer();
powerState = PowerState::DONE;
break; break;
} }
case PowerState::SHUTDOWN: { case PowerState::PENDING_SHUTDOWN: {
powerState = PowerState::OFF; powerState = PowerState::DONE;
break; break;
} }
default: { default: {
@ -1409,36 +1367,117 @@ void PlocMpsocHandler::disableExeReportReply() {
info->command->second.expectedReplies = 0; info->command->second.expectedReplies = 0;
} }
void PlocMpsocHandler::stopSpecialComHelper() {
if (specialComHelper != nullptr) {
specialComHelper->stopProcess();
}
specialComHelperExecuting = false;
}
bool PlocMpsocHandler::handleHwStartup() {
#if OBSW_MPSOC_JTAG_BOOT == 1
uartIsolatorSwitch.pullHigh();
startupState = StartupState::WAIT_CYCLES;
return true;
#endif
if (powerState == PowerState::IDLE) {
if (supv::SUPV_ON) {
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
supvTransitionCd.resetTimer();
powerState = PowerState::PENDING_STARTUP;
} else {
triggerEvent(SUPV_NOT_ON, 1);
// Set back to OFF for now, failing the transition.
setMode(MODE_OFF);
}
}
if (powerState == PowerState::SUPV_FAILED) {
setMode(MODE_OFF);
powerState = PowerState::IDLE;
return false;
}
if (powerState == PowerState::PENDING_STARTUP) {
if (supvTransitionCd.hasTimedOut()) {
// Process with transition nonetheless..
triggerEvent(SUPV_REPLY_TIMEOUT);
powerState = PowerState::DONE;
} else {
return false;
}
}
if (powerState == PowerState::DONE) {
if (mpsocBootTransitionCd.hasTimedOut()) {
// Wait a bit for the MPSoC to fully boot.
uartIsolatorSwitch.pullHigh();
powerState = PowerState::IDLE;
} else {
return false;
}
}
return true;
}
bool PlocMpsocHandler::handleHwShutdown() {
stopSpecialComHelper();
uartIsolatorSwitch.pullLow();
#if OBSW_MPSOC_JTAG_BOOT == 1
powerState = PowerState::DONE;
return true;
#endif
if (powerState == PowerState::IDLE) {
if (supv::SUPV_ON) {
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
supvTransitionCd.resetTimer();
powerState = PowerState::PENDING_SHUTDOWN;
} else {
triggerEvent(SUPV_NOT_ON, 0);
powerState = PowerState::DONE;
}
}
if (powerState == PowerState::PENDING_SHUTDOWN) {
if (supvTransitionCd.hasTimedOut()) {
powerState = PowerState::DONE;
// Process with transition nonetheless..
triggerEvent(SUPV_REPLY_TIMEOUT);
return true;
} else {
// Wait till power state is OFF.
return false;
}
}
return true;
}
void PlocMpsocHandler::handleActionCommandFailure(ActionId_t actionId) { void PlocMpsocHandler::handleActionCommandFailure(ActionId_t actionId) {
switch (actionId) { switch (actionId) {
case supv::ACK_REPORT: case supv::ACK_REPORT:
case supv::EXE_REPORT: case supv::EXE_REPORT:
break; break;
default: default:
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID " sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect the action ID "
<< std::endl; << actionId << std::endl;
return; return;
} }
switch (powerState) { switch (powerState) {
case PowerState::BOOTING: { case PowerState::PENDING_STARTUP: {
sif::info << "PlocMPSoCHandler::handleActionCommandFailure: MPSoC boot command failed" sif::info << "PlocMPSoCHandler::handleActionCommandFailure: MPSoC boot command failed"
<< std::endl; << std::endl;
// This is commonly the case when the MPSoC is already operational. Thus the power state is // This is commonly the case when the MPSoC is already operational. Thus the power state is
// set to on here // set to on here
powerState = PowerState::ON;
break; break;
} }
case PowerState::SHUTDOWN: { case PowerState::PENDING_SHUTDOWN: {
// FDIR will intercept event and switch PLOC power off // FDIR will intercept event and switch PLOC power off
triggerEvent(MPSOC_SHUTDOWN_FAILED); triggerEvent(MPSOC_SHUTDOWN_FAILED);
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC" sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC"
<< std::endl; << std::endl;
powerState = PowerState::OFF;
break; break;
} }
default: default:
break; break;
} }
powerState = PowerState::SUPV_FAILED;
return; return;
} }

View File

@ -103,11 +103,17 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
//! [EXPORT] : [COMMENT] Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and //! [EXPORT] : [COMMENT] Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and
//! thus also to shutdown the supervisor. //! thus also to shutdown the supervisor.
static const Event MPSOC_SHUTDOWN_FAILED = MAKE_EVENT(6, severity::HIGH); static const Event MPSOC_SHUTDOWN_FAILED = MAKE_EVENT(6, severity::HIGH);
//! [EXPORT] : [COMMENT] SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for
//! ON transition.
static constexpr Event SUPV_NOT_ON = event::makeEvent(SUBSYSTEM_ID, 7, severity::LOW);
static constexpr Event SUPV_REPLY_TIMEOUT = event::makeEvent(SUBSYSTEM_ID, 8, severity::LOW);
static const uint16_t APID_MASK = 0x7FF; static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
mpsoc::HkReport hkReport; mpsoc::HkReport hkReport;
Countdown mpsocBootTransitionCd = Countdown(6500);
Countdown supvTransitionCd = Countdown(3000);
MessageQueueIF* eventQueue = nullptr; MessageQueueIF* eventQueue = nullptr;
MessageQueueIF* commandActionHelperQueue = nullptr; MessageQueueIF* commandActionHelperQueue = nullptr;
@ -186,12 +192,11 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
size_t foundPacketLen = 0; size_t foundPacketLen = 0;
TelemetryBuffer tmBuffer; TelemetryBuffer tmBuffer;
uint32_t waitCycles = 0;
enum class StartupState { IDLE, HW_INIT, WAIT_CYCLES, DONE } startupState = StartupState::IDLE; enum class StartupState { IDLE, HW_INIT, DONE } startupState = StartupState::IDLE;
enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; enum class PowerState { IDLE, PENDING_STARTUP, PENDING_SHUTDOWN, SUPV_FAILED, DONE };
PowerState powerState = PowerState::OFF; PowerState powerState = PowerState::IDLE;
/** /**
* @brief Handles events received from the PLOC MPSoC helper * @brief Handles events received from the PLOC MPSoC helper
@ -299,6 +304,9 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
ReturnValue_t prepareTcModeReplay(); ReturnValue_t prepareTcModeReplay();
void cmdDoneHandler(bool success, ReturnValue_t result); void cmdDoneHandler(bool success, ReturnValue_t result);
bool handleHwStartup();
bool handleHwShutdown();
void stopSpecialComHelper();
void handleActionCommandFailure(ActionId_t actionId); void handleActionCommandFailure(ActionId_t actionId);
}; };

View File

@ -19,6 +19,8 @@
using namespace supv; using namespace supv;
using namespace returnvalue; using namespace returnvalue;
std::atomic_bool supv::SUPV_ON = false;
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, CookieIF* comCookie, PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, CookieIF* comCookie,
Gpio uartIsolatorSwitch, power::Switch_t powerSwitch, Gpio uartIsolatorSwitch, power::Switch_t powerSwitch,
PlocSupvUartManager& supvHelper) PlocSupvUartManager& supvHelper)
@ -156,6 +158,7 @@ void PlocSupervisorHandler::doStartUp() {
} }
if (startupState == StartupState::ON) { if (startupState == StartupState::ON) {
hkset.setReportingEnabled(true); hkset.setReportingEnabled(true);
supv::SUPV_ON = true;
setMode(_MODE_TO_ON); setMode(_MODE_TO_ON);
} }
} }
@ -169,6 +172,7 @@ void PlocSupervisorHandler::doShutDown() {
nextReplyId = supv::NONE; nextReplyId = supv::NONE;
uartManager.stop(); uartManager.stop();
uartIsolatorSwitch.pullLow(); uartIsolatorSwitch.pullLow();
supv::SUPV_ON = false;
startupState = StartupState::OFF; startupState = StartupState::OFF;
} }
@ -202,11 +206,13 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break; break;
} }
case START_MPSOC: { case START_MPSOC: {
sif::info << "PLOC SUPV: Starting MPSoC" << std::endl;
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::START_MPSOC)); prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::START_MPSOC));
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
case SHUTDOWN_MPSOC: { case SHUTDOWN_MPSOC: {
sif::info << "PLOC SUPV: Shutting down MPSoC" << std::endl;
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_MPSOC)); prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_MPSOC));
result = returnvalue::OK; result = returnvalue::OK;
break; break;
@ -1527,7 +1533,13 @@ void PlocSupervisorHandler::disableAllReplies() {
/* Disable ack reply */ /* Disable ack reply */
iter = deviceReplyMap.find(ACK_REPORT); iter = deviceReplyMap.find(ACK_REPORT);
if (iter == deviceReplyMap.end()) {
return;
}
DeviceReplyInfo* info = &(iter->second); DeviceReplyInfo* info = &(iter->second);
if (info == nullptr) {
return;
}
info->delayCycles = 0; info->delayCycles = 0;
info->command = deviceCommandMap.end(); info->command = deviceCommandMap.end();

View File

@ -10,12 +10,15 @@
#include <fsfw/tmtcpacket/ccsds/SpacePacketReader.h> #include <fsfw/tmtcpacket/ccsds/SpacePacketReader.h>
#include <mission/payload/plocSpBase.h> #include <mission/payload/plocSpBase.h>
#include <atomic>
#include <optional> #include <optional>
#include "eive/resultClassIds.h" #include "eive/resultClassIds.h"
namespace supv { namespace supv {
extern std::atomic_bool SUPV_ON;
namespace result { namespace result {
static const uint8_t INTERFACE_ID = CLASS_ID::SUPV_RETURN_VALUES_IF; static const uint8_t INTERFACE_ID = CLASS_ID::SUPV_RETURN_VALUES_IF;

2
tmtc

@ -1 +1 @@
Subproject commit d23cc6834ad0895c230d2378b0c8d9ba4f374f8d Subproject commit 22a42108b431bafa707de2b3a24cad9de95b70d0