firmware update wip
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
parent
4edbbf223c
commit
18d018b7d7
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "objects/systemObjectList.h"
|
#include "objects/systemObjectList.h"
|
||||||
|
|
||||||
namespace StarTracker {
|
namespace startracker {
|
||||||
|
|
||||||
/** This is the address of the star tracker */
|
/** This is the address of the star tracker */
|
||||||
static const uint8_t ADDRESS = 33;
|
static const uint8_t ADDRESS = 33;
|
||||||
@ -373,6 +373,56 @@ static const uint8_t BOOTLOADER = 1;
|
|||||||
static const uint8_t FIRMWARE = 2;
|
static const uint8_t FIRMWARE = 2;
|
||||||
} // namespace Program
|
} // namespace Program
|
||||||
|
|
||||||
|
namespace region_secrets {
|
||||||
|
static const uint32_t REGION_0_SECRET = 0xd1a220d3;
|
||||||
|
static const uint32_t REGION_1_SECRET = 0xdc770fa8;
|
||||||
|
static const uint32_t REGION_2_SECRET = 0xdf9066b0;
|
||||||
|
static const uint32_t REGION_3_SECRET = 0x5f6a0423;
|
||||||
|
static const uint32_t REGION_4_SECRET = 0xbbaad5d8;
|
||||||
|
static const uint32_t REGION_5_SECRET = 0xa81c3678;
|
||||||
|
static const uint32_t REGION_6_SECRET = 0xe10f76f8;
|
||||||
|
static const uint32_t REGION_7_SECRET = 0x83220919;
|
||||||
|
static const uint32_t REGION_8_SECRET = 0xec37289d;
|
||||||
|
static const uint32_t REGION_9_SECRET = 0x27ac0ef8;
|
||||||
|
static const uint32_t REGION_10_SECRET = 0xf017e43d;
|
||||||
|
static const uint32_t REGION_11_SECRET = 0xbc7f7f49;
|
||||||
|
static const uint32_t REGION_12_SECRET = 0x42fedef6;
|
||||||
|
static const uint32_t REGION_13_SECRET = 0xe53cf10d;
|
||||||
|
static const uint32_t REGION_14_SECRET = 0xe862b70b;
|
||||||
|
static const uint32_t REGION_15_SECRET = 0x79b537ca;
|
||||||
|
uint32_t secret[16] {
|
||||||
|
REGION_0_SECRET,
|
||||||
|
REGION_1_SECRET,
|
||||||
|
REGION_2_SECRET,
|
||||||
|
REGION_3_SECRET,
|
||||||
|
REGION_4_SECRET,
|
||||||
|
REGION_5_SECRET,
|
||||||
|
REGION_6_SECRET,
|
||||||
|
REGION_7_SECRET,
|
||||||
|
REGION_8_SECRET,
|
||||||
|
REGION_9_SECRET,
|
||||||
|
REGION_10_SECRET,
|
||||||
|
REGION_11_SECRET,
|
||||||
|
REGION_12_SECRET,
|
||||||
|
REGION_13_SECRET,
|
||||||
|
REGION_14_SECRET,
|
||||||
|
REGION_15_SECRET
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class FlashSections: uint8_t {
|
||||||
|
BOOTLOADER_SECTION = 0,
|
||||||
|
MAIN_FIRMWARE_SECTION = 1,
|
||||||
|
ARC_CONFIG_SECTION = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class FirmwareRegions: uint32_t {
|
||||||
|
START = 1,
|
||||||
|
END = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint32_t FLASH_REGION_SIZE = 0x20000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This dataset can be used to store the temperature of a reaction wheel.
|
* @brief This dataset can be used to store the temperature of a reaction wheel.
|
||||||
*/
|
*/
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -245,26 +245,26 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
|||||||
|
|
||||||
ArcsecDatalinkLayer dataLinkLayer;
|
ArcsecDatalinkLayer dataLinkLayer;
|
||||||
|
|
||||||
StarTracker::TemperatureSet temperatureSet;
|
startracker::TemperatureSet temperatureSet;
|
||||||
StarTracker::VersionSet versionSet;
|
startracker::VersionSet versionSet;
|
||||||
StarTracker::PowerSet powerSet;
|
startracker::PowerSet powerSet;
|
||||||
StarTracker::InterfaceSet interfaceSet;
|
startracker::InterfaceSet interfaceSet;
|
||||||
StarTracker::TimeSet timeSet;
|
startracker::TimeSet timeSet;
|
||||||
StarTracker::SolutionSet solutionSet;
|
startracker::SolutionSet solutionSet;
|
||||||
StarTracker::HistogramSet histogramSet;
|
startracker::HistogramSet histogramSet;
|
||||||
StarTracker::ContrastSet contrastSet;
|
startracker::ContrastSet contrastSet;
|
||||||
StarTracker::ChecksumSet checksumSet;
|
startracker::ChecksumSet checksumSet;
|
||||||
StarTracker::DownloadCentroidSet downloadCentroidSet;
|
startracker::DownloadCentroidSet downloadCentroidSet;
|
||||||
StarTracker::DownloadMatchedStar downloadMatchedStar;
|
startracker::DownloadMatchedStar downloadMatchedStar;
|
||||||
StarTracker::DownloadDBImage downloadDbImage;
|
startracker::DownloadDBImage downloadDbImage;
|
||||||
StarTracker::DownloadBlobPixel downloadBlobPixel;
|
startracker::DownloadBlobPixel downloadBlobPixel;
|
||||||
StarTracker::CameraSet cameraSet;
|
startracker::CameraSet cameraSet;
|
||||||
StarTracker::LimitsSet limitsSet;
|
startracker::LimitsSet limitsSet;
|
||||||
|
|
||||||
// Pointer to object responsible for uploading and downloading images to/from the star tracker
|
// Pointer to object responsible for uploading and downloading images to/from the star tracker
|
||||||
StrHelper* strHelper = nullptr;
|
StrHelper* strHelper = nullptr;
|
||||||
|
|
||||||
uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE];
|
uint8_t commandBuffer[startracker::MAX_FRAME_SIZE];
|
||||||
|
|
||||||
// Countdown to insert delay for star tracker to switch from bootloader to firmware program
|
// Countdown to insert delay for star tracker to switch from bootloader to firmware program
|
||||||
Countdown bootCountdown;
|
Countdown bootCountdown;
|
||||||
|
@ -154,7 +154,7 @@ ReturnValue_t StrHelper::startFirmwareUpdate(std::string fullname) {
|
|||||||
return FILE_NOT_EXISTS;
|
return FILE_NOT_EXISTS;
|
||||||
}
|
}
|
||||||
flashWrite.address = 0;
|
flashWrite.address = 0;
|
||||||
flashWrite.region = static_cast<uint8_t>(RegionId::MAIN_FIRMWARE_SECTION);
|
flashWrite.section = static_cast<uint8_t>(RegionId::MAIN_FIRMWARE_SECTION);
|
||||||
internalState = InternalState::FIRMWARE_UPDATE;
|
internalState = InternalState::FIRMWARE_UPDATE;
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
terminate = false;
|
terminate = false;
|
||||||
@ -317,12 +317,10 @@ ReturnValue_t StrHelper::performImageUpload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t StrHelper::performFirmwareUpdate() {
|
ReturnValue_t StrHelper::performFirmwareUpdate() {
|
||||||
|
using namespace startracker;
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
result = unlock(flashWrite.region);
|
result = unlockAndEraseRegions(static_cast<uint32_t>(FirmwareRegions::START),
|
||||||
if (result != RETURN_OK) {
|
static_cast<uint32_t>(FirmwareRegions::END));
|
||||||
return result;
|
|
||||||
}
|
|
||||||
eraseF(flashWrite.region);
|
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -345,7 +343,7 @@ ReturnValue_t StrHelper::performFlashWrite() {
|
|||||||
file.seekg(0, file.end);
|
file.seekg(0, file.end);
|
||||||
fileSize = file.tellg();
|
fileSize = file.tellg();
|
||||||
remainingBytes = fileSize;
|
remainingBytes = fileSize;
|
||||||
req.region = flashWrite.region;
|
req.region = flashWrite.section;
|
||||||
req.address = flashWrite.address;
|
req.address = flashWrite.address;
|
||||||
req.length = MAX_FLASH_DATA;
|
req.length = MAX_FLASH_DATA;
|
||||||
while (remainingBytes >= MAX_FLASH_DATA) {
|
while (remainingBytes >= MAX_FLASH_DATA) {
|
||||||
@ -357,7 +355,7 @@ ReturnValue_t StrHelper::performFlashWrite() {
|
|||||||
arc_pack_write_action_req(&req, commandBuffer, &size);
|
arc_pack_write_action_req(&req, commandBuffer, &size);
|
||||||
result = sendAndRead(size, req.address);
|
result = sendAndRead(size, req.address);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return RETURN_FAILED;
|
return result;
|
||||||
}
|
}
|
||||||
result = checkFlashActionReply(req.region, req.address, req.length);
|
result = checkFlashActionReply(req.region, req.address, req.length);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -371,7 +369,7 @@ ReturnValue_t StrHelper::performFlashWrite() {
|
|||||||
arc_pack_write_action_req(&req, commandBuffer, &size);
|
arc_pack_write_action_req(&req, commandBuffer, &size);
|
||||||
result = sendAndRead(size, req.address);
|
result = sendAndRead(size, req.address);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return RETURN_FAILED;
|
return result;
|
||||||
}
|
}
|
||||||
result = checkFlashActionReply(req.region, req.address, req.length);
|
result = checkFlashActionReply(req.region, req.address, req.length);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -551,7 +549,7 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
|
|||||||
}
|
}
|
||||||
decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS;
|
decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS;
|
||||||
while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) {
|
while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) {
|
||||||
result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
result = uartComIF->requestReceiveMessage(comCookie, startracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl;
|
sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl;
|
||||||
triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter);
|
triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter);
|
||||||
@ -706,3 +704,31 @@ void StrHelper::printProgress(uint32_t itemsTransferred, uint32_t fullNumItems)
|
|||||||
nextProgressPrint = 0;
|
nextProgressPrint = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t StrHelper::unlockAndEraseRegions(uint32_t from, uint32_t to) {
|
||||||
|
using namespace startracker::region_secrets;
|
||||||
|
struct UnlockActionRequest unlockReq;
|
||||||
|
struct EraseActionRequest eraseReq;
|
||||||
|
uint32_t size = 0;
|
||||||
|
for (uint8_t idx = from; idx <= to; idx++) {
|
||||||
|
unlockReq.region = idx;
|
||||||
|
unlockReq.code = secret[idx];
|
||||||
|
arc_pack_unlock_action_req(&req, commandBuffer, &size);
|
||||||
|
sendAndRead(size, req.region);
|
||||||
|
result = checkActionReply();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
sif::warning << "StrHelper::unlockAndEraseRegions: Failed to unlock region with id "
|
||||||
|
<< static_cast<unsigned int>(unlockReq.region) << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
eraseReq.region = idx;
|
||||||
|
arc_pack_erase_action_req(&eraseReq, commandBuffer, &size);
|
||||||
|
result = sendAndRead(size, eraseReq.region);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
sif::warning << "StrHelper::unlockAndEraseRegions: Failed to erase region with id "
|
||||||
|
<< static_cast<unsigned int>(eraseReq.region) << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,9 @@ extern "C" {
|
|||||||
* @brief Helper class for the star tracker handler to accelerate large data transfers.
|
* @brief Helper class for the star tracker handler to accelerate large data transfers.
|
||||||
*/
|
*/
|
||||||
class StrHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF {
|
class StrHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF {
|
||||||
|
|
||||||
|
using namespace startracker;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER;
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER;
|
||||||
|
|
||||||
@ -267,8 +270,8 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
|
|||||||
public:
|
public:
|
||||||
// File which contains data to write when executing the flash write command
|
// File which contains data to write when executing the flash write command
|
||||||
std::string fullname;
|
std::string fullname;
|
||||||
// Will be set with the flash write command
|
// Section where to write to
|
||||||
uint8_t region = 0;
|
uint8_t section = 0;
|
||||||
// Will be set with the flash write command and specifies the start address where to write the
|
// Will be set with the flash write command and specifies the start address where to write the
|
||||||
// flash data to
|
// flash data to
|
||||||
uint32_t address = 0;
|
uint32_t address = 0;
|
||||||
@ -291,15 +294,9 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
|
|||||||
};
|
};
|
||||||
FlashRead flashRead;
|
FlashRead flashRead;
|
||||||
|
|
||||||
enum class RegionId : uint8_t {
|
|
||||||
BOOTLOADER_SECTION = 0,
|
|
||||||
MAIN_FIRMWARE_SECTION = 1,
|
|
||||||
ARC_CONFIG_SECTION = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
SdCardManager* sdcMan = nullptr;
|
SdCardManager* sdcMan = nullptr;
|
||||||
|
|
||||||
uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE];
|
uint8_t commandBuffer[startracker::MAX_FRAME_SIZE];
|
||||||
|
|
||||||
bool terminate = false;
|
bool terminate = false;
|
||||||
|
|
||||||
@ -413,6 +410,15 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
|
|||||||
* @param fullNumItems Full number of items to transfer
|
* @param fullNumItems Full number of items to transfer
|
||||||
*/
|
*/
|
||||||
void printProgress(uint32_t itemsTransferred, uint32_t fullNumItems);
|
void printProgress(uint32_t itemsTransferred, uint32_t fullNumItems);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unlocks a range of flash regions
|
||||||
|
*
|
||||||
|
* @param from First region in range to unlock
|
||||||
|
* @param to Last region in range to unlock
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ReturnValue_t unlockRegions(uint32_t from, uint32_t to);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */
|
#endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */
|
||||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit faf7da2743dcd30d83c3ab2f7b4d85277878e636
|
Subproject commit f08d291e3e22950e729c327c101d22a943910e9b
|
Loading…
Reference in New Issue
Block a user