start impl auto switch feature
This commit is contained in:
parent
4ee84c0a78
commit
2e210a0572
@ -76,7 +76,6 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil
|
|||||||
int result = std::system(oss.str().c_str());
|
int result = std::system(oss.str().c_str());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
if (WEXITSTATUS(result) == 1) {
|
if (WEXITSTATUS(result) == 1) {
|
||||||
sif::warning << "scratch::readToFile: Key " << name << " does not exist" << std::endl;
|
|
||||||
// Could not find value
|
// Could not find value
|
||||||
std::remove(filename.c_str());
|
std::remove(filename.c_str());
|
||||||
return KEY_NOT_FOUND;
|
return KEY_NOT_FOUND;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "bsp_q7s/core/WatchdogHandler.h"
|
#include "bsp_q7s/core/WatchdogHandler.h"
|
||||||
|
#include "memory/scratchApi.h"
|
||||||
#include "commonConfig.h"
|
#include "commonConfig.h"
|
||||||
#include "fsfw/tasks/TaskFactory.h"
|
#include "fsfw/tasks/TaskFactory.h"
|
||||||
#include "fsfw/version.h"
|
#include "fsfw/version.h"
|
||||||
@ -18,6 +19,7 @@
|
|||||||
#include "mission/system/systemTree.h"
|
#include "mission/system/systemTree.h"
|
||||||
#include "q7sConfig.h"
|
#include "q7sConfig.h"
|
||||||
#include "scheduling.h"
|
#include "scheduling.h"
|
||||||
|
#include <libxiphos.h>
|
||||||
#include "watchdog/definitions.h"
|
#include "watchdog/definitions.h"
|
||||||
|
|
||||||
static constexpr int OBSW_ALREADY_RUNNING = -2;
|
static constexpr int OBSW_ALREADY_RUNNING = -2;
|
||||||
@ -50,6 +52,8 @@ int obsw::obsw(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
autoSwitchHandling();
|
||||||
|
|
||||||
// Delay the boot if applicable.
|
// Delay the boot if applicable.
|
||||||
bootDelayHandling();
|
bootDelayHandling();
|
||||||
|
|
||||||
@ -82,6 +86,27 @@ int obsw::obsw(int argc, char* argv[]) {
|
|||||||
return 0;
|
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() {
|
void obsw::bootDelayHandling() {
|
||||||
const char* homedir = nullptr;
|
const char* homedir = nullptr;
|
||||||
homedir = getenv("HOME");
|
homedir = getenv("HOME");
|
||||||
|
@ -5,6 +5,12 @@ namespace obsw {
|
|||||||
|
|
||||||
int obsw(int argc, char* argv[]);
|
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 bootDelayHandling();
|
||||||
void commandEiveSystemToSafe();
|
void commandEiveSystemToSafe();
|
||||||
void commandComSubsystemRxOnly();
|
void commandComSubsystemRxOnly();
|
||||||
|
Loading…
Reference in New Issue
Block a user