supervisor udpate wip
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -1486,44 +1486,47 @@ class UpdateInfo : public SupvTcSpacePacket {
|
||||
*/
|
||||
class UpdatePacket : public SupvTcSpacePacket {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param payloadLength Update data length (data field length without CRC)
|
||||
*/
|
||||
UpdatePacket(uint16_t payloadLength) : SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) {}
|
||||
|
||||
/**
|
||||
* @brief Returns the pointer to the beginning of the data field.
|
||||
*/
|
||||
uint8_t* getDataFieldPointer() { return this->localData.fields.buffer; }
|
||||
};
|
||||
/**
|
||||
* @brief Constrcutor
|
||||
*
|
||||
* @param updateData Pointer to buffer containing update data
|
||||
*/
|
||||
UpdatePacket(uint8_t memoryId, uint32_t startAddress, uint16_t length, uint8_t* updateData)
|
||||
: SupvTcSpacePacket(META_DATA_LENGTH + length, apid),
|
||||
memoryId(memoryId),
|
||||
startAddress(startAddress),
|
||||
length(length) {
|
||||
initPacket(updateData);
|
||||
makeCrc();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This dataset stores the boot status report of the supervisor.
|
||||
*/
|
||||
class BootStatusReport : public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
|
||||
public:
|
||||
BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {}
|
||||
static const uint16_t MAX_UPDATE_DATA = 1010;
|
||||
|
||||
BootStatusReport(object_id_t objectId)
|
||||
: StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {}
|
||||
private:
|
||||
static const uint16_t META_DATA_LENGTH = 8;
|
||||
|
||||
/** Information about boot status of MPSoC */
|
||||
lp_var_t<uint8_t> bootSignal = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_SIGNAL, this);
|
||||
lp_var_t<uint8_t> resetCounter = lp_var_t<uint8_t>(sid.objectId, PoolIds::RESET_COUNTER, this);
|
||||
/** Time the MPSoC needs for last boot */
|
||||
lp_var_t<uint32_t> bootAfterMs = lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_AFTER_MS, this);
|
||||
/** The currently set boot timeout */
|
||||
lp_var_t<uint32_t> bootTimeoutMs =
|
||||
lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this);
|
||||
lp_var_t<uint8_t> activeNvm = lp_var_t<uint8_t>(sid.objectId, PoolIds::ACTIVE_NVM, this);
|
||||
/** States of the boot partition pins */
|
||||
lp_var_t<uint8_t> bp0State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP0_STATE, this);
|
||||
lp_var_t<uint8_t> bp1State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP1_STATE, this);
|
||||
lp_var_t<uint8_t> bp2State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP2_STATE, this);
|
||||
lp_var_t<uint8_t> bootState = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_STATE, this);
|
||||
lp_var_t<uint8_t> bootCycles = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_CYCLES, this);
|
||||
uint8_t memoryId =0;
|
||||
uint8_t n = 1;
|
||||
uint32_t startAddress = 0;
|
||||
uint16_t length = 0;
|
||||
|
||||
void initPacket(uint8_t* updateData) {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* data_field_ptr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint8_t>(&memoryId, &data_field_ptr, &serializedSize,
|
||||
sizeof(memoryId), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint8_t>(&n, &data_field_ptr, &serializedSize,
|
||||
sizeof(n), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint32_t>(&startAddress, &data_field_ptr, &serializedSize,
|
||||
sizeof(startAddress), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint16_t>(&length, &data_field_ptr, &serializedSize,
|
||||
sizeof(length), SerializeIF::Endianness::BIG);
|
||||
std::memcpy(data_field_ptr, updateData, length);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1579,6 +1582,68 @@ class LatchupStatusReport : public StaticLocalDataSet<LATCHUP_RPT_SET_ENTRIES> {
|
||||
lp_var_t<uint8_t> timeYear =
|
||||
lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class for handling tm replies of the supervisor.
|
||||
*/
|
||||
class TmPacket : public SpacePacket, public MPSoCReturnValuesIF {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
|
||||
*/
|
||||
TmPacket() : SpacePacket(PACKET_MAX_SIZE) {}
|
||||
|
||||
ReturnValue_t checkCrc() {
|
||||
uint8_t* crcPtr = this->getPacketData() + this->getPacketDataLength() - 1;
|
||||
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
|
||||
uint16_t recalculatedCrc =
|
||||
CRC::crc16ccitt(this->localData.byteStream, this->getFullSize() - CRC_SIZE);
|
||||
if (recalculatedCrc != receivedCrc) {
|
||||
return CRC_FAILURE;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class can be used to package the update available or update verify command.
|
||||
*/
|
||||
class EraseMemory : public SupvTcSpacePacket {
|
||||
public:
|
||||
|
||||
EraseMemory(uint8_t memoryId, uint32_t startAddress, uint32_t length)
|
||||
: SupvTcSpacePacket(PAYLOAD_LENGTH, apid),
|
||||
memoryId(memoryId),
|
||||
startAddress(startAddress),
|
||||
length(length) {
|
||||
initPacket();
|
||||
makeCrc();
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint16_t PAYLOAD_LENGTH = 10; // length without CRC field
|
||||
|
||||
uint8_t memoryId =0;
|
||||
uint8_t n = 1;
|
||||
uint32_t startAddress = 0;
|
||||
uint32_t length = 0;
|
||||
|
||||
void initPacket() {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* data_field_ptr = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint8_t>(&memoryId, &data_field_ptr, &serializedSize,
|
||||
sizeof(memoryId), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint8_t>(&n, &data_field_ptr, &serializedSize,
|
||||
sizeof(n), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint32_t>(&startAddress, &data_field_ptr, &serializedSize,
|
||||
sizeof(startAddress), SerializeIF::Endianness::BIG);
|
||||
serializedSize = 0;
|
||||
SerializeAdapter::serialize<uint32_t>(&length, &data_field_ptr, &serializedSize,
|
||||
sizeof(length), SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
} // namespace supv
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */
|
||||
|
Reference in New Issue
Block a user