Merge branch 'v4.0.0-dev' into extend-cp-helper
Some checks are pending
EIVE/eive-obsw/pipeline/pr-v4.0.0-dev Build queued...

This commit is contained in:
Robin Müller 2023-06-22 16:44:39 +02:00
commit 4c66d8fb5f
5 changed files with 104 additions and 22 deletions

View File

@ -32,11 +32,15 @@ will consitute of a breaking change warranting a new major release:
- Removed PTME busy/ready signals. Those were not used anyway because register reads are used now.
- APB bus access busy checking is not done anymore as this is performed by the bus itself now.
- Core controller will now announce version and image information event in addition to reboot
event in the `inititalize` function.
- Added core controller action to read reboot mechansm information
## Added
- Added PL I2C reset pin. It is not used for now but could be used for FDIR procedures to restore
the PL I2C.
- Core controller now announces firmware version as well when requesting a version info event
# [v3.3.0] 2023-06-21

View File

@ -171,6 +171,8 @@ ReturnValue_t CoreController::initialize() {
sdStateMachine();
triggerEvent(core::REBOOT_SW, CURRENT_CHIP, CURRENT_COPY);
announceCurrentImageInfo();
announceVersionInfo();
EventManagerIF *eventManager =
ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (eventManager == nullptr or eventQueue == nullptr) {
@ -220,24 +222,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
using namespace core;
switch (actionId) {
case (ANNOUNCE_VERSION): {
uint32_t p1 = (common::OBSW_VERSION_MAJOR << 24) | (common::OBSW_VERSION_MINOR << 16) |
(common::OBSW_VERSION_REVISION << 8);
uint32_t p2 = 0;
if (strcmp("", common::OBSW_VERSION_CST_GIT_SHA1) != 0) {
p1 |= 1;
auto shaAsStr = std::string(common::OBSW_VERSION_CST_GIT_SHA1);
size_t posDash = shaAsStr.find("-");
auto gitHash = shaAsStr.substr(posDash + 2, 4);
// Only copy first 4 letters of git hash
memcpy(&p2, gitHash.c_str(), 4);
}
triggerEvent(VERSION_INFO, p1, p2);
if (mappedSysRomAddr != nullptr) {
uint32_t p1Firmware = *(reinterpret_cast<uint32_t *>(mappedSysRomAddr));
uint32_t p2Firmware = *(reinterpret_cast<uint32_t *>(mappedSysRomAddr) + 1);
triggerEvent(FIRMWARE_INFO, p1Firmware, p2Firmware);
}
announceVersionInfo();
return HasActionsIF::EXECUTION_FINISHED;
}
case (ANNOUNCE_BOOT_COUNTS): {
@ -245,7 +230,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
return HasActionsIF::EXECUTION_FINISHED;
}
case (ANNOUNCE_CURRENT_IMAGE): {
triggerEvent(CURRENT_IMAGE_INFO, CURRENT_CHIP, CURRENT_COPY);
announceCurrentImageInfo();
return HasActionsIF::EXECUTION_FINISHED;
}
case (LIST_DIRECTORY_INTO_FILE): {
@ -337,7 +322,6 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
return HasActionsIF::INVALID_PARAMETERS;
}
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
// Disable the reboot file mechanism
parseRebootFile(path, rebootFile);
if (data[0] == 0) {
rebootFile.enabled = false;
@ -350,6 +334,16 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
}
return HasActionsIF::EXECUTION_FINISHED;
}
case (READ_REBOOT_MECHANISM_INFO): {
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
parseRebootFile(path, rebootFile);
RebootMechanismPacket packet(rebootFile);
ReturnValue_t result = actionHelper.reportData(commandedBy, actionId, &packet);
if (result != returnvalue::OK) {
return result;
}
return HasActionsIF::EXECUTION_FINISHED;
}
case (RESET_REBOOT_COUNTERS): {
if (size == 0) {
resetRebootCount(xsc::ALL_CHIP, xsc::ALL_COPY);
@ -2016,7 +2010,6 @@ bool CoreController::parseRebootFile(std::string path, RebootFile &rf) {
void CoreController::resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy) {
std::string path = currMntPrefix + REBOOT_FILE;
// Disable the reboot file mechanism
parseRebootFile(path, rebootFile);
if (tgtChip == xsc::ALL_CHIP and tgtCopy == xsc::ALL_COPY) {
rebootFile.img00Cnt = 0;
@ -2423,6 +2416,33 @@ void CoreController::dirListingDumpHandler() {
}
}
void CoreController::announceVersionInfo() {
using namespace core;
uint32_t p1 = (common::OBSW_VERSION_MAJOR << 24) | (common::OBSW_VERSION_MINOR << 16) |
(common::OBSW_VERSION_REVISION << 8);
uint32_t p2 = 0;
if (strcmp("", common::OBSW_VERSION_CST_GIT_SHA1) != 0) {
p1 |= 1;
auto shaAsStr = std::string(common::OBSW_VERSION_CST_GIT_SHA1);
size_t posDash = shaAsStr.find("-");
auto gitHash = shaAsStr.substr(posDash + 2, 4);
// Only copy first 4 letters of git hash
memcpy(&p2, gitHash.c_str(), 4);
}
triggerEvent(VERSION_INFO, p1, p2);
if (mappedSysRomAddr != nullptr) {
uint32_t p1Firmware = *(reinterpret_cast<uint32_t *>(mappedSysRomAddr));
uint32_t p2Firmware = *(reinterpret_cast<uint32_t *>(mappedSysRomAddr) + 1);
triggerEvent(FIRMWARE_INFO, p1Firmware, p2Firmware);
}
}
void CoreController::announceCurrentImageInfo() {
using namespace core;
triggerEvent(CURRENT_IMAGE_INFO, CURRENT_CHIP, CURRENT_COPY);
}
bool CoreController::isNumber(const std::string &s) {
return !s.empty() && std::find_if(s.begin(), s.end(),
[](unsigned char c) { return !std::isdigit(c); }) == s.end();

View File

@ -45,6 +45,61 @@ struct RebootFile {
xsc::Copy mechanismNextCopy = xsc::Copy::NO_COPY;
};
class RebootMechanismPacket : public SerialLinkedListAdapter<SerializeIF> {
public:
RebootMechanismPacket(RebootFile& rf) {
enabled = rf.enabled;
maxCount = rf.maxCount;
img00Count = rf.img00Cnt;
img01Count = rf.img01Cnt;
img10Count = rf.img10Cnt;
img11Count = rf.img11Cnt;
img00Lock = rf.img00Lock;
img01Lock = rf.img01Lock;
img10Lock = rf.img10Lock;
img11Lock = rf.img11Lock;
lastChip = static_cast<uint8_t>(rf.lastChip);
lastCopy = static_cast<uint8_t>(rf.lastCopy);
nextChip = static_cast<uint8_t>(rf.mechanismNextChip);
nextCopy = static_cast<uint8_t>(rf.mechanismNextCopy);
setLinks();
}
private:
void setLinks() {
setStart(&enabled);
enabled.setNext(&maxCount);
maxCount.setNext(&img00Count);
img00Count.setNext(&img01Count);
img01Count.setNext(&img10Count);
img10Count.setNext(&img11Count);
img11Count.setNext(&img00Lock);
img00Lock.setNext(&img01Lock);
img01Lock.setNext(&img10Lock);
img10Lock.setNext(&img11Lock);
img11Lock.setNext(&lastChip);
lastChip.setNext(&lastCopy);
lastCopy.setNext(&nextChip);
nextChip.setNext(&nextCopy);
setLast(&nextCopy);
}
SerializeElement<uint8_t> enabled = false;
SerializeElement<uint32_t> maxCount = 0;
SerializeElement<uint32_t> img00Count = 0;
SerializeElement<uint32_t> img01Count = 0;
SerializeElement<uint32_t> img10Count = 0;
SerializeElement<uint32_t> img11Count = 0;
SerializeElement<uint8_t> img00Lock = false;
SerializeElement<uint8_t> img01Lock = false;
SerializeElement<uint8_t> img10Lock = false;
SerializeElement<uint8_t> img11Lock = false;
SerializeElement<uint8_t> lastChip = 0;
SerializeElement<uint8_t> lastCopy = 0;
SerializeElement<uint8_t> nextChip = 0;
SerializeElement<uint8_t> nextCopy = 0;
};
class CoreController : public ExtendedControllerBase, public ReceivesParameterMessagesIF {
public:
enum ParamId : uint8_t { PREF_SD = 0, NUM_IDS };
@ -289,6 +344,8 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe
bool parseRebootFile(std::string path, RebootFile& file);
void rewriteRebootFile(RebootFile file);
void announceBootCounts();
void announceVersionInfo();
void announceCurrentImageInfo();
void readHkData();
void dirListingDumpHandler();
bool isNumber(const std::string& s);

View File

@ -53,6 +53,7 @@ static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5;
static constexpr ActionId_t RESET_REBOOT_COUNTERS = 6;
static constexpr ActionId_t SWITCH_IMG_LOCK = 7;
static constexpr ActionId_t SET_MAX_REBOOT_CNT = 8;
static constexpr ActionId_t READ_REBOOT_MECHANISM_INFO = 9;
static constexpr ActionId_t OBSW_UPDATE_FROM_SD_0 = 10;
static constexpr ActionId_t OBSW_UPDATE_FROM_SD_1 = 11;

2
tmtc

@ -1 +1 @@
Subproject commit 1bb8bea8d92fef2c9ec58ea657b04b56635c16dd
Subproject commit daceb6bc1d85c3e63b4f2c777668e55223e6cabb