separate branch for reboot file handling
This commit is contained in:
@ -2,6 +2,9 @@
|
||||
#define BSP_Q7S_CORE_CORECONTROLLER_H_
|
||||
|
||||
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
|
||||
#include <libxiphos.h>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "events/subsystemIdRanges.h"
|
||||
@ -10,24 +13,64 @@
|
||||
class Timer;
|
||||
class SdCardManager;
|
||||
|
||||
namespace xsc {
|
||||
|
||||
enum Chip : uint8_t { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP };
|
||||
enum Copy : uint8_t { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY };
|
||||
|
||||
} // namespace xsc
|
||||
|
||||
struct RebootFile {
|
||||
static constexpr uint8_t DEFAULT_MAX_BOOT_CNT = 10;
|
||||
|
||||
bool enabled = false;
|
||||
size_t maxCount = DEFAULT_MAX_BOOT_CNT;
|
||||
uint8_t img00Cnt = 0;
|
||||
uint8_t img01Cnt = 0;
|
||||
uint8_t img10Cnt = 0;
|
||||
uint8_t img11Cnt = 0;
|
||||
uint8_t relevantBootCnt = 0;
|
||||
bool bootFlag = false;
|
||||
xsc::Chip lastChip = xsc::Chip::CHIP_0;
|
||||
xsc::Copy lastCopy = xsc::Copy::COPY_0;
|
||||
};
|
||||
|
||||
class CoreController : public ExtendedControllerBase {
|
||||
public:
|
||||
enum Chip : uint8_t { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP };
|
||||
|
||||
enum Copy : uint8_t { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY };
|
||||
static xsc::Chip CURRENT_CHIP;
|
||||
static xsc::Copy CURRENT_COPY;
|
||||
|
||||
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 CURR_COPY_FILE[] = "/tmp/curr_copy.txt";
|
||||
static constexpr char VERSION_FILE[] = "/conf/sd_status";
|
||||
static constexpr char VERSION_FILE[] = "/conf/version.txt";
|
||||
static constexpr char REBOOT_FILE[] = "/conf/reboot.txt";
|
||||
|
||||
static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0;
|
||||
static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5;
|
||||
static constexpr ActionId_t RESET_ALL_REBOOT_COUNTERS = 6;
|
||||
static constexpr ActionId_t RESET_REBOOT_COUNTER_00 = 7;
|
||||
static constexpr ActionId_t RESET_REBOOT_COUNTER_01 = 8;
|
||||
static constexpr ActionId_t RESET_REBOOT_COUNTER_10 = 9;
|
||||
static constexpr ActionId_t RESET_REBOOT_COUNTER_11 = 10;
|
||||
static constexpr ActionId_t SET_MAX_REBOOT_CNT = 11;
|
||||
|
||||
static constexpr ActionId_t REBOOT_OBC = 32;
|
||||
static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
|
||||
|
||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
||||
|
||||
static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] Software reboot occured. Can also be a systemd reboot.
|
||||
//! P1: Current Chip, P2: Current Copy
|
||||
static constexpr Event REBOOT_SW = event::makeEvent(SUBSYSTEM_ID, 1, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] The reboot mechanism was triggered.
|
||||
//! P1: First 16 bits: Last Chip, Last 16 bits: Last Copy,
|
||||
//! P2: Each byte is the respective reboot count for the slots
|
||||
static constexpr Event REBOOT_MECHANISM_TRIGGERED =
|
||||
event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM);
|
||||
//! Trying to find a way how to determine that the reboot came from ProASIC3 or PCDU..
|
||||
static constexpr Event REBOOT_HW = event::makeEvent(SUBSYSTEM_ID, 3, severity::MEDIUM);
|
||||
|
||||
CoreController(object_id_t objectId);
|
||||
virtual ~CoreController();
|
||||
@ -48,7 +91,7 @@ class CoreController : public ExtendedControllerBase {
|
||||
*/
|
||||
static ReturnValue_t generateChipStateFile();
|
||||
static ReturnValue_t incrementAllocationFailureCount();
|
||||
static void getCurrentBootCopy(Chip& chip, Copy& copy);
|
||||
static void getCurrentBootCopy(xsc::Chip& chip, xsc::Copy& copy);
|
||||
|
||||
ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true);
|
||||
|
||||
@ -63,15 +106,12 @@ class CoreController : public ExtendedControllerBase {
|
||||
* @param updateProtFile Specify whether the protection info file is updated
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect,
|
||||
ReturnValue_t setBootCopyProtection(xsc::Chip targetChip, xsc::Copy targetCopy, bool protect,
|
||||
bool& protOperationPerformed, bool updateProtFile = true);
|
||||
|
||||
bool sdInitFinished() const;
|
||||
|
||||
private:
|
||||
static Chip CURRENT_CHIP;
|
||||
static Copy CURRENT_COPY;
|
||||
|
||||
// Designated value for rechecking FIFO open
|
||||
static constexpr int RETRY_FIFO_OPEN = -2;
|
||||
int watchdogFifoFd = 0;
|
||||
@ -122,6 +162,8 @@ class CoreController : public ExtendedControllerBase {
|
||||
sd::SdState commandedState = sd::SdState::OFF;
|
||||
};
|
||||
SdInfo sdInfo;
|
||||
RebootFile rebootFile = {};
|
||||
bool doPerformRebootFileHandling = true;
|
||||
|
||||
/**
|
||||
* Index 0: Chip 0 Copy 0
|
||||
@ -152,6 +194,7 @@ class CoreController : public ExtendedControllerBase {
|
||||
void determinePreferredSdCard();
|
||||
void executeNextExternalSdCommand();
|
||||
void checkExternalSdCommandStatus();
|
||||
void performRebootFileHandling(bool recreateFile);
|
||||
|
||||
ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size);
|
||||
@ -160,9 +203,14 @@ class CoreController : public ExtendedControllerBase {
|
||||
void performWatchdogControlOperation();
|
||||
|
||||
ReturnValue_t handleProtInfoUpdateLine(std::string nextLine);
|
||||
int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect,
|
||||
int handleBootCopyProtAtIndex(xsc::Chip targetChip, xsc::Copy targetCopy, bool protect,
|
||||
bool& protOperationPerformed, bool selfChip, bool selfCopy,
|
||||
bool allChips, bool allCopies, uint8_t arrIdx);
|
||||
void determineAndExecuteReboot(RebootFile& rf, bool& needsReboot, xsc::Chip& tgtChip,
|
||||
xsc::Copy& tgtCopy);
|
||||
void resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy);
|
||||
bool parseRebootFile(std::string path, RebootFile& file);
|
||||
void rewriteRebootFile(RebootFile file);
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */
|
||||
|
Reference in New Issue
Block a user