2021-08-09 16:30:59 +02:00
|
|
|
#ifndef MISSION_DEVICES_PLOCUPDATER_H_
|
|
|
|
#define MISSION_DEVICES_PLOCUPDATER_H_
|
|
|
|
|
2021-08-09 17:19:10 +02:00
|
|
|
#include "OBSWConfig.h"
|
2022-01-18 11:41:19 +01:00
|
|
|
#include "bsp_q7s/memory/SdCardManager.h"
|
2021-08-09 17:19:10 +02:00
|
|
|
#include "devicedefinitions/PlocSupervisorDefinitions.h"
|
2021-08-09 16:30:59 +02:00
|
|
|
#include "fsfw/action/ActionHelper.h"
|
2022-01-18 11:41:19 +01:00
|
|
|
#include "fsfw/action/CommandActionHelper.h"
|
2021-08-09 16:30:59 +02:00
|
|
|
#include "fsfw/action/CommandsActionsIF.h"
|
2022-01-18 11:41:19 +01:00
|
|
|
#include "fsfw/action/HasActionsIF.h"
|
|
|
|
#include "fsfw/objectmanager/SystemObject.h"
|
2021-08-09 16:30:59 +02:00
|
|
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
|
|
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
|
|
|
#include "fsfw/tmtcpacket/SpacePacket.h"
|
2022-01-18 11:41:19 +01:00
|
|
|
#include "linux/fsfwconfig/objects/systemObjectList.h"
|
2021-08-09 16:30:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief An object of this class can be used to perform the software updates of the PLOC. The
|
|
|
|
* software update will be read from one of the SD cards, split into multiple space
|
|
|
|
* packets and sent to the PlocSupervisorHandler.
|
|
|
|
*
|
2022-01-18 11:41:19 +01:00
|
|
|
* @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition
|
|
|
|
* A and Partition B)
|
2021-08-09 16:30:59 +02:00
|
|
|
*
|
|
|
|
* @author J. Meier
|
|
|
|
*/
|
|
|
|
class PlocUpdater : public SystemObject,
|
2022-01-18 11:41:19 +01:00
|
|
|
public HasActionsIF,
|
|
|
|
public ExecutableObjectIF,
|
|
|
|
public HasReturnvaluesIF,
|
|
|
|
public CommandsActionsIF {
|
|
|
|
public:
|
|
|
|
static const ActionId_t UPDATE_A_UBOOT = 0;
|
|
|
|
static const ActionId_t UPDATE_A_BITSTREAM = 1;
|
|
|
|
static const ActionId_t UPDATE_A_LINUX = 2;
|
|
|
|
static const ActionId_t UPDATE_A_APP_SW = 3;
|
|
|
|
static const ActionId_t UPDATE_B_UBOOT = 4;
|
|
|
|
static const ActionId_t UPDATE_B_BITSTREAM = 5;
|
|
|
|
static const ActionId_t UPDATE_B_LINUX = 6;
|
|
|
|
static const ActionId_t UPDATE_B_APP_SW = 7;
|
|
|
|
|
|
|
|
PlocUpdater(object_id_t objectId);
|
|
|
|
virtual ~PlocUpdater();
|
|
|
|
|
|
|
|
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
|
|
|
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
|
|
|
const uint8_t* data, size_t size);
|
|
|
|
MessageQueueId_t getCommandQueue() const;
|
|
|
|
ReturnValue_t initialize() override;
|
|
|
|
MessageQueueIF* getCommandQueuePtr() override;
|
|
|
|
void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override;
|
|
|
|
void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override;
|
|
|
|
void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override;
|
|
|
|
void completionSuccessfulReceived(ActionId_t actionId) override;
|
|
|
|
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER;
|
|
|
|
|
|
|
|
//! [EXPORT] : [COMMENT] Updater is already performing an update
|
|
|
|
static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0);
|
|
|
|
//! [EXPORT] : [COMMENT] Received update command with invalid path string (too long).
|
|
|
|
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1);
|
|
|
|
//! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not
|
|
|
|
//! mounted.
|
|
|
|
static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2);
|
|
|
|
//! [EXPORT] : [COMMENT] Update file received with update command does not exist.
|
|
|
|
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3);
|
|
|
|
|
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER;
|
|
|
|
|
|
|
|
//! [EXPORT] : [COMMENT] Try to read update file but the file does not exist.
|
|
|
|
//! P1: Indicates in which state the file read fails
|
|
|
|
//! P2: During the update transfer the second parameter gives information about the number of
|
|
|
|
//! already sent packets
|
|
|
|
static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW);
|
|
|
|
//! [EXPORT] : [COMMENT] Failed to send command to supervisor handler
|
|
|
|
//! P1: Return value of CommandActionHelper::commandAction
|
|
|
|
//! P2: Action ID of command to send
|
|
|
|
static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW);
|
|
|
|
//! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution
|
|
|
|
//! failure of the update available command
|
|
|
|
static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW);
|
|
|
|
//! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet.
|
|
|
|
//! P1: Parameter holds the number of update packets already sent (inclusive the failed packet)
|
|
|
|
static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW);
|
|
|
|
//! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command.
|
|
|
|
static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW);
|
|
|
|
//! [EXPORT] : [COMMENT] MPSoC update successful completed
|
|
|
|
static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO);
|
|
|
|
|
|
|
|
static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE;
|
|
|
|
static const size_t MAX_PLOC_UPDATE_PATH = 50;
|
|
|
|
static const size_t SD_PREFIX_LENGTH = 8;
|
|
|
|
// Maximum size of update payload data per space packet (max size of space packet is 1024 bytes)
|
|
|
|
static const size_t MAX_SP_DATA = 1016;
|
|
|
|
|
|
|
|
static const uint32_t TOPBIT_32 = (1 << 31);
|
|
|
|
static const uint32_t POLYNOMIAL_32 = 0x04C11DB7;
|
|
|
|
static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF;
|
|
|
|
static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
MessageQueueIF* commandQueue = nullptr;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2021-08-17 16:14:23 +02:00
|
|
|
#if BOARD_TE0720 == 0
|
2022-01-18 11:41:19 +01:00
|
|
|
SdCardManager* sdcMan = nullptr;
|
2021-08-17 16:14:23 +02:00
|
|
|
#endif
|
2022-01-18 11:41:19 +01:00
|
|
|
CommandActionHelper commandActionHelper;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
ActionHelper actionHelper;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
enum class State : uint8_t {
|
|
|
|
IDLE,
|
|
|
|
UPDATE_AVAILABLE,
|
|
|
|
UPDATE_TRANSFER,
|
|
|
|
UPDATE_VERIFY,
|
|
|
|
COMMAND_EXECUTING
|
|
|
|
};
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
State state = State::IDLE;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
ActionId_t pendingCommand = PLOC_SPV::NONE;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
enum class Image : uint8_t { NONE, A, B };
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
Image image = Image::NONE;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
enum class Partition : uint8_t { NONE, UBOOT, BITSTREAM, LINUX_OS, APP_SW };
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
Partition partition = Partition::NONE;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
uint32_t packetsSent = 0;
|
|
|
|
uint32_t remainingPackets = 0;
|
|
|
|
// Number of packets required to transfer the update image
|
|
|
|
uint32_t numOfUpdatePackets = 0;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
std::string updateFile;
|
|
|
|
uint32_t imageSize = 0;
|
|
|
|
uint32_t imageCrc = 0;
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
void readCommandQueue();
|
|
|
|
void doStateMachine();
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
/**
|
|
|
|
* @brief Extracts the path and name of the update image from the service 8 command data.
|
|
|
|
*/
|
|
|
|
ReturnValue_t getImageLocation(const uint8_t* data, size_t size);
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
ReturnValue_t checkNameLength(size_t size);
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
/**
|
|
|
|
* @brief Prepares and sends update available command to PLOC supervisor handler.
|
|
|
|
*/
|
|
|
|
void commandUpdateAvailable();
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
/**
|
|
|
|
* @brief Prepares and sends and update packet to the PLOC supervisor handler.
|
|
|
|
*/
|
|
|
|
void commandUpdatePacket();
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
/**
|
|
|
|
* @brief Prepares and sends the update verification packet to the PLOC supervisor handler.
|
|
|
|
*/
|
|
|
|
void commandUpdateVerify();
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
void calcImageCrc();
|
2021-08-09 16:30:59 +02:00
|
|
|
|
2022-01-18 11:41:19 +01:00
|
|
|
void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet);
|
2021-08-09 16:30:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_DEVICES_PLOCUPDATER_H_ */
|