star tracker flash read
This commit is contained in:
parent
3593f5ab8c
commit
e082f3973a
@ -1,8 +1,6 @@
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include <devConf.h>
|
||||
#include <fsfw/src/fsfw/osal/common/TcpTmTcBridge.h>
|
||||
#include <fsfw/src/fsfw/osal/common/TcpTmTcServer.h>
|
||||
#include <fsfw_hal/linux/uart/UartComIF.h>
|
||||
#include <fsfw_hal/linux/uart/UartCookie.h>
|
||||
#include <mission/devices/GPSHyperionHandler.h>
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
/**
|
||||
* @brief This is the main program and entry point for the egse (raspberry pi 4)
|
||||
* @brief This is the main program entry point for the egse (raspberry pi 4)
|
||||
* @return
|
||||
*/
|
||||
int main(void) {
|
||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit 3c06d2dbbb0d79608e003a8a3c89ae90cc71f409
|
||||
Subproject commit 09c1918c1fe36a07ce611a33ff20799187d8d962
|
@ -371,7 +371,7 @@ static const DeviceCommandId_t TRACKING = 47;
|
||||
static const DeviceCommandId_t VALIDATION = 48;
|
||||
static const DeviceCommandId_t ALGO = 49;
|
||||
static const DeviceCommandId_t CHECKSUM = 50;
|
||||
static const DeviceCommandId_t READ = 51;
|
||||
static const DeviceCommandId_t FLASH_READ = 51;
|
||||
static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53;
|
||||
static const DeviceCommandId_t STOP_IMAGE_LOADER = 55;
|
||||
static const DeviceCommandId_t RESET_ERROR = 56;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -48,6 +48,8 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
|
||||
void performOperationHook() override;
|
||||
|
||||
Submode_t getInitialSubmode() override;
|
||||
|
||||
static const Submode_t SUBMODE_BOOTLOADER = 1;
|
||||
static const Submode_t SUBMODE_FIRMWARE = 2;
|
||||
|
||||
@ -183,11 +185,8 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
|
||||
class ReadCmd {
|
||||
public:
|
||||
static const uint8_t ADDRESS_OFFSET = 1;
|
||||
static const uint8_t LENGTH_OFFSET = 5;
|
||||
static const uint8_t FILE_OFFSET = 9;
|
||||
// Minimum length of a read command (region, address, length and filename)
|
||||
static const size_t MIN_LENGTH = 11;
|
||||
// Minimum length of a read command (region, length and filename)
|
||||
static const size_t MIN_LENGTH = 7;
|
||||
};
|
||||
|
||||
class EraseCmd {
|
||||
@ -408,7 +407,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
*
|
||||
* @return RETURN_OK if start of execution was successful, otherwise error return value
|
||||
*/
|
||||
ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t executeFlashReadCommand(const uint8_t* commandData, size_t commandDataLen);
|
||||
|
||||
/**
|
||||
* @brief Fills command buffer with data to boot image (works only when star tracker is
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -118,11 +118,10 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
|
||||
* @brief Starts the flash read procedure
|
||||
*
|
||||
* @param path Path where file with read flash data will be created
|
||||
* @param region Region ID of flash region to read from
|
||||
* @param address Start address of flash section to read
|
||||
* @param startRegion Region form where to start reading
|
||||
* @param length Number of bytes to read from flash
|
||||
*/
|
||||
ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, uint32_t length);
|
||||
ReturnValue_t startFlashRead(std::string path, uint8_t startRegion, uint32_t length);
|
||||
|
||||
/**
|
||||
* @brief Can be used to interrupt a running data transfer.
|
||||
@ -191,7 +190,7 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
|
||||
static const uint8_t ADDRESS_OFFSET = 3;
|
||||
static const uint8_t LENGTH_OFFSET = 7;
|
||||
static const size_t CHUNK_SIZE = 1024;
|
||||
static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 2000;
|
||||
static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3;
|
||||
static const uint32_t FLASH_ERASE_DELAY = 500;
|
||||
|
||||
enum class InternalState {
|
||||
@ -245,10 +244,7 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
|
||||
// Default name of file containing the data read from flash, can be changed via command
|
||||
std::string filename = "flashread.bin";
|
||||
// Will be set with the flash read command
|
||||
uint8_t region = 0;
|
||||
// Will be set with the flash read command and specifies the start address of the flash section
|
||||
// to read
|
||||
uint32_t address = 0;
|
||||
uint8_t startRegion = 0;
|
||||
// Number of bytes to read from flash
|
||||
uint32_t size = 0;
|
||||
};
|
||||
@ -372,7 +368,15 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
|
||||
*/
|
||||
ReturnValue_t unlockAndEraseRegions(uint32_t from, uint32_t to);
|
||||
|
||||
std::string makeFilename();
|
||||
/**
|
||||
* @brief Creates full filename either with timestamp or without
|
||||
*
|
||||
* @param path Path where to create the file
|
||||
* @param filename Name fo the file
|
||||
*
|
||||
* @return Full filename
|
||||
*/
|
||||
std::string makeFullFilename(std::string path, std::string filename);
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user