1. add parser binary data from uart for parse struct data. All works
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"name": "endurance_50_60_marchFTE_5",
|
"name": "endurance_50_60_marchFTE_5",
|
||||||
"description": "start endurance test in NAND Flash",
|
"description": "start endurance test in NAND Flash",
|
||||||
|
"input_data_type": "text",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"cmd_code": 22,
|
"cmd_code": 22,
|
||||||
"block_check_cnt": 2,
|
"block_check_cnt": 2,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"name": "get_savedBadBlockMap_fromNAND",
|
"name": "get_savedBadBlockMap_fromNAND",
|
||||||
"description": "get bad block map from NAND Flash into RAM",
|
"description": "get bad block map from NAND Flash into RAM",
|
||||||
|
"input_data_type": "text",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"cmd_code": 4,
|
"cmd_code": 4,
|
||||||
"badBlockMapOperMode": 2
|
"badBlockMapOperMode": 2
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"name": "randomDataTest_100_110",
|
"name": "randomDataTest_100_110",
|
||||||
"description": "start random data test in all target of NAND Flash",
|
"description": "start random data test in all target of NAND Flash",
|
||||||
|
"input_data_type": "text",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"cmd_code": 19,
|
"cmd_code": 19,
|
||||||
"mode_random": 2,
|
"mode_random": 2,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"name": "set_micron_MT29F16G08AJADAWP",
|
"name": "set_micron_MT29F16G08AJADAWP",
|
||||||
"description": "check settings for micron_MT29F16G08AJADAWP",
|
"description": "check settings for micron_MT29F16G08AJADAWP",
|
||||||
|
"input_data_type": "text",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"cmd_code": 5,
|
"cmd_code": 5,
|
||||||
"endurance": 100000,
|
"endurance": 100000,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"name": "start_March-FTE_all_targ0_repeat2",
|
"name": "start_March-FTE_all_targ0_repeat2",
|
||||||
"description": "start March-FTE for all target",
|
"description": "start March-FTE for all target",
|
||||||
|
"input_data_type": "text",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"cmd_code": 20,
|
"cmd_code": 20,
|
||||||
"target": 0,
|
"target": 0,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"name": "start_March-FTE_by_blocks",
|
"name": "start_March-FTE_by_blocks",
|
||||||
"description": "start March-FTE by specified blocks",
|
"description": "start March-FTE by specified blocks",
|
||||||
|
"input_data_type": "text",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"cmd_code": 21,
|
"cmd_code": 21,
|
||||||
"mode_March_FTE": 2,
|
"mode_March_FTE": 2,
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
|
|
||||||
"abort": [
|
"abort": [
|
||||||
"test_abort.json"
|
"test_abort.json"
|
||||||
|
],
|
||||||
|
|
||||||
|
"one": [
|
||||||
|
"test_UART_cmdSetDataInterface.json",
|
||||||
|
"test_readSnapshot_HK.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
src/core/crc8.cpp
Normal file
53
src/core/crc8.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include "crc8.h"
|
||||||
|
|
||||||
|
static const unsigned char RMAP_CRCTable[] = {
|
||||||
|
0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
|
||||||
|
0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
|
||||||
|
0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
|
||||||
|
0x12, 0x83, 0xf1, 0x60, 0x15, 0x84, 0xf6, 0x67,
|
||||||
|
0x38, 0xa9, 0xdb, 0x4a, 0x3f, 0xae, 0xdc, 0x4d,
|
||||||
|
0x36, 0xa7, 0xd5, 0x44, 0x31, 0xa0, 0xd2, 0x43,
|
||||||
|
0x24, 0xb5, 0xc7, 0x56, 0x23, 0xb2, 0xc0, 0x51,
|
||||||
|
0x2a, 0xbb, 0xc9, 0x58, 0x2d, 0xbc, 0xce, 0x5f,
|
||||||
|
0x70, 0xe1, 0x93, 0x02, 0x77, 0xe6, 0x94, 0x05,
|
||||||
|
0x7e, 0xef, 0x9d, 0x0c, 0x79, 0xe8, 0x9a, 0x0b,
|
||||||
|
0x6c, 0xfd, 0x8f, 0x1e, 0x6b, 0xfa, 0x88, 0x19,
|
||||||
|
0x62, 0xf3, 0x81, 0x10, 0x65, 0xf4, 0x86, 0x17,
|
||||||
|
0x48, 0xd9, 0xab, 0x3a, 0x4f, 0xde, 0xac, 0x3d,
|
||||||
|
0x46, 0xd7, 0xa5, 0x34, 0x41, 0xd0, 0xa2, 0x33,
|
||||||
|
0x54, 0xc5, 0xb7, 0x26, 0x53, 0xc2, 0xb0, 0x21,
|
||||||
|
0x5a, 0xcb, 0xb9, 0x28, 0x5d, 0xcc, 0xbe, 0x2f,
|
||||||
|
0xe0, 0x71, 0x03, 0x92, 0xe7, 0x76, 0x04, 0x95,
|
||||||
|
0xee, 0x7f, 0x0d, 0x9c, 0xe9, 0x78, 0x0a, 0x9b,
|
||||||
|
0xfc, 0x6d, 0x1f, 0x8e, 0xfb, 0x6a, 0x18, 0x89,
|
||||||
|
0xf2, 0x63, 0x11, 0x80, 0xf5, 0x64, 0x16, 0x87,
|
||||||
|
0xd8, 0x49, 0x3b, 0xaa, 0xdf, 0x4e, 0x3c, 0xad,
|
||||||
|
0xd6, 0x47, 0x35, 0xa4, 0xd1, 0x40, 0x32, 0xa3,
|
||||||
|
0xc4, 0x55, 0x27, 0xb6, 0xc3, 0x52, 0x20, 0xb1,
|
||||||
|
0xca, 0x5b, 0x29, 0xb8, 0xcd, 0x5c, 0x2e, 0xbf,
|
||||||
|
0x90, 0x01, 0x73, 0xe2, 0x97, 0x06, 0x74, 0xe5,
|
||||||
|
0x9e, 0x0f, 0x7d, 0xec, 0x99, 0x08, 0x7a, 0xeb,
|
||||||
|
0x8c, 0x1d, 0x6f, 0xfe, 0x8b, 0x1a, 0x68, 0xf9,
|
||||||
|
0x82, 0x13, 0x61, 0xf0, 0x85, 0x14, 0x66, 0xf7,
|
||||||
|
0xa8, 0x39, 0x4b, 0xda, 0xaf, 0x3e, 0x4c, 0xdd,
|
||||||
|
0xa6, 0x37, 0x45, 0xd4, 0xa1, 0x30, 0x42, 0xd3,
|
||||||
|
0xb4, 0x25, 0x57, 0xc6, 0xb3, 0x22, 0x50, 0xc1,
|
||||||
|
0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned char crc8(const void * data, int size)
|
||||||
|
{
|
||||||
|
// INCRC - the intermediate RMAP CRC byte value
|
||||||
|
unsigned char INCRC = 0;
|
||||||
|
// INBYTE - The RMAP Header or Data byte
|
||||||
|
unsigned char * INBYTE = (unsigned char *) data;
|
||||||
|
|
||||||
|
unsigned char * end = INBYTE + size;
|
||||||
|
|
||||||
|
while (INBYTE < end)
|
||||||
|
{
|
||||||
|
INCRC = RMAP_CRCTable[INCRC ^ *INBYTE];
|
||||||
|
INBYTE++;
|
||||||
|
}
|
||||||
|
return INCRC;
|
||||||
|
}
|
||||||
10
src/core/crc8.h
Normal file
10
src/core/crc8.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef CRC8_H
|
||||||
|
#define CRC8_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
// CRC-8-CCIT, generator polynomial: x**8 + x**2 + x**1 + x**0
|
||||||
|
unsigned char crc8(const void * data, int size);
|
||||||
|
|
||||||
|
#endif // CRC8_H
|
||||||
@@ -22,11 +22,13 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QtEndian> // Для qbswap
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "loggingCategories.h"
|
#include "loggingCategories.h"
|
||||||
#include "html_report.h"
|
#include "html_report.h"
|
||||||
|
#include "crc8.h"
|
||||||
|
|
||||||
struct comSet_t {
|
struct comSet_t {
|
||||||
int addrRS485;
|
int addrRS485;
|
||||||
@@ -64,5 +66,336 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t replyAddrLength: 2; ///< reply address length field (for path addressing):
|
||||||
|
///< \arg 0b00 - 0 bytes,
|
||||||
|
///< \arg 0b01 - 4 bytes,
|
||||||
|
///< \arg 0b10 - 8 bytes,
|
||||||
|
///< \arg 0b11 - 12 bytes
|
||||||
|
uint8_t increment: 1; ///< 1 - incrementing address
|
||||||
|
uint8_t reply: 1; ///< 1 - transmit reply, 0 - not transmit reply
|
||||||
|
uint8_t checkData: 1; ///< 1 - checking data before write
|
||||||
|
uint8_t operationType: 1; ///< 1 - write data, 0 - read data
|
||||||
|
uint8_t packetTypeField: 2; ///< 0b00 - logical address, 0b01 - physical address - for MIL layer
|
||||||
|
///< 0b01 - command, 0b00 - reply for RMAP layer
|
||||||
|
|
||||||
|
} RMAP_instruct_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
uint8_t all;
|
||||||
|
RMAP_instruct_t bit;
|
||||||
|
} RMAP_instruct_u;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t targetLogAddr;
|
||||||
|
uint8_t protocolID;
|
||||||
|
RMAP_instruct_u instruct;
|
||||||
|
uint8_t key;
|
||||||
|
uint8_t initiatorLogAddr;
|
||||||
|
uint8_t transactID[2];
|
||||||
|
uint8_t addr[5];
|
||||||
|
uint8_t dataLength[3];
|
||||||
|
uint8_t headerCRC;
|
||||||
|
} RMAP_cmdWriteReadHeadLogAddr_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t initiatorLogAddr;
|
||||||
|
uint8_t protocolID;
|
||||||
|
uint8_t instruct;
|
||||||
|
uint8_t status;
|
||||||
|
uint8_t targetLogAddr;
|
||||||
|
uint16_t transactID;
|
||||||
|
uint8_t headerCRC;
|
||||||
|
} RMAP_WriteReplyHead_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t initiatorLogAddr;
|
||||||
|
uint8_t protocolID;
|
||||||
|
uint8_t instruct;
|
||||||
|
uint8_t status;
|
||||||
|
uint8_t targetLogAddr;
|
||||||
|
uint16_t transactID;
|
||||||
|
uint8_t reserved;
|
||||||
|
uint32_t dataLength;
|
||||||
|
uint8_t headerCRC;
|
||||||
|
} RMAP_ReadReplyHead_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t targetSpwAddr[2];
|
||||||
|
uint8_t targetLogAddr;
|
||||||
|
uint8_t protocolID;
|
||||||
|
RMAP_instruct_u instruct;
|
||||||
|
uint8_t key;
|
||||||
|
uint8_t replyAddr[4];
|
||||||
|
uint8_t initiatorLogAddr;
|
||||||
|
uint16_t transactID;
|
||||||
|
uint8_t extendAddr;
|
||||||
|
uint32_t addr;
|
||||||
|
uint8_t dataLength[3];
|
||||||
|
uint8_t headerCRC;
|
||||||
|
} RMAP_cmdWriteReadHeadPathAddr_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RMAP_success = 0, ///< 00
|
||||||
|
RMAP_errGeneral, ///< 01
|
||||||
|
RMAP_errUnusePackType, ///< 02
|
||||||
|
RMAP_errInvalKey, ///< 03
|
||||||
|
RMAP_errInvalDataCRC, ///< 04
|
||||||
|
RMAP_errDataEarlyEOP, ///< 05
|
||||||
|
RMAP_errTooMuchData, ///< 06
|
||||||
|
RMAP_errDataEEP, ///< 07
|
||||||
|
RMAP_errReserved, ///< 08
|
||||||
|
RMAP_errVerifyBufOver, ///< 09
|
||||||
|
RMAP_errCmdNotImplement, ///< 10
|
||||||
|
RMAP_errDataLengthErr, ///< 11
|
||||||
|
RMAP_errInvalTargLogAddr, ///< 12
|
||||||
|
RMAP_errHeaderEarlierEOP, ///< 13
|
||||||
|
RMAP_errInvalHeaderCRC, ///< 14
|
||||||
|
RMAP_errNotRMAP, ///< 15
|
||||||
|
RMAP_errReplyTimeout, ///< 16
|
||||||
|
RMAP_errUnknownTransactID, ///< 17
|
||||||
|
RMAP_spwReconnectFailed, ///< 18
|
||||||
|
RMAP_errInputParam, ///< 19
|
||||||
|
RMAP_unknownInitiatorLogAddrInReply,///< 20
|
||||||
|
RMAP_errTxTimeout, ///< 21
|
||||||
|
RMAP_errRxReplyTimeout, ///< 22
|
||||||
|
COUNT_ERR_MAX_ELEMENTS_RMAP = 30
|
||||||
|
} RMAP_errFlag_en;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief structure with exchange error status counters
|
||||||
|
* according to RMAP protocol (ECSS-E-ST-50-52C), table 5-4
|
||||||
|
*/
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t success; ///< 00
|
||||||
|
uint16_t general; ///< 01
|
||||||
|
uint16_t unusePackType; ///< 02
|
||||||
|
uint16_t invalKey; ///< 03
|
||||||
|
uint16_t invalDataCRC; ///< 04
|
||||||
|
uint16_t dataEarlyEOP; ///< 05
|
||||||
|
uint16_t tooMuchData; ///< 06
|
||||||
|
uint16_t dataEEP; ///< 07
|
||||||
|
uint16_t reserved; ///< 08
|
||||||
|
uint16_t verifyBufOver; ///< 09
|
||||||
|
uint16_t cmdNotImplement; ///< 10
|
||||||
|
uint16_t dataLengthErr; ///< 11
|
||||||
|
uint16_t invalTargLogAddr; ///< 12
|
||||||
|
uint16_t headerEarlierEOP; ///< 13
|
||||||
|
uint16_t invalHeaderCRC; ///< 14
|
||||||
|
uint16_t notRMAP; ///< 15
|
||||||
|
uint16_t replyTimeout; ///< 16
|
||||||
|
uint16_t unknownTransactID; ///< 17
|
||||||
|
uint16_t spwReconnectFailed; ///< 18
|
||||||
|
uint16_t invalInputParam; ///< 19
|
||||||
|
uint16_t unknownInitiatorLogAddrInReply; ///< 20
|
||||||
|
uint16_t txTimeout; ///< 21
|
||||||
|
uint16_t rxReplyTimeout; ///< 22
|
||||||
|
uint16_t reserve[7];
|
||||||
|
} RMAP_countErr_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
rmapNone = 0,
|
||||||
|
rmapRunTxCmd,
|
||||||
|
rmapTxCmdCmplt,
|
||||||
|
rmapWaitReply,
|
||||||
|
rmapRxReplyCmplt,
|
||||||
|
} RMAP_stateMachine_en;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RMAP_notRunOperation = 0,
|
||||||
|
RMAP_runOperation = 1,
|
||||||
|
RMAP_compltOperation = 2,
|
||||||
|
RMAP_abortOperation = 3
|
||||||
|
} RMAP_operStatus_en;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t spwPort; // 0 or 1
|
||||||
|
RMAP_cmdWriteReadHeadLogAddr_t cmdWRheadLogAddr;
|
||||||
|
RMAP_WriteReplyHead_t writeReplyHead;
|
||||||
|
RMAP_ReadReplyHead_t readReplyHead;
|
||||||
|
RMAP_cmdWriteReadHeadPathAddr_t cmdWRheadPathAddr;
|
||||||
|
uint32_t timeTxCmd;
|
||||||
|
uint32_t timeTxReply;
|
||||||
|
uint32_t timeWaitRxReply;
|
||||||
|
uint32_t rxReplyTimeout;
|
||||||
|
uint32_t txTimeout;
|
||||||
|
uint32_t timerPeriod;
|
||||||
|
volatile RMAP_stateMachine_en stateMachine;
|
||||||
|
volatile RMAP_errFlag_en errorCodeOperation;
|
||||||
|
volatile RMAP_operStatus_en operationStatus;
|
||||||
|
} RMAP_protocol_t;
|
||||||
|
|
||||||
|
extern RMAP_protocol_t RMAPcontrol;
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t reserve[11];
|
||||||
|
uint8_t repeatWriteCmd;
|
||||||
|
uint8_t repeatWriteCmdMax;
|
||||||
|
uint8_t targetLogAddr;
|
||||||
|
uint8_t initiatorLogAddr;
|
||||||
|
uint8_t targetSpwAddr[2];
|
||||||
|
uint16_t transactID;
|
||||||
|
RMAP_instruct_u instruction;
|
||||||
|
uint8_t errorLastOperation; //RMAP_errFlag_en
|
||||||
|
uint16_t error[COUNT_ERR_MAX_ELEMENTS_RMAP];
|
||||||
|
} RMAP_HK_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
extern RMAP_HK_t RMAP_HK;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
UART_errNone = 0, ///< 00
|
||||||
|
UART_errRxUnknownData, ///< 01
|
||||||
|
UART_errTxDMAfail, ///< 02
|
||||||
|
UART_errTxTimeout, ///< 03
|
||||||
|
UART_errOverflowFIFO, ///< 04
|
||||||
|
UART_errLineBreak, ///< 05
|
||||||
|
RMAP_errParityErr, ///< 06
|
||||||
|
RMAP_errFrameErr, ///< 07
|
||||||
|
RMAP_errRxTimeout, ///< 08
|
||||||
|
COUNT_ERR_MAX_ELEMENTS = 20,
|
||||||
|
} UART_operErrCode_enum;
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t reserve[9];
|
||||||
|
volatile uint8_t errorLastOperation; // UART_operErrCode_enum
|
||||||
|
volatile uint16_t error[COUNT_ERR_MAX_ELEMENTS];
|
||||||
|
} UART_HK_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
extern UART_HK_t UART_HK;
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t stack: 1;
|
||||||
|
uint8_t ram: 1;
|
||||||
|
uint8_t pFunc_start: 1;
|
||||||
|
uint8_t pFunc_end: 1;
|
||||||
|
uint8_t reserve: 4;
|
||||||
|
} Guard_memory_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
uint8_t all;
|
||||||
|
Guard_memory_t bit;
|
||||||
|
} Guard_memory_u;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
operationBeginOk = 0,
|
||||||
|
operationOk = 1,
|
||||||
|
unknownOperType = 2,
|
||||||
|
wrongNANDaddr = 3,
|
||||||
|
wrongInputParameters = 4,
|
||||||
|
DMAchannelBusy = 5,
|
||||||
|
RDYnotSet0 = 6,
|
||||||
|
RDYnotSetBackTo1 = 7,
|
||||||
|
DMAnotRun = 8,
|
||||||
|
DMAnotIRQ = 9,
|
||||||
|
DMAtimeout = 10,
|
||||||
|
DMAruntimeError = 11,
|
||||||
|
readStatusFail = 12,
|
||||||
|
featuresNotSet = 13,
|
||||||
|
repeatOperationFail = 14,
|
||||||
|
COUNT_ERR_NAND_FLASH_MAX = 20,
|
||||||
|
} NAND_operErrCode_enum;
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t column;
|
||||||
|
uint8_t page;
|
||||||
|
uint16_t block;
|
||||||
|
uint8_t LUN;
|
||||||
|
uint8_t numTarget[2]; ///< numTarg[0] - target Flash number with main data,
|
||||||
|
///< numTarg[1] - target Flash number with control data
|
||||||
|
} NAND_address_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t reserve[11];
|
||||||
|
NAND_address_t addr;
|
||||||
|
volatile uint32_t timeEraseBlock;
|
||||||
|
volatile uint16_t timeReadPage;
|
||||||
|
volatile uint16_t timeProgPage;
|
||||||
|
volatile uint8_t lastOperation; // NAND_operType_enum
|
||||||
|
volatile uint8_t lastOperationStatus; // NAND_operStatus_enum
|
||||||
|
volatile uint8_t errorLastOperation; // NAND_operErrCode_enum
|
||||||
|
uint16_t error[COUNT_ERR_NAND_FLASH_MAX];
|
||||||
|
} NAND_HK_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
extern NAND_HK_t NAND_HK;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
system_ok = 0,
|
||||||
|
memory_overflow = 1,
|
||||||
|
MAX_SYSTEM_ERROR = 255,
|
||||||
|
} system_error_enum;
|
||||||
|
|
||||||
|
#define HK_VERSION 1
|
||||||
|
#define HK_MAGIC 0x484B3031u // "HK01"
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t magic;
|
||||||
|
uint64_t version;
|
||||||
|
uint16_t size;
|
||||||
|
uint32_t counter;
|
||||||
|
|
||||||
|
uint8_t system_error;
|
||||||
|
Guard_memory_u guard;
|
||||||
|
|
||||||
|
UART_HK_t uart;
|
||||||
|
RMAP_HK_t rmap;
|
||||||
|
NAND_HK_t nand;
|
||||||
|
|
||||||
|
uint8_t crc;
|
||||||
|
|
||||||
|
} Snapshot_HK_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // DECLARATIONS_H
|
#endif // DECLARATIONS_H
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ UART UARTFixture::uart;
|
|||||||
comSettings_t UARTFixture::comPortSettings;
|
comSettings_t UARTFixture::comPortSettings;
|
||||||
Stats_t UARTFixture::stats;
|
Stats_t UARTFixture::stats;
|
||||||
path_t UARTFixture::path;
|
path_t UARTFixture::path;
|
||||||
|
UART_cmdReadMemory_t UARTFixture::iData;
|
||||||
|
char UARTFixture::cmdDataBuf[UART_DATA_MAX_BYTES];
|
||||||
QString UARTFixture::logFile;
|
QString UARTFixture::logFile;
|
||||||
|
|
||||||
int UARTFixture::extract_struct_from_elf(QString structTypeName)
|
int UARTFixture::extract_struct_from_elf(QString structTypeName)
|
||||||
@@ -197,6 +199,22 @@ TEST_P(UARTFixture, JsonCase)
|
|||||||
runCase(caseFile);
|
runCase(caseFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UARTFixture::writeToLog(QString errMsg, bool passed)
|
||||||
|
{
|
||||||
|
if (!passed)
|
||||||
|
{
|
||||||
|
stats.failed++;
|
||||||
|
qDebug(logCritical()) << errMsg << Qt::endl;
|
||||||
|
Logger::writeToConsol(QString("\nERROR: %1\n").arg(errMsg));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stats.passed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_TRUE(passed);
|
||||||
|
stats.total++;
|
||||||
|
}
|
||||||
|
|
||||||
void UARTFixture::runCase(
|
void UARTFixture::runCase(
|
||||||
const QString& caseFile)
|
const QString& caseFile)
|
||||||
{
|
{
|
||||||
@@ -204,26 +222,131 @@ void UARTFixture::runCase(
|
|||||||
QString msg;
|
QString msg;
|
||||||
QString err;
|
QString err;
|
||||||
QString error;
|
QString error;
|
||||||
|
bool passed = false;
|
||||||
|
QString protocolMsg;
|
||||||
|
QString test_case_path = "";
|
||||||
|
|
||||||
QFile caseFileJson(caseFile);
|
QFile caseFileJson(caseFile);
|
||||||
// ASSERT_TRUE(caseFileJson.open(QIODevice::ReadOnly));
|
|
||||||
if (!caseFileJson.open(QIODevice::ReadOnly))
|
|
||||||
|
|
||||||
|
if (!caseFileJson.open(QIODevice::ReadOnly))
|
||||||
|
{ writeToLog(QString("%1, path: %2").arg("json test case not found", caseFile), false); }
|
||||||
|
|
||||||
|
QJsonObject cfg =
|
||||||
|
QJsonDocument::fromJson(caseFileJson.readAll()).object();
|
||||||
|
|
||||||
|
QJsonObject meta = cfg["meta"].toObject();
|
||||||
|
|
||||||
|
if (meta.isEmpty())
|
||||||
{
|
{
|
||||||
msg = QString("%1, path: %2").arg("json test case not found", caseFile);
|
msg = QString("%1, path: %2").arg("incorrect json file: ", caseFile);
|
||||||
msgItog.append(msg);
|
msgItog.append(msg);
|
||||||
|
|
||||||
qDebug(logCritical()) << msg << Qt::endl;
|
qDebug(logCritical()) << msg << Qt::endl;
|
||||||
Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject cfg =
|
|
||||||
QJsonDocument::fromJson(caseFileJson.readAll()).object();
|
|
||||||
|
|
||||||
|
if (meta["input_data_type"].toString() == "binary")
|
||||||
|
{
|
||||||
|
QJsonObject param = meta["parameters"].toObject();
|
||||||
|
|
||||||
|
bool ok = false;
|
||||||
|
iData.version = param["version"].toInt();
|
||||||
|
|
||||||
|
if (param["addr_user_set"].toBool() == true)
|
||||||
|
{ iData.addr_begin = param["addr"].toString().toUInt(&ok, 16); }
|
||||||
|
|
||||||
|
if (param["size_user_set"].toBool() == true)
|
||||||
|
{ iData.size_bytes = param["size"].toInt(); }
|
||||||
|
|
||||||
|
|
||||||
|
if (iData.size_bytes >= UART_DATA_MAX_BYTES - 1)
|
||||||
|
{
|
||||||
|
msg = QString("%1: %2")
|
||||||
|
.arg("UART data did not send: ",
|
||||||
|
QString("required structure size %1 too big for UART transmission (MAX: %2). See test_case file: %3")
|
||||||
|
.arg(QString(iData.size_bytes), QString(UART_DATA_MAX_BYTES),
|
||||||
|
test_case_path));
|
||||||
|
msgItog.append(msg);
|
||||||
|
|
||||||
|
qDebug(logCritical()) << msg << Qt::endl;
|
||||||
|
Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
formCmdDataInBuffer();
|
||||||
|
QByteArray data;
|
||||||
|
|
||||||
|
if (param["cmd_from_binary_file"].toBool() == true)
|
||||||
|
{
|
||||||
|
QString binaryFile = cfg["binary"].toString();
|
||||||
|
QFile cmdFile(binaryFile);
|
||||||
|
if (!cmdFile.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
msg = QString("%1, path: %2").arg("command binary not found", binaryFile);
|
||||||
|
msgItog.append(msg);
|
||||||
|
|
||||||
|
qDebug(logCritical()) << msg << Qt::endl;
|
||||||
|
Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
data = cmdFile.readAll();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QByteArray data1(QByteArray::fromRawData(cmdDataBuf, UART_DATA_MAX_BYTES));
|
||||||
|
data = data1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uart.send(data, err))
|
||||||
|
{
|
||||||
|
msg = QString("%1: %2").arg("UART data did not send", err);
|
||||||
|
msgItog.append(msg);
|
||||||
|
|
||||||
|
qDebug(logCritical()) << msg << Qt::endl;
|
||||||
|
Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray rx_data = uart.receive(cfg["timeout_msec"].toInt());
|
||||||
|
|
||||||
|
Snapshot_HK_t snapshot;
|
||||||
|
memcpy(&snapshot, rx_data.constData(), sizeof(snapshot));
|
||||||
|
|
||||||
|
EXPECT_EQ(snapshot.version, 1);
|
||||||
|
EXPECT_EQ(snapshot.size, 222);
|
||||||
|
EXPECT_EQ(snapshot.system_error, 0);
|
||||||
|
EXPECT_EQ(snapshot.guard.all, 0);
|
||||||
|
|
||||||
|
EXPECT_EQ(snapshot.uart.errorLastOperation, 0);
|
||||||
|
|
||||||
|
QVector<int> excludedIdx;
|
||||||
|
excludedIdx.push_back(0);
|
||||||
|
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
bool excludeFlag = false;
|
||||||
|
|
||||||
|
for (int j = 0; j < excludedIdx.size(); j++)
|
||||||
|
{
|
||||||
|
if (i == excludedIdx[j])
|
||||||
|
{ excludeFlag = true; break; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (excludeFlag == false)
|
||||||
|
{ EXPECT_EQ(snapshot.uart.error[i], 0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
passed = true;
|
||||||
|
}
|
||||||
|
else if (meta["input_data_type"].toString() == "text")
|
||||||
|
{
|
||||||
QString binaryFile = cfg["binary"].toString();
|
QString binaryFile = cfg["binary"].toString();
|
||||||
|
|
||||||
QFile cmdFile(binaryFile);
|
QFile cmdFile(binaryFile);
|
||||||
// ASSERT_TRUE(cmdFile.open(QIODevice::ReadOnly));
|
|
||||||
if (!cmdFile.open(QIODevice::ReadOnly))
|
if (!cmdFile.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
msg = QString("%1, path: %2").arg("command binary not found", binaryFile);
|
msg = QString("%1, path: %2").arg("command binary not found", binaryFile);
|
||||||
@@ -242,20 +365,19 @@ void UARTFixture::runCase(
|
|||||||
qDebug(logCritical()) << msg << Qt::endl;
|
qDebug(logCritical()) << msg << Qt::endl;
|
||||||
Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
||||||
}
|
}
|
||||||
// ASSERT_TRUE(uart.send(tx_cmd, err));
|
|
||||||
|
|
||||||
QByteArray rx_data = uart.receive(cfg["timeout_msec"].toInt());
|
QByteArray rx_data = uart.receive(cfg["timeout_msec"].toInt());
|
||||||
|
|
||||||
ProtocolHandler handler(cfg["expectations"].toObject());
|
ProtocolHandler handler(cfg["expectations"].toObject());
|
||||||
handler.feed(rx_data);
|
handler.feed(rx_data);
|
||||||
|
|
||||||
QString protocolMsg;
|
|
||||||
bool passed = handler.isDone(protocolMsg);
|
|
||||||
|
|
||||||
if (!passed)
|
if (!passed)
|
||||||
{ error = QString("Protocol validation failed:\n%1").arg(protocolMsg); }
|
{ error = QString("Protocol validation failed:\n%1").arg(protocolMsg); }
|
||||||
|
|
||||||
|
passed = handler.isDone(protocolMsg);
|
||||||
Logger::saveTestLog(logFile, handler, cfg, passed, error);
|
Logger::saveTestLog(logFile, handler, cfg, passed, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
stats.total++;
|
stats.total++;
|
||||||
if (passed) stats.passed++;
|
if (passed) stats.passed++;
|
||||||
@@ -266,39 +388,89 @@ void UARTFixture::runCase(
|
|||||||
{ QThread::msleep(g_options.delayMs); }
|
{ QThread::msleep(g_options.delayMs); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UARTFixture::serializeCmdDataBuf(void *dataStruct, int countBytes)
|
||||||
|
{
|
||||||
|
UART_cmdWord_u cmdWord;
|
||||||
|
|
||||||
|
cmdWord.all = 0;
|
||||||
|
cmdWord.bit.cmdCode = UART_cmdReadMemory;
|
||||||
|
cmdWord.bit.countBytes = countBytes;
|
||||||
|
|
||||||
|
int cntBytesAll = CMD_WORD_SIZE + cmdWord.bit.countBytes;
|
||||||
|
|
||||||
|
memcpy(cmdDataBuf, &cmdWord.all, CMD_WORD_SIZE);
|
||||||
|
memcpy(cmdDataBuf + CMD_WORD_SIZE, dataStruct,
|
||||||
|
cmdWord.bit.countBytes - 1);
|
||||||
|
|
||||||
|
quint8 crc = crc8(cmdDataBuf, cntBytesAll - 1);
|
||||||
|
cmdDataBuf[cntBytesAll - 1] = crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UARTFixture::formCmdDataInBuffer()
|
||||||
|
{
|
||||||
|
int countBytesCmdData = sizeof(UART_cmdReadMemory_t) + 1;
|
||||||
|
serializeCmdDataBuf(&iData, countBytesCmdData);
|
||||||
|
}
|
||||||
|
|
||||||
void UARTFixture::TearDown()
|
void UARTFixture::TearDown()
|
||||||
{
|
{
|
||||||
// QString cleanupCase =
|
// QThread::msleep(200);
|
||||||
// "configs/test_cases/test_abort.json";
|
// QString msgItog;
|
||||||
|
// QString msg;
|
||||||
// QFile f(cleanupCase);
|
|
||||||
|
|
||||||
// if (!f.open(QIODevice::ReadOnly))
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// QJsonObject cfg =
|
|
||||||
// QJsonDocument::fromJson(
|
|
||||||
// f.readAll()
|
|
||||||
// ).object();
|
|
||||||
|
|
||||||
// QString binary =
|
|
||||||
// cfg["binary"].toString();
|
|
||||||
|
|
||||||
// QFile cmd(binary);
|
|
||||||
|
|
||||||
// if (!cmd.open(QIODevice::ReadOnly))
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// QByteArray tx = cmd.readAll();
|
|
||||||
|
|
||||||
// QString err;
|
// QString err;
|
||||||
|
// QString test_case_path = "";
|
||||||
|
|
||||||
// uart.send(tx, err);
|
// iData.version = 0x1;
|
||||||
|
// iData.addr_begin = 0x08125600;
|
||||||
|
// iData.size_bytes = 222;
|
||||||
|
|
||||||
// uart.receive(
|
// if (iData.size_bytes >= UART_DATA_MAX_BYTES - 1)
|
||||||
// cfg["timeout_msec"].toInt()
|
// {
|
||||||
// );
|
// msg = QString("%1: %2")
|
||||||
|
// .arg("UART data did not send: ",
|
||||||
|
// QString("required structure size %1 too big for UART transmission (MAX: %2). See test_case file: %3")
|
||||||
|
// .arg(QString(iData.size_bytes), QString(UART_DATA_MAX_BYTES),
|
||||||
|
// test_case_path));
|
||||||
|
// msgItog.append(msg);
|
||||||
|
|
||||||
|
// qDebug(logCritical()) << msg << Qt::endl;
|
||||||
|
// Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// formCmdDataInBuffer();
|
||||||
|
|
||||||
|
// QByteArray data(QByteArray::fromRawData(cmdDataBuf, UART_DATA_MAX_BYTES));
|
||||||
|
|
||||||
|
|
||||||
|
// QString pathData = "data.bin";
|
||||||
|
// QFile file(pathData);
|
||||||
|
|
||||||
|
// if (!file.open(QIODevice::WriteOnly))
|
||||||
|
// { printf("\t\n ERROR open file!"); }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// QDataStream out(&file);
|
||||||
|
// out.writeRawData(data, UART_DATA_MAX_BYTES);
|
||||||
|
// file.close();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// uart.send(data, err);
|
||||||
|
|
||||||
|
// if (!uart.send(data, err))
|
||||||
|
// {
|
||||||
|
// msg = QString("%1: %2").arg("UART data did not send", err);
|
||||||
|
// msgItog.append(msg);
|
||||||
|
|
||||||
|
// qDebug(logCritical()) << msg << Qt::endl;
|
||||||
|
// Logger::writeToConsol(QString("\nERROR: %1\n").arg(msg));
|
||||||
|
// }
|
||||||
|
//// QByteArray rx_data = uart.receive(cfg["timeout_msec"].toInt());
|
||||||
|
// QByteArray rx_data = uart.receive(1000);
|
||||||
|
// printf(rx_data);
|
||||||
|
// }
|
||||||
|
|
||||||
// QThread::msleep(200);
|
// QThread::msleep(200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
#include "../core/test_stats.h"
|
#include "../core/test_stats.h"
|
||||||
#include <json_processor.h>
|
#include <json_processor.h>
|
||||||
|
|
||||||
|
#define CMD_WORD_SIZE 4
|
||||||
|
#define UART_DATA_MAX_BYTES 1024
|
||||||
|
|
||||||
struct TestCaseParam
|
struct TestCaseParam
|
||||||
{
|
{
|
||||||
QString path;
|
QString path;
|
||||||
@@ -20,6 +23,52 @@ struct Stats_t
|
|||||||
uint16_t failed;
|
uint16_t failed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t version;
|
||||||
|
uint32_t addr_begin;
|
||||||
|
uint32_t size_bytes;
|
||||||
|
uint32_t reserve[20];
|
||||||
|
} UART_cmdReadMemory_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
quint32 all;
|
||||||
|
struct BITS
|
||||||
|
{
|
||||||
|
unsigned reserve: 2;
|
||||||
|
unsigned beginCmdFlag: 1;
|
||||||
|
unsigned endCmdFlag: 1;
|
||||||
|
unsigned countPack: 10;
|
||||||
|
unsigned countBytes: 10;
|
||||||
|
unsigned cmdCode: 8;
|
||||||
|
} bit;
|
||||||
|
} UART_cmdWord_u;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
UART_cmdErase = 1,
|
||||||
|
UART_cmdAbort = 2,
|
||||||
|
UART_cmdBuildBadBlockMapNAND = 3,
|
||||||
|
UART_cmdBadBlockMapOper = 4,
|
||||||
|
UART_cmdSetNANDsettings = 5,
|
||||||
|
UART_cmdReadPage = 6,
|
||||||
|
UART_cmdSetDataInterface = 7,
|
||||||
|
UART_cmdRandomDataTest = 19,
|
||||||
|
UART_cmdMarchFTEallTarget = 20,
|
||||||
|
UART_cmdMarchFTE = 21,
|
||||||
|
UART_cmdEnduranceTest = 22,
|
||||||
|
UART_cmdStartRetentionData = 23,
|
||||||
|
UART_cmdCheckRetentionTest = 24,
|
||||||
|
UART_cmdNotAbort = 25,
|
||||||
|
UART_cmdFail = 26,
|
||||||
|
UART_cmdReadMemory = 27,
|
||||||
|
UART_cmdEND = 255
|
||||||
|
} UART_cmd_en;
|
||||||
|
|
||||||
|
|
||||||
class UARTFixture :
|
class UARTFixture :
|
||||||
public ::testing::TestWithParam<TestCaseParam>
|
public ::testing::TestWithParam<TestCaseParam>
|
||||||
{
|
{
|
||||||
@@ -29,7 +78,11 @@ protected:
|
|||||||
static comSettings_t comPortSettings;
|
static comSettings_t comPortSettings;
|
||||||
static path_t path;
|
static path_t path;
|
||||||
static QString logFile;
|
static QString logFile;
|
||||||
|
static UART_cmdReadMemory_t iData;
|
||||||
|
static char cmdDataBuf[UART_DATA_MAX_BYTES];
|
||||||
|
|
||||||
|
static void serializeCmdDataBuf(void *dataStruct, int countBytes);
|
||||||
|
static void formCmdDataInBuffer();
|
||||||
static void SetUpTestSuite();
|
static void SetUpTestSuite();
|
||||||
static void TearDownTestSuite();
|
static void TearDownTestSuite();
|
||||||
|
|
||||||
@@ -40,5 +93,7 @@ protected:
|
|||||||
void TearDown() override;
|
void TearDown() override;
|
||||||
void runCase(const QString& caseFile);
|
void runCase(const QString& caseFile);
|
||||||
|
|
||||||
|
static void writeToLog(QString errMsg, bool passed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user