WIP: Start impl auto switch feature #811
@ -16,6 +16,13 @@ will consitute of a breaking change warranting a new major release:
|
||||
|
||||
# [unreleased]
|
||||
|
||||
## Added
|
||||
|
||||
- Added a new 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.
|
||||
See more information [here](https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/OBC_Auto_Switch_Image)
|
||||
|
||||
# [v7.2.0] 2023-10-27
|
||||
|
||||
- `eive-tmtc` v5.10.1
|
||||
|
@ -359,6 +359,29 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
||||
case (OBSW_UPDATE_FROM_TMP): {
|
||||
return executeSwUpdate(SwUpdateSources::TMP_DIR, data, size);
|
||||
}
|
||||
case (ENABLE_AUTO_SWITCH): {
|
||||
if (size < 2) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
uint8_t chip = data[0];
|
||||
uint8_t copy = data[1];
|
||||
if (chip > 1 or copy > 1) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
std::string value = std::to_string(chip) + std::to_string(copy);
|
||||
ReturnValue_t result = scratch::writeString(scratch::AUTO_SWITCH_IMAGE, value);
|
||||
if (result == returnvalue::OK) {
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case (DISABLE_AUTO_SWITCH): {
|
||||
ReturnValue_t result = scratch::clearValue(scratch::AUTO_SWITCH_IMAGE);
|
||||
if (result != returnvalue::OK and result != scratch::KEY_NOT_FOUND) {
|
||||
return result;
|
||||
}
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (SWITCH_TO_SD_0): {
|
||||
if (not startSdStateMachine(sd::SdCard::SLOT_0, SdCfgMode::COLD_REDUNDANT, commandedBy,
|
||||
actionId)) {
|
||||
|
@ -19,6 +19,7 @@ namespace scratch {
|
||||
|
||||
static constexpr char PREFERED_SDC_KEY[] = "PREFSD";
|
||||
static constexpr char ALLOC_FAILURE_COUNT[] = "ALLOCERR";
|
||||
static constexpr char AUTO_SWITCH_IMAGE[] = "ASWI";
|
||||
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::SCRATCH_BUFFER;
|
||||
static constexpr ReturnValue_t KEY_NOT_FOUND = returnvalue::makeCode(INTERFACE_ID, 0);
|
||||
@ -76,7 +77,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;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "obsw.h"
|
||||
|
||||
#include <libxiphos.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@ -13,6 +14,7 @@
|
||||
#include "commonConfig.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/version.h"
|
||||
#include "memory/scratchApi.h"
|
||||
#include "mission/acs/defs.h"
|
||||
#include "mission/com/defs.h"
|
||||
#include "mission/system/systemTree.h"
|
||||
@ -50,6 +52,8 @@ int obsw::obsw(int argc, char* argv[]) {
|
||||
}
|
||||
#endif
|
||||
|
||||
autoSwitchHandling();
|
||||
|
||||
// Delay the boot if applicable.
|
||||
bootDelayHandling();
|
||||
|
||||
@ -82,6 +86,33 @@ 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) {
|
||||
sif::warning << "Detected ASWI=" << autoSwitchTarget
|
||||
<< " in ProASIC scratch buffer, auto-switching to image " << int(chip) << " "
|
||||
<< int(copy) << std::endl;
|
||||
scratch::clearValue(scratch::AUTO_SWITCH_IMAGE);
|
||||
// A bit of delay to ensure printout works..
|
||||
TaskFactory::delayTask(500);
|
||||
xsc_boot_copy(chip, copy);
|
||||
};
|
||||
if (scratch::readString(scratch::AUTO_SWITCH_IMAGE, 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");
|
||||
|
@ -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();
|
||||
|
@ -75,6 +75,8 @@ static constexpr ActionId_t OBSW_UPDATE_FROM_TMP = 12;
|
||||
static constexpr ActionId_t SWITCH_TO_SD_0 = 16;
|
||||
static constexpr ActionId_t SWITCH_TO_SD_1 = 17;
|
||||
static constexpr ActionId_t SWITCH_TO_BOTH_SD_CARDS = 18;
|
||||
static constexpr ActionId_t ENABLE_AUTO_SWITCH = 19;
|
||||
static constexpr ActionId_t DISABLE_AUTO_SWITCH = 20;
|
||||
|
||||
//! Reboot using the xsc_boot_copy command
|
||||
static constexpr ActionId_t XSC_REBOOT_OBC = 32;
|
||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit 99c6c8bbd0d791d8b17720de481c6142091a54a4
|
||||
Subproject commit 92fe9d92def31d2f9d1c8cefe0ce4f244bcd1702
|
Loading…
Reference in New Issue
Block a user