adaptions and possible small fix for update process
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2023-04-13 12:08:31 +02:00
parent 99305846f8
commit ea606ce217
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 46 additions and 32 deletions

View File

@ -89,7 +89,7 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) {
break;
}
case InternalState::FIRMWARE_UPDATE: {
replyTimeout.setTimeout(200);
replyTimeout.setTimeout(2000);
resetReplyHandlingState();
result = performFirmwareUpdate();
if (result == returnvalue::OK) {
@ -390,7 +390,8 @@ ReturnValue_t StrComHandler::performFlashWrite() {
#endif
ReturnValue_t result = returnvalue::OK;
uint32_t size = 0;
uint32_t bytesWritten = 0;
uint32_t bytesWrittenInRegion = 0;
size_t totalBytesWritten = 0;
uint32_t fileSize = 0;
struct WriteActionRequest req;
@ -412,20 +413,18 @@ ReturnValue_t StrComHandler::performFlashWrite() {
ProgressPrinter progressPrinter("Flash write", fileSize);
#endif /* OBSW_DEBUG_STARTRACKER == 1 */
uint32_t fileChunks = fileSize / CHUNK_SIZE;
bytesWritten = 0;
bytesWrittenInRegion = 0;
req.region = flashWrite.firstRegion;
req.length = CHUNK_SIZE;
for (uint32_t idx = 0; idx < fileChunks; idx++) {
if (terminate) {
return returnvalue::OK;
}
file.seekg(idx * CHUNK_SIZE, file.beg);
auto writeNextSegment = [&](uint32_t chunkIdx) {
file.seekg(chunkIdx * CHUNK_SIZE, file.beg);
file.read(reinterpret_cast<char*>(req.data), CHUNK_SIZE);
if (bytesWritten + CHUNK_SIZE > FLASH_REGION_SIZE) {
if (bytesWrittenInRegion + CHUNK_SIZE > FLASH_REGION_SIZE) {
req.region++;
bytesWritten = 0;
bytesWrittenInRegion = 0;
}
req.address = bytesWritten;
req.address = bytesWrittenInRegion;
arc_pack_write_action_req(&req, cmdBuf.data(), &size);
result = sendAndRead(size, req.address);
if (result != returnvalue::OK) {
@ -435,26 +434,40 @@ ReturnValue_t StrComHandler::performFlashWrite() {
if (result != returnvalue::OK) {
return result;
}
bytesWritten += CHUNK_SIZE;
totalBytesWritten += CHUNK_SIZE;
bytesWrittenInRegion += CHUNK_SIZE;
#if OBSW_DEBUG_STARTRACKER == 1
progressPrinter.print(idx * CHUNK_SIZE);
progressPrinter.print(chunkIdx * CHUNK_SIZE);
#endif /* OBSW_DEBUG_STARTRACKER == 1 */
return result;
};
for (uint32_t idx = 0; idx < fileChunks; idx++) {
if (terminate) {
return returnvalue::OK;
}
result = writeNextSegment(idx);
if(result != returnvalue::OK) {
return result;
}
if (idx % 50 == 0) {
// Some grace time for other tasks
TaskFactory::delayTask(2);
}
}
uint32_t remainingBytes = fileSize - fileChunks * CHUNK_SIZE;
file.seekg((fileChunks - 1) * CHUNK_SIZE, file.beg);
if (remainingBytes > 0) {
file.seekg(fileChunks * CHUNK_SIZE, file.beg);
file.read(reinterpret_cast<char*>(req.data), remainingBytes);
file.close();
if (bytesWritten + CHUNK_SIZE > FLASH_REGION_SIZE) {
if (bytesWrittenInRegion + CHUNK_SIZE > FLASH_REGION_SIZE) {
req.region++;
bytesWritten = 0;
bytesWrittenInRegion = 0;
}
req.address = bytesWritten;
req.address = bytesWrittenInRegion;
req.length = remainingBytes;
bytesWritten += remainingBytes;
totalBytesWritten += CHUNK_SIZE;
bytesWrittenInRegion += remainingBytes;
arc_pack_write_action_req(&req, cmdBuf.data(), &size);
result = sendAndRead(size, req.address);
if (result != returnvalue::OK) {
@ -464,6 +477,7 @@ ReturnValue_t StrComHandler::performFlashWrite() {
if (result != returnvalue::OK) {
return result;
}
}
#if OBSW_DEBUG_STARTRACKER == 1
progressPrinter.print(fileSize);
#endif /* OBSW_DEBUG_STARTRACKER == 1 */

2
tmtc

@ -1 +1 @@
Subproject commit 01b3a894e66e7f38dd2e7a35e329e99a6199b7f1
Subproject commit 33fd280e517a55175072ea336c7f8e85bce6e55a