improved mount logic, create conf folder is missing
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
This commit is contained in:
parent
8e6d8a6fa8
commit
a2bc72a798
@ -59,7 +59,7 @@ ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) {
|
|||||||
void CoreController::performControlOperation() {
|
void CoreController::performControlOperation() {
|
||||||
performWatchdogControlOperation();
|
performWatchdogControlOperation();
|
||||||
sdStateMachine();
|
sdStateMachine();
|
||||||
performRebootFileHandling(false);
|
performMountedSdCardOperations();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||||
@ -94,7 +94,7 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sdStateMachine();
|
sdStateMachine();
|
||||||
result = initVersionFile();
|
performMountedSdCardOperations();
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
sif::warning << "CoreController::initialize: Version initialization failed" << std::endl;
|
sif::warning << "CoreController::initialize: Version initialization failed" << std::endl;
|
||||||
}
|
}
|
||||||
@ -1174,19 +1174,12 @@ void CoreController::performWatchdogControlOperation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::performRebootFileHandling(bool recreateFile) {
|
void CoreController::performRebootFileHandling(bool recreateFile) {
|
||||||
bool sdCardMounted = false;
|
|
||||||
if (not recreateFile and doPerformRebootFileHandling) {
|
|
||||||
sdCardMounted = sdcMan->isSdCardMounted(sdInfo.pref);
|
|
||||||
}
|
|
||||||
if ((doPerformRebootFileHandling and sdCardMounted) or recreateFile) {
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
if (recreateFile) {
|
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
||||||
|
if (not std::filesystem::exists(path) or recreateFile) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
|
||||||
if (not std::filesystem::exists(path) or recreateFile) {
|
|
||||||
rebootFile.enabled = true;
|
rebootFile.enabled = true;
|
||||||
rebootFile.img00Cnt = 0;
|
rebootFile.img00Cnt = 0;
|
||||||
rebootFile.img01Cnt = 0;
|
rebootFile.img01Cnt = 0;
|
||||||
@ -1269,8 +1262,6 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
|
|||||||
} else {
|
} else {
|
||||||
rewriteRebootFile(rebootFile);
|
rewriteRebootFile(rebootFile);
|
||||||
}
|
}
|
||||||
doPerformRebootFileHandling = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
|
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
|
||||||
@ -1520,6 +1511,22 @@ void CoreController::resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy) {
|
|||||||
rewriteRebootFile(rebootFile);
|
rewriteRebootFile(rebootFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoreController::performMountedSdCardOperations() {
|
||||||
|
if(doPerformMountedSdCardOps) {
|
||||||
|
bool sdCardMounted = false;
|
||||||
|
sdCardMounted = sdcMan->isSdCardMounted(sdInfo.pref);
|
||||||
|
if(sdCardMounted) {
|
||||||
|
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + "/" + CONF_FOLDER;
|
||||||
|
if(not std::filesystem::exists(path)) {
|
||||||
|
std::filesystem::create_directory(path);
|
||||||
|
}
|
||||||
|
initVersionFile();
|
||||||
|
performRebootFileHandling(true);
|
||||||
|
doPerformMountedSdCardOps = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CoreController::rewriteRebootFile(RebootFile file) {
|
void CoreController::rewriteRebootFile(RebootFile file) {
|
||||||
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
||||||
std::ofstream rebootFile(path);
|
std::ofstream rebootFile(path);
|
||||||
|
@ -43,8 +43,11 @@ class CoreController : public ExtendedControllerBase {
|
|||||||
static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh";
|
static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh";
|
||||||
static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt";
|
static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt";
|
||||||
static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt";
|
static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt";
|
||||||
static constexpr char VERSION_FILE[] = "/conf/version.txt";
|
static constexpr char CONF_FOLDER[] = "conf";
|
||||||
static constexpr char REBOOT_FILE[] = "/conf/reboot.txt";
|
static constexpr char VERSION_FILE_NAME[] = "version.txt";
|
||||||
|
static constexpr char REBOOT_FILE_NAME[] = "reboot.txt";
|
||||||
|
const std::string VERSION_FILE = "/" + std::string(CONF_FOLDER) + "/" + std::string(VERSION_FILE_NAME);
|
||||||
|
const std::string REBOOT_FILE = "/" + std::string(CONF_FOLDER) + "/" + std::string(REBOOT_FILE_NAME);
|
||||||
|
|
||||||
static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0;
|
static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0;
|
||||||
static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5;
|
static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5;
|
||||||
@ -162,7 +165,7 @@ class CoreController : public ExtendedControllerBase {
|
|||||||
sd::SdState commandedState = sd::SdState::OFF;
|
sd::SdState commandedState = sd::SdState::OFF;
|
||||||
} sdInfo;
|
} sdInfo;
|
||||||
RebootFile rebootFile = {};
|
RebootFile rebootFile = {};
|
||||||
bool doPerformRebootFileHandling = true;
|
bool doPerformMountedSdCardOps = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index 0: Chip 0 Copy 0
|
* Index 0: Chip 0 Copy 0
|
||||||
@ -177,7 +180,7 @@ class CoreController : public ExtendedControllerBase {
|
|||||||
LocalDataPoolManager& poolManager) override;
|
LocalDataPoolManager& poolManager) override;
|
||||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode);
|
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode);
|
||||||
|
void performMountedSdCardOperations();
|
||||||
ReturnValue_t initVersionFile();
|
ReturnValue_t initVersionFile();
|
||||||
ReturnValue_t initBootCopy();
|
ReturnValue_t initBootCopy();
|
||||||
ReturnValue_t initWatchdogFifo();
|
ReturnValue_t initWatchdogFifo();
|
||||||
@ -189,6 +192,7 @@ class CoreController : public ExtendedControllerBase {
|
|||||||
ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar,
|
ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar,
|
||||||
bool printOutput = true);
|
bool printOutput = true);
|
||||||
ReturnValue_t sdColdRedundantBlockingInit();
|
ReturnValue_t sdColdRedundantBlockingInit();
|
||||||
|
|
||||||
void currentStateSetter(sd::SdCard sdCard, sd::SdState newState);
|
void currentStateSetter(sd::SdCard sdCard, sd::SdState newState);
|
||||||
void determinePreferredSdCard();
|
void determinePreferredSdCard();
|
||||||
void executeNextExternalSdCommand();
|
void executeNextExternalSdCommand();
|
||||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit 2d9216ba19f1931225daa5b6b6f244a48c09f1b9
|
Subproject commit 6e0b90696da2dfd2ec4749dfdb73950be2283c25
|
@ -16,19 +16,12 @@ CoreController::CoreController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::performRebootFileHandling(bool recreateFile) {
|
void CoreController::performRebootFileHandling(bool recreateFile) {
|
||||||
bool sdCardMounted = false;
|
|
||||||
if (not recreateFile and doPerformRebootFileHandling) {
|
|
||||||
sdCardMounted = sdcMan->isSdCardMounted(sdInfo.pref);
|
|
||||||
}
|
|
||||||
if ((doPerformRebootFileHandling and sdCardMounted) or recreateFile) {
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
if (recreateFile) {
|
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
||||||
|
if (not std::filesystem::exists(path) or recreateFile) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
std::cout << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
std::cout << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
|
||||||
if (not std::filesystem::exists(path) or recreateFile) {
|
|
||||||
rebootFile.enabled = true;
|
rebootFile.enabled = true;
|
||||||
rebootFile.img00Cnt = 0;
|
rebootFile.img00Cnt = 0;
|
||||||
rebootFile.img01Cnt = 0;
|
rebootFile.img01Cnt = 0;
|
||||||
@ -111,10 +104,9 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
|
|||||||
} else {
|
} else {
|
||||||
rewriteRebootFile(rebootFile);
|
rewriteRebootFile(rebootFile);
|
||||||
}
|
}
|
||||||
doPerformRebootFileHandling = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
|
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
|
||||||
xsc::Chip &tgtChip, xsc::Copy &tgtCopy) {
|
xsc::Chip &tgtChip, xsc::Copy &tgtCopy) {
|
||||||
tgtChip = xsc::CHIP_0;
|
tgtChip = xsc::CHIP_0;
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
|
|
||||||
TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||||
CoreController ctrl;
|
CoreController ctrl;
|
||||||
std::cout << "Hello, world!\n";
|
ctrl.performRebootFileHandling(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user