Core Controller Remount SD Handling #253
@ -14,6 +14,8 @@ list yields a list of all related PRs for each release.
|
|||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
|
- Regular reboot command
|
||||||
|
PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/242
|
||||||
- Commands for individual RTD devices
|
- Commands for individual RTD devices
|
||||||
PR: https://egit.irs.uni-stuttgart.de/eive/eive-tmtc/pulls/84
|
PR: https://egit.irs.uni-stuttgart.de/eive/eive-tmtc/pulls/84
|
||||||
- `RwAssembly` added to system components. Assembly works in principle,
|
- `RwAssembly` added to system components. Assembly works in principle,
|
||||||
|
@ -220,8 +220,13 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
rewriteRebootFile(rebootFile);
|
rewriteRebootFile(rebootFile);
|
||||||
return HasActionsIF::EXECUTION_FINISHED;
|
return HasActionsIF::EXECUTION_FINISHED;
|
||||||
}
|
}
|
||||||
|
case (XSC_REBOOT_OBC): {
|
||||||
|
// Warning: This function will never return, because it reboots the system
|
||||||
|
return actionXscReboot(data, size);
|
||||||
|
}
|
||||||
case (REBOOT_OBC): {
|
case (REBOOT_OBC): {
|
||||||
return actionPerformReboot(data, size);
|
// Warning: This function will never return, because it reboots the system
|
||||||
|
return actionReboot(data, size);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return HasActionsIF::INVALID_ACTION_ID;
|
return HasActionsIF::INVALID_ACTION_ID;
|
||||||
@ -852,25 +857,18 @@ void CoreController::initPrint() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t size) {
|
ReturnValue_t CoreController::actionXscReboot(const uint8_t *data, size_t size) {
|
||||||
if (size < 1) {
|
if (size < 1) {
|
||||||
return HasActionsIF::INVALID_PARAMETERS;
|
return HasActionsIF::INVALID_PARAMETERS;
|
||||||
}
|
}
|
||||||
bool rebootSameBootCopy = data[0];
|
bool rebootSameBootCopy = data[0];
|
||||||
bool protOpPerformed;
|
bool protOpPerformed = false;
|
||||||
|
SdCardManager::instance()->setBlocking(true);
|
||||||
if (rebootSameBootCopy) {
|
if (rebootSameBootCopy) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl;
|
sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
// Attempt graceful shutdown by unmounting and switching off SD cards
|
gracefulShutdownTasks(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, protOpPerformed);
|
||||||
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0);
|
|
||||||
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1);
|
|
||||||
// If any boot copies are unprotected
|
|
||||||
ReturnValue_t retval = setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, true,
|
|
||||||
protOpPerformed, false);
|
|
||||||
if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
|
|
||||||
sif::info << "Running slot was writeprotected before reboot" << std::endl;
|
|
||||||
}
|
|
||||||
int result = std::system("xsc_boot_copy -r");
|
int result = std::system("xsc_boot_copy -r");
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
utility::handleSystemError(result, "CoreController::executeAction");
|
utility::handleSystemError(result, "CoreController::executeAction");
|
||||||
@ -892,12 +890,8 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
|
|||||||
auto tgtChip = static_cast<xsc::Chip>(data[1]);
|
auto tgtChip = static_cast<xsc::Chip>(data[1]);
|
||||||
auto tgtCopy = static_cast<xsc::Copy>(data[2]);
|
auto tgtCopy = static_cast<xsc::Copy>(data[2]);
|
||||||
|
|
||||||
ReturnValue_t retval =
|
// This function can not really fail
|
||||||
setBootCopyProtection(static_cast<xsc::Chip>(data[1]), static_cast<xsc::Copy>(data[2]), true,
|
gracefulShutdownTasks(tgtChip, tgtCopy, protOpPerformed);
|
||||||
protOpPerformed, false);
|
|
||||||
if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
|
|
||||||
sif::info << "Target slot was writeprotected before reboot" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (tgtChip) {
|
switch (tgtChip) {
|
||||||
case (xsc::Chip::CHIP_0): {
|
case (xsc::Chip::CHIP_0): {
|
||||||
@ -938,6 +932,30 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CoreController::actionReboot(const uint8_t *data, size_t size) {
|
||||||
|
bool protOpPerformed = false;
|
||||||
|
gracefulShutdownTasks(xsc::Chip::CHIP_0, xsc::Copy::COPY_0, protOpPerformed);
|
||||||
|
std::system("reboot");
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CoreController::gracefulShutdownTasks(xsc::Chip chip, xsc::Copy copy,
|
||||||
|
bool &protOpPerformed) {
|
||||||
|
sdcMan->setBlocking(true);
|
||||||
|
// Attempt graceful shutdown by unmounting and switching off SD cards
|
||||||
|
sdcMan->switchOffSdCard(sd::SdCard::SLOT_0);
|
||||||
|
sdcMan->switchOffSdCard(sd::SdCard::SLOT_1);
|
||||||
|
// If any boot copies are unprotected
|
||||||
|
ReturnValue_t result = setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, true,
|
||||||
|
protOpPerformed, false);
|
||||||
|
if (result == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
|
||||||
|
// TODO: Would be nice to notify operator. But we can't use the filesystem anymore
|
||||||
|
// and a reboot is imminent. Use scratch buffer?
|
||||||
|
sif::info << "Running slot was writeprotected before reboot" << std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
CoreController::~CoreController() {}
|
CoreController::~CoreController() {}
|
||||||
|
|
||||||
void CoreController::updateSdInfoOther() {
|
void CoreController::updateSdInfoOther() {
|
||||||
|
@ -67,8 +67,11 @@ class CoreController : public ExtendedControllerBase {
|
|||||||
static constexpr ActionId_t SWITCH_IMG_LOCK = 7;
|
static constexpr ActionId_t SWITCH_IMG_LOCK = 7;
|
||||||
static constexpr ActionId_t SET_MAX_REBOOT_CNT = 8;
|
static constexpr ActionId_t SET_MAX_REBOOT_CNT = 8;
|
||||||
|
|
||||||
static constexpr ActionId_t REBOOT_OBC = 32;
|
//! Reboot using the xsc_boot_copy command
|
||||||
|
static constexpr ActionId_t XSC_REBOOT_OBC = 32;
|
||||||
static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
|
static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
|
||||||
|
//! Reboot using the reboot command
|
||||||
|
static constexpr ActionId_t REBOOT_OBC = 34;
|
||||||
|
|
||||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
||||||
|
|
||||||
@ -223,7 +226,10 @@ class CoreController : public ExtendedControllerBase {
|
|||||||
|
|
||||||
ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy,
|
ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||||
const uint8_t* data, size_t size);
|
const uint8_t* data, size_t size);
|
||||||
ReturnValue_t actionPerformReboot(const uint8_t* data, size_t size);
|
ReturnValue_t actionXscReboot(const uint8_t* data, size_t size);
|
||||||
|
ReturnValue_t actionReboot(const uint8_t* data, size_t size);
|
||||||
|
|
||||||
|
ReturnValue_t gracefulShutdownTasks(xsc::Chip chip, xsc::Copy copy, bool& protOpPerformed);
|
||||||
|
|
||||||
void performWatchdogControlOperation();
|
void performWatchdogControlOperation();
|
||||||
|
|
||||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit 4b128d243569e0c87ae8868c545bdd80a354a2e6
|
Subproject commit c8355251967009559ea790b63c3ebfc67a27efef
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit 51bbeaa693a11bfc4d2cb342354041972dd93c1e
|
Subproject commit 6a209e1a0badc0db91a03e1ef32d43de54d58958
|
Loading…
Reference in New Issue
Block a user