v1.9.0 #175

Merged
muellerr merged 623 commits from develop into main 2022-03-08 10:32:41 +01:00
4 changed files with 58 additions and 30 deletions
Showing only changes of commit 4edbbf223c - Show all commits

View File

@ -269,8 +269,11 @@ class StarTrackerHandler : public DeviceHandlerBase {
// Countdown to insert delay for star tracker to switch from bootloader to firmware program
Countdown bootCountdown;
std::string paramJsonFile = "/mnt/sd0/startracker/full.json";
#if OBSW_STAR_TRACKER_GROUND_CONFIG == 1
std::string paramJsonFile = "/mnt/sd0/startracker/ground-config.json";
#else
std::string paramJsonFile = "/mnt/sd0/startracker/flight-config.json";
#endif
enum class InternalState { TEMPERATURE_REQUEST };
InternalState internalState = InternalState::TEMPERATURE_REQUEST;

View File

@ -48,16 +48,6 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
internalState = InternalState::IDLE;
break;
}
case InternalState::FLASH_WRITE: {
result = performFlashWrite();
if (result == RETURN_OK) {
triggerEvent(FLASH_WRITE_SUCCESSFUL);
} else {
triggerEvent(FLASH_WRITE_FAILED);
}
internalState = InternalState::IDLE;
break;
}
case InternalState::FLASH_READ: {
result = performFlashRead();
if (result == RETURN_OK) {
@ -88,6 +78,16 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
internalState = InternalState::IDLE;
break;
}
case InternalState::FIRMWARE_UPDATE: {
result = performFirmwareUpdate();
if (result == RETURN_OK) {
triggerEvent(FIRMWARE_UPDATE_SUCCESSFUL);
} else {
triggerEvent(FIRMWARE_UPDATE_FAILED);
}
internalState = InternalState::IDLE;
break;
}
default:
sif::debug << "StrHelper::performOperation: Invalid state" << std::endl;
break;
@ -144,7 +144,7 @@ void StrHelper::setFlashReadFilename(std::string filename) { flashRead.filename
void StrHelper::setDownloadFpgaImage(std::string filename) { fpgaDownload.fileName = filename; }
ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, uint32_t address) {
ReturnValue_t StrHelper::startFirmwareUpdate(std::string fullname) {
ReturnValue_t result = checkPath(fullname);
if (result != RETURN_OK) {
return result;
@ -153,9 +153,9 @@ ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, u
if (not std::filesystem::exists(flashWrite.fullname)) {
return FILE_NOT_EXISTS;
}
flashWrite.address = address;
flashWrite.region = region;
internalState = InternalState::FLASH_WRITE;
flashWrite.address = 0;
flashWrite.region = static_cast<uint8_t>(RegionId::MAIN_FIRMWARE_SECTION);
internalState = InternalState::FIRMWARE_UPDATE;
semaphore.release();
terminate = false;
return RETURN_OK;
@ -316,6 +316,20 @@ ReturnValue_t StrHelper::performImageUpload() {
return RETURN_OK;
}
ReturnValue_t StrHelper::performFirmwareUpdate() {
ReturnValue_t result = RETURN_OK;
result = unlock(flashWrite.region);
if (result != RETURN_OK) {
return result;
}
eraseF(flashWrite.region);
if (result != RETURN_OK) {
return result;
}
result = performFlashWrite();
return result;
}
ReturnValue_t StrHelper::performFlashWrite() {
ReturnValue_t result = RETURN_OK;
uint32_t size = 0;

View File

@ -48,37 +48,41 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW);
//! [EXPORT] : [COMMENT] Upload of FPGA image failed
static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW);
//! [EXPORT] : [COMMENT] Firmware update was successful
static const Event FIRMWARE_UPDATE_SUCCESSFUL = MAKE_EVENT(12, severity::LOW);
//! [EXPORT] : [COMMENT] Firmware update failed
static const Event FIRMWARE_UPDATE_FAILED = MAKE_EVENT(13, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to read communication interface reply data
//! P1: Return code of failed communication interface read call
//! P1: Upload/download position for which the read call failed
static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW);
static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(14, severity::LOW);
//! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence
//! P1: Return code of failed communication interface read call
//! P1: Upload/download position for which the read call failed
static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW);
static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(15, severity::LOW);
//! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off)
//! P1: Position of upload or download packet for which no reply was sent
static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW);
static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(16, severity::LOW);
//! [EXPORT] : [COMMENT] Error during decoding of received reply occurred
// P1: Return value of decoding function
// P2: Position of upload/download packet, or address of flash write/read request
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW);
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(17, severity::LOW);
//! [EXPORT] : [COMMENT] Position mismatch
//! P1: The expected position and thus the position for which the image upload/download failed
static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW);
static const Event POSITION_MISMATCH = MAKE_EVENT(18, severity::LOW);
//! [EXPORT] : [COMMENT] Specified file does not exist
//! P1: Internal state of str helper
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW);
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(19, severity::LOW);
//! [EXPORT] : [COMMENT] Sending packet to star tracker failed
//! P1: Return code of communication interface sendMessage function
//! P2: Position of upload/download packet, or address of flash write/read request for which
//! sending failed
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW);
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(20, severity::LOW);
//! [EXPORT] : [COMMENT] Communication interface requesting reply failed
//! P1: Return code of failed request
//! P1: Upload/download position, or address of flash write/read request for which transmission
//! failed
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW);
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(21, severity::LOW);
StrHelper(object_id_t objectId);
virtual ~StrHelper();
@ -105,13 +109,12 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
ReturnValue_t startImageDownload(std::string path);
/**
* @brief Starts the flash write procedure
* @brief Will start the firmware update
*
* @param fullname Full name including absolute path of file to write to flash
* @param region Region ID of flash region to write to
* @param address Start address of flash write procedure
* @param fullname Full name including absolute path of file containing firmware
* update.
*/
ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address);
ReturnValue_t startFirmwareUpdate(std::string fullname);
/**
* @brief Starts the flash read procedure
@ -234,7 +237,8 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
FLASH_WRITE,
FLASH_READ,
DOWNLOAD_FPGA_IMAGE,
UPLOAD_FPGA_IMAGE
UPLOAD_FPGA_IMAGE,
FIRMWARE_UPDATE
};
InternalState internalState = InternalState::IDLE;
@ -287,6 +291,12 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
};
FlashRead flashRead;
enum class RegionId : uint8_t {
BOOTLOADER_SECTION = 0,
MAIN_FIRMWARE_SECTION = 1,
ARC_CONFIG_SECTION = 2,
};
SdCardManager* sdcMan = nullptr;
uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE];

View File

@ -54,6 +54,7 @@ debugging. */
#define OBSW_ADD_SYRLINKS 0
#define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0
#define OBSW_SYRLINKS_SIMULATED 1
#define OBSW_STAR_TRACKER_GROUND_CONFIG 1
#endif