更新硬件SDK

This commit is contained in:
kerwincui
2023-03-04 03:44:56 +08:00
parent dcdf6e1b7c
commit e39d3d2f03
1900 changed files with 663153 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
/******************************************************************************
*(C) Copyright 2018 AirM2M International Ltd.
* All Rights Reserved
******************************************************************************
* Filename:
*
* Description:
*
* History:
*
* Notes:
*
******************************************************************************/
#ifndef EC_STRING_H
#define EC_STRING_H
/*----------------------------------------------------------------------------*
* GLOBAL FUNCTIONS DECLEARATION *
*----------------------------------------------------------------------------*/
#if defined(__cplusplus)
extern "C" {
#endif
int32_t strlen_fast(const char *str);
char* ec_strnstr(const char *s, const char *find, size_t slen);
#ifdef __cplusplus
}
#endif
#endif // EC_STRING_H

View File

@@ -0,0 +1,70 @@
#ifndef __EC_UICC_API_H__
#define __EC_UICC_API_H__
/******************************************************************************
Copyright: - 2017, All rights reserved by AirM2M Ltd.
File name: - ecuiccapi.h
Description: - the header file for UICC open API.
Function List: -
History: - 09/20/2022, Originated by xlhu
******************************************************************************/
/*********************************************************************************
* Includes
*********************************************************************************/
#include "commontypedef.h"
/*********************************************************************************
* Macros
*********************************************************************************/
/*********************************************************************************
* Type Definition
*********************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
/******************************************************************************
* SoftSimReset
* Description: This API called by modem/uiccdrv task to reset softsim and get ATR parameter from softsim,
* as same as code/warm reset with physical SIM card.
* param[out] UINT16 *atrLen, the pointer to the length of ATR, this memory don't need to be free.
* param[out] UINT8 *atrData, the pointer to the ATR data, this memory don't need to be free.
* atrData buffer size is 33, fill atrData shall not exceed 33 bytes.
* Comment: This API will be called only if softsim feature is enabled by AT CMD.
* Shall send signal/msg to softsim task and block to wait response .
* Softsim internal process running in this func is not allowed.
******************************************************************************/
void SoftSimReset(UINT16 *atrLen, UINT8 *atrData);
/******************************************************************************
* SoftSimApduReq
* Description: This API will be called by modem/uiccdrv task to send APDU(TPDU) request and get response from softsim,
* support case 1/2/3/4 command/response process.
* param[in] UINT16 txDataLen, the length of tx data
* param[in] UINT8 *txData, the pointer to the tx data, this memory don't need to be free.
* param[out] UINT16 *rxDataLen, the pointer to the length of rx data, this memory don't need to be free.
* param[out] UINT8 *rxData, the pointer to the rx data, this memory don't need to be free.
* rxData buffer size is 258, fill rxData shall not exceed 258 bytes.
* Comment: This API will be called only if softsim feature is enabled by AT CMD.
* Shall send signal/msg to softsim task and block to wait response.
* Softsim internal process running in this func is not allowed.
******************************************************************************/
void SoftSimApduReq(UINT16 txDataLen, UINT8 *txData, UINT16 *rxDataLen, UINT8 *rxData);
/******************************************************************************
* SoftSimInit
* Description: This api called by modem/uiccdrv task to start softsim task if softsim feature is enabled.
* input: void
* output: void
* Comment:
******************************************************************************/
void SoftSimInit(void);
#endif

View File

@@ -0,0 +1,109 @@
/**************************************************************************//**
* @file exception_dump.h
* @brief CMSIS OS Tick header file
* @version V1.0.0
* @date 05. June 2017
******************************************************************************/
/*
* Copyright (c) 2017-2017 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _EXCEPTION_DUMP_H
#define _EXCEPTION_DUMP_H
#include "cmsis_compiler.h"
#include "commontypedef.h"
#include "mem_map.h"
#define MAX_DELAYHHH 0//0xffffff
#define MAX_DELAY 0//0xff
#define DUMP_UART_INSTANCE 0
#define DUMP_SYNC_RSP_LEN 8
//#define DUMP_SYNC_RSP_LEN 2
#define DUMP_RECV_FIFO_LEN 16
#define CMD_FIX_LEN 8
#define CMD_FCS_LEN 4
#define PROTOCOL_RSP_FIX_LEN 8
#define PREAMBLE_CNT 1
#define PREAMBLE_STRING_LEN 10
#define PREAMBLE_WITH_NULL 1
#define MAX_CMD_DATALEN 32 //maximum data size for cmd
#define MAX_READ_DATALEN (48*1024) //maximum data size for cmd
#define MAX_RETRY_COUNT 32
#define DATA_DUMP_WAIT_SYNC_MAX_RETRY_COUNT 10
#define DATA_DUMP_GET_CMD_MAX_RETRY_COUNT 100
#define DUMP_CID 0xdc
#define N_DUMP_CID 0x23
#define READ_ONECE_DATA_LEN 256
#define ACK 0
#define NACK 1
#define GetDataCmd 0x20
#define GetInfoCmd 0x21
#define FinishCmd 0x25
#define WaitPeriod_1s 1000000
#define DUMP_RETRY_CMD_COUNT 1
#define DUMP_RETRY_CMD_RESEND 2
#define DUMP_RETRY_ADDR 0x00C000
#define DUMP_RETRY_COUNT_MAX 2
#define DUMP_END_FLAG_INIT 0xEC00
#define DUMP_END_FLAG_SUCC 0xEC88
typedef struct {
uint32_t ReadDataAddr;
uint32_t ReadLen;
}ReadDataReqCell;
typedef struct {
uint8_t Command;
uint8_t Sequence;
uint8_t CID;
uint8_t NCID;
uint16_t Status;
uint16_t Length;//Length for Data filed
//uint8_t Data[MAX_CMD_DATALEN];
uint32_t FCS;
}DumpRspWrap, *PtrDumpRspWrap;
typedef struct {
uint8_t Command;
uint8_t Sequence;
uint8_t CID;
uint8_t NCID;
uint32_t Length;//Length for Data filed
uint8_t Data[MAX_CMD_DATALEN];
uint32_t FCS;
}DumpReqWrap, *PtrDumpReqWrap;
uint32_t EcDumpTopFlow(void);
#ifdef FEATURE_UART_HELP_DUMP_ENABLE
#define EC_UART_HELP_DUMP_BUFF_LEN 128
uint32_t EcDumpHandshakeProcUart(uint32_t SyncPeriod);
uint32_t EcDumpDataFlowUart(void);
#endif
#endif /* _EXCEPTION_DUMP_H */

View File

@@ -0,0 +1,502 @@
/******************************************************************************
*(C) Copyright 2018 AirM2M International Ltd.
* All Rights Reserved
******************************************************************************
* Filename:exception_process.h
*
* Description:
*
* History:
*
* Notes:
*
******************************************************************************/
/*----------------------------------------------------------------------------*
* INCLUDES *
*----------------------------------------------------------------------------*/
#ifndef _EXCEPTION_PROCESS_H
#define _EXCEPTION_PROCESS_H
#include "cmsis_compiler.h"
#include "commontypedef.h"
#include "mem_map.h"
/*----------------------------------------------------------------------------*
* MACROS *
*----------------------------------------------------------------------------*/
#define EC_FUNC_CALL_ADDR_DEPTH 4
#define EC_ASSERT_FUNC_CALL_ADDR_DEPTH 4
#define EC_EXCEP_STACK_DEPTH 32
#define EC_EXCEP_SECTOR_SIZE 4096
#define EC_EXCEP_MAGIC_NUMBER (0x00ec00ec)
#define EC_EXCEP_FLASH_SECTOR_BASE EC_EXCEPTION_FLASH_BASE
#define EC_EXCEP_TASK_NAME_LEN 12
#define EC_SP_PSP_FLAG 0x4
#define EC_REG_SYS_CTRL_STATE (*(volatile unsigned int *) (0xE000ED24u))
#define EC_REG_MFSR (*(volatile unsigned int *) (0xE000ED28u))
#define EC_REG_MMAR (*(volatile unsigned int *) (0xE000ED34u))
#define EC_REG_BFSR (*(volatile unsigned int *) (0xE000ED29u))
#define EC_REG_BFAR (*(volatile unsigned int *) (0xE000ED38u))
#define EC_REG_UFSR (*(volatile unsigned int *) (0xE000ED2Au))
#define EC_REG_HFSR (*(volatile unsigned int *) (0xE000ED2Cu))
#define EC_REG_DFSR (*(volatile unsigned int *) (0xE000ED30u))
#define EC_REG_AFSR (*(volatile unsigned int *) (0xE000ED3Cu))
// magic number for fs assert indication "FS_Assert_sF", 12bytes/3 words 0x46535F41 0x73736572 0x745F7346
#define EC_FS_ASSERT_MAGIC_NUMBER0 (0x46535F41)
#define EC_FS_ASSERT_MAGIC_NUMBER1 (0x73736572)
#define EC_FS_ASSERT_MAGIC_NUMBER2 (0x745F7346)
#define EC_FS_ASSERT_REFORMAT_THRESHOLD (10)
#define AT_PORT_UART_INSTANCE (1)
#define RESET_REASON_MAGIC (0xACD20E00)
#define RESET_REASON_MASK (0xFFFFFF00)
#define ACTIVE_RESET_MAGIC (0x5)
#define ACTIVE_RESET_MASK (0xF)
#define FUNC_CALL_TRACE
#define EC_EXCEP_COMPRESS_SIZE 4096
#define EC_EXCEP_COMPRESS_HEAD_OFFSET 4
#define EC_AP_64K_RAM_START_ADDR 0x000
#define EC_AP_64K_RAM_END_ADDR 0x10000
#define EC_AP_64K_RAM_LEN (EC_AP_64K_RAM_END_ADDR - EC_AP_64K_RAM_START_ADDR)
#define EC_AP_125M_RAM_START_ADDR 0x400000
#define EC_AP_125M_RAM_END_ADDR 0x4B0000
#define EC_AP_125M_RAM_CODE_START_ADDR 0x400000
#define EC_AP_125M_RAM_CODE_END_ADDR 0x8000
#define EC_AP_125M_RAM_CODE_LEN (EC_AP_125M_RAM_CODE_END_ADDR - EC_AP_125M_RAM_CODE_START_ADDR)
#define EC_AP_125M_RAM_RW_START_ADDR 0x400000
#define EC_AP_125M_RAM_RW_END_ADDR 0x4B0000
#define EC_AP_125M_RAM_RW_LEN (EC_AP_125M_RAM_RW_END_ADDR - EC_AP_125M_RAM_RW_START_ADDR)
#define EC_CP_64K_RAM_START_ADDR 0x200000
#define EC_CP_64K_RAM_END_ADDR 0x210000
#define EC_CP_64K_RAM_LEN (EC_CP_64K_RAM_END_ADDR - EC_CP_64K_RAM_START_ADDR)
#define EC_CP_125M_RAM_START_ADDR 0x4B0000
#define EC_CP_125M_RAM_END_ADDR 0x4B0000
#define EC_CP_125M_RAM_CODE_START_ADDR 0x4B0000
#define EC_CP_125M_RAM_CODE_END_ADDR 0x4B0000
#define EC_CP_125M_RAM_CODE_LEN (EC_CP_125M_RAM_CODE_END_ADDR - EC_CP_125M_RAM_CODE_START_ADDR)
#define EC_CP_125M_RAM_RW_START_ADDR 0x4B0000
#define EC_CP_125M_RAM_RW_END_ADDR 0x4B0000
#define EC_CP_125M_RAM_RW_LEN (EC_CP_125M_RAM_RW_END_ADDR - EC_CP_125M_RAM_RW_START_ADDR)
#define EC_EXCEPTION_FLASH_BASE FLASH_EXCEP_DUMP_ADDR
#define EC_EXCEPTION_FLASH_BLOCK_NUMBS FLASH_EXCEP_DUMP_SECTOR_NUM // (420KB/105 sectors)
#define EC_EXCEPTION_FLASH_MAX_LEN (EC_EXCEPTION_FLASH_BLOCK_NUMBS*EC_EXCEP_COMPRESS_SIZE) // (424KB)
#define EC_EXCEPTION_AP_RAM_BASE (0x00000)
#define EC_EXCEPTION_AP_RAM_END (0x10000)
#define EC_EXCEPTION_AP_RAM_LEN (EC_EXCEPTION_AP_RAM_END - EC_EXCEPTION_AP_RAM_BASE)
#define EC_EXCEPTION_CP_RAM_BASE (0x200000)
#define EC_EXCEPTION_CP_RAM_END (0x210000)
#define EC_EXCEPTION_CP_RAM_LEN (EC_EXCEPTION_CP_RAM_END - EC_EXCEPTION_CP_RAM_BASE)
#define EC_EXCEPTION_APCP_RAM_BASE (0x400000)
#define EC_EXCEPTION_APCP_RAM_END (0x540000)
#define EC_EXCEPTION_APCP_RAM_LEN (EC_EXCEPTION_APCP_RAM_END - EC_EXCEPTION_APCP_RAM_BASE)
#define EC_EXCEPTION_CP_SHARED_RAM_LEN (0x14000)
#define EC_SHAREDINFO_RAM_END_ADDR (0x53F000)
#define EC_ASSERT_PC_ADDR (EC_SHAREDINFO_RAM_END_ADDR-0x20) // 0x53EFE0
#define EC_ASSERT_LR_ADDR (EC_SHAREDINFO_RAM_END_ADDR-0x18) // 0x53EFE8
#define EC_EXCEPTION_MAGIC_AP_ADDR (EC_SHAREDINFO_RAM_END_ADDR-0x10) // 0x53EFF0
#define EC_EXCEPTION_MAGIC_CP_ADDR (EC_SHAREDINFO_RAM_END_ADDR-0x0C) // 0x53EFF4
#define EC_EXCEPTION_STORE_RAM_ADDR (EC_SHAREDINFO_RAM_END_ADDR-0x8) // 0x53EFF8
#define EC_COMPRESS_FLAG_AP_64K "ec_comp_ap_64k"
#define EC_COMPRESS_FLAG_AP_125M "ec_comp_ap_125m"
#define EC_COMPRESS_FLAG_CP_64K "ec_comp_cp_64k"
#define EC_COMPRESS_FLAG_CP_125M "ec_comp_cp_125m"
#define EC_COMPRESS_ADDR_AP_64K "ec_comp_addr_ap:"
#define EC_COMPRESS_ADDR_CP_64K "ec_comp_addr_cp:"
#define EC_COMPRESS_ADDR_125M "ec_comp_addr_all:"
#define EC_COMPRESS_ADDR_AP_125M "ec_comp_addr_share_ap:"
#define EC_COMPRESS_ADDR_CP_125M "ec_comp_addr_share_cp:"
#define EC_AP_HARDFAULT_TASK_FLAG 0xAF012013
#define EC_AP_ASSERT_TASK_FLAG 0xAA012013
#define EC_AP_HARDFAULT_INT_FLAG 0xAF010129
#define EC_AP_ASSERT_INT_FLAG 0xAA010129
#define EC_AP_HARDFAULT_SMALLIMAGE_FLAG 0xAF019527
#define EC_AP_ASSERT_SMALLIMAGE_FLAG 0xAA019527
#define EC_CP_HARDFAULT_TASK_FLAG 0xCF012013
#define EC_CP_ASSERT_TASK_FLAG 0xCA012013
#define EC_CP_HARDFAULT_INT_FLAG 0xCF010129
#define EC_CP_ASSERT_INT_FLAG 0xCA010129
#define EC_CP_HARDFAULT_SMALLIMAGE_FLAG 0xCF019527
#define EC_CP_ASSERT_SMALLIMAGE_FLAG 0xCA019527
#define EC_EXCEP_TYPE_AP_TASK_HARDFAULT EC_AP_HARDFAULT_TASK_FLAG
#define EC_EXCEP_TYPE_AP_TASK_ASSERT EC_AP_ASSERT_TASK_FLAG
#define EC_EXCEP_TYPE_CP_TASK_HARDFAULT EC_CP_HARDFAULT_TASK_FLAG
#define EC_EXCEP_TYPE_CP_TASK_ASSERT EC_CP_ASSERT_TASK_FLAG
#define EC_EXCEP_TYPE_AP_INT_HARDFAULT EC_AP_HARDFAULT_INT_FLAG
#define EC_EXCEP_TYPE_AP_INT_ASSERT EC_AP_ASSERT_INT_FLAG
#define EC_EXCEP_TYPE_CP_INT_HARDFAULT EC_CP_HARDFAULT_INT_FLAG
#define EC_EXCEP_TYPE_CP_INT_ASSERT EC_CP_ASSERT_INT_FLAG
#define EC_EXCEP_TYPE_AP_SMALLIMAGE_HARDFAULT EC_AP_HARDFAULT_SMALLIMAGE_FLAG
#define EC_EXCEP_TYPE_AP_SMALLIMAGE_ASSERT EC_AP_ASSERT_SMALLIMAGE_FLAG
#define EC_EXCEP_TYPE_CP_SMALLIMAGE_HARDFAULT EC_CP_HARDFAULT_SMALLIMAGE_FLAG
#define EC_EXCEP_TYPE_CP_SMALLIMAGE_ASSERT EC_CP_ASSERT_SMALLIMAGE_FLAG
#define EC_EXCEPTION_START_FLAG 0xEC112013
#define EC_EXCEPTION_END_FLAG 0xEC990129
#define EC_EXCEP_ASSERT_BUFF_LEN 120
/*----------------------------------------------------------------------------*
* DATA TYPE DEFINITION *
*----------------------------------------------------------------------------*/
typedef struct ec_exception_comp_tag
{
uint32_t needCompressAddr;
uint32_t needCompressTotalLen;
uint32_t needCompressOnceLen;
uint32_t compressedBufAddr;
uint32_t compressedBufLen;
uint32_t writeFlashAddr;
uint32_t compressType;
}ec_comp_input;
typedef struct ec_exception_data_tag
{
UINT32 startAddr;
UINT32 compressedLen;
}ec_exception_data;
typedef struct ec_exception_addr_tag
{
uint32_t ap_ram_start_addr;
uint32_t ap_ram_end_addr;
uint32_t cp_ram_start_addr;
uint32_t cp_ram_end_addr;
uint32_t apcp_ram_start_addr;
uint32_t apcp_ram_end_addr;
uint32_t ec_stack_start_addr;
uint32_t ec_stack_end_addr;
uint32_t ec_code_start_addr;
uint32_t ec_code_end_addr;
}ec_exception_addr;
typedef struct _ec_m3_exception_regs
{
struct
{
uint32_t r0;
uint32_t r1;
uint32_t r2;
uint32_t r3;
uint32_t r4;
uint32_t r5;
uint32_t r6;
uint32_t r7;
uint32_t r8;
uint32_t r9;
uint32_t r10;
uint32_t r11;
uint32_t r12;
uint32_t sp;
uint32_t lr;
uint32_t pc;
union
{
uint32_t value;
struct
{
uint32_t IPSR : 8;
uint32_t EPSR : 8;
uint32_t APSR : 8;
}bits;
}psr;
uint32_t exc_return;
uint32_t msp;
uint32_t psp;
uint32_t CONTROL;
uint32_t BASEPRI;
uint32_t PRIMASK;
uint32_t FAULTMASK;
}stack_frame;
union
{
uint32_t value;
struct
{
uint32_t MEM_FAULT_ACT : 1;
uint32_t BUS_FAULT_ACT : 1;
uint32_t UNUSED_BITS1 : 1;
uint32_t USAGE_FAULT_ACT : 1;
uint32_t UNUSED_BITS2 : 3;
uint32_t SVCALLACT : 1;
uint32_t MONITORACT : 1;
uint32_t UNUSED_BITS3 : 1;
uint32_t PENDSVACT : 1;
uint32_t SYSTICKACT : 1;
uint32_t USAGEFAULTPENDED : 1;
uint32_t MEMFAULTPENDED : 1;
uint32_t BUSFAULTPENDED : 1;
uint32_t SVCALLPENDED : 1;
uint32_t MEMFAULT_EN : 1;
uint32_t BUSFAULT_EN : 1;
uint32_t USAGEFAULT_EN : 1;
}bits;
}sys_ctrl_stat;
union
{
uint8_t value;
struct
{
uint8_t IACCVIOL : 1;
uint8_t DACCVIOL : 1;
uint8_t UNUSED_BIT : 1;
uint8_t MUNSTKERR : 1;
uint8_t MSTKERR : 1;
uint8_t MLSPERR : 1;
uint8_t UNUSED_BIT2 : 1;
uint8_t MMARVALID : 1;
}bits;
}mfsr;
union
{
uint8_t value;
struct
{
uint8_t IBUSERR : 1;
uint8_t PRECISEER : 1;
uint8_t IMPREISEER : 1;
uint8_t UNSTKERR : 1;
uint8_t STKERR : 1;
uint8_t LSPERR : 1;
uint8_t UNUSED_BIT : 1;
uint8_t BFARVALID : 1;
}bits;
}bfsr;
union
{
unsigned short value;
struct
{
unsigned short UNDEFINSTR : 1;
unsigned short INVSTATE : 1;
unsigned short INVPC : 1;
unsigned short NOCP : 1;
unsigned short UNUSED_BITS : 4;
unsigned short UNALIGNED : 1;
unsigned short DIVBYZERO : 1;
}bits;
}ufsr;
union
{
uint32_t value;
struct
{
uint32_t UNUSED_BIT1 : 1;
uint32_t VECTBL : 1;
uint32_t UNUSED_BIT2 : 28;
uint32_t FORCED : 1;
uint32_t DEBUGEVT : 1;
}bits;
}hfsr;
union
{
uint32_t value;
struct
{
uint32_t HALTED : 1;
uint32_t BKPT : 1;
uint32_t DWTTRAP : 1;
uint32_t VCATCH : 1;
uint32_t EXTERNAL : 1;
}bits;
}dfsr;
uint32_t mmfar;
uint32_t bfar;
uint32_t afar;
}ec_m3_exception_regs;
typedef struct _ec_exception_store
{
uint32_t ec_start_flag;
uint32_t ec_exception_flag;
uint32_t ec_exception_count;
ec_m3_exception_regs excep_regs;
ec_exception_addr excep_addr;
uint32_t func_call_stack[EC_FUNC_CALL_ADDR_DEPTH];
uint32_t curr_time;
uint32_t excep_step;
uint8_t curr_task_name[EC_EXCEP_TASK_NAME_LEN];
uint8_t ec_assert_buff[EC_EXCEP_ASSERT_BUFF_LEN];
uint32_t ec_end_flag;
}ec_exception_store;
enum
{
excep_r0 = 0,
excep_r1 = 1,
excep_r2 = 2,
excep_r3 = 3,
excep_r12 = 4,
excep_lr = 5,
excep_pc = 6,
excep_psr = 7,
};
typedef enum EXCEPTION_CONFIG_OPTION
{
EXCEP_OPTION_DUMP_FLASH_EPAT_LOOP, /*0 -- dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))*/
EXCEP_OPTION_PRINT_RESET, /*print necessary exception info, and then reset*/
EXCEP_OPTION_DUMP_FLASH_RESET, /*dump full exception info to flash, and then reset*/
EXCEP_OPTION_DUMP_FLASH_EPAT_RESET, /*dump full exception info to flash and EPAT tool, and then reset*/
EXCEP_OPTION_SILENT_RESET, /*reset directly*/
EXCEP_OPTION_DUMP_FLASH_EPAT_LOOP_AND_UART_HELP_DUMP = 10, /*10 -- enable uart help dump and dump full exception info to flash and EPAT tool then trapped in endless loop(while(1))*/
EXCEP_OPTION_DUMP_FLASH_EPAT_RESET_AND_UART_HELP_DUMP = 13, /*13 -- enable uart help dump and dump full exception info to flash and EPAT tool, and then reset*/
EXCEP_OPTION_MAX
}ExcepConfigOp;
enum
{
reg_r0 = 0,
reg_r1,
reg_r2,
reg_r3,
reg_r4,
reg_r5,
reg_r6,
reg_r7,
reg_r8,
reg_r9,
reg_r10,
reg_r11,
reg_r12,
reg_sp,
reg_lr,
reg_pc,
};
typedef enum
{
EC_RAM_COMP_NORMAL = 0,
EC_AP_64K_RAM_COMP = 1,
EC_AP_125M_RAM_COMP,
EC_CP_64K_RAM_COMP,
EC_CP_125M_RAM_COMP,
}ecRamCompType;
typedef enum
{
EC_CORE_TYPE_AP = 1,
EC_CORE_TYPE_CP = 2,
}ecCoreType;
typedef enum
{
EC_CHIP_TYPE_EC616 = 0x616,
EC_CHIP_TYPE_EC618 = 0x618,
}ecChipType;
/*----------------------------------------------------------------------------*
* GLOBAL FUNCTIONS DECLEARATION *
*----------------------------------------------------------------------------*/
#if defined ( __CC_ARM )
extern unsigned int __current_pc(void); // arm_cc used to get pc, it cannot get pc directly
extern unsigned int __current_sp(void); // arm_cc used to get sp
#elif defined(__GNUC__)
void *__current_pc(void);
#endif
void ecRecordNodeInit(void);
void excepCheckFaultType(ec_m3_exception_regs *excep_regs);
void excepShowStackFrame(ec_m3_exception_regs *excep_regs);
extern void excepEcAssert(const char *func, uint32_t line, uint32_t v1, uint32_t v2, uint32_t v3);
void excepGetTaskInfo(void);
void excepCleanInExcephandler(void);
BOOL excepIsInExcephandler(void);
BOOL excepIsFsAssert(void);
BOOL excepDumpCheckPoint(uint8_t id);
#if defined ( __CC_ARM )
//extern __inline void ec_assert_regs(void);
extern __INLINE __asm void ec_assert_regs(void);
extern void excepPrintAssertInfo(const char *func, uint32_t line, const char *file, uint32_t v1, uint32_t v2, uint32_t v3);
#ifdef EC_ASSERT_FLAG
#define EC_ASSERT(x,v1,v2,v3) \
do { \
{ \
if((x) == 0) \
{ \
ec_assert_regs(); \
*((unsigned int *)EC_ASSERT_PC_ADDR) = __current_pc(); \
*((unsigned int *)EC_ASSERT_LR_ADDR) = __GET_RETURN_ADDRESS(); \
excepEcAssert(__FUNCTION__, __LINE__, (uint32_t)(v1),(uint32_t)(v2),(uint32_t)(v3)); \
while(1); \
}\
} \
} while(0)
#else
#define EC_ASSERT(x,v1,v2,v3) \
do { \
{ \
if((x) == 0) \
{ \
printf("Assert, func:%s, file: %s, line: %d, val: 0x%x,0x%x,0x%x \r\n", __FUNCTION__, __FILE__, __LINE__, (uint32_t)(v1),(uint32_t)(v2),(uint32_t)(v3)); \
__disable_irq();\
while(1);\
}\
} \
} while(0)
#endif
#elif defined(__GNUC__)
extern void ec_assert_regs(void);
#define EC_ASSERT(x,v1,v2,v3) \
do { \
{ \
if((x) == 0) \
{ \
ec_assert_regs(); \
excepEcAssert(__FUNCTION__, __LINE__, (uint32_t)(v1),(uint32_t)(v2),(uint32_t)(v3)); \
while(1); \
}\
} \
} while(0)
#endif
#ifdef FEATURE_DUMP_CHECK
#define EXCEP_CHECK_POINT(ID) excepDumpCheckPoint(ID)
#endif
#endif /* _EXCEPTION_H */

View File

@@ -0,0 +1,243 @@
#ifndef __SCT_AES_SHA_API_H__
#define __SCT_AES_SHA_API_H__
/******************************************************************************
******************************************************************************
Copy right: 2017-, Copyrigths of AirM2M Ltd.
File name: sct_aes_sha_api.h
Description: SCT AES/SHA API, external, and provide to app
History: 2020/12/02 Originated by Jason
******************************************************************************
******************************************************************************/
#include "osasys.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
typedef enum
{
SCT_AES_SHA_RET_OK = 0,
SCT_AES_SHA_ERROR = -1,
SCT_AES_SHA_BUSY = -2
}SctAesShaRetEnum;
typedef INT32 SctAesShaRet;
/*
* AES mode, same enum as: DescAESMode
*/
typedef enum
{
SCT_AES_ECB = 0,
SCT_AES_CBC = 1,
SCT_AES_CTR = 2
}SctAESMode;
/*
* AES PAD MODE, same enum as: DescAESPadMode
*/
typedef enum
{
/*
0 - No Padding, should: dataLen%16 == 0
1 - PKCS7, paddingLen = 16 <20>C dataLen%16, paddingValue = k
2 <20>C PaddingOneZeros (ISO/IEC 7816-4), paddingLen = 16 <20>C dataLen%16, paddingValue = 0x80,0x00,<2C><>..0x00
3 - PaddingZerosLen (ANSI X.923), paddingLen = 16 <20>C dataLen%16, paddingValue = 0x00,0x00,<2C><>..k
4 - PaddingZeros, paddingLen = 16 <20>C dataLen%16, paddingValue = 0x00,0x00,<2C><>..0x00
*/
SCT_AES_NO_PAD = 0,
SCT_AES_PKCS7_PAD = 1,
SCT_AES_ONE_ZEROS_PAD = 2,
SCT_AES_ZERO_LEN_PAD = 3,
SCT_AES_ZERO_PAD = 4
}SctAESPadMode;
/*
* AES Key source, same enum as: DescAESKeySelect
*/
typedef enum
{
SCT_AES_CK_FROM_ADDR = 0,
SCT_AES_CK_FROM_EFUSE = 1
}SctAESKeySelect;
/*
* AES CK len, same enum as: DescAESCKLen
*/
typedef enum
{
/* If key is from flash, only support length: 128/192 */
SCT_AES_CK_LEN_128 = 0,
SCT_AES_CK_LEN_192 = 1,
SCT_AES_CK_LEN_256 = 2
}SctAESCKLen;
/*
* AES DIR
* AESDIR is useless (default set to 0) for CTR (2) AES mode
*/
typedef enum
{
SCT_AES_ENC_DIR = 0, /* Encryption */
SCT_AES_DEC_DIR = 1 /* Decryption */
}SctAESDir;
/*
* endian
*/
typedef enum
{
SCT_LITTLE_ENDIAN = 0,
SCT_BIG_ENDIAN = 1
}SctEndianType;
/*
* SHA MODE, same enum as: DescSHAMode
*/
typedef enum
{
SCT_SHA_1 = 0, /* SHA output: 20 bytes */
SCT_SHA_224 = 1, /* SHA output: 28 bytes */
SCT_SHA_256 = 2 /* SHA output: 32 bytes */
}SctSHAMode;
/*
* SCT AES cipher request
*/
typedef struct
{
UINT32 inputByteLen : 16; /* AES input data length */
UINT32 aesMode : 2; /* SctAESMode: ECB/CBC/CTR */
UINT32 aesPadMode : 3; /* SctAESPadMode, For CTR mode, useless, set to 0 */
UINT32 ckSelect : 1; /* SctAESKeySelect, CK select from: "ckAddr", or from eFUSE */
UINT32 ckLen : 2; /* SctAESCKLen: 128/192/256, if CK select from eFUSE, only support: 128/192 */
UINT32 dir : 1; /* SctAESDir, Encryption/Decryption. For CTR mode, useless, set to 0 */
UINT32 ckBLEndian : 1; /* SctEndianType, if not certain/known, suggest big endian: DESC_BIG_ENDIAN */
UINT32 ivBLEndian : 1; /* SctEndianType, if not certain/known, suggest big endian: DESC_BIG_ENDIAN */
UINT32 : 5;
UINT8 *pInput; /* Input */
UINT8 *pOutput; /* Output */
UINT8 *pCkAddr; /* Ignore it, if key select from eFUSE. and must 4 bytes aligned */
UINT8 *pIvAddr; /* initial vector,
* Note:
* a) for CBC(AESMode = 1) mode, initial vector address
* b) for CTR(AESMode = 2) mode, initial counter address,
* c) Must 4 bytes aligned, and total 16 bytes
*/
}SctAesReq; //20 bytes
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
/*****************************************************************************
* Two types of SHA API
* 1> SHA segment API, which SHA input datas could be divided serveral segments
*
* 2> SHA whole API, all SHA datas input once.
*****************************************************************************/
/*******
* 1> SHA segment API
*******/
/*
* SHA start
*/
/******************************************************************************
* SctShaSegStart
* Description: SHA segment API, which SHA input datas could be divided serveral segments,
* SHA start and lock the SCT HW, before SHA done (called by SctShaSegEnd()),
* SHA HW can't used by other modules
* input: SctSHAMode shaMode //SHA mode
* const UINT8 *shaHdr //SHA header, which also need to calc SHA before input data, if none, input PNULL
* UINT16 shaHdrByteLen //SHA header byte length
* output: SctShaRet
* Note: "pShaHdr" should be freed in caller, after "SctShaSegEnd()" called
******************************************************************************/
SctAesShaRet SctShaSegStart(SctSHAMode shaMode, const UINT8 *pShaHdr, UINT16 shaHdrByteLen);
/******************************************************************************
* SctShaAppendSeg
* Description: SHA segment API, calc SHA
* input: SctSHAMode shaMode //SHA mode
* const UINT8 *pInput //SHA input source data
* UINT16 inputLen //SHA input source data length
* output: SctShaRet
******************************************************************************/
SctAesShaRet SctShaAppendSeg(SctSHAMode shaMode, const UINT8 *pInput, UINT16 inputLen);
/******************************************************************************
* SctShaSegEnd
* Description: SHA segment API, end SHA calc
* input: SctSHAMode shaMode //SHA mode
* SctEndianType outBLType //output, big/little endian, if not known, suggest BIG endian
* UINT8 shaOutput[32] //output, SHA value
* output: SctShaRet
******************************************************************************/
SctAesShaRet SctShaSegEnd(SctSHAMode shaMode, SctEndianType outBLType, UINT8 shaOutput[32]);
/********
* 2. SHA whole API, all SHA datas input once.
********/
/******************************************************************************
* SctShaCalc
* Description: SHA whole API, all SHA datas input once
* input: SctSHAMode shaMode //SHA mode
* const UINT8 *pInput //pInput data
* UINT16 inputLen //input data length in byte
* const UINT8 *pShaHdr //SHA header, which also need to calc SHA before input data, if none, input PNULL
* UINT16 shaHdrByteLen //SHA header length in byte
* SctEndianType outBLType //big/little endian, if not known, suggest BIG endian
* UINT8 shaOutput[32] //output, SHA value
* output: SctShaRet
******************************************************************************/
SctAesShaRet SctShaCalc(SctSHAMode shaMode,
UINT8 *pInput,
UINT16 inByteLen,
UINT8 *pShaHdr,
UINT16 shaHdrByteLen,
SctEndianType outBLType,
UINT8 shaOutput[32]);
/*****************************************************************************
* AES API
*****************************************************************************/
/******************************************************************************
* SctAesCalc
* Description: AES encrypt/decrypt calculation
* input: SctAesReq *pAesReq
* output: SctShaRet
******************************************************************************/
SctAesShaRet SctAesCalc(SctAesReq *pAesReq);
#endif

View File

@@ -0,0 +1,141 @@
#ifndef __SCT_PPP_CRC_API_H__
#define __SCT_PPP_CRC_API_H__
/******************************************************************************
******************************************************************************
Copy right: 2017-, Copyrigths of AirM2M Ltd.
File name: sct_ppp_crc_api.h
Description: SCT PPP EEA and CRC API, which provide to app
History: 2022/02/08 Originated by Jason
******************************************************************************
******************************************************************************/
#include "osasys.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
/*
* UINT32 * 8 = 256 bits
*/
#define SCT_PPP_ACCM_TABLE_WORD_SIZE 8
typedef enum
{
SCT_PPP_RET_OK = 0,
SCT_PPP_ERROR = -1,
SCT_PPP_BUSY = -2,
SCT_PPP_INVALID_INPUT = -3
}SctPppRetEnum;
typedef INT32 SctPppRet;
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
/*
* PPP escape ACCM table config
*/
void SctPppEscapeAccmConfig(UINT32 pppAccmTbl[SCT_PPP_ACCM_TABLE_WORD_SIZE]);
/*
* PPP de-escape ACCM table config
*/
void SctPppDeEscapeAccmConfig(UINT32 pppAccmTbl[SCT_PPP_ACCM_TABLE_WORD_SIZE]);
/******************************************************************************
* SctPppEscapeCalcSize
* Description: calc PPP escape PKG size/length in bytes
* input: const DlPduBlock *pHead //input, a list, one PDU one PPP raw packet
* UINT32 *pOutList //output, should be a UINT32 array, escape pkg size for each PDU, and must 4 bytes aligned
* UINT32 listSize //input, "pOutList" array size
* DlPduBlock **pRetNext //output, if PDU number in input: "pHead" > "listSize", then not all PDU could calc escaped size, then output here
* output: INT32 //succ return 0, or return < 0
* Comment:
* 1> PPP raw pkg (DlPduBlock) input format:
* +-------+---------------------+
* |PPP hdr| data |
* +-------+---------------------+
* 2> \PPP escape pkg format: \
* +--+-------------------------------+-----+--+
* |7E| escaped PPP pkg | CRC |7E|
* +--+-------------------------------+-----+--+
* |<-------------- output size -------------->|
* 3> if "pOutList[n]" set to 0, means last PKG
* 4> !!!!!! "pOutList" must be __ALIGNED(4) !!!!!!
******************************************************************************/
SctPppRet SctPppEscapeCalcSize(DlPduBlock *pHead, UINT32 *pOutList, UINT32 listSize, DlPduBlock **pRetNext);
/******************************************************************************
* SctPppEscape
* Description: PPP escape: add "7E" and CRC
* input: const DlPduBlock *pHead //input, a list, one PDU one PPP raw packet
* DlPduBlock *pEscapeHead //ouput, output buffer should allocated in caller
* output: INT32 //succ return 0, or return < 0
* Comment:
* 1> PPP raw pkg (DlPduBlock) input format:
* +-------+---------------------+
* |PPP hdr| data |
* +-------+---------------------+
* 2> \output PPP escape pkg format: \
* +--+-------------------------------+-----+--+
* |7E| escaped PPP pkg | CRC |7E|
* +--+-------------------------------+-----+--+
* |<------ pEscapeHead->length -------------->|
* ^pEscapeHead->pPdu
* Note:
* a) Caller should call: SctPppEscapeCalcSize() to calc the escaped pkg size;
* b) then alloc the buffer (maybe from DLFC) according to the escaped pkg size;
* c) finally call this API: SctPppEscape() to do PPP escape, and the escaped pkg size
* will be checked again in this API, to avoid a bug cause overflow
******************************************************************************/
SctPppRet SctPppEscape(const DlPduBlock *pHead, DlPduBlock *pEscapeHead);
/******************************************************************************
* SctPppDeEscape
* Description: PPP deescape
* input: const UlPduBlock *pHead //input, a list, PPP pkg start and end with "7E"
* UlPduBlock *pDeEscapeHead //ouput, output buffer should allocated in caller
* output: INT32 //succ return 0, or return < 0
* Comment:
* 1> PPP pkg (UlPduBlock) input format: //note, PKG should start and end with "7E" (will check in this API)
* +--+-------------------------------+-----+--+
* |7E| escaped PPP pkg | CRC |7E|
* +--+-------------------------------+-----+--+
* 2> |output PPP deescape pkg format: /
* +-------+----------------------+-----+
* |PPP hdr| data | CRC |
* +-------+----------------------+-----+
* |<------ pDeEscapeHead->length ----->|
* ^pDeEscapeHead->ptr
* 3> If CRC checked failed, "pDeEscapeHead->pppCrcNok" set to 1
* Note:
* a) The caller should be pre-alloc the buffer in "pDeEscapeHead", use to fill
* de-escaped pkg. And the pre-alloc buffer size should be estimated big enough, suggest
* equal the input escaped pkg size.
* b) After de-escaped in this API, de-escaped pkg size will be checked and set to
* the actually value.
* c) In some case, the caller can't input the header "7E", so we don't check it as mandatory
******************************************************************************/
SctPppRet SctPppDeEscape(const UlPduBlock *pHead, UlPduBlock *pDeEscapeHead);
#endif

View File

@@ -0,0 +1,67 @@
#ifndef _SYS_RECORD_H
#define _SYS_RECORD_H
#define EC_TRACE_SCHEDULE_RECORD 1
#define EC_TRACE_SCHEDULE_PRINT 1
#define RECORD_LIST_LEN 30
#define RECORD_LIST_NAME_LEN 4
typedef enum ecRecordType_enum
{
EC_RECORD_TYPE_RESV = 0,
EC_RECORD_TYPE_USB = 1,
EC_RECORD_TYPE_XIC = 2,
EC_RECORD_TYPE_TASK = 3,
EC_RECORD_TYPE_MAX,
}ecRecordType;
typedef enum ecRecordPrintType_enum
{
EC_RECORD_PRINT_RESV = 0,
EC_RECORD_PRINT_IN = 1,
EC_RECORD_PRINT_OUT = 2,
EC_RECORD_PRINT_MAX,
}ecRecordPrintType;
typedef union
{
UINT32 ecNVICAndResv; // NVIC(0-14)---U16 resv(0xFFFF)---U16
UINT32 ecXicModuleAndIdx; // xic module(0-2)---U16 idx(0-31)---U16
CHAR ecRecordName[RECORD_LIST_NAME_LEN]; //
}ecInterInfo;
typedef struct _recordNodeList
{
ecInterInfo ecInterInfos;
UINT32 ecInTime;
}ecRecordNodeList;
typedef struct _recordNodeParam
{
UINT32 ecRecordType;
UINT32 ecLogInOrOut;
UINT32 ecNVIC;
UINT32 ecResv;
UINT32 ecInTime;
UINT32 ecXicModule;
UINT32 ecInterruptIdx;
UINT32 ecInterruptType;
}vRecordParam;
void ecTraceUsbIntOut(void);
void ecTraceUsbIntIn(void);
void ecTraceXicIntOut(INT32 module, INT32 idx);
void ecTraceXicIntIn(INT32 module, INT32 idx);
void vTracePrintSchedule(vRecordParam recordParam);
void vTraceScheduleRecord(vRecordParam recordParam);
#endif

View File

@@ -0,0 +1,81 @@
/*----------------------------------------------------------------------------*
* INCLUDES *
*----------------------------------------------------------------------------*/
#include <stdint.h>
#include <string.h>
/*----------------------------------------------------------------------------*
* MACROS *
*----------------------------------------------------------------------------*/
#define UNALIGNED(x) ((uint32_t)x & 0x3)
#define DETECTNULL(x) (((x) - 0x01010101) & ~(x) & 0x80808080)
/*----------------------------------------------------------------------------*
* GLOBAL FUNCTIONS *
*----------------------------------------------------------------------------*/
/*
* Reference: https://github.com/eblot/newlib/blob/master/newlib/libc/string/strlen.c
*/
int32_t strlen_fast(const char *str)
{
const char *start = str;
uint32_t* aligned_addr;
while(UNALIGNED(str))
{
if(!*str)
{
return str - start;
}
str++;
}
aligned_addr = (uint32_t*)str;
while(!DETECTNULL(*aligned_addr))
{
aligned_addr++;
}
str = (char *)aligned_addr;
while(*str)
{
str++;
}
return str - start;
}
/*
* Reference: http://src.gnu-darwin.org/src/lib/libc/string/strnstr.c.html
*/
char* ec_strnstr(const char *s, const char *find, size_t slen)
{
char c, sc;
size_t len;
if((c = *find++) != '\0')
{
len = strlen(find);
do
{
do
{
if((sc = *s++) == '\0' || slen-- < 1)
return NULL;
} while(sc != c);
if(len > slen)
return NULL;
} while(strncmp(s, find, len) != 0);
s--;
}
return (char*)s;
}

View File

@@ -0,0 +1,200 @@
/******************************************************************************
Copyright: - 2017, All rights reserved by AirM2M Ltd.
File name: - ecuiccapi.c
Description: - UICC open API.
Function List: -
History: - 09/20/2022, Originated by xlhu
******************************************************************************/
/******************************************************************************
* Include Files
*******************************************************************************/
#include "cmsis_os2.h"
#include "FreeRTOS.h"
#include "task.h"
#include "os_common.h"
#include DEBUG_LOG_HEADER_FILE
#include "debug_trace.h"
#include "ecuiccapi.h"
/*********************************************************************************
* Macros
*********************************************************************************/
/******************************************************************************
* Extern global variables
*******************************************************************************/
/******************************************************************************
* Extern functions
*******************************************************************************/
/******************************************************************************
* Global variables
*******************************************************************************/
/*
* bSoftSIMTaskCreate
* Whether the SoftSIM task created.
*/
BOOL bSoftSIMTaskCreate = FALSE;
/******************************************************************************
* Types
*******************************************************************************/
/******************************************************************************
* Local variables
*******************************************************************************/
/******************************************************************************
* Function Prototypes
*******************************************************************************/
/******************************************************************************
* Function definition
*******************************************************************************/
#define __DEFINE_SOFTSIM_ADAPT_FUNCTION__ //just for easy to find this position in SS
/******************************************************************************
* SoftSIM interface adapted note
* 1> The SoftSIM feature is disable as default, and enabled by AT+ECSIMCFG="softsim",1
* 2> SoftSIM task shall be created in SoftSimInit func or appinit depended by softsim vender.
* 3> SoftSIM vender shall adapt functions SoftSimReset/SoftSimApduReq.
*******************************************************************************/
/******************************************************************************
* SoftSimReset
* Description: This API called by modem/uiccdrv task to reset softsim and get ATR parameter from softsim,
* as same as code/warm reset with physical SIM card.
* param[in] null
* param[out] UINT16 *atrLen, the pointer to the length of ATR, this memory don't need to be free.
* param[out] UINT8 *atrData, the pointer to the ATR data, this memory don't need to be free.
* atrData buffer size is 33, fill atrData shall not exceed 33 bytes.
* Comment: This API will be called only if softsim feature is enabled by AT CMD.
* Shall send signal/msg to softsim task and block to wait response .
* Softsim internal process running in this func is not allowed.
******************************************************************************/
void SoftSimReset(UINT16 *atrLen, UINT8 *atrData)
{
osSemaphoreId_t sem = osSemaphoreNew(1U, 0, PNULL);
osStatus_t osState = osOK;
/*
* softsim vender shall implement 3 steps as below
*/
/*
* 1> create signal/msg
*/
/*
* 2> send signal/msg to softsim task with sem/atrLen/atrData
*/
/*
* 3> process signal/msg on softsim task, then retrun paramters and release sem on softsim task
*/
/*
* wait for sem 2sec
*/
if ((osState = osSemaphoreAcquire(sem, 2000)) != osOK)
{
OsaDebugBegin(FALSE, osState, 0, 0);
OsaDebugEnd();
}
/*
* Semaphore delete
*/
osSemaphoreDelete(sem);
}
/******************************************************************************
* SoftSimApduReq
* Description: This API will be called by modem/uiccdrv task to send APDU(TPDU) request and get response from softsim,
* support case 1/2/3/4 command/response process.
* param[in] UINT16 txDataLen, the length of tx data
* param[in] UINT8 *txData, the pointer to the tx data, this memory don't need to be free.
* param[out] UINT16 *rxDataLen, the pointer to the length of rx data, this memory don't need to be free.
* param[out] UINT8 *rxData, the pointer to the rx data, this memory don't need to be free.
* rxData buffer size is 258, fill rxData shall not exceed 258 bytes.
* Comment: This API will be called only if softsim feature is enabled by AT CMD.
* Shall send signal/msg to softsim task and block to wait response.
* Softsim internal process running in this func is not allowed.
******************************************************************************/
void SoftSimApduReq(UINT16 txDataLen, UINT8 *txData, UINT16 *rxDataLen, UINT8 *rxData)
{
osSemaphoreId_t sem = osSemaphoreNew(1U, 0, PNULL);
osStatus_t osState = osOK;
/*
* softsim vender shall implement 3 steps as below
*/
/*
* 1> create signal/msg
*/
/*
* 2> send signal/msg to softsim task with sem/txDataLen/txData/rxDataLen/rxData
*/
/*
* 3> process signal/msg on softsim task, then retrun paramters and release sem on softsim task
*/
/*
* wait for sem 2sec
*/
if ((osState = osSemaphoreAcquire(sem, 2000)) != osOK)
{
OsaDebugBegin(FALSE, osState, 0, 0);
OsaDebugEnd();
}
/*
* Semaphore delete
*/
osSemaphoreDelete(sem);
}
/******************************************************************************
* SoftSimInit
* Description: This api called by modem/uiccdrv task to start softsim task if softsim feature is enabled.
* input: void
* output: void
* Comment:
******************************************************************************/
void SoftSimInit(void)
{
if (bSoftSIMTaskCreate == TRUE)
{
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, SoftSimInit_0, P_INFO, "Softsim task has already been created");
return;
}
/*
* start softsim task
*/
ECPLAT_PRINTF(UNILOG_PLA_DRIVER, SoftSimInit_1, P_INFO, "Start softsim task");
/*
* softsim vender implement softsim task created
*/
//delay 100ms for softsim task init
osDelay(100);
//set flag after task created
bSoftSIMTaskCreate = TRUE;
}

View File

@@ -0,0 +1,781 @@
#include "stdio.h"
#include "string.h"
#include "uart.h"
#if FEATURE_CCIO_ENABLE
#include "usb_device.h"
#endif
#include DEBUG_LOG_HEADER_FILE
#include "mem_map.h"
#include "exception_process.h"
#include "hal_dumpMedia.h"
#include "exception_dump.h"
#include "plat_config.h"
#ifdef FEATURE_UART_HELP_DUMP_ENABLE
int *excepStepDump = (int *)0x404008;
uint32_t excepCfgOption = 0xff;
#define EcDumpGetUartDumpModeId(ownerId, moduleId, subId) (ownerId##__##moduleId##__##subId)
#endif
extern int *excepStep;
int excepDumpEndFlag = DUMP_END_FLAG_INIT;
uint32_t dumpRetryReadCount = MAX_RETRY_COUNT;
uint32_t dumpHandshakeRetryCnt = MAX_RETRY_COUNT;
uint32_t dumpWaitSyncRetryCnt = DATA_DUMP_WAIT_SYNC_MAX_RETRY_COUNT;
uint32_t dumpGetCmdRetryCnt = DATA_DUMP_GET_CMD_MAX_RETRY_COUNT;
const uint8_t dump_handshake_code[]= "enter assert dump mode";
const uint8_t dump_response_code[]= "ok";
const uint8_t PreambleDumpString[PREAMBLE_STRING_LEN] = {0x44, 0x55, 0x4d, 0x50, 0x44, 0x55, 0x4d, 0x50, 0xd, 0xa};
const uint16_t wCRCTableAbs[] =
{
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401, 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400,
};
uint32_t tDataInfoCell [][2]=
{
{EC_EXCEPTION_AP_RAM_BASE, EC_EXCEPTION_AP_RAM_LEN},
{EC_EXCEPTION_CP_RAM_BASE, EC_EXCEPTION_CP_RAM_LEN},
{EC_EXCEPTION_APCP_RAM_BASE, EC_EXCEPTION_APCP_RAM_LEN},
};
extern void delay_us(uint32_t us);
extern void usbc_trace_disable(void);
int excepDelay(uint32_t maxDelay)
{
int i=0;
int j=0;
for(i=0; i<maxDelay; i++)
{
if(i==0xfff)
{
j = maxDelay+2;
}
}
return j;
}
uint32_t EcDumpCheckIfNeedRetry(uint32_t cmdType, PtrDumpReqWrap dumpReqWrap, PtrDumpReqWrap dumpReqWrapTemp)
{
ReadDataReqCell * ptrReadDataReqCell;
ReadDataReqCell * ptrReadDataReqCellTemp;
switch(cmdType)
{
case DUMP_RETRY_CMD_COUNT:
*excepStep = (*excepStep | 0x10000000);
ptrReadDataReqCell = (ReadDataReqCell*)(&(dumpReqWrap->Data[0]));
ptrReadDataReqCellTemp = (ReadDataReqCell*)(&(dumpReqWrapTemp->Data[0]));
if(ptrReadDataReqCell->ReadDataAddr == ptrReadDataReqCellTemp->ReadDataAddr)
{
dumpRetryReadCount++;
}
else
{
dumpRetryReadCount = 0;
memcpy(dumpReqWrapTemp, dumpReqWrap, sizeof(DumpReqWrap));
}
break;
case DUMP_RETRY_CMD_RESEND:
*excepStep = (*excepStep | 0x20000000);
if(dumpRetryReadCount >= DUMP_RETRY_COUNT_MAX)
{
ptrReadDataReqCell = (ReadDataReqCell*)(&dumpReqWrap->Data);
memset((void *)DUMP_RETRY_ADDR, 0, ptrReadDataReqCell->ReadLen);
memcpy((void *)DUMP_RETRY_ADDR, (void *)ptrReadDataReqCell->ReadDataAddr, ptrReadDataReqCell->ReadLen);
ptrReadDataReqCell->ReadDataAddr = DUMP_RETRY_ADDR;
}
break;
}
return 0;
}
static uint16_t EcDumpCRC16(uint16_t wCRC, uint8_t *pchMsg, uint16_t wDataLen)
{
//uint16_t wCRC = 0xFFFF;
uint16_t i;
uint8_t chChar;
for (i = 0; i < wDataLen; i++)
{
chChar = *pchMsg++;
wCRC = wCRCTableAbs[(chChar^wCRC)&15]^(wCRC>>4);
wCRC = wCRCTableAbs[((chChar >>4)^ wCRC)&15]^(wCRC>>4);
}
return wCRC;
}
uint32_t VerifyPreamble(uint8_t *Preamble)
{
uint32_t idx;
uint32_t CheckCnt = 0;
for (idx = 0; idx < sizeof(PreambleDumpString); idx++)
{
if (PreambleDumpString[idx] == Preamble[idx]) {
CheckCnt++;
}
}
if (CheckCnt>1)
{
return TRUE;
}
return FALSE;
}
uint32_t EcDumpWaitSync(void)
{
uint8_t idx = 0;
uint8_t RecChar[DUMP_RECV_FIFO_LEN];
uint8_t RetValue = 0;
uint8_t epNum = 0xff;
uint32_t instance;
uint32_t instanceTemp;
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
instance = DUMP_UART_INSTANCE;
instanceTemp = instance;
eehDumpMediaFlush(UART_0_FOR_UNILOG);//flush RX FIFO is better to avoid left hdsk data, only for UART
}
else
{
instance = (uint32_t)usbDevGetLogIfIdx();
epNum = usbDevGetEpNumFromIf(usbDevGetLogIfIdx());
instanceTemp = (epNum&0xf);
extern void usbc_ctrl_full_flush_txfifo (uint32_t num );
usbc_ctrl_full_flush_txfifo((epNum>>4)&0xf);
}
delay_us(400000);//wait and let EPAT change its baudrate
for (idx = 0; idx < PREAMBLE_CNT; idx++)
{
RetValue = eehDumpMediaSend(instance, (uint8_t *)&PreambleDumpString[0], PREAMBLE_STRING_LEN, 1000);
if (RetValue != PREAMBLE_STRING_LEN)
{
*excepStep = (*excepStep | 0x8);
return 1;
}
}
//Host send Preamble twice
RetValue = eehDumpMediaRecv(instanceTemp, &RecChar[0], PREAMBLE_CNT*PREAMBLE_STRING_LEN-2 + PREAMBLE_WITH_NULL, WaitPeriod_1s);
if(RetValue > 0)
{
eehDumpMediaSend(instance, &RecChar[0], RetValue, 1000);
}
if (RetValue != (PREAMBLE_CNT*PREAMBLE_STRING_LEN+PREAMBLE_WITH_NULL-2))
{
*excepStep = (*excepStep | 0x10);
return 1;
}
if (VerifyPreamble(&RecChar[0]) ||VerifyPreamble(&RecChar[4]))
{
*excepStep = (*excepStep | 0x20);
return 0;
}
*excepStep = (*excepStep | 0x40);
return 1;
}
uint32_t EcDumpWaitCmd(PtrDumpReqWrap ptrDumpReqWrap)
{
uint32_t RetValue = 0;
uint8_t epNum;
uint32_t instance;
uint32_t instanceTemp;
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
instance = DUMP_UART_INSTANCE;
instanceTemp = instance;
}
else
{
instance = (uint32_t)usbDevGetLogIfIdx();
epNum = usbDevGetEpNumFromIf(usbDevGetLogIfIdx());
instanceTemp = (epNum&0xf);
}
RetValue = eehDumpMediaRecv(instanceTemp, (uint8_t *)ptrDumpReqWrap, CMD_FIX_LEN, WaitPeriod_1s);
if (RetValue != CMD_FIX_LEN)
{
*excepStep = (*excepStep | 0x100);
return 1;
}
if (ptrDumpReqWrap->Length > MAX_CMD_DATALEN)
{
ptrDumpReqWrap->Length = MAX_CMD_DATALEN;
}
#if 1
RetValue = eehDumpMediaRecv(instanceTemp, (uint8_t *)(&ptrDumpReqWrap->Data[0]), ptrDumpReqWrap->Length, WaitPeriod_1s);
if (RetValue != ptrDumpReqWrap->Length)
{
*excepStep = (*excepStep | 0x200);
return 1;
}
RetValue = eehDumpMediaRecv(instanceTemp, (uint8_t *)(&ptrDumpReqWrap->FCS), CMD_FCS_LEN, WaitPeriod_1s);
if (RetValue != CMD_FCS_LEN)
{
*excepStep = (*excepStep | 0x400);
return 1;
}
#endif
*excepStep = (*excepStep | 0x800);
return 0;
}
uint32_t EcDumpCheckCmd(PtrDumpReqWrap ptrDumpReqWrap)
{
uint32_t sum = 0;
uint8_t * pStartAddr;
if ((ptrDumpReqWrap->CID != DUMP_CID) ||(ptrDumpReqWrap->NCID != N_DUMP_CID))
{
*excepStep = (*excepStep | 0x1000);
return 1;
}
pStartAddr = (uint8_t*) (&ptrDumpReqWrap->Command);
sum = EcDumpCRC16(0xFFFF, pStartAddr, CMD_FIX_LEN + ptrDumpReqWrap->Length);
if (sum != ptrDumpReqWrap->FCS)
{
//return 0;//test now , no check sum
*excepStep = (*excepStep | 0x2000);
return 1;
}
*excepStep = (*excepStep | 0x4000);
return 0;
}
uint32_t EcDumpHandleGetData(PtrDumpReqWrap ptrDumpReqWrap)
{
uint32_t RetValue = 0;
DumpRspWrap tDumpRspWrap;
ReadDataReqCell * ptrReadDataReqCell;
uint32_t Sum = 0xFFFF;
uint32_t Idx;
uint32_t *DataBuff;
uint32_t instance;
uint32_t sendDataLenLeft;
uint32_t sendDataLen;
uint32_t sendDataLastFlag = 0;
uint8_t dataAndCrcBuf[READ_ONECE_DATA_LEN+CMD_FCS_LEN] = {0};
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
instance = DUMP_UART_INSTANCE;
EcDumpCheckIfNeedRetry(DUMP_RETRY_CMD_RESEND, ptrDumpReqWrap, NULL);
}
else
{
instance = (uint32_t)usbDevGetLogIfIdx();
EcDumpCheckIfNeedRetry(DUMP_RETRY_CMD_RESEND, ptrDumpReqWrap, NULL);
}
ptrReadDataReqCell = (ReadDataReqCell*)(&ptrDumpReqWrap->Data[0]);
tDumpRspWrap.Command = ptrDumpReqWrap->Command;
tDumpRspWrap.Sequence = ptrDumpReqWrap->Sequence;
tDumpRspWrap.CID = ptrDumpReqWrap->CID;
tDumpRspWrap.NCID = ptrDumpReqWrap->NCID;
if ((ptrReadDataReqCell->ReadLen > MAX_READ_DATALEN) || ((ptrReadDataReqCell->ReadDataAddr%4)!=0))
{
tDumpRspWrap.Length = 0;
tDumpRspWrap.Status = NACK;
Sum = EcDumpCRC16(0xFFFF, &tDumpRspWrap.Command, PROTOCOL_RSP_FIX_LEN+tDumpRspWrap.Length);
tDumpRspWrap.FCS = Sum;
RetValue = eehDumpMediaSend(instance, &tDumpRspWrap.Command, PROTOCOL_RSP_FIX_LEN+tDumpRspWrap.Length + CMD_FCS_LEN, 1000);
*excepStep = (*excepStep | 0x10000);
return RetValue;
}
tDumpRspWrap.Status = ACK;
tDumpRspWrap.Length = ptrReadDataReqCell->ReadLen;
RetValue = eehDumpMediaSend(instance, &tDumpRspWrap.Command, PROTOCOL_RSP_FIX_LEN, 1000);
if (RetValue != PROTOCOL_RSP_FIX_LEN)
{
*excepStep = (*excepStep | 0x20000);
return 1;
}
Sum = EcDumpCRC16(Sum, &tDumpRspWrap.Command,PROTOCOL_RSP_FIX_LEN);
for (Idx = 0; Idx < ptrReadDataReqCell->ReadLen;)
{
(DataBuff) = (uint32_t *)(ptrReadDataReqCell->ReadDataAddr + Idx);
sendDataLenLeft = ptrReadDataReqCell->ReadLen - Idx;
if(sendDataLenLeft < READ_ONECE_DATA_LEN)
{
sendDataLen = sendDataLenLeft;
}
else
{
sendDataLen = READ_ONECE_DATA_LEN;
}
Sum = EcDumpCRC16(Sum, (uint8_t*)(DataBuff), sendDataLen);
Idx = Idx + sendDataLen;
}
tDumpRspWrap.FCS = Sum;
for (Idx = 0; Idx < ptrReadDataReqCell->ReadLen;)
{
(DataBuff) = (uint32_t *)(ptrReadDataReqCell->ReadDataAddr + Idx);
sendDataLenLeft = ptrReadDataReqCell->ReadLen - Idx;
if(sendDataLenLeft < READ_ONECE_DATA_LEN)
{
sendDataLen = sendDataLenLeft;
sendDataLastFlag = 1;
}
else
{
sendDataLen = READ_ONECE_DATA_LEN;
if((READ_ONECE_DATA_LEN+Idx)==ptrReadDataReqCell->ReadLen)
{
sendDataLastFlag = 1;
}
}
if(sendDataLastFlag != 1)
{
RetValue = eehDumpMediaSend(instance, (uint8_t*)(DataBuff), sendDataLen, 5000);
}
else
{
memcpy(dataAndCrcBuf, (uint8_t*)(DataBuff), READ_ONECE_DATA_LEN);
memcpy(&dataAndCrcBuf[READ_ONECE_DATA_LEN], (uint8_t *)(&tDumpRspWrap.FCS), CMD_FCS_LEN);
RetValue = eehDumpMediaSend(instance, (uint8_t*)(dataAndCrcBuf), (READ_ONECE_DATA_LEN+CMD_FCS_LEN), 5000);
}
//excepDelay(1000);
if (RetValue != READ_ONECE_DATA_LEN)
{
*excepStep = (*excepStep | 0x40000);
return 1;
}
Idx = Idx + sendDataLen;
}
*excepStep = (*excepStep | 0x100000);
return RetValue;
}
uint32_t EcDumpHandleGetInfo(PtrDumpReqWrap ptrDumpReqWrap)
{
uint32_t RetValue = 0;
DumpRspWrap tDumpRspWrap;
uint32_t Sum = 0xFFFF;
uint32_t instance;
char infoCmdBuf[96] = {0};
uint32_t infoCellLen = sizeof(tDataInfoCell);
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
instance = DUMP_UART_INSTANCE;
}
else
{
instance = (uint32_t)usbDevGetLogIfIdx();
}
tDumpRspWrap.Command = ptrDumpReqWrap->Command;
tDumpRspWrap.Sequence = ptrDumpReqWrap->Sequence;
tDumpRspWrap.CID = ptrDumpReqWrap->CID;
tDumpRspWrap.NCID = ptrDumpReqWrap->NCID;
tDumpRspWrap.Status = ACK;
tDumpRspWrap.Length = sizeof(tDataInfoCell);
memcpy(infoCmdBuf, &tDumpRspWrap.Command, PROTOCOL_RSP_FIX_LEN);
Sum = EcDumpCRC16(Sum, &tDumpRspWrap.Command,PROTOCOL_RSP_FIX_LEN);
memcpy(&infoCmdBuf[PROTOCOL_RSP_FIX_LEN], (uint8_t *)&tDataInfoCell, sizeof(tDataInfoCell));
Sum = EcDumpCRC16(Sum, (uint8_t *)&tDataInfoCell, sizeof(tDataInfoCell));
tDumpRspWrap.FCS = Sum;
memcpy(&infoCmdBuf[PROTOCOL_RSP_FIX_LEN+infoCellLen], (uint8_t *)(&tDumpRspWrap.FCS), CMD_FCS_LEN);
RetValue = eehDumpMediaSend(instance, (uint8_t *)infoCmdBuf, PROTOCOL_RSP_FIX_LEN+infoCellLen+CMD_FCS_LEN, 1000);
if (RetValue != CMD_FCS_LEN)
{
*excepStep = (*excepStep | 0x1000000);
return 1;
}
*excepStep = (*excepStep | 0x2000000);
return 0;
}
uint32_t EcDumpDataFlow(void)
{
uint32_t retryCount = dumpWaitSyncRetryCnt;
uint32_t RetValue = 1;
DumpReqWrap tDumpReqWrap;
DumpReqWrap tDumpReqWrapTmep;
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
//UART_init(DUMP_UART_INSTANCE, 921600, false);
eehDumpMediaInit();
}
while(retryCount)
{
RetValue = EcDumpWaitSync();
if(RetValue == 0)
{
break;
}
else
{
retryCount--;
}
}
if(retryCount == 0)//sync failed
{
return 1;
}
retryCount = dumpGetCmdRetryCnt;
while(retryCount)
{
memset(&tDumpReqWrap, 0, sizeof(tDumpReqWrap));
*excepStep = (*excepStep | 0x80);
RetValue = EcDumpWaitCmd(&tDumpReqWrap);
if (RetValue != 0)
{
retryCount--;
continue;
}
if(tDumpReqWrap.Command != 0x00)
{
EcDumpCheckIfNeedRetry(DUMP_RETRY_CMD_COUNT, &tDumpReqWrap, &tDumpReqWrapTmep);
}
*excepStep = (*excepStep | 0x10);
RetValue = EcDumpCheckCmd(&tDumpReqWrap);
if (RetValue != 0)
{
continue;
}
retryCount = dumpGetCmdRetryCnt;
switch(tDumpReqWrap.Command)
{
case GetDataCmd:
*excepStep = (*excepStep | 0x8000);
EcDumpHandleGetData(&tDumpReqWrap);
break;
case GetInfoCmd:
*excepStep = (*excepStep | 0x200000);
EcDumpHandleGetInfo(&tDumpReqWrap);
break;
case FinishCmd:
excepDumpEndFlag = DUMP_END_FLAG_SUCC;
return 0;
default:
break;
}
}
return RetValue;
}
uint32_t EcDumpHandshakeProc(uint32_t SyncPeriod)
{
uint8_t recv_buffer[DUMP_SYNC_RSP_LEN];
uint32_t SyncCnt = 0;
uint32_t RetValue = 0;
uint32_t idx;
uint8_t epNum;
uint32_t instance;
uint32_t retryCnt = 0;
uint32_t instanceTemp;
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
instance = DUMP_UART_INSTANCE;
retryCnt = dumpHandshakeRetryCnt;
instanceTemp = instance;
}
else
{
retryCnt = dumpHandshakeRetryCnt;
instance = (uint32_t)usbDevGetLogIfIdx();
epNum = usbDevGetEpNumFromIf(usbDevGetLogIfIdx());
instanceTemp = (epNum&0xf);
}
//eehDumpMediaPurgeRx(instance); only valid for UART and no need to reset RX FIFO again
memset(recv_buffer, 0, sizeof(recv_buffer));
while(SyncCnt++ < retryCnt)
{
uniLogFlushOut();
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
ECPLAT_PRINTF(UNILOG_PLA_INTERNAL_CMD, ecDumpHandshakeProc, P_ERROR, "enter dump handshake mode");
uniLogFlushOut();
}
else
{
ECPLAT_PRINTF(UNILOG_PLA_INTERNAL_CMD, ecDumpUsbHandshakeProc, P_ERROR, "enter USB dump handshake mode");
uniLogFlushOut();
}
RetValue = eehDumpMediaRecv(instanceTemp, recv_buffer, DUMP_SYNC_RSP_LEN, WaitPeriod_1s/2);
if (RetValue >= 2)
{
if(RetValue < (DUMP_SYNC_RSP_LEN - 2))
{
delay_us(WaitPeriod_1s/2);
}
else
{
for (idx = 0; idx < DUMP_SYNC_RSP_LEN - 2; idx++)
{
if ((recv_buffer[idx] == dump_response_code[0]) && (recv_buffer[idx+1] == dump_response_code[1]))
{
*excepStep = (*excepStep | 0x2);
return 0;
}
}
}
}
else
{
delay_us(WaitPeriod_1s/2);
}
}
*excepStep = (*excepStep | 0x4);
return 1;
}
uint32_t EcDumpTopFlow(void)
{
uint32_t RetValue = 1;
uint32_t instance = 0;
*excepStep = 0x0;
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
instance = DUMP_UART_INSTANCE;
}
else
{
usbc_trace_disable();
eehDumpMediaInit();
instance = (uint32_t)usbDevGetLogIfIdx();
}
*excepStep = (*excepStep | 0x1);
eehDumpMediaFlush(instance);
RetValue = EcDumpHandshakeProc(WaitPeriod_1s>>1);
if (RetValue == 0)
{
RetValue = EcDumpDataFlow();
*excepStep = (*excepStep | 0x4000000);
}
*excepStep = (*excepStep | 0x8000000);
#ifdef FEATURE_UART_HELP_DUMP_ENABLE
excepCfgOption = BSP_GetPlatConfigItemValue(PLAT_CONFIG_ITEM_FAULT_ACTION);
if ((RetValue == 1)&&((excepCfgOption == EXCEP_OPTION_DUMP_FLASH_EPAT_LOOP_AND_UART_HELP_DUMP)||(excepCfgOption == EXCEP_OPTION_DUMP_FLASH_EPAT_RESET_AND_UART_HELP_DUMP)))
{
RetValue = EcDumpHandshakeProcUart(WaitPeriod_1s>>1);
if (RetValue == 0)
{
RetValue = EcDumpDataFlowUart();
*excepStepDump = (*excepStepDump | 0x4000000);
}
*excepStepDump = (*excepStepDump | 0x8000000);
}
#endif
return RetValue;
}
#ifdef FEATURE_UART_HELP_DUMP_ENABLE
uint32_t EcDumpHandshakeProcUart(uint32_t SyncPeriod)
{
uint8_t recv_buffer[DUMP_SYNC_RSP_LEN];
uint32_t SyncCnt = 0;
uint32_t RetValue = 0;
uint32_t idx;
uint32_t retryCnt = 0;
uint32_t instanceTemp;
uint32_t uartDumpModeId = 0;
uint32_t atPortBaudRate = 0xff;
uint8_t uartDumpModeBuff[EC_UART_HELP_DUMP_BUFF_LEN] = {0};
int i;
*excepStepDump = 0;
uniLogSetPherType(UART_0_FOR_UNILOG);
atPortBaudRate = BSP_GetPlatConfigItemValue(PLAT_CONFIG_ITEM_LOG_BAUDRATE);
UART_init(DUMP_UART_INSTANCE, atPortBaudRate & 0x7FFFFFFFUL, false);
retryCnt = 32;
instanceTemp = DUMP_UART_INSTANCE;
memset(recv_buffer, 0, sizeof(recv_buffer));
for(i=0; i<EC_UART_HELP_DUMP_BUFF_LEN; i++)
{
uartDumpModeBuff[i] = 0xff;
if(((i%16) == 3)||((i%16) == 11))
{
uartDumpModeBuff[i] = 0xfe;
}
}
uartDumpModeBuff[28] = 0x6e;
uartDumpModeBuff[29] = 0x27;
uartDumpModeBuff[30] = 0xc9;
uartDumpModeBuff[31] = 0x70;
uartDumpModeId = EcDumpGetUartDumpModeId(UNILOG_PLAT_AP, UNILOG_PLA_INTERNAL_CMD, ecDumpHandshakeProc);
uartDumpModeId = uartDumpModeId & ~0x7FF;
uartDumpModeBuff[32] = ((uartDumpModeId >> 28)&0xff)|0x20;
uartDumpModeBuff[33] = (uartDumpModeId >> 20)&0xff;
uartDumpModeBuff[34] = (uartDumpModeId >> 12)&0xff;
uartDumpModeBuff[35] = (uartDumpModeId >> 4)&0xf0;
uartDumpModeBuff[36] = 0xf;
while(SyncCnt++ < retryCnt)
{
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
//ECPLAT_PRINTF(UNILOG_EXCEP_PRINT, ecDumpHandshakeProc, P_ERROR, "enter dump handshake mode");
UART_send(DUMP_UART_INSTANCE, (const uint8_t *)uartDumpModeBuff, EC_UART_HELP_DUMP_BUFF_LEN, 10000);
}
RetValue = eehDumpMediaRecv(instanceTemp, recv_buffer, DUMP_SYNC_RSP_LEN, WaitPeriod_1s);
if (RetValue >= 2)
{
for (idx = 0; idx < DUMP_SYNC_RSP_LEN - 2; idx++)
{
if ((recv_buffer[idx] == dump_response_code[0]) && (recv_buffer[idx+1] == dump_response_code[1]))
{
*excepStepDump = (*excepStepDump | 0x2);
return 0;
}
}
}
}
*excepStepDump = (*excepStepDump | 0x4);
return 1;
}
uint32_t EcDumpDataFlowUart(void)
{
uint32_t retryCount = dumpWaitSyncRetryCnt;
uint32_t RetValue = 1;
DumpReqWrap tDumpReqWrap;
DumpReqWrap tDumpReqWrapTmep;
if(uniLogGetPherType() == UART_0_FOR_UNILOG)
{
//UART_init(DUMP_UART_INSTANCE, 921600, false);
eehDumpMediaInit();
}
while(retryCount)
{
RetValue = EcDumpWaitSync();
if(RetValue == 0)
{
break;
}
else
{
retryCount--;
}
}
if(retryCount == 0)//sync failed
{
return 1;
}
retryCount = dumpGetCmdRetryCnt;
while(retryCount)
{
memset(&tDumpReqWrap, 0, sizeof(tDumpReqWrap));
*excepStepDump = (*excepStepDump | 0x80);
RetValue = EcDumpWaitCmd(&tDumpReqWrap);
if (RetValue != 0)
{
retryCount--;
continue;
}
if(tDumpReqWrap.Command != 0x00)
{
EcDumpCheckIfNeedRetry(DUMP_RETRY_CMD_COUNT, &tDumpReqWrap, &tDumpReqWrapTmep);
}
*excepStepDump = (*excepStepDump | 0x10);
RetValue = EcDumpCheckCmd(&tDumpReqWrap);
if (RetValue != 0)
{
continue;
}
retryCount = dumpGetCmdRetryCnt;
switch(tDumpReqWrap.Command)
{
case GetDataCmd:
*excepStepDump = (*excepStepDump | 0x8000);
EcDumpHandleGetData(&tDumpReqWrap);
break;
case GetInfoCmd:
*excepStepDump = (*excepStepDump | 0x200000);
EcDumpHandleGetInfo(&tDumpReqWrap);
break;
case FinishCmd:
excepDumpEndFlag = DUMP_END_FLAG_SUCC;
return 0;
default:
break;
}
}
return RetValue;
}
#endif