star tracker flash read
This commit is contained in:
@ -141,7 +141,6 @@ ReturnValue_t StrHelper::startFirmwareUpdate(std::string fullname) {
|
||||
if (not std::filesystem::exists(flashWrite.fullname)) {
|
||||
return FILE_NOT_EXISTS;
|
||||
}
|
||||
flashWrite.address = 0;
|
||||
flashWrite.firstRegion = static_cast<uint8_t>(startracker::FirmwareRegions::FIRST);
|
||||
flashWrite.lastRegion = static_cast<uint8_t>(startracker::FirmwareRegions::LAST);
|
||||
internalState = InternalState::FIRMWARE_UPDATE;
|
||||
@ -150,8 +149,7 @@ ReturnValue_t StrHelper::startFirmwareUpdate(std::string fullname) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, uint32_t address,
|
||||
uint32_t length) {
|
||||
ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t startRegion, uint32_t length) {
|
||||
#ifdef XIPHOS_Q7S
|
||||
ReturnValue_t result = checkPath(path);
|
||||
if (result != RETURN_OK) {
|
||||
@ -162,8 +160,7 @@ ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, uint32
|
||||
if (not std::filesystem::exists(flashRead.path)) {
|
||||
return FILE_NOT_EXISTS;
|
||||
}
|
||||
flashRead.address = address;
|
||||
flashRead.region = region;
|
||||
flashRead.startRegion = startRegion;
|
||||
flashRead.size = length;
|
||||
internalState = InternalState::FLASH_READ;
|
||||
semaphore.release();
|
||||
@ -184,8 +181,7 @@ ReturnValue_t StrHelper::performImageDownload() {
|
||||
struct DownloadActionRequest downloadReq;
|
||||
uint32_t size = 0;
|
||||
uint32_t retries = 0;
|
||||
std::string image = makeFilename();
|
||||
// std::ofstream file(image, std::ios_base::app | std::ios_base::out);
|
||||
std::string image = makeFullFilename(downloadImage.path, downloadImage.filename);
|
||||
std::ofstream file(image, std::ios_base::out);
|
||||
if (not std::filesystem::exists(image)) {
|
||||
return FILE_CREATION_FAILED;
|
||||
@ -388,12 +384,13 @@ ReturnValue_t StrHelper::performFlashRead() {
|
||||
uint32_t size = 0;
|
||||
uint32_t retries = 0;
|
||||
Timestamp timestamp;
|
||||
std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename;
|
||||
std::string fullname = makeFullFilename(flashRead.path, flashRead.filename);
|
||||
std::ofstream file(fullname, std::ios_base::app | std::ios_base::out);
|
||||
if (not std::filesystem::exists(fullname)) {
|
||||
return FILE_CREATION_FAILED;
|
||||
}
|
||||
req.region = flashRead.region;
|
||||
req.region = flashRead.startRegion;
|
||||
req.address = 0;
|
||||
while (bytesRead < flashRead.size) {
|
||||
if (terminate) {
|
||||
return RETURN_OK;
|
||||
@ -403,7 +400,6 @@ ReturnValue_t StrHelper::performFlashRead() {
|
||||
} else {
|
||||
req.length = CHUNK_SIZE;
|
||||
}
|
||||
req.address = flashRead.address + bytesRead;
|
||||
arc_pack_read_action_req(&req, commandBuffer, &size);
|
||||
result = sendAndRead(size, req.address);
|
||||
if (result != RETURN_OK) {
|
||||
@ -425,19 +421,14 @@ ReturnValue_t StrHelper::performFlashRead() {
|
||||
file.close();
|
||||
return result;
|
||||
}
|
||||
result = checkActionReply();
|
||||
if (result != RETURN_OK) {
|
||||
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
|
||||
uartComIF->flushUartRxBuffer(comCookie);
|
||||
retries++;
|
||||
continue;
|
||||
}
|
||||
file.close();
|
||||
return result;
|
||||
}
|
||||
file.write(reinterpret_cast<const char*>(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET),
|
||||
req.length);
|
||||
bytesRead += req.length;
|
||||
req.address += req.length;
|
||||
if (req.address >= FLASH_REGION_SIZE) {
|
||||
req.address = 0;
|
||||
req.region++;
|
||||
}
|
||||
retries = 0;
|
||||
}
|
||||
file.close();
|
||||
@ -585,14 +576,14 @@ ReturnValue_t StrHelper::unlockAndEraseRegions(uint32_t from, uint32_t to) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string StrHelper::makeFilename() {
|
||||
std::string StrHelper::makeFullFilename(std::string path, std::string filename) {
|
||||
std::string image;
|
||||
Timestamp timestamp;
|
||||
if (timestamping) {
|
||||
image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename;
|
||||
image = path + "/" + timestamp.str() + filename;
|
||||
}
|
||||
else {
|
||||
image = downloadImage.path + "/" + downloadImage.filename;
|
||||
image = path + "/" + filename;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
Reference in New Issue
Block a user