start impl auto switch feature
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-10-19 13:31:43 +02:00
parent 4ee84c0a78
commit 2e210a0572
Signed by: muellerr
GPG Key ID: A649FB78196E3849
3 changed files with 31 additions and 1 deletions

View File

@ -76,7 +76,6 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil
int result = std::system(oss.str().c_str());
if (result != 0) {
if (WEXITSTATUS(result) == 1) {
sif::warning << "scratch::readToFile: Key " << name << " does not exist" << std::endl;
// Could not find value
std::remove(filename.c_str());
return KEY_NOT_FOUND;

View File

@ -10,6 +10,7 @@
#include "OBSWConfig.h"
#include "bsp_q7s/core/WatchdogHandler.h"
#include "memory/scratchApi.h"
#include "commonConfig.h"
#include "fsfw/tasks/TaskFactory.h"
#include "fsfw/version.h"
@ -18,6 +19,7 @@
#include "mission/system/systemTree.h"
#include "q7sConfig.h"
#include "scheduling.h"
#include <libxiphos.h>
#include "watchdog/definitions.h"
static constexpr int OBSW_ALREADY_RUNNING = -2;
@ -50,6 +52,8 @@ int obsw::obsw(int argc, char* argv[]) {
}
#endif
autoSwitchHandling();
// Delay the boot if applicable.
bootDelayHandling();
@ -82,6 +86,27 @@ int obsw::obsw(int argc, char* argv[]) {
return 0;
}
void obsw::autoSwitchHandling() {
std::string autoSwitchTarget;
auto switchToTarget = [](xsc_libnor_chip_t chip, xsc_libnor_copy_t copy) {
scratch::clearValue("ASWI");
xsc_boot_copy(chip, copy);
};
if (scratch::readString("ASWI", autoSwitchTarget) == returnvalue::OK) {
if (autoSwitchTarget == "00") {
switchToTarget(XSC_LIBNOR_CHIP_0, XSC_LIBNOR_COPY_NOMINAL);
} else if (autoSwitchTarget == "01") {
switchToTarget(XSC_LIBNOR_CHIP_0, XSC_LIBNOR_COPY_GOLD);
} else if (autoSwitchTarget == "10") {
switchToTarget(XSC_LIBNOR_CHIP_1, XSC_LIBNOR_COPY_NOMINAL);
} else if(autoSwitchTarget == "11") {
switchToTarget(XSC_LIBNOR_CHIP_1, XSC_LIBNOR_COPY_GOLD);
} else {
sif::warning << "Invalid Auto Switch Image (ASWI) value detected: " << autoSwitchTarget << std::endl;
}
}
}
void obsw::bootDelayHandling() {
const char* homedir = nullptr;
homedir = getenv("HOME");

View File

@ -5,6 +5,12 @@ namespace obsw {
int obsw(int argc, char* argv[]);
/**
* This is a safety mechanism where the ProASIC scratch buffer can be used to trigger an
* auto-boot to another image. The auto-boot is currently implemented as a one-shot mechanism:
* The key-value pair which triggers the auto-boot will be removed from the scratch buffer.
*/
void autoSwitchHandling();
void bootDelayHandling();
void commandEiveSystemToSafe();
void commandComSubsystemRxOnly();