updated OBSW code
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include "SdCardManager.h"
|
||||
#include "event.h"
|
||||
#include "libxiphos.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -22,7 +23,7 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
|
||||
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
||||
if (not std::filesystem::exists(path) or recreateFile) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
std::cout << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
||||
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
||||
#endif
|
||||
rebootFile.enabled = true;
|
||||
rebootFile.img00Cnt = 0;
|
||||
@ -62,15 +63,22 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
|
||||
if (rebootFile.bootFlag) {
|
||||
// Trigger event to inform ground that a reboot was triggered
|
||||
uint32_t p1 = rebootFile.lastChip << 16 | rebootFile.lastCopy;
|
||||
uint32_t p2 = rebootFile.img00Cnt << 24 | rebootFile.img01Cnt << 16 |
|
||||
rebootFile.img10Cnt << 8 | rebootFile.img11Cnt;
|
||||
uint32_t p2 = rebootFile.img00Cnt << 24 | rebootFile.img01Cnt << 16 | rebootFile.img10Cnt << 8 |
|
||||
rebootFile.img11Cnt;
|
||||
triggerEvent(REBOOT_MECHANISM_TRIGGERED, p1, p2);
|
||||
// Clear the boot flag
|
||||
rebootFile.bootFlag = false;
|
||||
}
|
||||
|
||||
if(rebootFile.mechanismNextChip != xsc::NO_CHIP and rebootFile.mechanismNextCopy != xsc::NO_COPY) {
|
||||
if(CURRENT_CHIP != rebootFile.mechanismNextChip or CURRENT_COPY != rebootFile.mechanismNextCopy) {
|
||||
if (rebootFile.mechanismNextChip != xsc::NO_CHIP and
|
||||
rebootFile.mechanismNextCopy != xsc::NO_COPY) {
|
||||
if (CURRENT_CHIP != rebootFile.mechanismNextChip or
|
||||
CURRENT_COPY != rebootFile.mechanismNextCopy) {
|
||||
std::string infoString = static_cast<int>(rebootFile.mechanismNextChip) + " " +
|
||||
static_cast<int>(rebootFile.mechanismNextCopy);
|
||||
sif::warning << "CoreController::performRebootFileHandling: Expected to be on image"
|
||||
<< infoString << " but currently on other image. Locking" << infoString
|
||||
<< std::endl;
|
||||
// Firmware or other component might be corrupt and we are on another image then the target
|
||||
// image specified by the mechanism. We can't really trust the target image anymore.
|
||||
// Lock it for now
|
||||
@ -101,9 +109,8 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
|
||||
if (doReboot) {
|
||||
rebootFile.bootFlag = true;
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
std::cout << "Boot counter for image " << CURRENT_CHIP << " " << CURRENT_COPY
|
||||
<< " too high. Rebooting to " << tgtChip << " " << tgtCopy
|
||||
<< std::endl;
|
||||
sif::info << "Boot counter for image " << CURRENT_CHIP << " " << CURRENT_COPY
|
||||
<< " too high. Rebooting to " << tgtChip << " " << tgtCopy << std::endl;
|
||||
#endif
|
||||
rebootFile.lastChip = CURRENT_CHIP;
|
||||
rebootFile.lastCopy = CURRENT_COPY;
|
||||
@ -118,7 +125,6 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
|
||||
xsc::Chip &tgtChip, xsc::Copy &tgtCopy) {
|
||||
tgtChip = xsc::CHIP_0;
|
||||
@ -130,7 +136,7 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
|
||||
if (rf.img01Cnt < rf.maxCount and not rf.img01Lock) {
|
||||
tgtCopy = xsc::COPY_1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (rf.img10Cnt < rf.maxCount and not rf.img10Lock) {
|
||||
tgtChip = xsc::CHIP_1;
|
||||
return;
|
||||
@ -141,7 +147,9 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
|
||||
return;
|
||||
}
|
||||
// Can't really do much here. Stay on image
|
||||
std::cout << "All reboot counts too high or all fallback images locked, already on fallback image" << std::endl;
|
||||
sif::warning
|
||||
<< "All reboot counts too high or all fallback images locked, already on fallback image"
|
||||
<< std::endl;
|
||||
needsReboot = false;
|
||||
return;
|
||||
}
|
||||
@ -160,12 +168,12 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
|
||||
tgtChip = xsc::CHIP_1;
|
||||
tgtCopy = xsc::COPY_1;
|
||||
}
|
||||
if(rf.img00Lock) {
|
||||
if (rf.img00Lock) {
|
||||
needsReboot = false;
|
||||
}
|
||||
// Reboot to fallback image
|
||||
}
|
||||
if ((CURRENT_CHIP == xsc::CHIP_1) and (CURRENT_COPY == xsc::COPY_0) and
|
||||
if ((CURRENT_CHIP == xsc::CHIP_1) and (CURRENT_COPY == xsc::COPY_0) and
|
||||
(rf.img10Cnt >= rf.maxCount)) {
|
||||
needsReboot = true;
|
||||
if (rf.img11Cnt < rf.maxCount and not rf.img11Lock) {
|
||||
@ -180,7 +188,7 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
|
||||
tgtCopy = xsc::COPY_1;
|
||||
return;
|
||||
}
|
||||
if(rf.img00Lock) {
|
||||
if (rf.img00Lock) {
|
||||
needsReboot = false;
|
||||
}
|
||||
// Reboot to fallback image
|
||||
@ -199,7 +207,7 @@ void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot
|
||||
tgtCopy = xsc::COPY_1;
|
||||
return;
|
||||
}
|
||||
if(rf.img00Lock) {
|
||||
if (rf.img00Lock) {
|
||||
needsReboot = false;
|
||||
}
|
||||
// Reboot to fallback image
|
||||
@ -382,7 +390,7 @@ bool CoreController::parseRebootFile(std::string path, RebootFile &rf) {
|
||||
}
|
||||
lineIdx++;
|
||||
}
|
||||
if (lineIdx < 8) {
|
||||
if (lineIdx < 12) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user