first implementation finished
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2022-02-23 17:53:23 +01:00
parent 00eb5a2f1e
commit 37cf7ac01b
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 74 additions and 32 deletions

View File

@ -1166,29 +1166,71 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
// Trigger event to inform ground that a reboot was triggered // Trigger event to inform ground that a reboot was triggered
} }
switch (CURRENT_CHIP) {
case (xsc::CHIP_0): {
switch (CURRENT_COPY) {
case (xsc::COPY_0): {
rebootFile.img00Cnt++;
break;
}
case (xsc::COPY_1): {
rebootFile.img01Cnt++;
break;
}
default: {
break;
}
}
break;
}
case (xsc::CHIP_1): {
switch (CURRENT_COPY) {
case (xsc::COPY_0): {
rebootFile.img10Cnt++;
break;
}
case (xsc::COPY_1): {
rebootFile.img11Cnt++;
break;
}
default: {
break;
}
}
break;
}
default: {
break;
}
}
if (CURRENT_CHIP == xsc::CHIP_0 and CURRENT_COPY == xsc::COPY_0) {
}
if (rebootFile.relevantBootCnt > rebootFile.maxCount) { if (rebootFile.relevantBootCnt > rebootFile.maxCount) {
// Reboot to other image // Reboot to other image
bool doReboot = false; bool doReboot = false;
xsc_libnor_chip_t tgtChip; determineAndExecuteReboot(rebootFile, doReboot, rebootFile.lastChip, rebootFile.lastCopy);
xsc_libnor_copy_t tgtCopy;
determineAndExecuteReboot(rebootFile, doReboot, tgtChip, tgtCopy);
if (doReboot) { if (doReboot) {
rebootFile.bootFlag = true;
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
sif::info << "Boot counter for image " << CURRENT_CHIP << " " << CURRENT_COPY sif::info << "Boot counter for image " << CURRENT_CHIP << " " << CURRENT_COPY
<< "too high. Rebooting to " << tgtChip << " " << tgtCopy << std::endl; << "too high. Rebooting to " << rebootFile.lastChip << " " << rebootFile.lastCopy
<< std::endl;
#endif #endif
xsc_boot_copy(tgtChip, tgtCopy); rewriteRebootFile(rebootFile);
xsc_boot_copy(static_cast<xsc_libnor_chip_t>(rebootFile.lastChip),
static_cast<xsc_libnor_copy_t>(rebootFile.lastCopy));
} }
} else {
rewriteRebootFile(rebootFile);
} }
doPerformRebootFileHandling = false; doPerformRebootFileHandling = false;
} }
} }
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot, void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
xsc_libnor_chip_t &tgtChip, xsc::Chip &tgtChip, xsc::Copy &tgtCopy) {
xsc_libnor_copy_t &tgtCopy) { tgtChip = xsc::CHIP_0;
tgtChip = XSC_LIBNOR_CHIP_0; tgtCopy = xsc::COPY_0;
tgtCopy = XSC_LIBNOR_COPY_NOMINAL;
needsReboot = false; needsReboot = false;
if ((CURRENT_COPY == xsc::COPY_0) and (CURRENT_CHIP == xsc::CHIP_0) and if ((CURRENT_COPY == xsc::COPY_0) and (CURRENT_CHIP == xsc::CHIP_0) and
(rf.img00Cnt >= rf.maxCount)) { (rf.img00Cnt >= rf.maxCount)) {
@ -1200,15 +1242,15 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
sif::warning << "All reboot counts too high, but already on fallback image" << std::endl; sif::warning << "All reboot counts too high, but already on fallback image" << std::endl;
return; return;
} else { } else {
tgtCopy = XSC_LIBNOR_COPY_GOLD; tgtChip = xsc::CHIP_1;
tgtChip = XSC_LIBNOR_CHIP_1; tgtCopy = xsc::COPY_1;
} }
} else { } else {
tgtCopy = XSC_LIBNOR_COPY_GOLD; tgtChip = xsc::CHIP_0;
tgtChip = XSC_LIBNOR_CHIP_0; tgtCopy = xsc::COPY_1;
} }
} else { } else {
tgtCopy = XSC_LIBNOR_COPY_GOLD; tgtCopy = xsc::COPY_1;
} }
} }
if ((CURRENT_COPY == xsc::COPY_0) and (CURRENT_CHIP == xsc::CHIP_1) and if ((CURRENT_COPY == xsc::COPY_0) and (CURRENT_CHIP == xsc::CHIP_1) and
@ -1219,12 +1261,12 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
if (rf.img11Cnt >= rf.maxCount) { if (rf.img11Cnt >= rf.maxCount) {
// Reboot to fallback image // Reboot to fallback image
} else { } else {
tgtChip = XSC_LIBNOR_CHIP_1; tgtChip = xsc::CHIP_1;
tgtCopy = XSC_LIBNOR_COPY_GOLD; tgtCopy = xsc::COPY_1;
} }
} else { } else {
tgtChip = XSC_LIBNOR_CHIP_1; tgtChip = xsc::CHIP_1;
tgtCopy = XSC_LIBNOR_COPY_NOMINAL; tgtCopy = xsc::COPY_0;
} }
} else { } else {
// Reboot on fallback image // Reboot on fallback image
@ -1238,16 +1280,16 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
if (rf.img01Cnt >= rf.maxCount) { if (rf.img01Cnt >= rf.maxCount) {
// Reboot to fallback image // Reboot to fallback image
} else { } else {
tgtChip = XSC_LIBNOR_CHIP_0; tgtChip = xsc::CHIP_0;
tgtCopy = XSC_LIBNOR_COPY_GOLD; tgtCopy = xsc::COPY_1;
} }
} else { } else {
tgtChip = XSC_LIBNOR_CHIP_0; tgtChip = xsc::CHIP_0;
tgtCopy = XSC_LIBNOR_COPY_NOMINAL; tgtCopy = xsc::COPY_0;
} }
} else { } else {
tgtCopy = XSC_LIBNOR_COPY_GOLD; tgtChip = xsc::CHIP_1;
tgtChip = XSC_LIBNOR_CHIP_1; tgtCopy = xsc::COPY_1;
} }
} }
if ((CURRENT_COPY == xsc::COPY_1) and (CURRENT_CHIP == xsc::CHIP_1) and if ((CURRENT_COPY == xsc::COPY_1) and (CURRENT_CHIP == xsc::CHIP_1) and
@ -1258,16 +1300,16 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
if (rf.img01Cnt >= rf.maxCount) { if (rf.img01Cnt >= rf.maxCount) {
// Reboot to fallback image // Reboot to fallback image
} else { } else {
tgtChip = XSC_LIBNOR_CHIP_0; tgtChip = xsc::CHIP_0;
tgtCopy = XSC_LIBNOR_COPY_GOLD; tgtCopy = xsc::COPY_1;
} }
} else { } else {
tgtChip = XSC_LIBNOR_CHIP_0; tgtChip = xsc::CHIP_0;
tgtCopy = XSC_LIBNOR_COPY_NOMINAL; tgtCopy = xsc::COPY_0;
} }
} else { } else {
tgtChip = XSC_LIBNOR_CHIP_1; tgtChip = xsc::CHIP_1;
tgtCopy = XSC_LIBNOR_COPY_NOMINAL; tgtCopy = xsc::COPY_0;
} }
} }
} }

View File

@ -188,8 +188,8 @@ class CoreController : public ExtendedControllerBase {
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);
void determineAndExecuteReboot(RebootFile& rf, bool& needsReboot, xsc_libnor_chip_t& tgtChip, void determineAndExecuteReboot(RebootFile& rf, bool& needsReboot, xsc::Chip& tgtChip,
xsc_libnor_copy_t& tgtCopy); xsc::Copy& tgtCopy);
bool parseRebootFile(std::string path, RebootFile& file); bool parseRebootFile(std::string path, RebootFile& file);
void rewriteRebootFile(RebootFile file); void rewriteRebootFile(RebootFile file);
}; };