nvm enable command

This commit is contained in:
Jakob Meier 2022-05-05 19:18:39 +02:00
parent 9bd5595999
commit 5911ca79b5
3 changed files with 75 additions and 19 deletions

View File

@ -55,15 +55,16 @@ static const DeviceCommandId_t LOGGING_CLEAR_COUNTERS = 55;
static const DeviceCommandId_t LOGGING_SET_TOPIC = 56;
static const DeviceCommandId_t REQUEST_ADC_REPORT = 57;
static const DeviceCommandId_t RESET_PL = 58;
static const DeviceCommandId_t ENABLE_NVMS = 59;
/** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50;
static const DeviceCommandId_t EXE_REPORT = 51;
static const DeviceCommandId_t HK_REPORT = 52;
static const DeviceCommandId_t BOOT_STATUS_REPORT = 53;
static const DeviceCommandId_t LATCHUP_REPORT = 54;
static const DeviceCommandId_t LOGGING_REPORT = 55;
static const DeviceCommandId_t ADC_REPORT = 56;
static const DeviceCommandId_t ACK_REPORT = 100;
static const DeviceCommandId_t EXE_REPORT = 101;
static const DeviceCommandId_t HK_REPORT = 102;
static const DeviceCommandId_t BOOT_STATUS_REPORT = 103;
static const DeviceCommandId_t LATCHUP_REPORT = 104;
static const DeviceCommandId_t LOGGING_REPORT = 105;
static const DeviceCommandId_t ADC_REPORT = 106;
// Size of complete space packet (6 byte header + size of data + 2 byte CRC)
static const uint16_t SIZE_ACK_REPORT = 14;
@ -122,6 +123,7 @@ static const uint16_t APID_SET_ADC_THRESHOLD = 0xE3;
static const uint16_t APID_GET_LATCHUP_STATUS_REPORT = 0xD9;
static const uint16_t APID_COPY_ADC_DATA_TO_MRAM = 0xDA;
static const uint16_t APID_REQUEST_ADC_REPORT = 0xDB;
static const uint16_t APID_ENABLE_NVMS = 0xF0;
static const uint16_t APID_RUN_AUTO_EM_TESTS = 0xF2;
static const uint16_t APID_WIPE_MRAM = 0xF3;
static const uint16_t APID_DUMP_MRAM = 0xF4;
@ -357,6 +359,50 @@ class MPSoCBootSelect : public SpacePacket {
}
};
/**
* @brief This class creates the command to enable or disable the NVMs connected to the
* supervisor.
*/
class EnableNvms : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param mem The memory to boot from: NVM0 (0), NVM1 (1)
* @param bp0 Partition pin 0
* @param bp1 Partition pin 1
* @param bp2 Partition pin 2
*/
EnableNvms(uint8_t nvm01, uint8_t nvm3)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT),
nvm01(nvm01),
nvm3(nvm3) {
initPacket();
}
private:
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint8_t DATA_FIELD_LENGTH = 4;
static const uint8_t CRC_OFFSET = 2;
uint8_t nvm01 = 0;
uint8_t nvm3 = 0;
void initPacket() {
*(this->localData.fields.buffer) = nvm01;
*(this->localData.fields.buffer + 1) = nvm3;
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
/* Add crc to packet data field of space packet */
size_t serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class generates the space packet to update the time of the PLOC supervisor.
*/
@ -1664,13 +1710,7 @@ class BootStatusReport : public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
*/
class HkSet : public StaticLocalDataSet<HK_SET_ENTRIES> {
public:
enum class SocState {
OFF = 0,
BOOTING = 1,
OPERATIONAL = 3,
SHUTDOWN = 4
};
enum class SocState { OFF = 0, BOOTING = 1, OPERATIONAL = 3, SHUTDOWN = 4 };
HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {}

View File

@ -147,7 +147,7 @@ void PlocSupervisorHandler::doStartUp() {
case StartupState::BOOTING: {
if (bootTimeout.hasTimedOut()) {
uartIsolatorSwitch.pullHigh();
// startupState = StartupState::SET_TIME;
// startupState = StartupState::SET_TIME;
startupState = StartupState::ON;
}
}
@ -377,6 +377,10 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
result = RETURN_OK;
break;
}
case ENABLE_NVMS: {
result = prepareEnableNvmsCommand(commandData);
break;
}
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
@ -432,6 +436,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(LOGGING_CLEAR_COUNTERS);
this->insertInCommandMap(LOGGING_SET_TOPIC);
this->insertInCommandMap(RESET_PL);
this->insertInCommandMap(ENABLE_NVMS);
this->insertInCommandAndReplyMap(FIRST_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(CONSECUTIVE_MRAM_DUMP, 3);
this->insertInReplyMap(ACK_REPORT, 3, nullptr, SIZE_ACK_REPORT);
@ -552,6 +557,7 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
case LOGGING_CLEAR_COUNTERS:
case LOGGING_SET_TOPIC:
case RESET_PL:
case ENABLE_NVMS:
enabledReplies = 2;
break;
default:
@ -878,7 +884,7 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
case SupvReturnValuesIF::RECEIVED_ACK_FAILURE: {
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
sif::debug << "PlocSupervisorHandler: Received Ack failure report with status code: 0x"
<< std::hex << ack.getStatusCode() << std::endl;
<< std::hex << ack.getStatusCode() << std::endl;
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
@ -1176,7 +1182,7 @@ ReturnValue_t PlocSupervisorHandler::handleLoggingReport(const uint8_t* data) {
if (result == SupvReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocSupervisorHandler::handleLoggingReport: Logging report has "
<< "invalid crc" << std::endl;
<< "invalid crc" << std::endl;
return result;
}
@ -1533,6 +1539,15 @@ ReturnValue_t PlocSupervisorHandler::prepareLoggingRequest(const uint8_t* comman
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareEnableNvmsCommand(const uint8_t* commandData) {
using namespace supv;
uint8_t nvm01 = *(commandData);
uint8_t nvm3 = *(commandData + 1);
EnableNvms packet(nvm01, nvm3);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
return RETURN_OK;
}
void PlocSupervisorHandler::disableAllReplies() {
DeviceReplyMap::iterator iter;
@ -1872,8 +1887,8 @@ void PlocSupervisorHandler::handleExecutionSuccessReport(const uint8_t* data) {
}
uint8_t data[sizeof(gpioState)];
size_t size = 0;
ReturnValue_t result = SerializeAdapter::serialize(
&gpioState, data, &size, sizeof(gpioState), SerializeIF::Endianness::BIG);
ReturnValue_t result = SerializeAdapter::serialize(&gpioState, data, &size, sizeof(gpioState),
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler: Failed to deserialize GPIO state" << std::endl;
}

View File

@ -280,6 +280,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
void prepareSetGpioCmd(const uint8_t* commandData);
void prepareReadGpioCmd(const uint8_t* commandData);
ReturnValue_t prepareLoggingRequest(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareEnableNvmsCommand(const uint8_t* commandData);
/**
* @brief Copies the content of a space packet to the command buffer.