|
|
|
@ -16,6 +16,7 @@
|
|
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <libxiphos.h>
|
|
|
|
|
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
|
|
|
|
@ -691,7 +692,7 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId,
|
|
|
|
|
|
|
|
|
|
ReturnValue_t CoreController::initBootCopy() {
|
|
|
|
|
if (not std::filesystem::exists(CURR_COPY_FILE)) {
|
|
|
|
|
// Thils file is created by the systemd service eive-early-config so this should
|
|
|
|
|
// This file is created by the systemd service eive-early-config so this should
|
|
|
|
|
// not happen normally
|
|
|
|
|
std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE);
|
|
|
|
|
int result = std::system(cmd.c_str());
|
|
|
|
@ -773,7 +774,7 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
|
|
|
|
|
}
|
|
|
|
|
return HasActionsIF::EXECUTION_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
if (size < 3) {
|
|
|
|
|
if (size < 3 or (data[1] > 1 or data[2] > 1)) {
|
|
|
|
|
return HasActionsIF::INVALID_PARAMETERS;
|
|
|
|
|
}
|
|
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
|
|
|
@ -784,21 +785,52 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
|
|
|
|
|
// Check that the target chip and copy is writeprotected first
|
|
|
|
|
generateChipStateFile();
|
|
|
|
|
// If any boot copies are unprotected, protect them here
|
|
|
|
|
auto tgtChip = static_cast<Chip>(data[1]);
|
|
|
|
|
auto tgtCopy = static_cast<Copy>(data[2]);
|
|
|
|
|
|
|
|
|
|
ReturnValue_t retval = setBootCopyProtection(
|
|
|
|
|
static_cast<Chip>(data[1]), static_cast<Copy>(data[2]), true, protOpPerformed, false);
|
|
|
|
|
if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
|
|
|
|
|
sif::info << "Target slot was writeprotected before reboot" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The second byte in data is the target chip, the third byte is the target copy
|
|
|
|
|
std::string cmdString =
|
|
|
|
|
"xsc_boot_copy " + std::to_string(data[1]) + " " + std::to_string(data[2]);
|
|
|
|
|
int result = std::system(cmdString.c_str());
|
|
|
|
|
if (result != 0) {
|
|
|
|
|
utility::handleSystemError(result, "CoreController::executeAction");
|
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
|
switch(tgtChip) {
|
|
|
|
|
case(Chip::CHIP_0): {
|
|
|
|
|
switch(tgtCopy) {
|
|
|
|
|
case(Copy::COPY_0): {
|
|
|
|
|
xsc_boot_copy(XSC_LIBNOR_CHIP_0, XSC_LIBNOR_COPY_NOMINAL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case(Copy::COPY_1): {
|
|
|
|
|
xsc_boot_copy(XSC_LIBNOR_CHIP_0, XSC_LIBNOR_COPY_GOLD);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return HasActionsIF::EXECUTION_FINISHED;
|
|
|
|
|
case(Chip::CHIP_1): {
|
|
|
|
|
switch(tgtCopy) {
|
|
|
|
|
case(Copy::COPY_0): {
|
|
|
|
|
xsc_boot_copy(XSC_LIBNOR_CHIP_1, XSC_LIBNOR_COPY_NOMINAL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case(Copy::COPY_1): {
|
|
|
|
|
xsc_boot_copy(XSC_LIBNOR_CHIP_1, XSC_LIBNOR_COPY_GOLD);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CoreController::~CoreController() {}
|
|
|
|
|