improve MPSoC boot and shutdown process
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
35fd2c72d8
commit
0d0a98220a
@ -188,72 +188,27 @@ 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
|
hkReport.setReportingEnabled(false);
|
||||||
if (powerState == PowerState::ON) {
|
setMode(_MODE_POWER_DOWN);
|
||||||
uartIsolatorSwitch.pullLow();
|
commandIsPending = false;
|
||||||
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
sequenceCount = 0;
|
||||||
powerState = PowerState::SHUTDOWN;
|
powerState = PowerState::IDLE;
|
||||||
return;
|
startupState = StartupState::IDLE;
|
||||||
} 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);
|
|
||||||
setMode(_MODE_POWER_DOWN);
|
|
||||||
commandIsPending = false;
|
|
||||||
sequenceCount = 0;
|
|
||||||
specialComHelperExecuting = false;
|
|
||||||
startupState = StartupState::IDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||||
@ -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) {
|
||||||
@ -1272,16 +1224,14 @@ 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::EXE_REPORT) {
|
||||||
sif::warning << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
|
sif::warning << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
|
||||||
<< "ID " << actionId << std::endl;
|
<< "ID " << actionId << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (powerState) {
|
switch (powerState) {
|
||||||
case PowerState::BOOTING: {
|
case PowerState::PENDING_STARTUP:
|
||||||
powerState = PowerState::ON;
|
case PowerState::PENDING_SHUTDOWN: {
|
||||||
break;
|
// sif::debug << "power switching done" << std::endl;
|
||||||
}
|
powerState = PowerState::DONE;
|
||||||
case PowerState::SHUTDOWN: {
|
|
||||||
powerState = PowerState::OFF;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -1409,6 +1359,88 @@ 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 (not !supvTransitionCd.hasTimedOut()) {
|
||||||
|
// Wait a bit for the MPSoC to fully boot. We re-use the SUPV transition countdown
|
||||||
|
// for this.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
uartIsolatorSwitch.pullHigh();
|
||||||
|
powerState = PowerState::IDLE;
|
||||||
|
}
|
||||||
|
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:
|
||||||
@ -1420,25 +1452,24 @@ void PlocMpsocHandler::handleActionCommandFailure(ActionId_t actionId) {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,11 +103,16 @@ 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, 6, severity::LOW);
|
||||||
|
static constexpr Event SUPV_REPLY_TIMEOUT = event::makeEvent(SUBSYSTEM_ID, 7, 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 supvTransitionCd = Countdown(3000);
|
||||||
|
|
||||||
MessageQueueIF* eventQueue = nullptr;
|
MessageQueueIF* eventQueue = nullptr;
|
||||||
MessageQueueIF* commandActionHelperQueue = nullptr;
|
MessageQueueIF* commandActionHelperQueue = nullptr;
|
||||||
@ -188,10 +193,10 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
|||||||
TelemetryBuffer tmBuffer;
|
TelemetryBuffer tmBuffer;
|
||||||
uint32_t waitCycles = 0;
|
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);
|
||||||
};
|
};
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user