ploc supervisor update available command, wip

This commit is contained in:
Jakob.Meier 2021-07-25 20:42:24 +02:00
parent 8c1a5bd9ad
commit 0cd814db76
4 changed files with 134 additions and 23 deletions

2
fsfw

@ -1 +1 @@
Subproject commit c5b4b0136217219a4443d858f42c368af9b15f27
Subproject commit b83259592a1f0ae5af20b00d1aef813fa26cd350

View File

@ -110,6 +110,11 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT);
result = RETURN_OK;
break;
}
case(PLOC_SPV::UPDATE_AVAILABLE): {
prepareUpdateAvailableCmd();
result = RETURN_OK;
break;
}
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
@ -142,7 +147,9 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT);
this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT);
this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT);
this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, nullptr, PLOC_SPV::SIZE_HK_REPORT);
this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT);
this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &bootStatusReport,
PLOC_SPV::SIZE_BOOT_STATUS_REPORT);
}
ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start,
@ -441,34 +448,42 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET;
bootStatusReport.bootSignal = *(data + offset);
offest += 1;
offset += 1;
bootStatusReport.resetCounter = *(data + offset);
offest += 1;
offset += 1;
bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offest += 4;
offset += 4;
bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offest += 4;
offset += 4;
bootStatusReport.activeNvm = *(data + offset);
offest += 1;
offset += 1;
bootStatusReport.bp0State = *(data + offset);
offest += 1;
offset += 1;
bootStatusReport.bp1State = *(data + offset);
offest += 1;
offset += 1;
bootStatusReport.bp2State = *(data + offset);
nextReplyId = PLOC_SPV::EXE_REPORT;
#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_SUPERVISOR_DEBUG == 1
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " << static_cast<unsigned int>(bootStatusReport.bootSignal.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " << static_cast<unsigned int>(bootStatusReport.resetCounter.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " << bootStatusReport.bootAfterMs << " ms" << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << bootStatusReport.bootTimeoutMs << " ms" << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " << static_cast<unsigned int>(bootStatusReport.activeNvm.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " << static_cast<unsigned int>(bootStatusReport.bp0State) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " << static_cast<unsigned int>(bootStatusReport.bp1State) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " << static_cast<unsigned int>(bootStatusReport.bp2State) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: "
<< static_cast<unsigned int>(bootStatusReport.bootSignal.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: "
<< static_cast<unsigned int>(bootStatusReport.resetCounter.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: "
<< bootStatusReport.bootAfterMs << " ms" << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: "
<< bootStatusReport.bootTimeoutMs << " ms" << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: "
<< static_cast<unsigned int>(bootStatusReport.activeNvm.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: "
<< static_cast<unsigned int>(bootStatusReport.bp0State.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: "
<< static_cast<unsigned int>(bootStatusReport.bp1State.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: "
<< static_cast<unsigned int>(bootStatusReport.bp2State.value) << std::endl;
#endif
return result;
@ -493,6 +508,16 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
}
break;
}
case PLOC_SPV::GET_BOOT_STATUS_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
PLOC_SPV::BOOT_STATUS_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl;
}
break;
}
case PLOC_SPV::RESTART_MPSOC:
case PLOC_SPV::START_MPSOC:
case PLOC_SPV::SHUTDOWN_MPSOC:
@ -650,6 +675,29 @@ void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData)
nextReplyId = PLOC_SPV::ACK_REPORT;
}
void PlocSupervisorHandler::prepareUpdateAvailableCmd(const uint8_t * commandData) {
uint8_t offset = 0;
uint8_t imageSelect = *(commandData + offset);
offset += 1;
uint8_t imagePartition = *(commandData + offset);
offset += 1;
uint32_t imageSize = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
offset += 4;
uint32_t imageCrc = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
offset += 4;
uint32_t numberOfPackets = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
PLOC_SPV::UpdateAvailable packet(imageSelect, imagePartition, imageSize, imageCrc,
numberOfPackets);
memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = packet.getFullSize();
nextReplyId = PLOC_SPV::ACK_REPORT;
}
void PlocSupervisorHandler::disableAllReplies() {
DeviceReplyMap::iterator iter;

View File

@ -21,6 +21,8 @@ static const DeviceCommandId_t RESET_MPSOC = 8;
static const DeviceCommandId_t SET_TIME_REF = 9;
static const DeviceCommandId_t DISABLE_PERIOIC_HK_TRANSMISSION = 10;
static const DeviceCommandId_t GET_BOOT_STATUS_REPORT = 11;
/** Notifies the supervisor that a new update is available for the MPSoC */
static const DeviceCommandId_t UPDATE_AVAILABLE = 12;
/** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50;
@ -427,12 +429,73 @@ public:
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<uint32_t>(sid.objectId, PoolIds::ACTIVE_NVM, 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<uint32_t>(sid.objectId, PoolIds::BP0_STATE, this);
lp_var_t<uint8_t> bp1State = lp_var_t<uint32_t>(sid.objectId, PoolIds::BP1_STATE, this);
lp_var_t<uint8_t> bp2State = lp_var_t<uint32_t>(sid.objectId, PoolIds::BP2_STATE, this);
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);
};
}
/**
* @brief This class packages the command to notify the supervisor that a new update for the
* MPSoC is available.
*/
class UpdateAvailable: public SpacePacket {
public:
/**
* @brief Constructor
*
* @param imageSelect
* @param imagePartition
* @param imageSize
* @param imageCrc
* @param numberOfPackets
*/
UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize,
uint32_t imageCrc, uint32_t numberOfPackets) :
SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE,
DEFAULT_SEQUENCE_COUNT), imageSelect(imageSelect), imagePartition(
imagePartition), imageSize(imageSize), imageCrc(imageCrc), numberOfPackets(
numberOfPackets) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 16;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t imageSelect = 0;
uint8_t imagePartition = 0;
uint32_t imageSize = 0;
uint32_t imageCrc = 0;
uint32_t numberOfPackets = 0;
void initPacket() {
uint8_t offset = 0;
uint8_t* data_field_start = this->localData.fields.buffer;
std::memcpy(data_field_start + offset, &imageSelect, sizeof(imageSelect));
offset += 1;
std::memcpy(data_field_start + offset, &imagePartition, sizeof(imagePartition));
offset += 1;
std::memcpy(data_field_start + offset, &imageSize, sizeof(imageSize));
offset += 4;
std::memcpy(data_field_start + offset, &imageCrc, sizeof(imageCrc));
offset += 4;
std::memcpy(data_field_start + offset, &numberOfPackets, sizeof(numberOfPackets));
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
/* Add crc to packet data field of space packet */
size_t serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */

2
tmtc

@ -1 +1 @@
Subproject commit 2e942ec21e47485b9ab6416a0341b9ab8ec30543
Subproject commit 6352a6f272b3138257831fcd1f5d9ffcd4902681