updates on same image are problematic..
EIVE/eive-obsw/pipeline/pr-develop This commit looks good Details

This commit is contained in:
Robin Müller 2022-09-27 14:29:39 +02:00
parent ff243fa46c
commit 3c746e954b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 40 additions and 13 deletions

View File

@ -410,6 +410,7 @@ ReturnValue_t CoreController::sdStateMachine() {
<< std::endl;
#endif
sdcMan->setActiveSdCard(sdInfo.active);
currMntPrefix = sdcMan->getCurrentMountPrefix();
sdFsmState = SdStates::DETERMINE_OTHER;
} else if (sdInfo.activeState == sd::SdState::OFF) {
sdCardSetup(sdInfo.active, sd::SdState::ON, sdInfo.activeChar, false);
@ -432,6 +433,7 @@ ReturnValue_t CoreController::sdStateMachine() {
} else {
if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) {
sdcMan->setActiveSdCard(sdInfo.active);
currMntPrefix = sdcMan->getCurrentMountPrefix();
sdInfo.activeState = sd::SdState::MOUNTED;
currentStateSetter(sdInfo.active, sd::SdState::MOUNTED);
}
@ -1869,6 +1871,13 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
} else {
sourceStr = "tmp directory";
}
bool sameChipAndCopy = false;
if(chip == CURRENT_CHIP and copy == CURRENT_COPY) {
// This is problematic if the OBSW is running as a systemd service.
// Do not allow for now.
return HasActionsIF::INVALID_PARAMETERS;
//sameChipAndCopy = true;
}
sif::info << "Executing SW update for Chip " << static_cast<int>(data[0]) << " Copy "
<< static_cast<int>(data[1]) << " from " << sourceStr << std::endl;
path prefixPath;
@ -1901,17 +1910,35 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
}
cmd.str("");
cmd.clear();
cmd << "xsc_mount_copy " << std::to_string(data[0]) << " " << std::to_string(data[1]);
result = system(cmd.str().c_str());
if (result != 0) {
std::string contextString = "CoreController::executeAction: SW Update Mounting " +
std::to_string(data[0]) + " " + std::to_string(data[1]);
utility::handleSystemError(result, contextString);
path obswDestPath;
path obswVersionDestPath;
if(not sameChipAndCopy) {
cmd << "xsc_mount_copy " << std::to_string(data[0]) << " " << std::to_string(data[1]);
result = system(cmd.str().c_str());
if (result != 0) {
std::string contextString = "CoreController::executeAction: SW Update Mounting " +
std::to_string(data[0]) + " " + std::to_string(data[1]);
utility::handleSystemError(result, contextString);
}
cmd.str("");
cmd.clear();
path xscMountDest(getXscMountDir(chip, copy));
obswDestPath = xscMountDest / path(relative(config::OBSW_PATH, "/"));
obswVersionDestPath = xscMountDest / path(relative(config::OBSW_VERSION_FILE_PATH, "/"));
} else {
obswDestPath = path(config::OBSW_PATH);
obswVersionDestPath = path(config::OBSW_VERSION_FILE_PATH);
cmd << "writeprotect " << std::to_string(CURRENT_CHIP) << " " << std::to_string(CURRENT_COPY)
<< " 0";
result = system(cmd.str().c_str());
if (result != 0) {
std::string contextString = "CoreController::executeAction: Unlocking current chip";
utility::handleSystemError(result, contextString);
}
cmd.str("");
cmd.clear();
}
cmd.str("");
cmd.clear();
path xscMountDest(getXscMountDir(chip, copy));
path obswDestPath = xscMountDest / path(relative(config::OBSW_PATH, "/"));
cmd << "cp " << strippedImagePath << " " << obswDestPath;
result = system(cmd.str().c_str());
if (result != 0) {
@ -1919,7 +1946,7 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
}
cmd.str("");
cmd.clear();
path obswVersionDestPath = xscMountDest / path(relative(config::OBSW_VERSION_FILE_PATH, "/"));
cmd << "cp " << obswVersionFilePath << " " << obswVersionDestPath;
result = system(cmd.str().c_str());
if (result != 0) {
@ -1933,7 +1960,7 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
result = system(cmd.str().c_str());
if (result != 0) {
utility::handleSystemError(result,
"CoreController::executeAction: Copying SW permissions 0755");
"CoreController::executeAction: Setting SW permissions 0755");
}
cmd.str("");
cmd.clear();

2
tmtc

@ -1 +1 @@
Subproject commit aae1fbddf4f5a208b3407dd11f61e33bb526268f
Subproject commit a2991988f56b631b5bab67e452e9d7c126b49480