diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index 8a642647..6901d8fe 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1116,6 +1116,56 @@ class WriteMemory : public TcBase { } }; +/** + * @brief This class packages the space packet to wipe or dump parts of the MRAM. + */ +class MramCmd : public TcBase { + public: + enum class MramAction { WIPE, DUMP }; + + /** + * @brief Constructor + * + * @param start Start address of the MRAM section to wipe or dump + * @param stop End address of the MRAM section to wipe or dump + * @param action Dump or wipe MRAM + * + * @note The content at the stop address is excluded from the dump or wipe operation. + */ + MramCmd(TcParams params) : TcBase(params, Apid::DATA_LOGGER) { setLenFromPayloadLen(6); } + + ReturnValue_t buildPacket(uint32_t start, uint32_t stop, MramAction action) { + if (action == MramAction::WIPE) { + setServiceId(static_cast(tc::DataLoggerServiceId::WIPE_MRAM)); + } else if (action == MramAction::DUMP) { + setServiceId(static_cast(tc::DataLoggerServiceId::DUMP_MRAM)); + } else { + sif::debug << "WipeMram: Invalid action specified"; + } + auto res = checkSizeAndSerializeHeader(); + if (res != returnvalue::OK) { + return res; + } + initPacket(start, stop); + return calcAndSetCrc(); + } + + private: + uint32_t start = 0; + uint32_t stop = 0; + + void initPacket(uint32_t start, uint32_t stop) { + uint8_t concatBuffer[6]; + concatBuffer[0] = static_cast(start >> 16); + concatBuffer[1] = static_cast(start >> 8); + concatBuffer[2] = static_cast(start); + concatBuffer[3] = static_cast(stop >> 16); + concatBuffer[4] = static_cast(stop >> 8); + concatBuffer[5] = static_cast(stop); + std::memcpy(payloadStart, concatBuffer, sizeof(concatBuffer)); + } +}; + /** * @brief This class can be used to package erase memory command */ @@ -1931,56 +1981,6 @@ class EnableNvms : public TcBase { } }; -/** - * @brief This class packages the space packet to wipe or dump parts of the MRAM. - */ -class MramCmd : public TcBase { - public: - enum class MramAction { WIPE, DUMP }; - - /** - * @brief Constructor - * - * @param start Start address of the MRAM section to wipe or dump - * @param stop End address of the MRAM section to wipe or dump - * @param action Dump or wipe MRAM - * - * @note The content at the stop address is excluded from the dump or wipe operation. - */ - MramCmd(TcParams params) : TcBase(params, Apid::DATA_LOGGER) { setLenFromPayloadLen(6); } - - ReturnValue_t buildPacket(uint32_t start, uint32_t stop, MramAction action) { - if (action == MramAction::WIPE) { - setServiceId(static_cast(tc::DataLoggerServiceId::WIPE_MRAM)); - } else if (action == MramAction::DUMP) { - setServiceId(static_cast(tc::DataLoggerServiceId::DUMP_MRAM)); - } else { - sif::debug << "WipeMram: Invalid action specified"; - } - auto res = checkSizeAndSerializeHeader(); - if (res != returnvalue::OK) { - return res; - } - initPacket(start, stop); - return calcAndSetCrc(); - } - - private: - uint32_t start = 0; - uint32_t stop = 0; - - void initPacket(uint32_t start, uint32_t stop) { - uint8_t concatBuffer[6]; - concatBuffer[0] = static_cast(start >> 16); - concatBuffer[1] = static_cast(start >> 8); - concatBuffer[2] = static_cast(start); - concatBuffer[3] = static_cast(stop >> 16); - concatBuffer[4] = static_cast(stop >> 8); - concatBuffer[5] = static_cast(stop); - std::memcpy(payloadStart, concatBuffer, sizeof(concatBuffer)); - } -}; - /** * @brief This class creates the space packet to enable the auto TM generation */ diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 86547b73..b6783449 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -417,10 +417,10 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d // result = returnvalue::OK; // break; // } - // case WIPE_MRAM: { - // result = prepareWipeMramCmd(commandData); - // break; - // } + case WIPE_MRAM: { + result = prepareWipeMramCmd(commandData); + break; + } // case FIRST_MRAM_DUMP: // case CONSECUTIVE_MRAM_DUMP: // result = prepareDumpMramCmd(commandData); @@ -562,7 +562,7 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case SET_ADC_THRESHOLD: // case COPY_ADC_DATA_TO_MRAM: case RUN_AUTO_EM_TESTS: - // case WIPE_MRAM: + case WIPE_MRAM: case SET_GPIO: case FACTORY_RESET: case READ_GPIO: @@ -1725,6 +1725,24 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { return returnvalue::OK; } +ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) { + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + if ((stop - start) <= 0) { + return result::INVALID_MRAM_ADDRESSES; + } + supv::MramCmd packet(spParams); + ReturnValue_t result = packet.buildPacket(start, stop, supv::MramCmd::MramAction::WIPE); + if (result != returnvalue::OK) { + return result; + } + finishTcPrep(packet.getFullPacketLen()); + return returnvalue::OK; +} + uint16_t PlocSupervisorHandler::readSpacePacketLength(uint8_t* spacePacket) { return spacePacket[4] << 8 | spacePacket[5]; } @@ -2013,24 +2031,6 @@ uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t mod // return result; // } -// ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) { -// uint32_t start = 0; -// uint32_t stop = 0; -// size_t size = sizeof(start) + sizeof(stop); -// SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); -// SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); -// if ((stop - start) <= 0) { -// return SupvReturnValuesIF::INVALID_MRAM_ADDRESSES; -// } -// supv::MramCmd packet(spParams); -// ReturnValue_t result = packet.buildPacket(start, stop, supv::MramCmd::MramAction::WIPE); -// if (result != returnvalue::OK) { -// return result; -// } -// finishTcPrep(packet.getFullPacketLen()); -// return returnvalue::OK; -// } - // ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) { // uint32_t start = 0; // uint32_t stop = 0; diff --git a/linux/devices/ploc/PlocSupervisorHandler.h b/linux/devices/ploc/PlocSupervisorHandler.h index 9480667c..174ffa9e 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.h +++ b/linux/devices/ploc/PlocSupervisorHandler.h @@ -285,7 +285,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase { ReturnValue_t prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); ReturnValue_t prepareSetAdcThresholdCmd(const uint8_t* commandData); ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); - // ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); + ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); // ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); ReturnValue_t prepareSetGpioCmd(const uint8_t* commandData); ReturnValue_t prepareReadGpioCmd(const uint8_t* commandData); diff --git a/linux/devices/ploc/PlocSupvUartMan.cpp b/linux/devices/ploc/PlocSupvUartMan.cpp index d0c96e93..3bb6e764 100644 --- a/linux/devices/ploc/PlocSupvUartMan.cpp +++ b/linux/devices/ploc/PlocSupvUartMan.cpp @@ -417,7 +417,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() { return result; } result = handlePacketTransmissionNoReply(packet); - //result = encodeAndSendPacket(packet.getFullPacket(), packet.getFullPacketLen()); + // result = encodeAndSendPacket(packet.getFullPacket(), packet.getFullPacketLen()); if (result != returnvalue::OK) { triggerEvent(WRITE_MEMORY_FAILED, buildProgParams1(progPercent, update.sequenceCount), update.bytesWritten);