SD shutdown handling non-blocking #753
@ -1229,12 +1229,17 @@ ReturnValue_t CoreController::gracefulShutdownTasks(xsc::Chip chip, xsc::Copy co
|
|||||||
// Ensure that all writes/reads do finish.
|
// Ensure that all writes/reads do finish.
|
||||||
sync();
|
sync();
|
||||||
|
|
||||||
// Attempt graceful shutdown by unmounting and switching off SD cards
|
// Unmount and switch off SD cards. This could possibly fix issues with the SD card and is
|
||||||
sdcMan->switchOffSdCard(sd::SdCard::SLOT_0);
|
// the more graceful way to reboot the system.
|
||||||
sdcMan->switchOffSdCard(sd::SdCard::SLOT_1);
|
ReturnValue_t result = handleSwitchingSdCardsOffNonBlocking();
|
||||||
|
if(result != returnvalue::OK) {
|
||||||
|
sif::error << "CoreController::gracefulShutdownTasks: Issues unmounting or switching SD cards off"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// If any boot copies are unprotected.
|
// If any boot copies are unprotected.
|
||||||
// Actually this function only ensures that reboots to the own image are protected..
|
// Actually this function only ensures that reboots to the own image are protected..
|
||||||
ReturnValue_t result = setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, true,
|
result = setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, true,
|
||||||
protOpPerformed, false);
|
protOpPerformed, false);
|
||||||
if (result == returnvalue::OK and protOpPerformed) {
|
if (result == returnvalue::OK and protOpPerformed) {
|
||||||
// TODO: Would be nice to notify operator. But we can't use the filesystem anymore
|
// TODO: Would be nice to notify operator. But we can't use the filesystem anymore
|
||||||
@ -2583,6 +2588,46 @@ void CoreController::announceSdInfo(SdCardManager::SdStatePair sdStates) {
|
|||||||
triggerEvent(core::ACTIVE_SD_INFO, p1, p2);
|
triggerEvent(core::ACTIVE_SD_INFO, p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CoreController::handleSwitchingSdCardsOffNonBlocking() {
|
||||||
|
Countdown maxWaitTimeCd(6000);
|
||||||
|
Stopwatch watch;
|
||||||
|
|
||||||
|
sdcMan->setBlocking(false);
|
||||||
|
SdCardManager::Operations op;
|
||||||
|
auto waitingForFinish = [&]() {
|
||||||
|
while (sdcMan->checkCurrentOp(op) == SdCardManager::OpStatus::ONGOING) {
|
||||||
|
TaskFactory::delayTask(50);
|
||||||
|
if (maxWaitTimeCd.hasTimedOut()) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnvalue::OK;
|
||||||
|
};
|
||||||
|
|
||||||
|
sdcMan->unmountSdCard(sd::SdCard::SLOT_0);
|
||||||
|
ReturnValue_t result = waitingForFinish();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
sdcMan->unmountSdCard(sd::SdCard::SLOT_1);
|
||||||
|
result = waitingForFinish();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdcMan->switchOffSdCard(sd::SdCard::SLOT_0, false);
|
||||||
|
result = waitingForFinish();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
sdcMan->switchOffSdCard(sd::SdCard::SLOT_1, false);
|
||||||
|
result = waitingForFinish();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool CoreController::isNumber(const std::string &s) {
|
bool CoreController::isNumber(const std::string &s) {
|
||||||
return !s.empty() && std::find_if(s.begin(), s.end(),
|
return !s.empty() && std::find_if(s.begin(), s.end(),
|
||||||
[](unsigned char c) { return !std::isdigit(c); }) == s.end();
|
[](unsigned char c) { return !std::isdigit(c); }) == s.end();
|
||||||
|
@ -374,6 +374,7 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe
|
|||||||
ReturnValue_t gracefulShutdownTasks(xsc::Chip chip, xsc::Copy copy, bool& protOpPerformed);
|
ReturnValue_t gracefulShutdownTasks(xsc::Chip chip, xsc::Copy copy, bool& protOpPerformed);
|
||||||
|
|
||||||
ReturnValue_t handleProtInfoUpdateLine(std::string nextLine);
|
ReturnValue_t handleProtInfoUpdateLine(std::string nextLine);
|
||||||
|
ReturnValue_t handleSwitchingSdCardsOffNonBlocking();
|
||||||
int handleBootCopyProtAtIndex(xsc::Chip targetChip, xsc::Copy targetCopy, bool protect,
|
int handleBootCopyProtAtIndex(xsc::Chip targetChip, xsc::Copy targetCopy, bool protect,
|
||||||
bool& protOperationPerformed, bool selfChip, bool selfCopy,
|
bool& protOperationPerformed, bool selfChip, bool selfCopy,
|
||||||
bool allChips, bool allCopies, uint8_t arrIdx);
|
bool allChips, bool allCopies, uint8_t arrIdx);
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit a82cbff5a83eb37c68234bdeecd3b7d308d65eb1
|
Subproject commit 95b69541751c9ea7146e0a342122da83bdb50f29
|
Loading…
Reference in New Issue
Block a user