continuation of failed mpsoc update
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
@ -52,6 +52,18 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
case InternalState::CONTINUE_UPDATE: {
|
||||
result = continueUpdate();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(SUPV_CONTINUE_UPDATE_SUCCESSFUL, result);
|
||||
} else if (result == PROCESS_TERMINATED) {
|
||||
// Event already triggered
|
||||
} else {
|
||||
triggerEvent(SUPV_CONTINUE_UPDATE_FAILED, result);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
case InternalState::REQUEST_EVENT_BUFFER: {
|
||||
result = performEventBufferRequest();
|
||||
if (result == RETURN_OK) {
|
||||
@ -110,12 +122,21 @@ ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
|
||||
update.length = getFileSize(update.file);
|
||||
update.memoryId = memoryId;
|
||||
update.startAddress = startAddress;
|
||||
update.remainingSize = update.length;
|
||||
update.bytesWritten = 0;
|
||||
update.packetNum = 1;
|
||||
update.sequenceCount = 1;
|
||||
internalState = InternalState::UPDATE;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::initiateUpdateContinuation() {
|
||||
internalState = InternalState::CONTINUE_UPDATE;
|
||||
semaphore.release();
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::startEventbBufferRequest(std::string path) {
|
||||
#ifdef XIPHOS_Q7S
|
||||
ReturnValue_t result = FilesystemHelper::checkPath(path);
|
||||
@ -141,6 +162,10 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = selectMemory();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = prepareUpdate();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
@ -149,65 +174,87 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = writeUpdatePackets();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleCheckMemoryCommand();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::continueUpdate() {
|
||||
ReturnValue_t result = prepareUpdate();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = writeUpdatePackets();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleCheckMemoryCommand();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
||||
ProgressPrinter progressPrinter("Supervisor update", update.length,
|
||||
ProgressPrinter::HALF_PERCENT);
|
||||
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
||||
uint8_t tempData[supv::WriteMemory::CHUNK_MAX];
|
||||
std::ifstream file(update.file, std::ifstream::binary);
|
||||
size_t remainingSize = update.length;
|
||||
uint16_t dataLength = 0;
|
||||
size_t bytesWritten = 0;
|
||||
uint16_t sequenceCount = 1;
|
||||
uint32_t packetNum = 1;
|
||||
supv::SequenceFlags seqFlags = supv::SequenceFlags::FIRST_PKT;
|
||||
while (remainingSize > 0) {
|
||||
supv::SequenceFlags seqFlags;
|
||||
while (update.remainingSize > 0) {
|
||||
if (terminate) {
|
||||
terminate = false;
|
||||
return PROCESS_TERMINATED;
|
||||
}
|
||||
if (remainingSize > supv::WriteMemory::CHUNK_MAX) {
|
||||
if (update.remainingSize > supv::WriteMemory::CHUNK_MAX) {
|
||||
dataLength = supv::WriteMemory::CHUNK_MAX;
|
||||
} else {
|
||||
dataLength = static_cast<uint16_t>(remainingSize);
|
||||
dataLength = static_cast<uint16_t>(update.remainingSize);
|
||||
}
|
||||
if (file.is_open()) {
|
||||
file.seekg(bytesWritten, file.beg);
|
||||
file.seekg(update.bytesWritten, file.beg);
|
||||
file.read(reinterpret_cast<char*>(tempData), dataLength);
|
||||
if (!file) {
|
||||
sif::warning << "PlocSupvHelper::performUpdate: Read only " << file.gcount() << " of "
|
||||
<< dataLength << " bytes" << std::endl;
|
||||
sif::info << "PlocSupvHelper::performUpdate: Failed when trying to read byte "
|
||||
<< bytesWritten << std::endl;
|
||||
<< update.bytesWritten << std::endl;
|
||||
}
|
||||
remainingSize -= dataLength;
|
||||
} else {
|
||||
return FILE_CLOSED_ACCIDENTALLY;
|
||||
}
|
||||
if (bytesWritten == 0) {
|
||||
if (update.bytesWritten == 0) {
|
||||
seqFlags = supv::SequenceFlags::FIRST_PKT;
|
||||
} else if (remainingSize == 0) {
|
||||
} else if (update.remainingSize == 0) {
|
||||
seqFlags = supv::SequenceFlags::LAST_PKT;
|
||||
} else {
|
||||
seqFlags = supv::SequenceFlags::CONTINUED_PKT;
|
||||
}
|
||||
supv::WriteMemory packet(seqFlags, sequenceCount++, update.memoryId,
|
||||
update.startAddress + bytesWritten, dataLength, tempData);
|
||||
supv::WriteMemory packet(seqFlags, update.sequenceCount++, update.memoryId,
|
||||
update.startAddress + update.bytesWritten, dataLength, tempData);
|
||||
result = handlePacketTransmission(packet);
|
||||
if (result != RETURN_OK) {
|
||||
triggerEvent(WRITE_MEMORY_FAILED, packetNum);
|
||||
update.sequenceCount--;
|
||||
triggerEvent(WRITE_MEMORY_FAILED, update.packetNum);
|
||||
return result;
|
||||
}
|
||||
packetNum += 1;
|
||||
bytesWritten += dataLength;
|
||||
update.remainingSize -= dataLength;
|
||||
update.packetNum += 1;
|
||||
update.bytesWritten += dataLength;
|
||||
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
|
||||
progressPrinter.print(bytesWritten);
|
||||
progressPrinter.print(update.bytesWritten);
|
||||
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
|
||||
}
|
||||
result = handleCheckMemoryCommand();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -234,6 +281,16 @@ ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::selectMemory() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
supv::MPSoCBootSelect packet(update.memoryId);
|
||||
result = handlePacketTransmission(packet);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::prepareUpdate() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
supv::ApidOnlyPacket packet(supv::APID_PREPARE_UPDATE);
|
||||
|
Reference in New Issue
Block a user