successfull SW update
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-09-26 23:17:12 +02:00
parent 9d440838e9
commit d87baa8da9
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 33 additions and 10 deletions

View File

@ -1884,6 +1884,20 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
} }
auto chip = static_cast<xsc::Chip>(data[0]); auto chip = static_cast<xsc::Chip>(data[0]);
auto copy = static_cast<xsc::Copy>(data[1]); auto copy = static_cast<xsc::Copy>(data[1]);
const char *sourceStr = "unknown";
if (sourceDir == SwUpdateSources::SD_0) {
sourceStr = "SD 0";
} else if (sourceDir == SwUpdateSources::SD_1) {
sourceStr = "SD 1";
} else {
sourceStr = "tmp directory";
}
sif::info << "Executing SW update for Chip " << static_cast<int>(data[0]) << " Copy "
<< static_cast<int>(data[1]) << " from " << sourceStr << std::endl;
if (chip == CURRENT_CHIP and copy == CURRENT_COPY) {
// Not allowed / possible. TODO: Dedicated returnvalue?
return returnvalue::FAILED;
}
path prefixPath; path prefixPath;
if (sourceDir == SwUpdateSources::SD_0) { if (sourceDir == SwUpdateSources::SD_0) {
prefixPath = path(config::SD_0_MOUNT_POINT); prefixPath = path(config::SD_0_MOUNT_POINT);
@ -1896,8 +1910,8 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
if (not exists(archivePath)) { if (not exists(archivePath)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST; return HasFileSystemIF::FILE_DOES_NOT_EXIST;
} }
ostringstream cmd("tar -xJvf"); ostringstream cmd("tar -xJf", ios::app);
cmd << " " << archivePath; cmd << " " << archivePath << " -C " << prefixPath;
int result = system(cmd.str().c_str()); int result = system(cmd.str().c_str());
if (result != 0) { if (result != 0) {
utility::handleSystemError(result, "CoreController::executeAction: SW Update Decompression"); utility::handleSystemError(result, "CoreController::executeAction: SW Update Decompression");
@ -1912,55 +1926,64 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
// TODO: Custom returnvalue? // TODO: Custom returnvalue?
return returnvalue::FAILED; return returnvalue::FAILED;
} }
cmd.str("");
cmd.clear(); cmd.clear();
cmd << "xsc_mount_copy " << data[0] << " " << data[1]; cmd << "xsc_mount_copy " << std::to_string(data[0]) << " " << std::to_string(data[1]);
result = system(cmd.str().c_str()); result = system(cmd.str().c_str());
if (result != 0) { if (result != 0) {
std::string contextString = "CoreController::executeAction: SW Update Mounting " + std::string contextString = "CoreController::executeAction: SW Update Mounting " +
std::to_string(data[0]) + " " + std::to_string(data[1]); std::to_string(data[0]) + " " + std::to_string(data[1]);
utility::handleSystemError(result, contextString); utility::handleSystemError(result, contextString);
} }
cmd.str("");
cmd.clear(); cmd.clear();
std::string xscMountDest = std::string(getXscMountDir(chip, copy)); path xscMountDest(getXscMountDir(chip, copy));
path obswDestPath = xscMountDest / config::OBSW_PATH; path obswDestPath = xscMountDest / path(relative(config::OBSW_PATH, "/"));
cmd << "cp " << strippedImagePath << " " << obswDestPath; cmd << "cp " << strippedImagePath << " " << obswDestPath;
result = system(cmd.str().c_str()); result = system(cmd.str().c_str());
if (result != 0) { if (result != 0) {
utility::handleSystemError(result, "CoreController::executeAction: Copying SW update"); utility::handleSystemError(result, "CoreController::executeAction: Copying SW update");
} }
cmd.str("");
cmd.clear(); cmd.clear();
path obswVersionDestPath = xscMountDest / config::OBSW_VERSION_FILE_PATH; path obswVersionDestPath = xscMountDest / path(relative(config::OBSW_VERSION_FILE_PATH, "/"));
cmd << "cp " << obswVersionFilePath << " " << obswVersionDestPath; cmd << "cp " << obswVersionFilePath << " " << obswVersionDestPath;
result = system(cmd.str().c_str()); result = system(cmd.str().c_str());
if (result != 0) { if (result != 0) {
utility::handleSystemError(result, "CoreController::executeAction: Copying SW version file"); utility::handleSystemError(result, "CoreController::executeAction: Copying SW version file");
} }
cmd.str("");
cmd.clear(); cmd.clear();
// Set correct permission for both files // Set correct permission for both files
cmd << "chmod 0755 " << obswDestPath; cmd << "chmod 0755 " << obswDestPath;
result = system(cmd.str().c_str()); result = system(cmd.str().c_str());
if (result != 0) { if (result != 0) {
utility::handleSystemError(result, "CoreController::executeAction: Copying SW permissions 0755"); utility::handleSystemError(result,
"CoreController::executeAction: Copying SW permissions 0755");
} }
cmd.str("");
cmd.clear(); cmd.clear();
cmd << "chmod 0644 " << obswVersionDestPath; cmd << "chmod 0644 " << obswVersionDestPath;
result = system(cmd.str().c_str()); result = system(cmd.str().c_str());
if (result != 0) { if (result != 0) {
utility::handleSystemError(result, "CoreController::executeAction: Setting version file permission 0644"); utility::handleSystemError(
result, "CoreController::executeAction: Setting version file permission 0644");
} }
cmd.str("");
cmd.clear(); cmd.clear();
// TODO: This takes a long time and will block the core controller.. Maybe use command executor? // TODO: This takes a long time and will block the core controller.. Maybe use command executor?
// For now dont care.. // For now dont care..
cmd << "writeprotect " << data[0] << " " << data[1] << " 1"; cmd << "writeprotect " << std::to_string(data[0]) << " " << std::to_string(data[1]) << " 1";
result = system(cmd.str().c_str()); result = system(cmd.str().c_str());
if (result != 0) { if (result != 0) {
std::string contextString = "CoreController::executeAction: Writeprotecting " + std::string contextString = "CoreController::executeAction: Writeprotecting " +
std::to_string(data[0]) + " " + std::to_string(data[1]); std::to_string(data[0]) + " " + std::to_string(data[1]);
utility::handleSystemError(result, contextString); utility::handleSystemError(result, contextString);
} }
sif::info << "SW update complete" << std::endl;
return HasActionsIF::EXECUTION_FINISHED; return HasActionsIF::EXECUTION_FINISHED;
} }

2
tmtc

@ -1 +1 @@
Subproject commit 847a9dc000da29ae6faca3c97eb0af660cf96572 Subproject commit 4307620a56c1f030247e4ad4a73a8e07864dde92