Compare commits

...

11 Commits

Author SHA1 Message Date
c12706ef05 Merge branch 'main' into auto-switch-image-feature
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
EIVE/eive-obsw/pipeline/head This commit looks good
2023-10-30 15:02:23 +01:00
8e1f95ebf2
Merge remote-tracking branch 'origin/main' into auto-switch-image-feature
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2023-10-30 14:45:13 +01:00
4e0842c607
add link
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2023-10-23 13:39:47 +02:00
4fd18e94fd
changelog
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2023-10-23 13:30:45 +02:00
18bcb434e9
tiny tweak
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2023-10-19 15:24:52 +02:00
f0ade7274a
works
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2023-10-19 15:23:23 +02:00
674202c6fb
delay
Some checks failed
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit
2023-10-19 15:18:39 +02:00
fecaad7af7
better printout 2023-10-19 15:18:06 +02:00
befe7ec441
bump tmtc
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2023-10-19 15:06:26 +02:00
01ce1f154e
that should get the job done
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2023-10-19 14:43:29 +02:00
2e210a0572
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
2023-10-19 13:31:43 +02:00
7 changed files with 71 additions and 2 deletions

View File

@ -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

View File

@ -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)) {

View File

@ -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;

View File

@ -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");

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();

View File

@ -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

@ -1 +1 @@
Subproject commit 99c6c8bbd0d791d8b17720de481c6142091a54a4
Subproject commit 92fe9d92def31d2f9d1c8cefe0ce4f244bcd1702