keep history after reset to GRK39D
diff --git a/Android.mk b/Android.mk
index 2ae7f39..8f64cba 100644
--- a/Android.mk
+++ b/Android.mk
@@ -106,14 +106,11 @@
LOCAL_SRC_FILES += Linux_x86/phDal4Nfc_messageQueueLib.c
# Really verbose:
-#LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DDEBUG -DNFC_TIMER_CONTEXT -DDAL_TRACE -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common -fpic
+#LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DDEBUG -DDAL_TRACE -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common -fpic
# Just show I2C traffic:
-#LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DNFC_TIMER_CONTEXT -DINCLUDE_DALINIT_DEINIT -DLOW_LEVEL_TRACES -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common -fpic
+#LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DINCLUDE_DALINIT_DEINIT -DLOW_LEVEL_TRACES -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common -fpic
# Quiet:
-LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DNFC_TIMER_CONTEXT -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -fpic
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_CFLAGS += -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common
-endif
+LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common -fpic
ifeq ($(NFC_BUILD_VARIANT),debug)
LOCAL_CFLAGS += -DDEBUG -D_DEBUG
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index ec92566..6d3c9fb 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -282,7 +282,7 @@
return result;
}
-NFCSTATUS phDal4Nfc_ConfigRelease(void *pHwRef)
+NFCSTATUS phDal4Nfc_ConfigRelease( void *pHwRef)
{
NFCSTATUS result = NFCSTATUS_SUCCESS;
@@ -292,23 +292,19 @@
if (gDalContext.hw_valid == TRUE)
{
- /* Signal the read and write threads to exit. NOTE: there
- actually is no write thread! :) */
- DAL_PRINT("Stop Reader Thread");
- gReadWriteContext.nReadThreadAlive = 0;
- gReadWriteContext.nWriteThreadAlive = 0;
+ DAL_PRINT("Release Read Semaphore");
+ sem_post(&nfc_read_sem);
- /* Wake up the read thread so it can exit */
- DAL_PRINT("Release Read Semaphore");
- sem_post(&nfc_read_sem);
+ /* Kill the read and write threads */
+ DAL_PRINT("Stop Reader Thread");
+ gReadWriteContext.nReadThreadAlive = 0;
+ gReadWriteContext.nWriteThreadAlive = 0;
- DAL_DEBUG("phDal4Nfc_ConfigRelease - doing pthread_join(%d)",
- gReadWriteContext.nReadThread);
- if (pthread_join(gReadWriteContext.nReadThread, &pThreadReturn) != 0)
- {
- result = PHNFCSTVAL(CID_NFC_DAL, NFCSTATUS_FAILED);
- DAL_PRINT("phDal4Nfc_ConfigRelease KO");
- }
+ if (pthread_join(gReadWriteContext.nReadThread, &pThreadReturn) != 0)
+ {
+ result = PHNFCSTVAL(CID_NFC_DAL, NFCSTATUS_FAILED);
+ DAL_PRINT("phDal4Nfc_ConfigRelease KO");
+ }
/* Close the message queue */
#ifdef USE_MQ_MESSAGE_QUEUE
@@ -587,7 +583,6 @@
gDalContext.hw_valid = TRUE;
- phDal4Nfc_Reset(1);
phDal4Nfc_Reset(0);
phDal4Nfc_Reset(1);
@@ -682,20 +677,12 @@
DAL_PRINT("RX Thread Sem Lock\n");
sem_wait(&nfc_read_sem);
DAL_PRINT("RX Thread Sem UnLock\n");
-
- if (!gReadWriteContext.nReadThreadAlive)
- {
- /* got the signal that we should exit. NOTE: we don't
- attempt to read below, since the read may block */
- break;
- }
-
/* Issue read operation.*/
i2c_error_count = 0;
retry:
gReadWriteContext.nNbOfBytesRead=0;
- DAL_DEBUG("RX Thread *New *** *****Request Length = %d",gReadWriteContext.nNbOfBytesToRead);
+ DAL_DEBUG("\n*New *** *****Request Length = %d",gReadWriteContext.nNbOfBytesToRead);
memsetRet=memset(gReadWriteContext.pReadBuffer,0,gReadWriteContext.nNbOfBytesToRead);
/* Wait for IRQ !!! */
@@ -709,12 +696,12 @@
if(gReadWriteContext.nNbOfBytesToRead == 1 && gReadWriteContext.pReadBuffer[0] == 0x57)
{
i2c_error_count++;
- DAL_DEBUG("RX Thread Read 0x57 %d times\n", i2c_error_count);
+ DAL_DEBUG("Read 0x57 %d times\n", i2c_error_count);
if (i2c_error_count < 5) {
usleep(2000);
goto retry;
}
- DAL_PRINT("RX Thread NOTHING TO READ, RECOVER");
+ DAL_PRINT("NOTHING TO READ, RECOVER");
phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1);
}
else
@@ -723,14 +710,14 @@
#ifdef LOW_LEVEL_TRACES
phOsalNfc_PrintData("Received buffer", (uint16_t)gReadWriteContext.nNbOfBytesRead, gReadWriteContext.pReadBuffer);
#endif
- DAL_DEBUG("RX Thread Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
- DAL_DEBUG("RX Thread NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
- DAL_PRINT("RX Thread ReadBuff[]={ ");
+ DAL_DEBUG("Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
+ DAL_DEBUG("NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
+ DAL_PRINT("ReadBuff[]={ ");
for (i = 0; i < gReadWriteContext.nNbOfBytesRead; i++)
{
- DAL_DEBUG("RX Thread 0x%x ", gReadWriteContext.pReadBuffer[i]);
+ DAL_DEBUG("0x%x ", gReadWriteContext.pReadBuffer[i]);
}
- DAL_PRINT("RX Thread }\n");
+ DAL_PRINT("}\n");
/* read completed immediately */
sMsg.eMsgType= PHDAL4NFC_READ_MESSAGE;
@@ -742,9 +729,6 @@
}
} /* End of thread Loop*/
-
- DAL_PRINT("RX Thread exiting");
-
return TRUE;
}
@@ -968,3 +952,4 @@
}
#undef _DAL_4_NFC_C
+
diff --git a/inc/phNfcConfig.h b/inc/phNfcConfig.h
index b11e79d..19a881b 100644
--- a/inc/phNfcConfig.h
+++ b/inc/phNfcConfig.h
@@ -369,15 +369,11 @@
/**< Macro to Enable the Card Emulation Feature */
/* #define HOST_EMULATION */
-#define NXP_HAL_VERIFY_EEPROM_CRC 0x01U
-
/**< Macro to Enable the Download Mode Feature */
#define FW_DOWNLOAD
/**< Macro to Enable the Firmware Download Timer */
-/* 0x01U to use overall timeout */
-/* 0x02U to use per frame timeout */
-#define FW_DOWNLOAD_TIMER 0x02U
+#define FW_DOWNLOAD_TIMER
/**< Macro to Verify the Firmware Download */
/* #define FW_DOWNLOAD_VERIFY */
@@ -386,9 +382,6 @@
#define NXP_FW_INTEGRITY_CHK 1
#endif
-/* To specify the Maximum TX/RX Len */
-#define NXP_FW_MAX_TX_RX_LEN 0x200
-
#define UICC_CONNECTIVITY_PATCH
/* Work around to Delay the initiator activation */
diff --git a/inc/phNfcHalTypes.h b/inc/phNfcHalTypes.h
index 47e9036..748f01b 100644
--- a/inc/phNfcHalTypes.h
+++ b/inc/phNfcHalTypes.h
@@ -36,8 +36,6 @@
*
* File: \ref phNfcHalTypes.h
*
- * Developed By: Ravindra U.
- *
*/
/*@{*/
@@ -49,26 +47,6 @@
#include <phNfcCompId.h>
#include <phNfcConfig.h>
-#ifndef NXP_HAL_MEM_INFO_SIZE
-#define NXP_HAL_MEM_INFO_SIZE 0x01U
-#endif
-
-#if (NXP_HAL_MEM_INFO_SIZE > 0x01)
-#define NXP_FW_UPLOAD_PROGRESS 0x965AU
-#define NXP_FW_UPLOAD_SUCCESS 0x0000U
-#else
-#define NXP_FW_UPLOAD_PROGRESS 0x5AU
-#define NXP_FW_UPLOAD_SUCCESS 0x00U
-#endif
-
-
-typedef struct phHal_sMemInfo
-{
- uint16_t fw_magic;
- uint16_t fw_rfu;
- uint32_t hal_version;
-}phHal_sMemInfo_t;
-
/** \ingroup grp_hal_common
*
@@ -857,13 +835,7 @@
/* NXP Specific System Information Events */
NFC_INFO_TXLDO_OVERCUR = 0x71U,
NFC_INFO_MEM_VIOLATION = 0x73U,
- NFC_INFO_TEMP_OVERHEAT = 0x74U,
- NFC_INFO_LLC_ERROR = 0x75U,
-
- /* NXP EVENTS */
- NFC_EVT_MIFARE_ACCESS = 0x35,
- NFC_EVT_APDU_RECEIVED = 0x36,
- NFC_EVT_EMV_CARD_REMOVAL = 0x37
+ NFC_INFO_TEMP_OVERHEAT = 0x74U
}phHal_Event_t;
diff --git a/src/phDnldNfc.c b/src/phDnldNfc.c
index 0c11377..76fd88b 100644
--- a/src/phDnldNfc.c
+++ b/src/phDnldNfc.c
@@ -58,6 +58,9 @@
#define STATIC static
#endif
+#define SECTION_HDR
+
+
#if defined (DNLD_SUMMARY) && !defined (DNLD_TRACE)
#define DNLD_TRACE
#endif
@@ -88,53 +91,12 @@
#define DNLD_PRINT_BUFFER(msg,buf,len)
#endif
-#define DO_DELAY(period) { unsigned i=0; for(;i<period;i++); }
-
-#define PHDNLD_DNLD_DELAY 0x1000U
-#define PHDNLD_MAX_PACKET 0x0200U /* Max Total Packet Size is 512 */
-#define PHDNLD_DATA_SIZE ((PHDNLD_MAX_PACKET)- 8U) /* 0x01F8U */
- /* Max Data Size is 504 */
-#define PHDNLD_MIN_PACKET 0x03U /* Minimum Packet Size is 3*/
-
-#define DNLD_DEFAULT_RESPONSE_TIMEOUT 0x4000U
-
-#define NXP_FW_MIN_TX_RX_LEN 0x0AU
-
-
-#if defined( NXP_FW_MAX_TX_RX_LEN ) && \
- ( NXP_FW_MAX_TX_RX_LEN > NXP_FW_MIN_TX_RX_LEN )
-
-#define PHDNLD_FW_TX_RX_LEN NXP_FW_MAX_TX_RX_LEN
-
-#elif !defined( NXP_FW_MAX_TX_RX_LEN )
-
-/* To specify the Maximum TX/RX Len */
-#define NXP_FW_MAX_TX_RX_LEN 0x200
-#define PHDNLD_FW_TX_RX_LEN NXP_FW_MAX_TX_RX_LEN
-
-#else
-
-#define PHDNLD_FW_TX_RX_LEN NXP_FW_MIN_TX_RX_LEN
-
-#endif
-
#define PHDNLD_FRAME_LEN_SIZE 0x02U
#define PHDNLD_ADDR_SIZE 0x03U
#define PHDNLD_DATA_LEN_SIZE 0x02U
-#define PHDNLD_FRAME_DATA_OFFSET 0x03U
-
-#define DNLD_SM_UNLOCK_MASK 0x01U
-#define DNLD_TRIM_MASK 0x02U
-#define DNLD_RESET_MASK 0x04U
-#define DNLD_VERIFY_MASK 0x08U
-#define DNLD_CRITICAL_MASK 0x10U
-
-
-#define NXP_NFC_IMAG_FW_MAX 0x05U
-
-#define PHDNLD_FW_PATCH_SEC 0x5FU
-
-#define PHDNLD_PAGE_SIZE 0x80U /* Page Size Configured for 64 Bytes */
+#define PHDNLD_MIN_PACKET 0x03U /* Minimum Packet Size is 3*/
+#define PHDNLD_MAX_PACKET 0x0200U /* Max Total Packet Size is 512 */
+#define PHDNLD_DATA_SIZE 0x01F8U /* Max Data Size is 504 */
#define FW_MAX_SECTION 0x15U /* Max Number of Sections */
@@ -142,14 +104,11 @@
#define DNLD_CRC32_SIZE 0x04U
-#define DNLD_CFG_PG_ADDR 0x00008000U
-#define DNLD_FW_CODE_ADDR 0x00800000U
-#define DNLD_PATCH_CODE_ADDR 0x00018800U
-#define DNLD_PATCH_TABLE_ADDR 0x00008200U
+#define DNLD_FW_CODE_ADDR 0x00800000
+#define DNLD_PATCH_CODE_ADDR 0x00018800
+#define DNLD_PATCH_TABLE_ADDR 0x00008200
-/* Raw Command to pass the Data in Download Mode */
-#define PHDNLD_CMD_RAW 0x00U
/* Command to Reset the Device in Download Mode */
#define PHDNLD_CMD_RESET 0x01U
/* Command to Read from the Address specified in Download Mode */
@@ -157,7 +116,6 @@
#define PHDNLD_CMD_READ_LEN 0x0005U
/* Command to write to the Address specified in Download Mode */
#define PHDNLD_CMD_WRITE 0x08U
-#define PHDNLD_CMD_SEC_WRITE 0x0CU
#define PHDNLD_CMD_WRITE_MIN_LEN 0x0005U
#define PHDNLD_CMD_WRITE_MAX_LEN PHDNLD_DATA_SIZE
/* Command to verify the data written */
@@ -178,9 +136,6 @@
/* Command to verify the Integrity of the data written */
#define PHDNLD_CMD_CHECK_INTEGRITY 0x0BU
-/* Command to verify the Integrity of the data written */
-#define PHDNLD_CMD_ENCAPSULATE 0x0DU
-
#define CHECK_INTEGRITY_RESP_CRC16_LEN 0x03U
#define CHECK_INTEGRITY_RESP_CRC32_LEN 0x05U
#define CHECK_INTEGRITY_RESP_COMP_LEN 0x10U
@@ -198,23 +153,8 @@
#define PHDNLD_RESP_PROTOCOL_ERROR 0x0BU
/* Invalid parameter Response to a Command Sent in the Download Mode */
#define PHDNLD_RESP_INVALID_PARAMETER 0x11U
-/* Command Not Supported Response to a Command Sent in the Download Mode */
-#define PHDNLD_RESP_CMD_NOT_SUPPORTED 0x13U
/* Length parameter error Response to a Command Sent in the Download Mode */
#define PHDNLD_RESP_INVALID_LENGTH 0x18U
-/* Checksum Error Response to a Command Sent in the Download Mode */
-#define PHDNLD_RESP_CHKSUM_ERROR 0x19U
-/* Version already uptodate Response to a Command Sent in the Download Mode */
-#define PHDNLD_RESP_VERSION_UPTODATE 0x1DU
-/* Memory operation error during the processing of
- the Command Frame in the Download Mode */
-#define PHDNLD_RESP_MEMORY_UPDATE_ERROR 0x20U
-/* The Chaining of the Command Frame was Successful in the Download Mode */
-#define PHDNLD_RESP_CHAINING_SUCCESS 0x21U
-/* The Command is not allowed anymore in the Download Mode */
-#define PHDNLD_RESP_CMD_NOT_ALLOWED 0xE0U
-/* The Error during the Chaining the Command Frame in the Download Mode */
-#define PHDNLD_RESP_CHAINING_ERROR 0xE6U
/* Write Error Response to a Command Sent in the Download Mode */
#define PHDNLD_RESP_WRITE_ERROR 0x74U
@@ -222,7 +162,7 @@
#define NXP_MAX_DNLD_RETRY 0x02U
-#define NXP_MAX_SECTION_WRITE 0x05U
+#define NXP_MAX_SECTION_WRITE 0x04U
#define NXP_PATCH_VER_INDEX 0x05U
@@ -236,7 +176,6 @@
typedef enum phDnldNfc_eSeqType{
DNLD_SEQ_RESET = 0x00U,
DNLD_SEQ_INIT,
- DNLD_SEQ_RAW,
DNLD_SEQ_LOCK,
DNLD_SEQ_UNLOCK,
DNLD_SEQ_UPDATE,
@@ -258,8 +197,6 @@
typedef enum phDnldNfc_eSeq
{
phDnld_Reset_Seq = 0x00,
- phDnld_Activate_Patch,
- phDnld_Deactivate_Patch,
phDnld_Update_Patch,
phDnld_Update_Patchtable,
phDnld_Lock_System,
@@ -268,7 +205,6 @@
phDnld_Verify_Integrity,
phDnld_Verify_Section,
phDnld_Complete_Seq,
- phDnld_Raw_Upgrade,
phDnld_Invalid_Seq
}phDnldNfc_eSeq_t;
@@ -297,7 +233,7 @@
uint8_t img_data_offset;
/* Number of fimware images available in the img_data */
uint8_t no_of_fw_img;
- /* Fimware image Padding in the img_data */
+ /* Number of fimware images available in the img_data */
uint8_t fw_img_pad[2];
/* HW Compatiblity table for the set of the Hardwares */
hw_comp_tbl_t comp_tbl;
@@ -326,12 +262,25 @@
{
uint8_t section_hdr_len;
uint8_t section_mem_type;
- uint8_t section_checksum;
- uint8_t section_conf;
+ uint16_t section_data_crc;
uint32_t section_address;
uint32_t section_length;
}section_hdr_t;
+
+typedef struct section_type
+{
+ unsigned system_mem_unlock:1;
+ unsigned trim_val:1;
+ unsigned reset_required:1;
+ unsigned verify_mem:1;
+ unsigned trim_check:1;
+ unsigned section_crc_check:1;
+ unsigned section_type_rfu:2;
+ unsigned section_type_pad:24;
+
+}section_type_t;
+
typedef struct section_info
{
section_hdr_t *p_sec_hdr;
@@ -340,10 +289,6 @@
* to be loaded to the particular address.
*/
uint8_t *p_sec_data;
- /* The Section checksum to verify the integrity of the section
- * data.
- */
- uint8_t *p_sec_chksum;
/** \internal Index used to refer and process the
* Firmware Section Data */
volatile uint32_t section_offset;
@@ -369,24 +314,13 @@
uint8_t data_packet[PHDNLD_DATA_SIZE];
}phDnldNfc_sParam_t;
+
typedef struct phDnldNfc_sDataHdr
{
uint8_t frame_type;
uint8_t frame_length[PHDNLD_FRAME_LEN_SIZE];
}phDnldNfc_sData_Hdr_t;
-typedef struct phDnldNfc_sRawHdr
-{
- uint8_t frame_type;
- uint8_t frame_length[PHDNLD_FRAME_LEN_SIZE];
-}phDnldNfc_sRawHdr_t;
-
-typedef struct phDnldNfc_sRawDataHdr
-{
- uint8_t data_addr[PHDNLD_ADDR_SIZE];
- uint8_t data_len[PHDNLD_DATA_LEN_SIZE];
-}phDnldNfc_sRawDataHdr_t;
-
typedef struct phDnldNfc_sChkCrc16_Resp
{
uint8_t Chk_status;
@@ -418,58 +352,10 @@
{
phDnldNfc_sParam_t data_param;
uint8_t response_data[PHDNLD_MAX_PACKET];
- uint8_t cmd_param;
+ uint8_t config_verify_param;
}param_info;
}phDnldNfc_sData_t;
-#ifdef NXP_NFC_MULTIPLE_FW
-
-typedef struct phDnldNfc_sFwImageInfo
-{
- /** \internal Data Pointer to the Firmware header section of the Firmware */
- fw_data_hdr_t *p_fw_hdr;
- /** \internal Buffer pointer to store the Firmware Section Data */
- section_info_t *p_fw_sec;
- /** \internal Buffer pointer to store the Firmware Raw Data */
- uint8_t *p_fw_raw;
-}phDnldNfc_sFwImageInfo_t;
-
-#endif /* #ifdef NXP_NFC_MULTIPLE_FW */
-
-
-typedef struct phDnldNfc_TxInfo
-{
- uint8_t *transmit_frame;
-
- uint16_t tx_offset;
-
- /** \internal Remaining amount of data to be sent */
- uint16_t tx_len;
-
- uint16_t tx_total;
-
- /** \internal Chain information for the data to be sent */
- uint8_t tx_chain;
-
-}phDnldNfc_TxInfo_t;
-
-
-typedef struct phDnldNfc_RxInfo
-{
- /** \internal Total length of the received buffer */
- uint16_t rx_total;
- /** \internal Chain information of the received buffer */
- uint16_t rx_chain;
- /** \internal Remaining Data information to be read to complete the
- * Data Information.
- */
- uint16_t rx_remain;
-
- /** \internal Buffer to Send the Raw Data Frame */
- uint8_t raw_buffer_data[PHDNLD_MAX_PACKET
- + PHDNLD_PAGE_SIZE];
-}phDnldNfc_RxInfo_t;
-
typedef struct phDnldNfc_sContext
{
@@ -488,29 +374,18 @@
/** \internal Timer ID for the Download Abort */
uint32_t timer_id;
- /** \internal Internal Download for the Download Abort */
- uint32_t dnld_timeout;
/** \internal Data Pointer to the Image header section of the Firmware */
img_data_hdr_t *p_img_hdr;
-
-#ifdef NXP_NFC_MULTIPLE_FW
- /** \internal Data Pointer to the Firmware Image Information */
- phDnldNfc_sFwImageInfo_t *p_img_info;
-#endif /* #ifdef NXP_NFC_MULTIPLE_FW */
-
/** \internal Data Pointer to the Firmware header section of the Firmware */
fw_data_hdr_t *p_fw_hdr;
/** \internal Buffer pointer to store the Firmware Data */
section_info_t *p_fw_sec;
- /** \internal Buffer pointer to store the Firmware Raw Data */
- uint8_t *p_fw_raw;
/** \internal Previous Download Size */
uint32_t prev_dnld_size;
/** \internal Single Data Block to download the Firmware */
- uint8_t dnld_data[PHDNLD_MAX_PACKET
- + PHDNLD_PAGE_SIZE];
+ phDnldNfc_sData_t dnld_data;
/** \internal Index used to refer and process the Download Data */
volatile uint32_t dnld_index;
@@ -538,12 +413,11 @@
#define NXP_FW_VMID_CARD_MODE_ADDR 0x00009931U
#define NXP_FW_VMID_RD_MODE_ADDR 0x00009981U
- uint8_t vmid_trim_update;
+ unsigned vmid_trim_update:1;
+ unsigned trim_bits_rfu:31;
#endif /* #ifdef NXP_FW_SW_VMID_TRIM */
- uint8_t cur_frame_info;
-
- uint8_t raw_mode_upgrade;
+ uint8_t *p_system_mem_crc;
uint8_t *p_patch_table_crc;
@@ -553,12 +427,18 @@
uint16_t resp_length;
+ /** \internal Total length of the received buffer */
+ volatile uint16_t rx_total;
+
/** \internal Current FW Section in Process */
volatile uint8_t section_index;
/** \internal Previous Command sent */
volatile uint8_t prev_cmd;
+ /** \internal Download Response pending */
+ volatile uint8_t recv_pending;
+
uint8_t dnld_retry;
/** \internal Current Download State */
@@ -571,38 +451,16 @@
/** \internal Next step in Download Sequence */
volatile uint8_t next_dnld_seq;
- /* \internal Data Transmit information */
- phDnldNfc_TxInfo_t tx_info;
-
- /* \internal Data Receive information */
- phDnldNfc_RxInfo_t rx_info;
-
-
}phDnldNfc_sContext_t;
+
/*
################################################################################
******************** Global and Static Variables Definition ********************
################################################################################
*/
-
-#ifndef NFC_TIMER_CONTEXT
static phDnldNfc_sContext_t *gpphDnldContext = NULL;
-#endif
-
-#ifdef NXP_FW_DNLD_CHECK_PHASE
-
-#define NXP_FW_DNLD_COMPLETE_PHASE 0x00U
-#define NXP_FW_DNLD_SYSTEM_PHASE 0x01U
-#define NXP_FW_DNLD_CFG_PHASE 0x02U
-#define NXP_FW_DNLD_DATA_PHASE 0x03U
-#define NXP_FW_DNLD_RAW_PHASE 0x04U
-#define NXP_FW_DNLD_INVALID_PHASE 0xFFU
-
-static uint8_t gphDnldPhase = NXP_FW_DNLD_COMPLETE_PHASE;
-
-#endif /* #ifdef NXP_FW_DNLD_CHECK_PHASE */
/**/
@@ -769,10 +627,8 @@
STATIC
void
phDnldNfc_Abort (
- uint32_t abort_id
-#ifdef NFC_TIMER_CONTEXT
- , void *dnld_cntxt
-#endif
+ uint32_t abort_id ,
+ void * pcontext
);
@@ -1038,7 +894,7 @@
NFCSTATUS status = NFCSTATUS_SUCCESS;
static uint8_t prev_temp_state = 0;
static uint8_t prev_temp_seq =
- (uint8_t) phDnld_Activate_Patch;
+ (uint8_t) phDnld_Update_Patch;
switch(seq_type)
{
@@ -1049,49 +905,12 @@
(uint8_t) phDnld_Reset_State;
psDnldContext->next_dnld_state =
(uint8_t)phDnld_Upgrade_State;
- psDnldContext->cur_dnld_seq =
+ psDnldContext->next_dnld_seq =
(uint8_t)phDnld_Upgrade_Section;
psDnldContext->next_dnld_seq =
psDnldContext->cur_dnld_seq;
break;
}
- case DNLD_SEQ_RAW:
- {
- psDnldContext->cur_dnld_state =
- (uint8_t) phDnld_Reset_State;
- psDnldContext->next_dnld_state =
- (uint8_t)phDnld_Upgrade_State;
- psDnldContext->cur_dnld_seq =
- (uint8_t)phDnld_Raw_Upgrade;
- psDnldContext->next_dnld_seq =
- psDnldContext->cur_dnld_seq;
- break;
- }
- case DNLD_SEQ_UNLOCK:
- {
- psDnldContext->cur_dnld_state =
- (uint8_t) phDnld_Reset_State;
-
-#ifdef NXP_FW_DNLD_CHECK_PHASE
- if( NXP_FW_DNLD_SYSTEM_PHASE < gphDnldPhase )
- {
- psDnldContext->next_dnld_state =
- (uint8_t)phDnld_Upgrade_State;
- psDnldContext->cur_dnld_seq =
- (uint8_t)phDnld_Upgrade_Section;
- }
- else
-#endif /* NXP_FW_DNLD_CHECK_PHASE */
- {
- psDnldContext->next_dnld_state =
- (uint8_t) phDnld_Unlock_State;
- psDnldContext->cur_dnld_seq =
- (uint8_t) phDnld_Activate_Patch;
- }
- psDnldContext->next_dnld_seq =
- psDnldContext->cur_dnld_seq;
- break;
- }
case DNLD_SEQ_LOCK:
{
psDnldContext->cur_dnld_state =
@@ -1104,6 +923,18 @@
psDnldContext->cur_dnld_seq;
break;
}
+ case DNLD_SEQ_UNLOCK:
+ {
+ psDnldContext->cur_dnld_state =
+ (uint8_t) phDnld_Reset_State;
+ psDnldContext->next_dnld_state =
+ (uint8_t) phDnld_Unlock_State;
+ psDnldContext->cur_dnld_seq =
+ (uint8_t) phDnld_Update_Patch;
+ psDnldContext->next_dnld_seq =
+ psDnldContext->cur_dnld_seq;
+ break;
+ }
case DNLD_SEQ_UPDATE:
{
prev_temp_state = (uint8_t) psDnldContext->cur_dnld_state;
@@ -1141,6 +972,26 @@
psDnldContext->cur_dnld_seq ;
break;
}
+#if 0
+ case DNLD_UPDATE_STATE1:
+ {
+ prev_temp_state = (uint8_t) psDnldContext->cur_dnld_state;
+ psDnldContext->cur_dnld_state =
+ psDnldContext->next_dnld_state;
+ /* psDnldContext->next_dnld_state =
+ (uint8_t)phDnld_Invalid_State ; */
+ break;
+ }
+ case DNLD_ROLLBACK_STATE1:
+ {
+ psDnldContext->cur_dnld_state = (uint8_t) prev_temp_state;
+ /* psDnldContext->next_dnld_state =
+ (uint8_t)phDnld_Invalid_State ; */
+ prev_temp_state = 0;
+
+ break;
+ }
+#endif
default:
{
break;
@@ -1182,36 +1033,6 @@
#endif
status = plower_if->send((void *)plower_if->pcontext,
(void *)pHwRef, pdata, length);
-
-#if defined(FW_DOWNLOAD_TIMER) && \
- (FW_DOWNLOAD_TIMER == 2)
- if (
- (NFCSTATUS_PENDING == status)
- && ( NXP_INVALID_TIMER_ID != psDnldContext->timer_id )
- )
- {
- psDnldContext->dnld_timeout = NXP_DNLD_COMPLETE_TIMEOUT;
-
- if ( psDnldContext->dnld_timeout
- < DNLD_DEFAULT_RESPONSE_TIMEOUT)
- {
- psDnldContext->dnld_timeout
- = DNLD_DEFAULT_RESPONSE_TIMEOUT;
- }
- /* Start the Download Timer */
- phOsalNfc_Timer_Start( psDnldContext->timer_id,
- psDnldContext->dnld_timeout,
- (ppCallBck_t) phDnldNfc_Abort
-#ifdef NFC_TIMER_CONTEXT
- , (void *) psDnldContext
-#endif
- );
-
- DNLD_DEBUG(" DNLD : Timer %X Started ", psDnldContext->timer_id);
- DNLD_DEBUG(" \t\t With %U Timeout \n", psDnldContext->dnld_timeout);
- }
-
-#endif /* (NXP_NFC_DNLD_TIMER == 1) */
}
return status;
@@ -1267,10 +1088,8 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- phDnldNfc_sData_t *p_dnld_data =
- (phDnldNfc_sData_t *)psDnldContext->dnld_data;
- phDnldNfc_sParam_t *p_data_param =
- &p_dnld_data->param_info.data_param;
+ phDnldNfc_sParam_t *p_dnld_data =
+ &psDnldContext->dnld_data.param_info.data_param;
uint32_t read_addr = (p_sec_info->p_sec_hdr->section_address
+ p_sec_info->section_offset);
static unsigned sec_type = 0;
@@ -1280,7 +1099,7 @@
sec_type = (unsigned int)p_sec_info->p_sec_hdr->section_mem_type;
if( ( FALSE == p_sec_info->section_read )
- && ((sec_type & DNLD_TRIM_MASK))
+ && (TRUE == ((section_type_t *)(&sec_type))->trim_val)
&& (FALSE == p_sec_info->trim_write) )
{
read_size = (uint16_t) p_sec_info->p_sec_hdr->section_length;
@@ -1288,26 +1107,18 @@
}
else
{
+#ifdef FW_DOWNLOAD_VERIFY
if (( FALSE == p_sec_info->section_read )
- && ((sec_type & DNLD_VERIFY_MASK))
- )
+ && (TRUE == ((section_type_t *)(&sec_type))->verify_mem ))
{
read_size = (uint16_t)(psDnldContext->prev_dnld_size );
DNLD_DEBUG(" FW_DNLD: Section Read = %X \n", read_size);
}
- else if( ( TRUE == p_sec_info->section_read )
- && ( TRUE == p_sec_info->section_write )
- )
+ else
+#endif /* #ifdef FW_DOWNLOAD_VERIFY */
{
/*Already Read the Data Hence Ignore the Read */
- DNLD_DEBUG(" FW_DNLD: Already Read, Read Ignored, read_size = %X \n", read_size);
- }
- else
- {
- /* Ignore the Read */
- DNLD_DEBUG(" FW_DNLD: Section Read Status = %X \n", p_sec_info->section_read);
- DNLD_DEBUG(" FW_DNLD: Section Write Status = %X \n", p_sec_info->section_write);
- DNLD_DEBUG(" FW_DNLD: No Read Required, Read_size = %X \n", read_size);
+ DNLD_DEBUG(" FW_DNLD: Already Read/Read Back Ignored = %X \n", read_size);
}
}
@@ -1317,24 +1128,24 @@
read_size = (uint16_t)((PHDNLD_DATA_SIZE >= read_size)?
read_size: PHDNLD_DATA_SIZE);
- p_dnld_data->frame_length[i] = (uint8_t)0;
+ psDnldContext->dnld_data.frame_length[i] = (uint8_t)0;
/* Update the LSB of the Data and the Address Parameter*/
- p_data_param->data_addr[i] = (uint8_t)((read_addr >>
+ p_dnld_data->data_addr[i] = (uint8_t)((read_addr >>
(BYTE_SIZE + BYTE_SIZE)) & BYTE_MASK);
- p_data_param->data_len[i] = (uint8_t)((read_size >>
+ p_dnld_data->data_len[i] = (uint8_t)((read_size >>
BYTE_SIZE) & BYTE_MASK);
i++;
- p_dnld_data->frame_length[i] = (uint8_t)
+ psDnldContext->dnld_data.frame_length[i] = (uint8_t)
( PHDNLD_CMD_READ_LEN & BYTE_MASK);
/* Update the 2nd byte of the Data and the Address Parameter*/
- p_data_param->data_addr[i] = (uint8_t)((read_addr >>
+ p_dnld_data->data_addr[i] = (uint8_t)((read_addr >>
BYTE_SIZE) & BYTE_MASK);
- p_data_param->data_len[i] = (uint8_t) (read_size & BYTE_MASK);
+ p_dnld_data->data_len[i] = (uint8_t) (read_size & BYTE_MASK);
i++;
/* Update the 3rd byte of the the Address Parameter*/
- p_data_param->data_addr[i] = (uint8_t)(read_addr & BYTE_MASK);
+ p_dnld_data->data_addr[i] = (uint8_t)(read_addr & BYTE_MASK);
status = phDnldNfc_Send_Command( psDnldContext, pHwRef,
PHDNLD_CMD_READ, NULL , 0 );
@@ -1363,10 +1174,8 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- phDnldNfc_sData_t *p_dnld_data =
- (phDnldNfc_sData_t *)psDnldContext->dnld_data;
phDnldNfc_sParam_t *dnld_data =
- &p_dnld_data->param_info.data_param;
+ &psDnldContext->dnld_data.param_info.data_param;
uint8_t *p_sm_trim_data = (uint8_t *)psDnldContext->
dnld_resp.param_info.response_data;
uint32_t dnld_addr = 0;
@@ -1376,7 +1185,9 @@
static unsigned sec_type = 0;
uint8_t i = 0;
uint16_t dnld_size = 0;
+#ifdef FW_DOWNLOAD_VERIFY
int cmp_val = 0x00;
+#endif /* #ifdef FW_DOWNLOAD_VERIFY */
sec_type = (unsigned int)p_sec_info->p_sec_hdr->section_mem_type;
@@ -1386,38 +1197,27 @@
{
if( (TRUE == p_sec_info->trim_write)
&& (TRUE == p_sec_info->section_read)
- && ((sec_type & DNLD_VERIFY_MASK))
)
{
+#ifdef FW_DOWNLOAD_VERIFY
if(NULL != psDnldContext->trim_store.buffer)
{
- uint32_t trim_cmp_size = psDnldContext->prev_dnld_size;
-
- if( p_sec_info->p_sec_hdr->section_address
- < (DNLD_CFG_PG_ADDR + PHDNLD_PAGE_SIZE) )
- {
- trim_cmp_size = trim_cmp_size - 2;
- }
-
/* Below Comparison fails due to the checksum */
cmp_val = phOsalNfc_MemCompare(
psDnldContext->trim_store.buffer,
&psDnldContext->dnld_resp.
param_info.response_data[0]
- ,trim_cmp_size);
- DNLD_DEBUG(" FW_DNLD: %X Bytes Trim Write Complete ",
- psDnldContext->prev_dnld_size);
- DNLD_DEBUG(" Comparison Status %X\n", cmp_val);
+ ,psDnldContext->prev_dnld_size);
}
+#endif /* #ifdef FW_DOWNLOAD_VERIFY */
p_sec_info->trim_write = FALSE;
DNLD_DEBUG(" FW_DNLD: TRIMMED %X Bytes Write Complete\n", psDnldContext->prev_dnld_size);
}
else
{
+#ifdef FW_DOWNLOAD_VERIFY
if((NULL != psDnldContext->dnld_store.buffer)
- && ((sec_type & DNLD_VERIFY_MASK))
- && (TRUE == p_sec_info->section_write)
- && (TRUE == p_sec_info->section_read)
+ && (TRUE == ((section_type_t *)(&sec_type))->verify_mem )
)
{
cmp_val = phOsalNfc_MemCompare(
@@ -1425,26 +1225,18 @@
&psDnldContext->dnld_resp.
param_info.response_data[0]
,psDnldContext->dnld_store.length);
- p_sec_info->section_read = FALSE;
- p_sec_info->section_write = FALSE;
DNLD_DEBUG(" FW_DNLD: %X Bytes Write Complete ",
psDnldContext->dnld_store.length);
DNLD_DEBUG(" Comparison Status %X\n", cmp_val);
}
- else
- {
- if(( TRUE == p_sec_info->section_write)
- && ( FALSE == p_sec_info->section_read)
- )
- {
- p_sec_info->section_write = FALSE;
- }
- }
+#endif /* #ifdef FW_DOWNLOAD_VERIFY */
/* p_sec_info->section_read = FALSE; */
}
if (( 0 == psDnldContext->dnld_retry )
+#ifdef FW_DOWNLOAD_VERIFY
&& (0 == cmp_val)
+#endif
)
{
p_sec_info->sec_verify_retry = 0;
@@ -1480,6 +1272,7 @@
if (dnld_size != 0)
{
+
dnld_size = (uint16_t)((PHDNLD_DATA_SIZE >= dnld_size)?
dnld_size: PHDNLD_DATA_SIZE);
@@ -1488,7 +1281,7 @@
(BYTE_SIZE + BYTE_SIZE)) & BYTE_MASK);
dnld_data->data_len[i] = (uint8_t)((dnld_size >> BYTE_SIZE)
& BYTE_MASK);
- p_dnld_data->frame_length[i] = (uint8_t)
+ psDnldContext->dnld_data.frame_length[i] = (uint8_t)
(((dnld_size + PHDNLD_CMD_WRITE_MIN_LEN) >> BYTE_SIZE)
& BYTE_MASK);
i++;
@@ -1496,7 +1289,7 @@
dnld_data->data_addr[i] = (uint8_t)((dnld_addr >> BYTE_SIZE)
& BYTE_MASK);
dnld_data->data_len[i] = (uint8_t) (dnld_size & BYTE_MASK);
- p_dnld_data->frame_length[i] = (uint8_t) ((dnld_size +
+ psDnldContext->dnld_data.frame_length[i] = (uint8_t) ((dnld_size +
PHDNLD_CMD_WRITE_MIN_LEN) & BYTE_MASK);
i++;
/* Update the 3rd byte of the the Address Parameter*/
@@ -1505,15 +1298,7 @@
(void)memcpy( dnld_data->data_packet,
(p_sec_info->p_sec_data + *p_sec_offset), dnld_size );
- if( ((sec_type & DNLD_TRIM_MASK))
- && (p_sec_info->sec_verify_retry != 0)
- && (NULL != psDnldContext->trim_store.buffer)
- )
- {
- (void)memcpy( dnld_data->data_packet,
- psDnldContext->trim_store.buffer, dnld_size );
- }
- else if(((sec_type & DNLD_TRIM_MASK))
+ if((TRUE == ((section_type_t *)(&sec_type))->trim_val )
&& ( TRUE == p_sec_info->section_read )
)
{
@@ -1563,14 +1348,8 @@
psDnldContext->trim_store.buffer = NULL;
psDnldContext->trim_store.length = 0;
}
-#if 1
- (void)
- phDnldNfc_Allocate_Resource((void **)
- &(psDnldContext->trim_store.buffer),dnld_size);
-#else
psDnldContext->trim_store.buffer =
(uint8_t *) phOsalNfc_GetMemory(dnld_size);
-#endif
if(NULL != psDnldContext->trim_store.buffer)
{
@@ -1593,14 +1372,8 @@
psDnldContext->dnld_store.buffer = NULL;
psDnldContext->dnld_store.length = 0;
}
-#if 1
- (void)
- phDnldNfc_Allocate_Resource((void **)
- &(psDnldContext->dnld_store.buffer),dnld_size);
-#else
psDnldContext->dnld_store.buffer =
(uint8_t *) phOsalNfc_GetMemory(dnld_size);
-#endif
if(NULL != psDnldContext->dnld_store.buffer)
{
(void )memset((void *)psDnldContext->dnld_store.buffer,0,
@@ -1612,24 +1385,14 @@
DNLD_DEBUG(" of Size %X ", dnld_size );
}
}
-
- if(PHDNLD_FW_PATCH_SEC != psDnldContext->p_fw_hdr->fw_patch)
- {
status = phDnldNfc_Send_Command( psDnldContext, pHwRef,
PHDNLD_CMD_WRITE, NULL , 0 );
- }
- else
- {
- status = phDnldNfc_Send_Command( psDnldContext, pHwRef,
- PHDNLD_CMD_SEC_WRITE, NULL , 0 );
- }
- DNLD_DEBUG(" FW_DNLD: Memory Write Status = %X \n", status);
+ DNLD_DEBUG(" : Memory Write Status = %X \n", status);
if ( NFCSTATUS_PENDING == status )
{
psDnldContext->prev_dnld_size = dnld_size;
- cmp_val = 0x00;
- if((sec_type & DNLD_TRIM_MASK))
+ if(TRUE == ((section_type_t *)(&sec_type))->trim_val )
{
p_sec_info->trim_write = TRUE;
DNLD_DEBUG(" FW_DNLD: Bytes Downloaded (Trimming Values) = %X Bytes \n",
@@ -1637,7 +1400,6 @@
}
else
{
- p_sec_info->section_write = TRUE;
DNLD_DEBUG(" FW_DNLD: Bytes Downloaded = %X : ",
(*p_sec_offset + dnld_size));
DNLD_DEBUG(" Bytes Remaining = %X \n",
@@ -1678,11 +1440,10 @@
p_sec_info->section_offset = 0;
p_sec_info->section_read = FALSE;
- p_sec_info->section_write = FALSE;
p_sec_info->trim_write = FALSE;
DNLD_DEBUG(" FW_DNLD: Section %02X Download Complete\n", sec_index);
- if((sec_type & DNLD_RESET_MASK))
+ if(TRUE == ((section_type_t *)(&sec_type))->reset_required )
{
DNLD_DEBUG(" FW_DNLD: Reset After Section %02X Download \n", sec_index);
status = phDnldNfc_Send_Command( psDnldContext, pHwRef,
@@ -1691,36 +1452,7 @@
DNLD_PRINT("*******************************************\n\n");
sec_index++;
-
-#ifdef NXP_FW_DNLD_CHECK_PHASE
- if( p_sec_info->p_sec_hdr->section_address
- < (DNLD_CFG_PG_ADDR + PHDNLD_PAGE_SIZE) )
- {
- gphDnldPhase = NXP_FW_DNLD_DATA_PHASE;
-
- }
-
p_sec_info = (psDnldContext->p_fw_sec + sec_index);
-
- if( (sec_index < psDnldContext->p_fw_hdr->no_of_sections)
- && ( p_sec_info->p_sec_hdr->section_address
- < (DNLD_CFG_PG_ADDR + PHDNLD_PAGE_SIZE) )
- )
- {
- if( NXP_FW_DNLD_CFG_PHASE >= gphDnldPhase )
- {
- gphDnldPhase = NXP_FW_DNLD_CFG_PHASE;
- }
- else
- {
- sec_index++;
- p_sec_info = (psDnldContext->p_fw_sec + sec_index);
- }
- }
-#else
- p_sec_info = (psDnldContext->p_fw_sec + sec_index);
-#endif /* #ifdef NXP_FW_DNLD_CHECK_PHASE */
-
psDnldContext->section_index = sec_index;
/* psDnldContext->next_dnld_state = (uint8_t) phDnld_Upgrade_State; */
}
@@ -1751,7 +1483,7 @@
#if (ES_HW_VER <= 30)
#define NXP_DNLD_PATCH_ADDR 0x01AFFFU
#else
-#define NXP_DNLD_PATCH_ADDR 0x01A1E0U
+#define NXP_DNLD_PATCH_ADDR 0x01AFE0U
#endif
#if (ES_HW_VER <= 30)
@@ -1772,16 +1504,14 @@
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
uint32_t dnld_addr = 0;
- phDnldNfc_sData_t *p_dnld_data =
- (phDnldNfc_sData_t *)psDnldContext->dnld_data;
- phDnldNfc_sParam_t *p_data_param =
- & p_dnld_data->param_info.data_param;
+ phDnldNfc_sParam_t *dnld_data = &psDnldContext->dnld_data
+ .param_info.data_param;
uint8_t *p_data = NULL;
static uint32_t patch_size = 0;
#if (ES_HW_VER == 32)
- static uint8_t patch_table[] = {0xA0, 0xA1, 0xE0, 0x80, 0xA9, 0x6C };
+ static uint8_t patch_table[] = {0xA0, 0xAF, 0xE0, 0x80, 0xA9, 0x6C };
static uint8_t patch_data[] = {0xA5, 0xD0, 0xFE, 0xA5, 0xD0, 0xFD, 0xA5,
0xD0, 0xFC, 0xA5, 0x02, 0x80, 0xA9, 0x75};
@@ -1818,32 +1548,6 @@
break;
}
- case phDnld_Activate_Patch:
- {
- uint8_t patch_activate = 0x01;
- psDnldContext->next_dnld_seq =
- (uint8_t)phDnld_Update_Patch;
-#ifdef NXP_FW_DNLD_CHECK_PHASE
- gphDnldPhase = NXP_FW_DNLD_SYSTEM_PHASE;
-#endif /* NXP_FW_DNLD_CHECK_PHASE */
-
- status = phDnldNfc_Send_Command( psDnldContext, pHwRef,
- PHDNLD_CMD_ACTIVATE_PATCH , &patch_activate, sizeof(patch_activate) );
- DNLD_PRINT(" FW_DNLD: Activate the Patch Update .... \n");
- break;
- }
- case phDnld_Deactivate_Patch:
- {
- uint8_t patch_activate = 0x00;
-
- psDnldContext->next_dnld_state =
- (uint8_t)phDnld_Reset_State;
-
- status = phDnldNfc_Send_Command( psDnldContext, pHwRef,
- PHDNLD_CMD_ACTIVATE_PATCH , &patch_activate, sizeof(patch_activate) );
- DNLD_PRINT(" FW_DNLD: Deactivate the Patch Update .... \n");
- break;
- }
case phDnld_Update_Patch:
{
dnld_addr = NXP_DNLD_PATCH_ADDR;
@@ -1871,14 +1575,8 @@
dnld_addr = NXP_DNLD_SM_UNLOCK_ADDR;
patch_size = sizeof(unlock_data) ;
p_data = unlock_data;
-#define NXP_FW_PATCH_DISABLE
-#ifdef NXP_FW_PATCH_DISABLE
- psDnldContext->next_dnld_seq =
- (uint8_t)phDnld_Deactivate_Patch;
-#else
psDnldContext->next_dnld_state =
(uint8_t)phDnld_Reset_State;
-#endif
DNLD_PRINT(" FW_DNLD: System Memory Unlock Seq.... \n");
break;
@@ -1924,25 +1622,25 @@
{
/* Update the LSB of the Data and the Address Parameter*/
- p_data_param->data_addr[i] = (uint8_t)((dnld_addr >>
+ dnld_data->data_addr[i] = (uint8_t)((dnld_addr >>
(BYTE_SIZE + BYTE_SIZE))
& BYTE_MASK);
- p_data_param->data_len[i] = (uint8_t)((patch_size >> BYTE_SIZE)
+ dnld_data->data_len[i] = (uint8_t)((patch_size >> BYTE_SIZE)
& BYTE_MASK);
- p_dnld_data->frame_length[i] = (uint8_t)
+ psDnldContext->dnld_data.frame_length[i] = (uint8_t)
(((patch_size + PHDNLD_CMD_WRITE_MIN_LEN) >> BYTE_SIZE)
& BYTE_MASK);
i++;
/* Update the 2nd byte of the Data and the Address Parameter*/
- p_data_param->data_addr[i] = (uint8_t)((dnld_addr >> BYTE_SIZE)
+ dnld_data->data_addr[i] = (uint8_t)((dnld_addr >> BYTE_SIZE)
& BYTE_MASK);
- p_data_param->data_len[i] = (uint8_t) (patch_size & BYTE_MASK);
- p_dnld_data->frame_length[i] = (uint8_t)
+ dnld_data->data_len[i] = (uint8_t) (patch_size & BYTE_MASK);
+ psDnldContext->dnld_data.frame_length[i] = (uint8_t)
((patch_size + PHDNLD_CMD_WRITE_MIN_LEN)
& BYTE_MASK);
i++;
/* Update the 3rd byte of the the Address Parameter*/
- p_data_param->data_addr[i] = (uint8_t)(dnld_addr & BYTE_MASK);
+ dnld_data->data_addr[i] = (uint8_t)(dnld_addr & BYTE_MASK);
status = phDnldNfc_Send_Command( psDnldContext, pHwRef,
PHDNLD_CMD_WRITE,(void *)p_data , (uint8_t)patch_size );
@@ -1956,386 +1654,6 @@
return status;
}
-#define FRAME_HEADER_LEN 0x03U
-
-
-static
-void
-phDnldNfc_Tx_Reset(phDnldNfc_sContext_t *psDnldContext)
-{
- psDnldContext->tx_info.transmit_frame = NULL;
- psDnldContext->tx_info.tx_total = 0x00;
- psDnldContext->tx_info.tx_offset = 0x00;
- psDnldContext->tx_info.tx_len = 0x00;
- psDnldContext->tx_info.tx_chain = FALSE;
-}
-
-STATIC
-bool_t
-phDnldNfc_Extract_Chunks(
- uint8_t *frame_data,
- uint16_t frame_offset,
- uint16_t frame_length,
- uint16_t max_frame ,
- uint16_t *chunk_length
- );
-
-
-STATIC
-bool_t
-phDnldNfc_Extract_Chunks(
- uint8_t *frame_data,
- uint16_t frame_offset,
- uint16_t frame_length,
- uint16_t max_frame ,
- uint16_t *chunk_length
- )
-{
- bool_t chunk_present = FALSE;
-
- if( 0 == frame_offset)
- {
- if( max_frame >= (frame_length
- - frame_offset))
- {
- *chunk_length = (frame_length - frame_offset);
- }
- else
- {
- *chunk_length = max_frame
- - FRAME_HEADER_LEN;
- chunk_present = TRUE;
- }
- }
- else
- {
- if( max_frame >= (frame_length
- - frame_offset))
- {
- *chunk_length = (frame_length - frame_offset);
- }
- else
- {
- *chunk_length = max_frame
- - FRAME_HEADER_LEN;
- chunk_present = TRUE;
- }
- }
-
- return chunk_present;
-}
-
-
-STATIC
-NFCSTATUS
-phDnldNfc_Send_Raw(
- phDnldNfc_sContext_t *psDnldContext,
- void *pHwRef,
- uint8_t *raw_frame,
- uint16_t frame_offset,
- uint16_t frame_length
- )
-{
- NFCSTATUS status = NFCSTATUS_SUCCESS;
- phDnldNfc_sRawHdr_t *raw_frame_hdr = ( phDnldNfc_sRawHdr_t * ) raw_frame;
-
-
- switch(raw_frame_hdr->frame_type)
- {
- case PHDNLD_CMD_RESET:
- {
- break;
- }
- case PHDNLD_CMD_READ:
- {
- /* TODO: To Update the length and the buffer to receive data */
- break;
- }
- case PHDNLD_CMD_WRITE:
- {
- phDnldNfc_sRawDataHdr_t *raw_data_hdr =
- ( phDnldNfc_sRawDataHdr_t * ) (raw_frame + FRAME_HEADER_LEN);
-
- psDnldContext->resp_length = PHDNLD_MIN_PACKET;
-
- break;
- }
- case PHDNLD_CMD_SEC_WRITE:
- {
- uint16_t tx_length = 0x00;
- uint16_t frame_offset =
- psDnldContext->tx_info.tx_offset;
- uint16_t chain =
- psDnldContext->tx_info.tx_chain;
-
- chain =
- phDnldNfc_Extract_Chunks(
- raw_frame,
- frame_offset,
- frame_length,
- PHDNLD_FW_TX_RX_LEN,
- &tx_length
- );
-
- if( TRUE == chain )
- {
- status = phDnldNfc_Send_Command( psDnldContext,
- pHwRef, PHDNLD_CMD_ENCAPSULATE,
- (raw_frame + frame_offset),
- tx_length);
- if(NFCSTATUS_PENDING == status)
- {
- psDnldContext->prev_cmd = raw_frame_hdr->frame_type;
- /* TODO: Update for the Chaining */
- psDnldContext->tx_info.tx_offset += tx_length;
- psDnldContext->tx_info.tx_chain = chain;
- }
- }
- else if (0 != frame_offset)
- {
- status = phDnldNfc_Send_Command( psDnldContext,
- pHwRef, PHDNLD_CMD_ENCAPSULATE,
- (raw_frame + frame_offset),
- tx_length);
- if(NFCSTATUS_PENDING == status)
- {
- psDnldContext->prev_cmd = raw_frame_hdr->frame_type;
- /* TODO: Update for the Chaining */
- psDnldContext->prev_dnld_size = frame_length;
- phDnldNfc_Tx_Reset(psDnldContext);
- }
- }
- else
- {
- phDnldNfc_sRawDataHdr_t *raw_data_hdr =
- ( phDnldNfc_sRawDataHdr_t * ) (raw_frame + FRAME_HEADER_LEN);
- psDnldContext->resp_length = PHDNLD_MIN_PACKET;
- }
-
- break;
- }
- case PHDNLD_CMD_CHECK:
- {
- psDnldContext->resp_length = PHDNLD_MIN_PACKET;
- break;
- }
- case PHDNLD_CMD_SET_HIF:
- {
- psDnldContext->resp_length = PHDNLD_MIN_PACKET;
- break;
- }
- case PHDNLD_CMD_ACTIVATE_PATCH:
- {
- psDnldContext->resp_length = PHDNLD_MIN_PACKET;
- break;
- }
- case PHDNLD_CMD_CHECK_INTEGRITY:
- {
- uint8_t integrity_param =
- *(raw_frame + FRAME_HEADER_LEN);
- switch(integrity_param)
- {
- case CHK_INTEGRITY_CONFIG_PAGE_CRC:
- case CHK_INTEGRITY_PATCH_TABLE_CRC:
- {
- psDnldContext->resp_length = PHDNLD_MIN_PACKET
- + CHECK_INTEGRITY_RESP_CRC16_LEN;
- break;
- }
- case CHK_INTEGRITY_FLASH_CODE_CRC:
- case CHK_INTEGRITY_PATCH_CODE_CRC:
- {
- psDnldContext->resp_length = PHDNLD_MIN_PACKET
- + CHECK_INTEGRITY_RESP_CRC32_LEN;
- break;
- }
- case CHK_INTEGRITY_COMPLETE_CRC:
- default:
- {
- psDnldContext->resp_length = PHDNLD_MIN_PACKET
- + CHECK_INTEGRITY_RESP_COMP_LEN;
- break;
- }
- }
- break;
- }
- default:
- {
- status = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_FEATURE_NOT_SUPPORTED);
- break;
- }
- }
-
- if (NFCSTATUS_SUCCESS == status)
- {
- status = phDnldNfc_Send( psDnldContext, pHwRef ,
- raw_frame, frame_length);
-
- if(NFCSTATUS_PENDING == status)
- {
- psDnldContext->prev_cmd = raw_frame_hdr->frame_type;
- /* TODO: Update for the Chaining */
- psDnldContext->prev_dnld_size = frame_length;
- }
- }
-
- return status;
-}
-
-
-static
-NFCSTATUS
-phDnldNfc_Frame_Complete(phDnldNfc_sContext_t *psDnldContext)
-{
- NFCSTATUS status = NFCSTATUS_SUCCESS;
- phDnldNfc_sData_Hdr_t *p_dnld_raw = NULL;
- uint32_t dnld_index = psDnldContext->dnld_index;
- uint8_t *p_raw_sec_hdr = NULL;
- uint16_t tx_length = 0x00;
-
- dnld_index = dnld_index + psDnldContext->prev_dnld_size;
- p_raw_sec_hdr = psDnldContext->p_fw_raw + dnld_index;
- dnld_index = dnld_index + *p_raw_sec_hdr;
-
- p_dnld_raw = (phDnldNfc_sData_Hdr_t *) (psDnldContext->p_fw_raw +
- psDnldContext->dnld_index);
-
- tx_length = ((p_dnld_raw->frame_length[0] << BYTE_SIZE) |
- p_dnld_raw->frame_length[1]);
-
- tx_length = tx_length + PHDNLD_MIN_PACKET;
-
- return status;
-}
-
-
-static
-NFCSTATUS
-phDnldNfc_Raw_Write(
- phDnldNfc_sContext_t *psDnldContext,
- void *pHwRef
- )
-{
- NFCSTATUS status = NFCSTATUS_SUCCESS;
- uint32_t dnld_index = psDnldContext->dnld_index;
- uint32_t tx_length = 0;
- uint8_t *p_raw_sec_hdr = NULL;
- uint8_t dnld_flag = FALSE;
- uint8_t skip_frame = FALSE;
-
- if(NULL != psDnldContext->p_fw_raw)
- {
-
- if( (TRUE != psDnldContext->tx_info.tx_chain)
- && (0x00 == psDnldContext->dnld_retry)
- )
- {
- dnld_index = dnld_index + psDnldContext->prev_dnld_size;
- p_raw_sec_hdr = psDnldContext->p_fw_raw + dnld_index;
- dnld_index = dnld_index + *p_raw_sec_hdr;
- }
- else
- {
-
- phDnldNfc_sData_Hdr_t *p_dnld_raw = (phDnldNfc_sData_Hdr_t *)
- (psDnldContext->p_fw_raw +
- psDnldContext->dnld_index);
-
- tx_length = ((p_dnld_raw->frame_length[0] << BYTE_SIZE) |
- p_dnld_raw->frame_length[1]);
-
- tx_length = tx_length + PHDNLD_MIN_PACKET;
-
- status = phDnldNfc_Send_Raw( psDnldContext, pHwRef,
- (uint8_t *)(p_dnld_raw),
- psDnldContext->tx_info.tx_offset,
- (uint16_t)tx_length);
- }
-
-
-#define PHDNLD_MAJOR_OFFSET 0x04U
-#define PHDNLD_MINOR_OFFSET 0x05U
-#define PHDNLD_PHASE_OFFSET 0x06U
-#define PHDNLD_FRAMETYPE_OFFSET 0x07U
-
-#define PHDNLD_NO_OPERATION 0x00U
-#define PHDNLD_NORMAL_OPERATION 0x10U
-#define PHDNLD_ADVANCED_OPERATION 0x20U
-#define PHDNLD_SETUP_OPERATION 0x40U
-#define PHDNLD_RECOVER_OPERATION 0x80U
-#define PHDNLD_COMPLETE_OPERATION 0xF0U
-
-#define PHDNLD_TERMINATE_TYPE 0x0EU
-
-#define PHDNLD_MARKER_MASK 0x0FU
-
- while((NFCSTATUS_SUCCESS == status )
- && (FALSE == dnld_flag)
- )
- {
- phDnldNfc_sData_Hdr_t *p_dnld_raw = (phDnldNfc_sData_Hdr_t *)
- (psDnldContext->p_fw_raw + dnld_index);
- uint8_t frame_type = *(p_raw_sec_hdr + PHDNLD_FRAMETYPE_OFFSET);
-
- tx_length = ((p_dnld_raw->frame_length[0] << BYTE_SIZE) |
- p_dnld_raw->frame_length[1]);
-
- tx_length = tx_length + PHDNLD_MIN_PACKET;
-
- skip_frame = FALSE;
-
- if( (0x00 == *(p_raw_sec_hdr + PHDNLD_PHASE_OFFSET))
- || (0xFF == *(p_raw_sec_hdr + PHDNLD_PHASE_OFFSET))
- || !( psDnldContext->raw_mode_upgrade
- & (frame_type & (~PHDNLD_MARKER_MASK)) )
- )
- {
- dnld_index = dnld_index + tx_length;
- p_raw_sec_hdr = psDnldContext->p_fw_raw + dnld_index;
- dnld_index = dnld_index + *p_raw_sec_hdr;
- skip_frame = TRUE;
- }
- if (PHDNLD_TERMINATE_TYPE ==
- (frame_type & PHDNLD_MARKER_MASK))
- {
- if(TRUE != skip_frame)
- {
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade &
- ~(frame_type & ~PHDNLD_MARKER_MASK)) ;
- }
-
- if(PHDNLD_NO_OPERATION ==
- psDnldContext->raw_mode_upgrade)
- {
- dnld_flag = TRUE;
- }
- }
- else
- {
-
- }
-
- if((FALSE == skip_frame)
- && (FALSE == dnld_flag)
- )
- {
- status = phDnldNfc_Send_Raw( psDnldContext, pHwRef,
- (uint8_t *)(p_dnld_raw),
- psDnldContext->tx_info.tx_offset,
- (uint16_t)tx_length);
- }
-
- if( NFCSTATUS_PENDING == status )
- {
- psDnldContext->dnld_index = dnld_index;
- psDnldContext->cur_frame_info= frame_type;
- }
- }
- }
-
- return status;
-}
static
NFCSTATUS
@@ -2347,18 +1665,13 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
+ /* section_info_t *p_cur_sec = psDnldContext->p_fw_sec +
+ psDnldContext->section_index; */
PHNFC_UNUSED_VARIABLE(pdata);
PHNFC_UNUSED_VARIABLE(length);
- if(phDnld_Raw_Upgrade == psDnldContext->cur_dnld_seq)
- {
- status = phDnldNfc_Raw_Write( psDnldContext, pHwRef );
- }
- else
- {
status = phDnldNfc_Resume_Write( psDnldContext, pHwRef );
- }
return status;
}
@@ -2395,34 +1708,27 @@
(uint8_t)phDnld_Unlock_System;
break;
}
-#ifdef NXP_FW_PATCH_DISABLE
- case phDnld_Deactivate_Patch:
-#else
case phDnld_Unlock_System:
-#endif
{
psDnldContext->next_dnld_state =
(uint8_t)phDnld_Upgrade_State;
psDnldContext->next_dnld_seq =
(uint8_t)phDnld_Upgrade_Section;
-#ifdef NXP_FW_DNLD_CHECK_PHASE
- gphDnldPhase = NXP_FW_DNLD_CFG_PHASE;
-#endif /* NXP_FW_DNLD_CHECK_PHASE */
break;
}
case phDnld_Lock_System:
{
-#if (NXP_FW_INTEGRITY_CHK >= 0x01)
- psDnldContext->next_dnld_state =
- (uint8_t)phDnld_Verify_State;
- psDnldContext->next_dnld_seq =
- (uint8_t)phDnld_Verify_Integrity;
-#else
+//#if(NXP_FW_INTEGRITY_CHK >= 0x01)
+// psDnldContext->next_dnld_state =
+// (uint8_t)phDnld_Verify_State;
+// psDnldContext->next_dnld_seq =
+// (uint8_t)phDnld_Verify_Integrity;
+//#else
/* (void ) memset( (void *) &psDnldContext->chk_integrity_crc,
0, sizeof(psDnldContext->chk_integrity_crc)); */
psDnldContext->next_dnld_state =
(uint8_t) phDnld_Complete_State;
-#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
+//#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
break;
}
case phDnld_Verify_Integrity:
@@ -2460,21 +1766,21 @@
psDnldContext->next_dnld_seq =
psDnldContext->cur_dnld_seq;
#endif
-#if (NXP_FW_INTEGRITY_CHK >= 0x01)
- psDnldContext->next_dnld_state =
- (uint8_t)phDnld_Verify_State;
- psDnldContext->next_dnld_seq =
- (uint8_t)phDnld_Verify_Integrity;
- psDnldContext->cur_dnld_seq =
- psDnldContext->next_dnld_seq;
- status = phDnldNfc_Sequence( psDnldContext,
- pHwRef, pdata, length);
-#else
+//#if (NXP_FW_INTEGRITY_CHK >= 0x01)
+// psDnldContext->next_dnld_state =
+// (uint8_t)phDnld_Verify_State;
+// psDnldContext->next_dnld_seq =
+// (uint8_t)phDnld_Verify_Integrity;
+// psDnldContext->cur_dnld_seq =
+// psDnldContext->next_dnld_seq;
+// status = phDnldNfc_Sequence( psDnldContext,
+// pHwRef, pdata, length);
+//#else
/* (void ) memset( (void *) &psDnldContext->chk_integrity_crc,
0, sizeof(psDnldContext->chk_integrity_crc)); */
psDnldContext->next_dnld_state =
(uint8_t) phDnld_Complete_State;
-#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
+//#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
}
break;
}
@@ -2572,14 +1878,12 @@
psDnldContext->lower_interface.pcontext, pHwRef);
phDnldNfc_Release_Lower(psDnldContext, pHwRef);
phDnldNfc_Release_Resources(&psDnldContext);
-#ifndef NFC_TIMER_CONTEXT
- gpphDnldContext = psDnldContext;
-#endif
/* Notify the Error/Success Scenario to the upper layer */
phDnldNfc_Notify( p_upper_notify, p_upper_context, pHwRef, (uint8_t)
((NFCSTATUS_SUCCESS == comp_info.status )? NFC_IO_SUCCESS: NFC_IO_ERROR),
&comp_info );
}
+
return status;
}
@@ -2597,19 +1901,20 @@
(phDnldNfc_sData_Hdr_t *) pdata;
PHNFC_UNUSED_VARIABLE(pHwRef);
- DNLD_DEBUG(" FW_DNLD: Receive Length = %X \n", length );
- if(( psDnldContext->rx_info.rx_total == 0 )
+ /* DNLD_DEBUG(" FW_DNLD: Receive Length = %X \n", length ); */
+ if(( psDnldContext->rx_total == 0 )
&& (PHDNLD_MIN_PACKET <= length)
+ /* && (FALSE == psDnldContext->recv_pending) */
)
{
- psDnldContext->rx_info.rx_total =
+ psDnldContext->rx_total =
((uint16_t)resp_data->frame_length[0] << BYTE_SIZE)|
resp_data->frame_length[1];
- if( psDnldContext->rx_info.rx_total + PHDNLD_MIN_PACKET == length )
+ if( psDnldContext->rx_total + PHDNLD_MIN_PACKET == length )
{
DNLD_DEBUG(" FW_DNLD: Success Memory Read = %X \n",
- psDnldContext->rx_info.rx_total);
+ psDnldContext->rx_total);
#ifndef DNLD_SUMMARY
/* DNLD_PRINT_BUFFER("Receive Buffer",pdata,length); */
#endif
@@ -2619,11 +1924,13 @@
{
/* status = phDnldNfc_Receive( psDnldContext, pHwRef,
psDnldContext->p_resp_buffer,
- (uint8_t)((psDnldContext->rx_info.rx_total <= PHDNLD_MAX_PACKET)?
- psDnldContext->rx_info.rx_total: PHDNLD_MAX_PACKET) ); */
+ (uint8_t)((psDnldContext->rx_total <= PHDNLD_MAX_PACKET)?
+ psDnldContext->rx_total: PHDNLD_MAX_PACKET) );
+ psDnldContext->recv_pending =
+ (uint8_t)( NFCSTATUS_PENDING == status); */
DNLD_PRINT(" FW_DNLD: Invalid Receive length ");
DNLD_DEBUG(": Length Expected = %X \n",
- (psDnldContext->rx_info.rx_total + PHDNLD_MIN_PACKET));
+ (psDnldContext->rx_total + PHDNLD_MIN_PACKET));
status = PHNFCSTVAL( CID_NFC_DNLD,
NFCSTATUS_INVALID_RECEIVE_LENGTH );
}
@@ -2631,7 +1938,7 @@
else
{
/*TODO:*/
- psDnldContext->rx_info.rx_total = 0 ;
+ psDnldContext->rx_total = 0 ;
status = PHNFCSTVAL( CID_NFC_DNLD,
NFCSTATUS_INVALID_RECEIVE_LENGTH );
}
@@ -2666,7 +1973,6 @@
status = pInfo->status ;
length = pInfo->length ;
pdata = pInfo->buffer;
-
if(status != NFCSTATUS_SUCCESS)
{
DNLD_DEBUG(" Failed. Status = %02X\n",status);
@@ -2678,10 +1984,9 @@
/* Handle the Error Scenario */
status = PHNFCSTVAL( CID_NFC_DNLD, NFCSTATUS_FAILED );
}
- else if ((0 == length)
- || (PHDNLD_MIN_PACKET > length ))
+ else if (0 == length)
{
- DNLD_DEBUG(" Receive Response Length = %u .... \n",length);
+ DNLD_PRINT(" Receive Response Length = 0 .... \n");
/* Handle the Error Scenario */
#ifndef HAL_SW_DNLD_RLEN
status = PHNFCSTVAL( CID_NFC_DNLD,
@@ -2691,15 +1996,6 @@
else
{
-#if defined(FW_DOWNLOAD_TIMER) && \
- (FW_DOWNLOAD_TIMER == 2)
- if ( NXP_INVALID_TIMER_ID != psDnldContext->timer_id )
- {
- phOsalNfc_Timer_Stop( psDnldContext->timer_id );
- }
-
-#endif
-
#ifndef DNLD_SUMMARY
DNLD_PRINT_BUFFER("Receive Buffer",pdata,length);
#endif
@@ -2718,9 +2014,6 @@
{
case PHDNLD_CMD_READ :
{
- if( PHDNLD_NO_OPERATION
- == psDnldContext->raw_mode_upgrade)
- {
status = phDnldNfc_Process_Response(
psDnldContext, pHwRef, pdata , length);
@@ -2730,18 +2023,10 @@
psDnldContext->dnld_retry = NXP_MAX_DNLD_RETRY;
/* psDnldContext->dnld_retry < NXP_MAX_DNLD_RETRY */
}
- }
- else
- {
-
- }
break;
}
case PHDNLD_CMD_CHECK_INTEGRITY :
{
- if( PHDNLD_NO_OPERATION
- == psDnldContext->raw_mode_upgrade)
- {
#if (NXP_FW_INTEGRITY_CHK >= 0x01)
phDnldNfc_sChkCrcComplete_t *p_dnld_crc_all =
&psDnldContext->chk_integrity_crc;
@@ -2786,16 +2071,8 @@
break;
}
}
+
#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
- }
- else
- {
- psDnldContext->raw_mode_upgrade =
- (PHDNLD_SETUP_OPERATION | PHDNLD_ADVANCED_OPERATION);
- /* psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade &
- ( psDnldContext->cur_frame_info & ~PHDNLD_MARKER_MASK )); */
- }
break;
}
case PHDNLD_CMD_WRITE:
@@ -2803,18 +2080,10 @@
psDnldContext->dnld_retry = 0;
break;
}
- case PHDNLD_CMD_SEC_WRITE:
- {
- psDnldContext->dnld_retry = 0;
- break;
- }
case PHDNLD_CMD_ACTIVATE_PATCH:
case PHDNLD_CMD_CHECK:
default:
{
- if( PHDNLD_NO_OPERATION
- == psDnldContext->raw_mode_upgrade)
- {
if( ( (PHDNLD_MIN_PACKET > length)
|| ( 0 != resp_length) )
)
@@ -2827,20 +2096,14 @@
{
psDnldContext->dnld_retry = 0;
}
- }
- else
- {
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade & ~PHDNLD_RECOVER_OPERATION);
- }
break;
}
} /* End of the Previous Command Switch Case */
break;
}/* Case PHDNLD_RESP_SUCCESS*/
case PHDNLD_RESP_TIMEOUT:
- case PHDNLD_RESP_CRC_ERROR:
case PHDNLD_RESP_WRITE_ERROR:
+ case PHDNLD_RESP_CRC_ERROR:
{
if(psDnldContext->dnld_retry < NXP_MAX_DNLD_RETRY )
{
@@ -2852,139 +2115,22 @@
}
/* fall through */
case PHDNLD_RESP_ACCESS_DENIED:
+ case PHDNLD_RESP_PROTOCOL_ERROR:
case PHDNLD_RESP_INVALID_PARAMETER:
case PHDNLD_RESP_INVALID_LENGTH:
- /* Initial Frame Checksum */
- case PHDNLD_RESP_CHKSUM_ERROR:
- case PHDNLD_RESP_MEMORY_UPDATE_ERROR:
{
psDnldContext->dnld_retry = NXP_MAX_DNLD_RETRY;
status = PHNFCSTVAL(CID_NFC_DNLD,
resp_data->frame_type);
break;
}
- case PHDNLD_RESP_PROTOCOL_ERROR:
- {
- if(( PHDNLD_NO_OPERATION
- == psDnldContext->raw_mode_upgrade)
- || ( PHDNLD_ADVANCED_OPERATION
- == psDnldContext->raw_mode_upgrade)
- )
- {
- psDnldContext->dnld_retry = NXP_MAX_DNLD_RETRY;
- status = PHNFCSTVAL(CID_NFC_DNLD,
- NFCSTATUS_INVALID_FORMAT);
- }
- else if( (PHDNLD_NORMAL_OPERATION
- & psDnldContext->raw_mode_upgrade)
- )
- {
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade & ~PHDNLD_NORMAL_OPERATION);
- }
- else if ( PHDNLD_RECOVER_OPERATION
- & psDnldContext->raw_mode_upgrade )
- {
- psDnldContext->dnld_retry = NXP_MAX_DNLD_RETRY;
- status = PHNFCSTVAL(CID_NFC_DNLD,
- NFCSTATUS_INVALID_FORMAT);
- }
- else
- {
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade &
- ~( psDnldContext->cur_frame_info & ~PHDNLD_MARKER_MASK ));
- }
- break;
- }
- case PHDNLD_RESP_VERSION_UPTODATE:
- {
- /* TODO: to make sure that the Advance Frames are sent to get
- * the updated status */
- if ( PHDNLD_ADVANCED_OPERATION
- == psDnldContext->raw_mode_upgrade)
- {
- status = ( CID_NFC_DNLD << BYTE_SIZE ) ;
- }
- else if ( PHDNLD_NO_OPERATION
- != psDnldContext->raw_mode_upgrade)
- {
-
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade &
- ~( psDnldContext->cur_frame_info & ~PHDNLD_MARKER_MASK ));
- }
- else
- {
- }
- break;
- }
- case PHDNLD_RESP_CMD_NOT_SUPPORTED:
- {
-
- if ( PHDNLD_NO_OPERATION
- == psDnldContext->raw_mode_upgrade)
- {
- status = PHNFCSTVAL(CID_NFC_DNLD,
- NFCSTATUS_FEATURE_NOT_SUPPORTED);
- }
- else if ( PHDNLD_ADVANCED_OPERATION
- == psDnldContext->raw_mode_upgrade)
- {
- status = PHNFCSTVAL(CID_NFC_DNLD,
- NFCSTATUS_FEATURE_NOT_SUPPORTED);
- }
-#if 0
- else if( (PHDNLD_NORMAL_OPERATION
- & psDnldContext->raw_mode_upgrade)
- )
- {
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade & ~PHDNLD_NORMAL_OPERATION);
- }
- else if ( PHDNLD_SETUP_OPERATION
- & psDnldContext->raw_mode_upgrade )
- {
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade & ~PHDNLD_SETUP_OPERATION);
- }
-#endif
- else
- {
- psDnldContext->raw_mode_upgrade =
- (psDnldContext->raw_mode_upgrade &
- ~( psDnldContext->cur_frame_info & ~PHDNLD_MARKER_MASK ));
- }
- break;
- }
- /* The Chaining of the Command Frame
- was Successful in the Download Mode */
- case PHDNLD_RESP_CHAINING_SUCCESS:
- {
- /* TODO: Handle the Corner Case Scenarios
- * the updated status */
- psDnldContext->dnld_retry = 0x00;
- break;
- }
-/* The Error during the Chaining the Command Frame in the Download Mode */
- case PHDNLD_RESP_CHAINING_ERROR:
- {
- /* TODO: Restart the Chunk in Corner Case
- * the updated status */
- psDnldContext->dnld_retry++;
- phDnldNfc_Tx_Reset(psDnldContext);
- break;
- }
-/* The Command is not allowed anymore in the Download Mode */
- case PHDNLD_RESP_CMD_NOT_ALLOWED:
default:
{
psDnldContext->dnld_retry = NXP_MAX_DNLD_RETRY;
status = PHNFCSTVAL(CID_NFC_DNLD,
- NFCSTATUS_NOT_ALLOWED);
+ NFCSTATUS_FEATURE_NOT_SUPPORTED);
break;
}
-
} /* End of the Response Frame Type Switch */
if (NFCSTATUS_PENDING != status)
@@ -3003,57 +2149,10 @@
psDnldContext->lower_interface.pcontext, pHwRef);
phDnldNfc_Release_Lower(psDnldContext, pHwRef);
phDnldNfc_Release_Resources(&psDnldContext);
-#ifndef NFC_TIMER_CONTEXT
- gpphDnldContext = psDnldContext;
-#endif
/* Notify the Error/Success Scenario to the upper layer */
phDnldNfc_Notify( p_upper_notify, p_upper_context, pHwRef,
(uint8_t) NFC_IO_ERROR, &comp_info );
}
- else if ( (NFCSTATUS_SUCCESS != status) &&
- (NFCSTATUS_SUCCESS == PHNFCSTATUS(status))
- )
- {
- pphNfcIF_Notification_CB_t p_upper_notify =
- psDnldContext->p_upper_notify;
- void *p_upper_context =
- psDnldContext->p_upper_context;
-
- comp_info.status = NFCSTATUS_SUCCESS;
- DNLD_DEBUG(" FW_DNLD: Termination in Receive, Status = %X \n", status);
- status = phDal4Nfc_Unregister(
- psDnldContext->lower_interface.pcontext, pHwRef);
- phDnldNfc_Release_Lower(psDnldContext, pHwRef);
- phDnldNfc_Release_Resources(&psDnldContext);
-#ifndef NFC_TIMER_CONTEXT
- gpphDnldContext = psDnldContext;
-#endif
- /* Notify the Error/Success Scenario to the upper layer */
- phDnldNfc_Notify( p_upper_notify, p_upper_context, pHwRef,
- (uint8_t) NFC_IO_SUCCESS, &comp_info );
-
- }
- else if (NFCSTATUS_FEATURE_NOT_SUPPORTED == PHNFCSTATUS(status))
- {
- pphNfcIF_Notification_CB_t p_upper_notify =
- psDnldContext->p_upper_notify;
- void *p_upper_context =
- psDnldContext->p_upper_context;
-
- comp_info.status = status;
- DNLD_DEBUG(" FW_DNLD: Termination in Receive, Status = %X \n", status);
- status = phDal4Nfc_Unregister(
- psDnldContext->lower_interface.pcontext, pHwRef);
- phDnldNfc_Release_Lower(psDnldContext, pHwRef);
- phDnldNfc_Release_Resources(&psDnldContext);
-#ifndef NFC_TIMER_CONTEXT
- gpphDnldContext = psDnldContext;
-#endif
- /* Notify the Error/Success Scenario to the upper layer */
- phDnldNfc_Notify( p_upper_notify, p_upper_context, pHwRef,
- (uint8_t) NFC_IO_SUCCESS, &comp_info );
-
- }
else
{
/* DNLD_PRINT(" FW_DNLD: Successful.\n"); */
@@ -3103,28 +2202,17 @@
if ((PHDNLD_CMD_SET_HIF != psDnldContext->prev_cmd)
&& (PHDNLD_CMD_RESET != psDnldContext->prev_cmd))
{
- psDnldContext->rx_info.rx_total = 0;
+ psDnldContext->rx_total = 0;
status = phDnldNfc_Receive( psDnldContext, pHwRef,
(uint8_t *)(&psDnldContext->dnld_resp),
psDnldContext->resp_length);
+ /* psDnldContext->recv_pending =
+ (uint8_t)( NFCSTATUS_PENDING == status); */
}
else
{
psDnldContext->resp_length = 0;
psDnldContext->dnld_retry = 0;
- if( PHDNLD_CMD_RESET == psDnldContext->prev_cmd )
- {
- DO_DELAY(PHDNLD_DNLD_DELAY);
- }
-#if defined(FW_DOWNLOAD_TIMER) && \
- (FW_DOWNLOAD_TIMER == 2)
-
- if ( NXP_INVALID_TIMER_ID != psDnldContext->timer_id )
- {
- phOsalNfc_Timer_Stop( psDnldContext->timer_id );
- }
-#endif
-
status = phDnldNfc_Set_Seq(psDnldContext,
DNLD_SEQ_UPDATE);
}
@@ -3140,7 +2228,6 @@
}
-
STATIC
NFCSTATUS
phDnldNfc_Send_Command(
@@ -3155,8 +2242,6 @@
uint16_t tx_length = 0;
uint16_t rx_length = 0;
uint8_t **pp_resp_data = &psDnldContext->p_resp_buffer;
- phDnldNfc_sData_t *p_dnld_data =
- (phDnldNfc_sData_t *)psDnldContext->dnld_data;
switch(cmd)
{
@@ -3168,10 +2253,8 @@
}
case PHDNLD_CMD_READ:
{
- phDnldNfc_sData_t *p_dnld_data =
- (phDnldNfc_sData_t *)psDnldContext->dnld_data;
phDnldNfc_sParam_t *param_info = /* (phDnldNfc_sParam_t *)params */
- &p_dnld_data->param_info.data_param;
+ &psDnldContext->dnld_data.param_info.data_param;
tx_length = PHDNLD_CMD_READ_LEN;
if (NULL != *pp_resp_data)
{
@@ -3182,18 +2265,21 @@
<< BYTE_SIZE) + param_info->data_len[1]);
psDnldContext->resp_length =
- (( rx_length + PHDNLD_MIN_PACKET ));
+#if 0
+ (((rx_length > PHDNLD_DATA_SIZE)?
+ PHDNLD_DATA_SIZE + PHDNLD_MIN_PACKET:
+#else
+ ((
+#endif
+ rx_length + PHDNLD_MIN_PACKET ));
(void)phDnldNfc_Allocate_Resource( (void **) pp_resp_data,
rx_length);
break;
}
case PHDNLD_CMD_WRITE:
- case PHDNLD_CMD_SEC_WRITE:
{
- phDnldNfc_sData_t *p_dnld_data =
- (phDnldNfc_sData_t *)psDnldContext->dnld_data;
phDnldNfc_sParam_t *param_info = /* (phDnldNfc_sParam_t *)params */
- &p_dnld_data->param_info.data_param;
+ &psDnldContext->dnld_data.param_info.data_param;
tx_length = (uint16_t) (((uint16_t)param_info->data_len[0]
<< BYTE_SIZE) + param_info->data_len[1]
+ PHDNLD_CMD_WRITE_MIN_LEN );
@@ -3211,36 +2297,6 @@
psDnldContext->resp_length = PHDNLD_MIN_PACKET;
break;
}
- case PHDNLD_CMD_ENCAPSULATE:
- {
- uint8_t i = 0x00;
- if ((0 != param_length) && (NULL != params))
- {
- p_dnld_data->frame_type =
- PHDNLD_CMD_ENCAPSULATE;
- (void)memcpy((void *)( ((uint8_t *)p_dnld_data)
- + PHDNLD_FRAME_DATA_OFFSET)
- , params, param_length);
- tx_length = param_length;
-
- p_dnld_data->frame_length[i++] =
- (uint8_t)(tx_length >> BYTE_SIZE);
- p_dnld_data->frame_length[i] =
- (uint8_t)( tx_length & BYTE_MASK );
- tx_length += PHDNLD_FRAME_DATA_OFFSET;
-
- psDnldContext->resp_length = PHDNLD_MIN_PACKET;
-
- status = phDnldNfc_Send( psDnldContext, pHwRef ,
- (uint8_t *)p_dnld_data, tx_length);
- }
- else
- {
- status = PHNFCSTVAL(CID_NFC_DNLD,
- NFCSTATUS_NOT_ALLOWED);
- }
- break;
- }
case PHDNLD_CMD_SET_HIF:
{
tx_length++;
@@ -3249,18 +2305,8 @@
}
case PHDNLD_CMD_ACTIVATE_PATCH:
{
- psDnldContext->resp_length = PHDNLD_MIN_PACKET;
- if ((NULL != params) && ( param_length > 0 ))
- {
- p_dnld_data->param_info.cmd_param =
- (*(uint8_t *)params);
- tx_length = param_length;
- }
- else
- {
- p_dnld_data->param_info.cmd_param = FALSE;
tx_length++;
- }
+ psDnldContext->resp_length = PHDNLD_MIN_PACKET;
break;
}
case PHDNLD_CMD_CHECK_INTEGRITY:
@@ -3268,7 +2314,7 @@
#if (NXP_FW_INTEGRITY_CHK >= 0x01)
if ((NULL != params) && ( param_length > 0 ))
{
- psDnldContext->chk_integrity_param =
+ psDnldContext->chk_integrity_param =
(phDnldNfc_eChkCrc_t)(*(uint8_t *)params);
tx_length = param_length ;
}
@@ -3277,7 +2323,7 @@
psDnldContext->chk_integrity_param = CHK_INTEGRITY_COMPLETE_CRC;
tx_length++;
}
- p_dnld_data->param_info.cmd_param =
+ psDnldContext->dnld_data.param_info.config_verify_param =
(uint8_t) psDnldContext->chk_integrity_param;
switch(psDnldContext->chk_integrity_param)
{
@@ -3305,7 +2351,7 @@
}
#else
tx_length++;
- p_dnld_data->param_info.cmd_param =
+ psDnldContext->dnld_data.param_info.config_verify_param =
(uint8_t) CHK_INTEGRITY_COMPLETE_CRC;
#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
@@ -3321,19 +2367,19 @@
{
uint8_t i = 0;
- p_dnld_data->frame_type = cmd;
- p_dnld_data->frame_length[i++] =
+ psDnldContext->dnld_data.frame_type = cmd;
+ psDnldContext->dnld_data.frame_length[i++] =
(uint8_t)(tx_length >> BYTE_SIZE);
- p_dnld_data->frame_length[i] =
+ psDnldContext->dnld_data.frame_length[i] =
(uint8_t)( tx_length & BYTE_MASK );
tx_length = tx_length + PHDNLD_MIN_PACKET;
status = phDnldNfc_Send( psDnldContext, pHwRef ,
- (uint8_t *)p_dnld_data, tx_length);
+ (uint8_t *)(&psDnldContext->dnld_data), tx_length);
if(NFCSTATUS_PENDING == status)
{
psDnldContext->prev_cmd = cmd;
-
}
+
}
return status;
@@ -3341,12 +2387,34 @@
static
NFCSTATUS
-phDnldNfc_Check_FW(
- phHal_sHwReference_t *pHwRef,
- fw_data_hdr_t *cur_fw_hdr
+phDnldNfc_Process_FW(
+ phDnldNfc_sContext_t *psDnldContext,
+ phHal_sHwReference_t *pHwRef
+#ifdef NXP_FW_PARAM
+ ,uint8_t *nxp_nfc_fw
+#endif
)
{
NFCSTATUS status = NFCSTATUS_FAILED;
+ section_info_t *p_cur_sec = NULL;
+ static unsigned sec_type;
+ uint32_t fw_index = 0;
+ fw_data_hdr_t *cur_fw_hdr = NULL;
+ uint8_t sec_index = 0;
+ uint8_t i = 0;
+
+ psDnldContext->p_img_hdr = (img_data_hdr_t *) nxp_nfc_fw;
+
+ fw_index = sizeof (img_data_hdr_t);
+
+ for ( i=0; i < psDnldContext->p_img_hdr->no_of_fw_img; i++ )
+ {
+
+ psDnldContext->p_fw_hdr = (fw_data_hdr_t *) ( nxp_nfc_fw + fw_index );
+ /* TODO: Create a memory of pointers to store all the Firmwares */
+ cur_fw_hdr = psDnldContext->p_fw_hdr;
+
+ fw_index = fw_index + (cur_fw_hdr->fw_hdr_len * PNDNLD_WORD_LEN);
if ( !pHwRef->device_info.fw_version )
{
@@ -3362,6 +2430,9 @@
status = PHNFCSTVAL( CID_NFC_DNLD, NFCSTATUS_NOT_ALLOWED );
}
else if (( pHwRef->device_info.fw_version < cur_fw_hdr->fw_version )
+#ifdef NXP_FW_PATCH_VERIFY
+ && (pHwRef->device_info.full_version[NXP_PATCH_VER_INDEX] < cur_fw_hdr->fw_patch )
+#endif
)
{
/* TODO: Firmware Version Check and upgrade*/
@@ -3381,87 +2452,22 @@
DNLD_PRINT(" FW_DNLD: Already Updated .... \n");
status = ( CID_NFC_DNLD << BYTE_SIZE ) ;
}
-
- return status;
-}
-
-
-static
-NFCSTATUS
-phDnldNfc_Process_FW(
- phDnldNfc_sContext_t *psDnldContext,
- phHal_sHwReference_t *pHwRef
-#ifdef NXP_FW_PARAM
- ,uint8_t *nxp_nfc_fw
- ,uint32_t nxp_fw_len
-#endif
- )
-{
- NFCSTATUS status = NFCSTATUS_FAILED;
- section_info_t *p_cur_sec = NULL;
- static unsigned sec_type;
- uint32_t fw_index = 0;
-#ifdef NXP_NFC_MULTIPLE_FW
- phDnldNfc_sFwImageInfo_t *p_cur_fw = NULL;
-#endif /* #ifdef NXP_NFC_MULTIPLE_FW */
- fw_data_hdr_t *cur_fw_hdr = NULL;
- uint8_t sec_index = 0;
- uint8_t i = 0;
-
- psDnldContext->p_img_hdr = (img_data_hdr_t *) nxp_nfc_fw;
-
-#ifdef NXP_NFC_MULTIPLE_FW
-
- /* TODO: Create a memory of pointers to store all the Firmwares */
- if( (NXP_NFC_IMAG_FW_MAX > psDnldContext->p_img_hdr->no_of_fw_img)
- && (0 != psDnldContext->p_img_hdr->no_of_fw_img)
- )
- {
- ( void )phDnldNfc_Allocate_Resource((void **)&psDnldContext->p_img_info,
- (psDnldContext->p_img_hdr->no_of_fw_img * sizeof(phDnldNfc_sFwImageInfo_t)));
-
- if(NULL != psDnldContext->p_img_info)
- {
- p_cur_fw = psDnldContext->p_img_info;
- }
}
-#endif /* #ifdef NXP_NFC_MULTIPLE_FW */
-
- fw_index = sizeof (img_data_hdr_t);
-
- for ( i=0; i < psDnldContext->p_img_hdr->no_of_fw_img; i++ )
- {
-
- psDnldContext->p_fw_hdr = (fw_data_hdr_t *) ( nxp_nfc_fw + fw_index );
-
-#ifdef NXP_NFC_MULTIPLE_FW
- if(NULL != p_cur_fw)
- {
- ( p_cur_fw + i)->p_fw_hdr = psDnldContext->p_fw_hdr;
- }
-#endif /* #ifdef NXP_NFC_MULTIPLE_FW */
- cur_fw_hdr = psDnldContext->p_fw_hdr;
-
- fw_index = fw_index + (cur_fw_hdr->fw_hdr_len * PNDNLD_WORD_LEN);
-
- status = phDnldNfc_Check_FW( pHwRef, cur_fw_hdr);
-
- }
-
if ( ( NFCSTATUS_SUCCESS == status )
#if defined (NXP_FW_INTEGRITY_VERIFY)
|| (NFCSTATUS_SUCCESS == PHNFCSTATUS(status) )
#endif /* !defined (NXP_FW_INTEGRITY_VERIFY) */
)
{
- if( (BYTE_MASK > cur_fw_hdr->no_of_sections)
- && (0 != cur_fw_hdr->no_of_sections)
- )
- {
+
(void) phDnldNfc_Allocate_Resource((void **)&psDnldContext->p_fw_sec,
(cur_fw_hdr->no_of_sections * sizeof(section_info_t)));
-
- if(NULL != psDnldContext->p_fw_sec)
+ if(NULL == psDnldContext->p_fw_sec)
+ {
+ status = PHNFCSTVAL(CID_NFC_DNLD,
+ NFCSTATUS_INSUFFICIENT_RESOURCES);
+ }
+ else
{
DNLD_DEBUG(" FW_DNLD: FW Index : %x \n",
fw_index );
@@ -3490,7 +2496,7 @@
sec_type = (unsigned int)p_cur_sec->p_sec_hdr->section_mem_type;
- if((sec_type & DNLD_TRIM_MASK))
+ if(TRUE == ((section_type_t *)(&sec_type))->trim_val )
{
p_cur_sec->p_trim_data = (uint8_t *)
(nxp_nfc_fw + fw_index + sizeof(section_hdr_t));
@@ -3500,42 +2506,25 @@
p_cur_sec->p_trim_data = NULL;
}
- if (0 == sec_index)
- {
- if ((sec_type & DNLD_SM_UNLOCK_MASK))
- {
- (void)phDnldNfc_Set_Seq(psDnldContext,
- DNLD_SEQ_UNLOCK);
- }
- else
- {
- (void)phDnldNfc_Set_Seq(psDnldContext,
- DNLD_SEQ_INIT);
- }
- }
p_cur_sec->section_read = FALSE;
p_cur_sec->section_offset = 0;
p_cur_sec->p_sec_data = ((uint8_t *) nxp_nfc_fw) + fw_index +
+#ifdef SECTION_HDR
(p_cur_sec->p_sec_hdr->section_hdr_len * PNDNLD_WORD_LEN);
+#else
+ sizeof (section_hdr_t) ;
+#endif
fw_index = fw_index +
+#ifdef SECTION_HDR
(p_cur_sec->p_sec_hdr->section_hdr_len * PNDNLD_WORD_LEN)
+#else
+ sizeof (section_hdr_t)
+#endif
+ p_cur_sec->p_sec_hdr->section_length;
-
- if( 0 != p_cur_sec->p_sec_hdr->section_checksum )
- {
- DNLD_DEBUG(" FW_DNLD: Section checksum : %x \n",
- p_cur_sec->p_sec_hdr->section_checksum );
-
- p_cur_sec->p_sec_chksum = ( uint8_t *)(nxp_nfc_fw + fw_index);
-
- fw_index = fw_index +
- p_cur_sec->p_sec_hdr->section_checksum;
- }
-
DNLD_DEBUG(" FW_DNLD: FW Index : %x \n", fw_index );
#if (NXP_FW_INTEGRITY_CHK >= 0x01)
@@ -3569,37 +2558,13 @@
{
break;
}
-
- } /* End of Address Switch */
-#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
- } /* End of For Loop */
- } /* End of the Null Check */
- else
- {
- status = PHNFCSTVAL(CID_NFC_DNLD,
- NFCSTATUS_INSUFFICIENT_RESOURCES);
}
+#endif /* #if (NXP_FW_INTEGRITY_CHK >= 0x01) */
}
- else if (
- (0 == cur_fw_hdr->no_of_sections)
- && (PHDNLD_FW_PATCH_SEC == cur_fw_hdr->fw_patch)
- )
- {
- psDnldContext->p_fw_raw = (uint8_t *)(nxp_nfc_fw + fw_index);
-
- psDnldContext->raw_mode_upgrade = PHDNLD_COMPLETE_OPERATION;
-
- (void)phDnldNfc_Set_Seq(psDnldContext,
- DNLD_SEQ_RAW);
- }
- else
- {
- DNLD_PRINT("********* Empty Section and Firmware ******************\n\n");
- }
DNLD_PRINT("*******************************************\n\n");
-
+ }
}
return status;
}
@@ -3634,7 +2599,45 @@
fw_index = fw_index + (cur_fw_hdr->fw_hdr_len * PNDNLD_WORD_LEN);
- status = phDnldNfc_Check_FW( pHwRef, cur_fw_hdr);
+ if ( !pHwRef->device_info.fw_version )
+ {
+ /* Override the Firmware Version Check and upgrade*/;
+ DNLD_PRINT(" FW_DNLD_CHK: Forceful Upgrade of the Firmware .... Required \n");
+ status = NFCSTATUS_SUCCESS;
+ }
+ else if ( (pHwRef->device_info.fw_version >> (BYTE_SIZE * 2))
+ != ( cur_fw_hdr->fw_version >> (BYTE_SIZE * 2) ))
+ {
+ /* Check for the Compatible Romlib Version for the Hardware */
+ DNLD_PRINT(" FW_DNLD: IC Hardware Version Mismatch.. \n");
+ status = PHNFCSTVAL( CID_NFC_DNLD, NFCSTATUS_NOT_ALLOWED );
+ }
+ else if (( pHwRef->device_info.fw_version < cur_fw_hdr->fw_version )
+#ifdef NXP_FW_PATCH_VERIFY
+ && (pHwRef->device_info.full_version[NXP_PATCH_VER_INDEX] < cur_fw_hdr->fw_patch )
+#endif
+ )
+ {
+ /* TODO: Firmware Version Check and upgrade*/
+ DNLD_PRINT(" FW_DNLD_CHK: Older Firmware. Upgrading to newer one.... \n");
+ status = NFCSTATUS_SUCCESS;
+ }
+#ifdef NXP_FW_CHK_LATEST
+ else if (( pHwRef->device_info.fw_version > cur_fw_hdr->fw_version )
+ )
+ {
+ DNLD_PRINT(" FW_DNLD: Newer than the Stored One .... \n");
+ status = PHNFCSTVAL( CID_NFC_DNLD, NFCSTATUS_NOT_ALLOWED );
+ }
+#endif /* NXP_FW_CHK_LATEST */
+ else
+ {
+ DNLD_PRINT(" FW_DNLD_CHK: Already Updated .... \n");
+ status = ( CID_NFC_DNLD << BYTE_SIZE ) ;
+ }
+ }
+ if( NFCSTATUS_SUCCESS == status )
+ {
}
return status;
}
@@ -3645,39 +2648,26 @@
STATIC
void
phDnldNfc_Abort (
- uint32_t abort_id
-#ifdef NFC_TIMER_CONTEXT
- , void *dnld_cntxt
-#endif
+ uint32_t abort_id ,
+ void * pContext
)
{
phNfc_sCompletionInfo_t comp_info = {0};
- phDnldNfc_sContext_t *p_dnld_context = NULL;
-
-#ifdef NFC_TIMER_CONTEXT
- p_dnld_context = (phDnldNfc_sContext_t *)dnld_cntxt;
-#else
- p_dnld_context = gpphDnldContext;
-#endif
-
- if ( ( NULL != p_dnld_context)
- && (abort_id == p_dnld_context->timer_id ))
+ if ( ( NULL != gpphDnldContext)
+ && (abort_id == gpphDnldContext->timer_id ))
{
pphNfcIF_Notification_CB_t p_upper_notify =
- p_dnld_context->p_upper_notify;
+ gpphDnldContext->p_upper_notify;
void *p_upper_context =
- p_dnld_context->p_upper_context;
- phHal_sHwReference_t *pHwRef = p_dnld_context->p_hw_ref;
+ gpphDnldContext->p_upper_context;
+ phHal_sHwReference_t *pHwRef = gpphDnldContext->p_hw_ref;
(void)phDal4Nfc_Unregister(
- p_dnld_context->lower_interface.pcontext, pHwRef );
- phDnldNfc_Release_Lower(p_dnld_context, pHwRef);
- phDnldNfc_Release_Resources(&p_dnld_context);
-#ifndef NFC_TIMER_CONTEXT
- gpphDnldContext = p_dnld_context;
-#endif
+ gpphDnldContext->lower_interface.pcontext, pHwRef );
+ phDnldNfc_Release_Lower(gpphDnldContext, pHwRef);
+ phDnldNfc_Release_Resources(&gpphDnldContext);
/* Notify the Error/Success Scenario to the upper layer */
DNLD_DEBUG(" FW_DNLD: FW_DNLD Aborted with %x Timer Timeout \n",
@@ -3696,7 +2686,6 @@
phDnldNfc_Upgrade (
phHal_sHwReference_t *pHwRef,
#ifdef NXP_FW_PARAM
- uint8_t type,
uint8_t *nxp_nfc_fw,
uint32_t fw_length,
#endif
@@ -3720,15 +2709,16 @@
else
{
DNLD_PRINT(" FW_DNLD: Starting the FW Upgrade Sequence .... \n");
+ /* Create the memory for Download Mgmt Context */
+ psDnldContext = (phDnldNfc_sContext_t *)
+ phOsalNfc_GetMemory(sizeof(phDnldNfc_sContext_t));
- (void)
- phDnldNfc_Allocate_Resource((void **)
- &psDnldContext,sizeof(phDnldNfc_sContext_t));
if(psDnldContext != NULL)
{
-#ifndef NFC_TIMER_CONTEXT
+ (void ) memset((void *)psDnldContext,0,
+ sizeof(phDnldNfc_sContext_t));
+
gpphDnldContext = psDnldContext;
-#endif
psDnldContext->p_hw_ref = pHwRef;
psDnldContext->timer_id = NXP_INVALID_TIMER_ID;
@@ -3762,7 +2752,7 @@
status = phDnldNfc_Process_FW( psDnldContext, pHwRef
#ifdef NXP_FW_PARAM
- ,*nxp_nfc_fw , fw_length
+ ,*nxp_nfc_fw /*, fw_length */
#endif
);
@@ -3773,24 +2763,27 @@
if (NFCSTATUS_PENDING == status)
{
DNLD_PRINT("\n FW_DNLD: Initial Reset .... \n");
+ p_cur_sec = ((section_info_t *)
+ (psDnldContext->p_fw_sec ));
+ sec_type = (unsigned )
+ (p_cur_sec->p_sec_hdr->section_mem_type);
-#if defined(FW_DOWNLOAD_TIMER)
-
+ if(TRUE == ((section_type_t *)
+ (&sec_type))->system_mem_unlock )
+ {
+ (void)phDnldNfc_Set_Seq(psDnldContext,
+ DNLD_SEQ_UNLOCK);
+ }
+ else
+ {
+ (void)phDnldNfc_Set_Seq(psDnldContext,
+ DNLD_SEQ_INIT);
+ }
+#ifdef FW_DOWNLOAD_TIMER
psDnldContext->timer_id = phOsalNfc_Timer_Create( );
-
-#if (FW_DOWNLOAD_TIMER < 2)
phOsalNfc_Timer_Start( psDnldContext->timer_id,
- NXP_DNLD_COMPLETE_TIMEOUT,
- (ppCallBck_t) phDnldNfc_Abort
-#ifdef NFC_TIMER_CONTEXT
- , (void *) psDnldContext
+ NXP_DNLD_COMPLETE_TIMEOUT, phDnldNfc_Abort, NULL );
#endif
- );
-
-#endif /* #if (FW_DOWNLOAD_TIMER < 2) */
-
-#endif /* #if defined(FW_DOWNLOAD_TIMER) */
-
}
}
else if (NFCSTATUS_SUCCESS == PHNFCSTATUS(status))
@@ -3808,27 +2801,16 @@
(void)phDnldNfc_Set_Seq(psDnldContext, DNLD_SEQ_COMPLETE);
status = PHNFCSTVAL( CID_NFC_DNLD,
NFCSTATUS_PENDING );
-#if defined(FW_DOWNLOAD_TIMER)
+#ifdef FW_DOWNLOAD_TIMER
psDnldContext->timer_id = phOsalNfc_Timer_Create( );
-#if (FW_DOWNLOAD_TIMER < 2)
phOsalNfc_Timer_Start( psDnldContext->timer_id,
- NXP_DNLD_COMPLETE_TIMEOUT,
- (ppCallBck_t) phDnldNfc_Abort
-#ifdef NFC_TIMER_CONTEXT
- , (void *) psDnldContext
+ NXP_DNLD_COMPLETE_TIMEOUT, phDnldNfc_Abort, NULL );
#endif
- );
-
-#endif /* #if (FW_DOWNLOAD_TIMER < 2) */
-
-#endif /* #if defined(FW_DOWNLOAD_TIMER) */
}
#else
status = NFCSTATUS_SUCCESS;
-
-#endif /* #if defined (NXP_FW_INTEGRITY_VERIFY) */
-
+#endif
}
else
{
@@ -3839,12 +2821,9 @@
if (NFCSTATUS_PENDING != PHNFCSTATUS(status))
{
(void)phDal4Nfc_Unregister(
- psDnldContext->lower_interface.pcontext, pHwRef);
- phDnldNfc_Release_Lower(psDnldContext, pHwRef);
- phDnldNfc_Release_Resources(&psDnldContext);
-#ifndef NFC_TIMER_CONTEXT
- gpphDnldContext = psDnldContext;
-#endif
+ gpphDnldContext->lower_interface.pcontext, pHwRef);
+ phDnldNfc_Release_Lower(gpphDnldContext, pHwRef);
+ phDnldNfc_Release_Resources(&gpphDnldContext);
}
} /* End of Status Check for Memory */
else
diff --git a/src/phHal4Nfc.c b/src/phHal4Nfc.c
index 726b4b5..ebd447f 100644
--- a/src/phHal4Nfc.c
+++ b/src/phHal4Nfc.c
@@ -153,11 +153,7 @@
gpphHal4Nfc_Hwref = NULL;
PHDBG_INFO("Hal4:Open Failed");
/*Call upper layer's Open Cb with error status*/
- if(NULL != pUpper_OpenCb)
- {
- /*Upper layer's Open Cb*/
(*pUpper_OpenCb)(pUpper_Context,status);
- }
}
return;
}
@@ -408,7 +404,7 @@
if( openRetVal == NFCSTATUS_SUCCESS )
{
/*update Next state*/
- Hal4Ctxt->Hal4NextState = (HCI_NFC_DEVICE_TEST == eHciInitType?
+ Hal4Ctxt->Hal4NextState = (HCI_SELF_TEST == eHciInitType?
eHal4StateSelfTestMode:eHal4StateOpenAndReady);
/*Store callback and context ,and set Default settings in Context*/
Hal4Ctxt->sUpperLayerInfo.pUpperOpenCb = pOpenCallback;
@@ -472,17 +468,13 @@
else if(NULL == psHwReference->hal_context)
{
#ifdef FW_DOWNLOAD
-
-#if !defined (NXP_FW_INTEGRITY_VERIFY)
if(NFC_FW_DOWNLOAD_CHECK == IoctlCode)
{
RetStatus = phDnldNfc_Run_Check(
psHwReference
);
}
- else
-#endif /* !defined (NXP_FW_INTEGRITY_VERIFY) */
- if((NFC_FW_DOWNLOAD == IoctlCode)
+ else if((NFC_FW_DOWNLOAD == IoctlCode)
&&(NULL == gpphHal4Nfc_Hwref))/*Indicates current state is shutdown*/
{
Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *)
@@ -511,9 +503,7 @@
phHal4Nfc_DownloadComplete,
Hal4Ctxt
);
- if((NFCSTATUS_SUCCESS == RetStatus)
- || (NFCSTATUS_PENDING != PHNFCSTATUS(RetStatus))
- )
+ if(NFCSTATUS_SUCCESS == RetStatus)
{
phOsalNfc_FreeMemory(Hal4Ctxt);
((phHal_sHwReference_t *)psHwReference)->hal_context = NULL;
@@ -1016,15 +1006,10 @@
break;
case NFC_NOTIFY_DEVICE_ERROR:
{
- NFCSTATUS status = NFCSTATUS_BOARD_COMMUNICATION_ERROR;
- pphHal4Nfc_GenCallback_t pUpper_OpenCb
- = Hal4Ctxt->sUpperLayerInfo.pUpperOpenCb;
- void *pUpper_Context
- = Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt;
static phHal4Nfc_NotificationInfo_t uNotificationInfo;
+ Hal4Ctxt->Hal4NextState = eHal4StateInvalid;
if(NULL != Hal4Ctxt->sUpperLayerInfo.pDefaultEventHandler)
{
- Hal4Ctxt->Hal4NextState = eHal4StateInvalid;
Hal4Ctxt->sUpperLayerInfo.pDefaultEventHandler(
Hal4Ctxt->sUpperLayerInfo.DefaultListenerCtxt,
NFC_EVENT_NOTIFICATION,
@@ -1032,31 +1017,8 @@
NFCSTATUS_BOARD_COMMUNICATION_ERROR
);
}
- else if (( eHal4StateSelfTestMode == Hal4Ctxt->Hal4NextState )
- || ( eHal4StateOpenAndReady == Hal4Ctxt->Hal4NextState ) )
- {
- Hal4Ctxt->Hal4CurrentState = eHal4StateClosed;
- Hal4Ctxt->Hal4NextState = eHal4StateInvalid;
- (void)phHciNfc_Release((void *)Hal4Ctxt->psHciHandle,
- pHwRef, (pphNfcIF_Notification_CB_t)NULL,
- (void *)Hal4Ctxt);/*Clean up Hci*/
- Hal4Ctxt->psHciHandle = NULL;
- phOsalNfc_FreeMemory((void *)Hal4Ctxt->pHal4Nfc_LayerCfg);
- Hal4Ctxt->pHal4Nfc_LayerCfg = NULL;
- phOsalNfc_FreeMemory((void *)Hal4Ctxt);
- gpphHal4Nfc_Hwref->hal_context = NULL;
- gpphHal4Nfc_Hwref = NULL;
- PHDBG_INFO("Hal4:Open Failed");
- /*Call upper layer's Open Cb with error status*/
- if(NULL != pUpper_OpenCb)
- {
- /*Upper layer's Open Cb*/
- (*pUpper_OpenCb)(pUpper_Context,status);
- }
- }
else
{
- Hal4Ctxt->Hal4NextState = eHal4StateInvalid;
phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1);
}
break;
@@ -1254,7 +1216,6 @@
case NFC_INFO_TXLDO_OVERCUR:
case NFC_INFO_MEM_VIOLATION:
case NFC_INFO_TEMP_OVERHEAT:
- case NFC_INFO_LLC_ERROR:
{
sNotificationInfo.info = psEventInfo;
sNotificationInfo.status = NFCSTATUS_SUCCESS;
@@ -1279,10 +1240,7 @@
case NFC_EVT_START_OF_TRANSACTION:
case NFC_EVT_END_OF_TRANSACTION:
case NFC_EVT_CONNECTIVITY:
- case NFC_EVT_OPERATION_ENDED:
- case NFC_EVT_MIFARE_ACCESS:
- case NFC_EVT_APDU_RECEIVED:
- case NFC_EVT_EMV_CARD_REMOVAL:
+ case NFC_EVT_OPERATION_ENDED:
sNotificationInfo.info = psEventInfo;
sNotificationInfo.status = NFCSTATUS_SUCCESS;
sNotificationInfo.type = NFC_EVENT_NOTIFICATION;
@@ -1331,23 +1289,10 @@
= Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb;
void *pUpper_Context = Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt;
/*check for Success*/
- if(( DEVMGMT_SWP_TEST == Hal4Ctxt->Ioctl_Type )
- || ( DEVMGMT_ANTENNA_TEST == Hal4Ctxt->Ioctl_Type ))
+ if((SelfTestResults->length > 0) && (0 == SelfTestResults->buffer[0]))
{
status = NFCSTATUS_SUCCESS;
}
- else if((SelfTestResults->length > 0) && (0 == SelfTestResults->buffer[0]))
- {
- status = NFCSTATUS_SUCCESS;
- }
- else
- {
- if (NULL != pInfo)
- {
- status = ((phNfc_sCompletionInfo_t *)pInfo)->status;
- }
- }
-
/*Copy response buffer and length*/
(void)memcpy(Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam->buffer,
SelfTestResults->buffer,
@@ -1406,8 +1351,7 @@
{
/*for NFC_MEM_READ and NFC_GPIO_READ ,provide one Byte Response*/
if ((NFC_MEM_READ == Hal4Ctxt->Ioctl_Type)
- || (NFC_GPIO_READ == Hal4Ctxt->Ioctl_Type)
- )
+ || (NFC_GPIO_READ == Hal4Ctxt->Ioctl_Type))
{
Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam->length
= sizeof (uint8_t);
diff --git a/src/phHciNfc.h b/src/phHciNfc.h
index 4f52b4a..f360413 100644
--- a/src/phHciNfc.h
+++ b/src/phHciNfc.h
@@ -78,9 +78,8 @@
typedef enum phHciNfc_Init
{
HCI_SESSION = 0x00,
- HCI_NFC_DEVICE_TEST,
- HCI_CUSTOM_INIT,
- HCI_SELF_TEST
+ HCI_SELF_TEST,
+ HCI_CUSTOM_INIT
}phHciNfc_Init_t;
/** \ingroup grp_hal_hci
@@ -264,7 +263,7 @@
* of the HCI Layer.
* \param[in] pHwRef pHwRef is the Information of
* the Device Interface Link .
- * \param[in] discovery_type If True: Start re-polling of the target
+ * \param[in] re_poll If True: Start re-polling of the target
* after the Target Device is de-activated
* or else - continue discovery with next
* technology.
@@ -280,7 +279,7 @@
phHciNfc_Restart_Discovery (
void *psHciHandle,
void *pHwRef,
- uint8_t discovery_type
+ uint8_t repoll
);
@@ -496,11 +495,10 @@
* of the HCI Layer.
* \param[in] pHwRef pHwRef is the Information of
* the Device Interface Link .
- * \param[in] discovery_type If NFC_RF_DISCOVERY_REPOLL: Start re-polling of
- * the target after the Target Device is
- * de-activatedor if NFC_RF_DISCOVERY_CONTINUE -
- * continue discovery with next technology or
- * stop the discovery wheel.
+ * \param[in] re_poll If True: Start re-polling of the target
+ * after the Target Device is de-activated
+ * or else - continue discovery with next
+ * technology.
*
* \retval NFCSTATUS_PENDING To De-select the remote target pending.
* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
@@ -514,7 +512,7 @@
phHciNfc_Disconnect (
void *psHciHandle,
void *pHwRef,
- uint8_t discovery_type
+ uint8_t re_poll
);
diff --git a/src/phHciNfc_DevMgmt.c b/src/phHciNfc_DevMgmt.c
index 5b3eddc..32662c1 100644
--- a/src/phHciNfc_DevMgmt.c
+++ b/src/phHciNfc_DevMgmt.c
@@ -71,7 +71,6 @@
#define NXP_EVT_INFO_EXT_RF_FIELD 0x12U
#define NXP_EVT_INFO_MEM_VIOLATION 0x13U
#define NXP_EVT_INFO_TEMP_OVERHEAT 0x14U
-#define NXP_EVT_INFO_LLC_ERROR 0x15U
#define NFC_DEV_TXLDO_MASK 0x03U
@@ -519,8 +518,7 @@
if(status == NFCSTATUS_SUCCESS)
{
- if ((HCI_SELF_TEST == psHciContext->init_mode )
- || (HCI_NFC_DEVICE_TEST == psHciContext->init_mode ))
+ if (HCI_SELF_TEST == psHciContext->init_mode )
{
p_device_mgmt_info->next_seq =
DEV_MGMT_GPIO_PDIR;
@@ -643,27 +641,18 @@
#endif /* #if ( NXP_NFC_IFC_TIMEOUT & 0x01 ) */
case DEV_MGMT_TX_LDO:
{
-#if ( NXP_HAL_VERIFY_EEPROM_CRC & 0x01U )
- if (0 != p_device_mgmt_info->eeprom_crc)
- {
- status = NFCSTATUS_FAILED;
- }
- else
-#endif
- {
- config = (NFC_DEV_HWCONF_DEFAULT |
+ config = (NFC_DEV_HWCONF_DEFAULT |
(NXP_DEFAULT_TX_LDO & NFC_DEV_TXLDO_MASK));
- status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
+ status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
NFC_ADDRESS_HW_CONF , config );
- if(NFCSTATUS_PENDING == status )
- {
+ if(NFCSTATUS_PENDING == status )
+ {
#if ( SW_TYPE_RF_TUNING_BF & 0x01)
- p_device_mgmt_info->next_seq = DEV_MGMT_ANAIRQ_CONF;
+ p_device_mgmt_info->next_seq = DEV_MGMT_ANAIRQ_CONF;
#else
- p_device_mgmt_info->next_seq = DEV_MGMT_CLK_REQ;
+ p_device_mgmt_info->next_seq = DEV_MGMT_CLK_REQ;
#endif
- /* status = NFCSTATUS_SUCCESS; */
- }
+ /* status = NFCSTATUS_SUCCESS; */
}
break;
}
@@ -1063,20 +1052,17 @@
{
p_device_mgmt_info->current_seq = DEV_MGMT_PIPE_OPEN;
p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN ;
- break;
- }
+ }break;
case UPDATE_SEQ:
{
p_device_mgmt_info->current_seq = p_device_mgmt_info->next_seq;
- break;
- }
+ }break;
case REL_SEQ:
{
p_device_mgmt_info->current_seq = DEV_MGMT_EVT_AUTONOMOUS;
p_device_mgmt_info->next_seq = DEV_MGMT_EVT_AUTONOMOUS ;
- break;
- }
+ }break;
default:
{
break;
@@ -1121,8 +1107,6 @@
}
else
{
- phHciNfc_DevMgmt_Info_t *p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
- psHciContext->p_device_mgmt_info ;
p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
psHciContext->p_device_mgmt_info)->p_pipe_info ;
switch(test_type)
@@ -1140,8 +1124,6 @@
p_pipe_info->param_info = test_param->buffer;
p_pipe_info->param_length = (uint8_t)test_param->length;
}
- p_device_mgmt_info->test_result.buffer = NULL;
- p_device_mgmt_info->test_result.length = 0;
status =
phHciNfc_Send_DevMgmt_Command( psHciContext, pHwRef,
pipe_id, (uint8_t)test_type );
@@ -1231,15 +1213,15 @@
break;
}
case NXP_DBG_READ:
+ {
+ *p_device_mgmt_info->p_val = (uint8_t)( length > HCP_HEADER_LEN ) ?
+ pResponse[HCP_HEADER_LEN]: 0;
+ p_device_mgmt_info->p_val = NULL;
+
+ }
/* fall through */
case NXP_DBG_WRITE:
{
- if( NULL != p_device_mgmt_info->p_val )
- {
- *p_device_mgmt_info->p_val = (uint8_t)( length > HCP_HEADER_LEN ) ?
- pResponse[HCP_HEADER_LEN]: 0;
- p_device_mgmt_info->p_val = NULL;
- }
break;
}
/* Self Test Commands */
@@ -1368,11 +1350,6 @@
p_device_mgmt_info->overheat_status;
break;
}
- case NXP_EVT_INFO_LLC_ERROR:
- {
- event_info.eventType = NFC_INFO_LLC_ERROR;
- break;
- }
default:
{
status = PHNFCSTVAL(CID_NFC_HCI,
diff --git a/src/phHciNfc_Generic.h b/src/phHciNfc_Generic.h
index b4f8a6d..5410325 100644
--- a/src/phHciNfc_Generic.h
+++ b/src/phHciNfc_Generic.h
@@ -458,7 +458,6 @@
/* HCI Device Management Sequence */
DEV_INIT_SEQ,
- DEV_HAL_INFO_SEQ,
DEV_CONFIG_SEQ,
DEV_REL_SEQ,
@@ -612,8 +611,8 @@
/** \internal Mode of HCI Initialisation */
phHciNfc_Init_t init_mode;
- /** \internal Memory Information for HCI Initialisation */
- uint8_t hal_mem_info[NXP_HAL_MEM_INFO_SIZE];
+ /** \internal Mode of HCI Initialisation */
+ void *p_io_params;
/** \internal HCI Configuration Type */
phHciNfc_eConfigType_t config_type;
diff --git a/src/phHciNfc_Sequence.c b/src/phHciNfc_Sequence.c
index 53e8b70..13b8ad5 100644
--- a/src/phHciNfc_Sequence.c
+++ b/src/phHciNfc_Sequence.c
@@ -65,10 +65,6 @@
################################################################################
*/
-/* Address Definitions for HAL Configuration */
-#define NFC_ADDRESS_HAL_CONF 0x9FD0U
-
-
/*
################################################################################
********************** Structure/Enumeration Definitions ***********************
@@ -247,10 +243,8 @@
/* Initialise to Perform Test on
the Antenna/SWP Link */
case hciState_Test:
- {
status = NFCSTATUS_SUCCESS;
break;
- }
default:
break;
}
@@ -272,10 +266,8 @@
case hciState_Listen:
/* Specifies the Starting of the Release Sequence */
case hciState_Release:
- {
status = NFCSTATUS_SUCCESS;
break;
- }
default:
break;
}
@@ -314,10 +306,8 @@
case hciState_Connect:
/* Specifies the Starting of the Release Sequence */
case hciState_Release:
- {
status = NFCSTATUS_SUCCESS;
break;
- }
default:
break;
}
@@ -348,10 +338,8 @@
case hciState_Disconnect:
/* Specifies the Starting of the Release Sequence */
case hciState_Release:
- {
status = NFCSTATUS_SUCCESS;
break;
- }
default:
break;
}
@@ -375,10 +363,8 @@
case hciState_Transact:
/* Specifies the Starting of the Release Sequence */
case hciState_Release:
- {
status = NFCSTATUS_SUCCESS;
break;
- }
default:
break;
}
@@ -400,10 +386,8 @@
case hciState_Config:
/* Specifies the Starting of the Release Sequence */
case hciState_Release:
- {
status = NFCSTATUS_SUCCESS;
break;
- }
default:
break;
}
@@ -428,14 +412,10 @@
case hciState_Listen:
/* Specifies the Starting of the Release Sequence */
case hciState_Release:
- {
status = NFCSTATUS_SUCCESS;
break;
- }
default:
- {
break;
- }
}
break;
}
@@ -660,7 +640,7 @@
{
if (hciState_Reset == psHciContext->hci_state.cur_state)
{
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
phHciNfc_Release_Lower( psHciContext, pHwRef );
/* Release all the resources and
@@ -674,7 +654,7 @@
{
/* Notify the Poll/Emulation Configure failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
comp_info.status = error_status ;
@@ -691,8 +671,7 @@
{
/* Notify the Poll Configure failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
-
+ phNfc_sCompletionInfo_t comp_info;
psHciContext->error_status = error_status;
status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
@@ -721,7 +700,7 @@
case hciState_Config:
{
/* Notify the Configure failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
psHciContext->error_status = error_status;
status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
@@ -737,7 +716,7 @@
case hciState_Select:
{
/* Notify the Configure failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info={FALSE};
/* Rollback the FSM as the Target Discovery Failed */
phHciNfc_FSM_Rollback(psHciContext);
@@ -763,7 +742,7 @@
case hciState_Transact:
/* Notify the Transceive failure to the upper layer */
{
- phNfc_sTransactionInfo_t transact_info={FALSE,0,NULL,NULL,0};
+ phNfc_sTransactionInfo_t transact_info;
/* Rollback the FSM as the Transceive Failed */
phHciNfc_FSM_Rollback(psHciContext);
@@ -780,7 +759,7 @@
case hciState_Connect:
{
/* Notify the General failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
/* psHciContext->host_rf_type = phHal_eUnknown_DevType; */
status = phHciNfc_ReaderMgmt_Update_Sequence(
@@ -797,7 +776,7 @@
case hciState_Reactivate:
{
/* Notify the General failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info={FALSE};
/* psHciContext->host_rf_type = phHal_eUnknown_DevType;
status = phHciNfc_ReaderMgmt_Update_Sequence(
@@ -813,7 +792,7 @@
}
case hciState_Presence:
{
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
/* Roll Back to Connect State as Presence Check is Complete */
phHciNfc_FSM_Rollback(psHciContext);
@@ -830,7 +809,7 @@
case hciState_Disconnect:
{
/* Notify the General failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
phHciNfc_FSM_Rollback(psHciContext);
comp_info.status = error_status ;
@@ -844,7 +823,7 @@
#ifdef NXP_HCI_SHUTDOWN_OVERRIDE
status = phHciNfc_Release_Sequence(psHciContext ,pHwRef);
#else
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
phHciNfc_Release_Lower( psHciContext, pHwRef );
/* Release all the resources and
@@ -859,7 +838,7 @@
default:
{
/* Notify the General failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
phHciNfc_FSM_Rollback(psHciContext);
comp_info.status = error_status ;
@@ -880,7 +859,8 @@
else
{
/* Notify the General failure to the upper layer */
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
+
phHciNfc_FSM_Rollback(psHciContext);
comp_info.status = error_status ;
/* Disable the Notification to the Upper Layer */
@@ -946,7 +926,7 @@
case hciState_Select:
case hciState_Connect:
{
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
/* Update to the Intialise state as the discovery wheel is
* restarted.
@@ -1003,7 +983,7 @@
}
case hciState_Presence:
{
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
/* Roll Back to Connect State as Presence Check is Complete */
phHciNfc_FSM_Rollback(psHciContext);
@@ -1122,7 +1102,7 @@
}
else
{
-#if defined( ESTABLISH_SESSION )
+#ifdef ESTABLISH_SESSION
NFCSTATUS info_status = NFCSTATUS_SUCCESS;
PHNFC_UNUSED_VARIABLE(info_status);
info_status = phHciNfc_IDMgmt_Update_Sequence(
@@ -1130,11 +1110,7 @@
if(NFCSTATUS_SUCCESS == info_status)
{
-#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
- psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
-#else
psHciContext->hci_seq = IDENTITY_INFO_SEQ;
-#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
}
else
{
@@ -1142,11 +1118,10 @@
status = PHNFCSTVAL(CID_NFC_HCI,
NFCSTATUS_INVALID_HCI_SEQUENCE);
}
-#elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
- psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
#else
psHciContext->hci_seq = HCI_END_SEQ;
-#endif /* #ifdef ESTABLISH_SESSION */
+
+#endif
}
}
@@ -1183,10 +1158,8 @@
status = phHciNfc_EmuMgmt_Initialise( psHciContext,pHwRef );
if(NFCSTATUS_SUCCESS == status)
{
-#if defined( ESTABLISH_SESSION )
+#ifdef ESTABLISH_SESSION
psHciContext->hci_seq = ADMIN_SESSION_SEQ;
-#elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
- psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
#else
psHciContext->hci_seq = HCI_END_SEQ;
#endif
@@ -1199,11 +1172,7 @@
status = phHciNfc_Admin_Initialise( psHciContext,pHwRef );
if(NFCSTATUS_SUCCESS == status)
{
-#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
- psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
-#else
psHciContext->hci_seq = IDENTITY_INFO_SEQ;
-#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
}
break;
}
@@ -1213,13 +1182,11 @@
psHciContext, pHwRef );
if(NFCSTATUS_SUCCESS == status)
{
-#if defined( SW_AUTO_ACTIVATION )
+#ifdef SW_AUTO_ACTIVATION
psHciContext->hci_seq = READER_SW_AUTO_SEQ;
-#elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
- psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
#else
psHciContext->hci_seq = IDENTITY_INFO_SEQ;
-#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
+#endif
}
break;
}
@@ -1252,8 +1219,7 @@
{
if ((HCI_SELF_TEST != psHciContext->init_mode)
/* && ( TRUE == ((phHal_sHwReference_t *)pHwRef)->se_detect ) */
- && (HCI_CUSTOM_INIT != psHciContext->init_mode)
- && (HCI_NFC_DEVICE_TEST != psHciContext->init_mode))
+ && (HCI_CUSTOM_INIT != psHciContext->init_mode))
{
NFCSTATUS info_status = NFCSTATUS_SUCCESS;
PHNFC_UNUSED_VARIABLE(info_status);
@@ -1281,42 +1247,10 @@
}
break;
}
-#endif /* #ifdef ESTABLISH_SESSION */
-
-#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
- case DEV_HAL_INFO_SEQ:
- {
- static uint8_t mem_index = 0;
- status = phHciNfc_DevMgmt_Get_Info(psHciContext, pHwRef,
- (NFC_ADDRESS_HAL_CONF + mem_index),
- (psHciContext->hal_mem_info + mem_index));
- if(NFCSTATUS_PENDING == status)
- {
- mem_index++;
- if (NXP_HAL_MEM_INFO_SIZE <= mem_index )
- {
- NFCSTATUS info_status = NFCSTATUS_SUCCESS;
- PHNFC_UNUSED_VARIABLE(info_status);
- info_status = phHciNfc_IDMgmt_Update_Sequence(
- psHciContext, INFO_SEQ );
- mem_index = 0;
- psHciContext->hci_seq = IDENTITY_INFO_SEQ;
- /* psHciContext->hci_seq =
- (HCI_SELF_TEST != psHciContext->init_mode)?
- IDENTITY_INFO_SEQ : HCI_END_SEQ; */
- }
- }
- break;
- }
-#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
+#endif
case HCI_END_SEQ:
{
- phHal_sMemInfo_t *p_mem_info =
- (phHal_sMemInfo_t *) ( psHciContext->hal_mem_info );
- if (
- (HCI_SELF_TEST == psHciContext->init_mode )
- || (HCI_NFC_DEVICE_TEST == psHciContext->init_mode )
- )
+ if (HCI_SELF_TEST == psHciContext->init_mode )
{
psHciContext->hci_state.next_state
= (uint8_t) hciState_Test;
@@ -1326,17 +1260,10 @@
phHciNfc_Uicc_Connectivity( psHciContext, pHwRef );
#endif /* #ifdef UICC_CONNECTIVITY_PATCH */
-#if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
- if(NXP_FW_UPLOAD_SUCCESS != p_mem_info->fw_magic )
- {
- status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FAILED );
- }
-#endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
-
/* Initialisation Complete Notification to the Upper Layer */
if(NFCSTATUS_SUCCESS == status)
{
- phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
+ phNfc_sCompletionInfo_t comp_info;
comp_info.status = status;
phHciNfc_Notify(psHciContext->p_upper_notify,
@@ -1406,10 +1333,6 @@
}
case DEV_REL_SEQ:
{
- NFCSTATUS info_status = NFCSTATUS_SUCCESS;
- PHNFC_UNUSED_VARIABLE(info_status);
- info_status = phHciNfc_DevMgmt_Update_Sequence(
- psHciContext, REL_SEQ );
status = phHciNfc_DevMgmt_Release( psHciContext, pHwRef );
if(NFCSTATUS_SUCCESS == status)
{
@@ -1511,7 +1434,7 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
+ phNfc_sCompletionInfo_t comp_info;
switch(psHciContext->config_type)
{
@@ -1837,7 +1760,7 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- static phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
+ static phNfc_sCompletionInfo_t comp_info;
#if defined(HOST_EMULATION)
phHciNfc_GateID_t ce_gate = phHciNfc_UnknownGate;
#endif /* #ifdef HOST_EMULATION */
@@ -1984,7 +1907,8 @@
NFCSTATUS status = NFCSTATUS_SUCCESS;
phHal_sADD_Cfg_t *p_poll_config = (phHal_sADD_Cfg_t * )
psHciContext->p_config_params;
- phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
+ phNfc_sCompletionInfo_t comp_info;
+
if (NULL != p_poll_config)
{
switch(psHciContext->hci_seq)
@@ -2090,7 +2014,7 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- static phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
+ static phNfc_sCompletionInfo_t comp_info;
phHal_eRemDevType_t target_type = phHal_eUnknown_DevType;
if( NULL != psHciContext->p_target_info )
@@ -2202,7 +2126,7 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- static phNfc_sCompletionInfo_t comp_info = {FALSE, 0 , NULL};
+ static phNfc_sCompletionInfo_t comp_info;
phHal_eRemDevType_t target_type = phHal_eUnknown_DevType;
uint8_t re_poll = 0;
@@ -2286,7 +2210,7 @@
void *pHwRef
)
{
- static phNfc_sTransactionInfo_t transact_info = {FALSE,0,NULL,NULL,0};
+ static phNfc_sTransactionInfo_t transact_info;
pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify;
void *pcontext = psHciContext->p_upper_context;
@@ -2433,8 +2357,8 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- static phNfc_sCompletionInfo_t comp_info = {0};
- static phNfc_sData_t test_result= {NULL,0};
+ static phNfc_sCompletionInfo_t comp_info;
+ static phNfc_sData_t test_result;
/* Complete the Test Sequence and notify the HAL */
status = phHciNfc_FSM_Complete ( psHciContext );
@@ -2456,7 +2380,7 @@
phHciNfc_Notify(psHciContext->p_upper_notify,
psHciContext->p_upper_context, pHwRef,
NFC_NOTIFY_RESULT , &comp_info);
- HCI_DEBUG(" HCI System Test Completed : Status = %u\n", test_status);
+ HCI_PRINT(" HCI System Test Completed. \n");
}
else
{
@@ -2482,7 +2406,7 @@
)
{
NFCSTATUS status = NFCSTATUS_SUCCESS;
- static phNfc_sCompletionInfo_t comp_info = {0};
+ static phNfc_sCompletionInfo_t comp_info;
/* To remove "warning (VS 4100) : unreferenced formal parameter" */
PHNFC_UNUSED_VARIABLE(pdata);
diff --git a/src/phHciNfc_WI.c b/src/phHciNfc_WI.c
index e1310a4..4da2078 100644
--- a/src/phHciNfc_WI.c
+++ b/src/phHciNfc_WI.c
@@ -63,9 +63,6 @@
/****************** Static Function Declaration **************************/
-static uint8_t paypass_removal[2] = {0x50, 0x00};
-static uint8_t mifare_access = 0x60;
-
static
NFCSTATUS
phHciNfc_Recv_WI_Response(
@@ -703,33 +700,12 @@
EventInfo.eventType = NFC_EVT_TRANSACTION;
EventInfo.eventInfo.aid.buffer = (uint8_t *)p_wi_info->aid;
/* check for AID data is at least 1 byte is their */
- if (length > HCP_HEADER_LEN)
+ if(length > HCP_HEADER_LEN)
{
EventInfo.eventInfo.aid.length = length - HCP_HEADER_LEN;
- memcpy((void *)p_wi_info->aid, message->payload,
- EventInfo.eventInfo.aid.length );
+ (void) memcpy((void *)p_wi_info->aid,message->payload,
+ EventInfo.eventInfo.aid.length );
}
-
- /* Filter Transaction event */
- if (EventInfo.eventInfo.aid.length == 4)
- {
- EventInfo.eventType = NFC_EVT_APDU_RECEIVED;
- }
- else if (EventInfo.eventInfo.aid.length == 2)
- {
- if (!memcmp(paypass_removal, EventInfo.eventInfo.aid.buffer, EventInfo.eventInfo.aid.length))
- {
- EventInfo.eventType = NFC_EVT_EMV_CARD_REMOVAL;
- }
- else if(mifare_access == EventInfo.eventInfo.aid.buffer[0])
- {
- EventInfo.eventType = NFC_EVT_MIFARE_ACCESS;
- }
- }
-
- EventInfo.eventInfo.aid.buffer = (uint8_t *)p_wi_info->aid;
- (void) memcpy((void *)p_wi_info->aid,message->payload,
- EventInfo.eventInfo.aid.length );
break;
}
default:
diff --git a/src/phLibNfc.c b/src/phLibNfc.c
index e0ef435..9c7db4f 100644
--- a/src/phLibNfc.c
+++ b/src/phLibNfc.c
@@ -45,8 +45,6 @@
*************************** Macro's ******************************************
*/
-extern int dlopen_firmware();
-
#ifndef STATIC_DISABLE
#define STATIC static
#else
@@ -108,7 +106,6 @@
{
NFCSTATUS Status = NFCSTATUS_SUCCESS;
- Status = phDal4Nfc_Reset(1);
Status = phDal4Nfc_Reset(0);
Status = phDal4Nfc_Reset(1);
@@ -120,13 +117,6 @@
return phDal4Nfc_Download();
}
-int phLibNfc_Load_Firmware_Image ()
-{
- int status;
- status = dlopen_firmware();
- return status;
-}
-
extern uint8_t nxp_nfc_isoxchg_timeout;
NFCSTATUS phLibNfc_SetIsoXchgTimeout(uint8_t timeout) {
@@ -590,7 +580,6 @@
}
/* No device is connected */
gpphLibContext->Connected_handle = 0x00;
- gpphLibContext->Prev_Connected_handle = 0x00;
gpphLibContext->ReleaseType = NFC_INVALID_RELEASE_TYPE;
gpphLibContext->eLibNfcCfgMode = NFC_DISCOVERY_STOP;
/*Lib Nfc Stack is initilized and in idle state*/
diff --git a/src/phLibNfc.h b/src/phLibNfc.h
index 719cfc1..216196f 100644
--- a/src/phLibNfc.h
+++ b/src/phLibNfc.h
@@ -173,12 +173,6 @@
ETSI TS 102 622 V7.4.0 */
phLibNfc_eSE_EvtFieldOn, // consider using phLibNfc_eSE_EvtConnectivity
phLibNfc_eSE_EvtFieldOff,
-
- phLibNfc_eSE_EvtApduReceived, /* PAYPASS MagStripe or MCHIP_4 transaction */
-
- phLibNfc_eSE_EvtCardRemoval, /* Indicates the beginning of an EMV Card Removal sequence */
-
- phLibNfc_eSE_EvtMifareAccess /* Indicates when the SMX Emulation MIFARE is accessed */
} phLibNfc_eSE_EvtType_t;
/**
@@ -851,8 +845,6 @@
NFCSTATUS phLibNfc_Download_Mode ();
-int phLibNfc_Load_Firmware_Image ();
-
// timeout is 8 bits
// bits [0..3] => timeout value, (256*16/13.56*10^6) * 2^value
// [0] -> 0.0003s
diff --git a/src/phLibNfc_Internal.h b/src/phLibNfc_Internal.h
index 304ac22..10018ec 100644
--- a/src/phLibNfc_Internal.h
+++ b/src/phLibNfc_Internal.h
@@ -221,9 +221,6 @@
uint32_t Connected_handle,
Discov_handle[MAX_REMOTE_DEVICES];
- /* To store the previous connected handle in case of Multiple protocol tags */
- uint32_t Prev_Connected_handle;
-
/*Call back function pointers */
phLibNfc_eDiscoveryConfigMode_t eLibNfcCfgMode;
diff --git a/src/phLibNfc_Ioctl.c b/src/phLibNfc_Ioctl.c
index 08f34b5..9983c60 100644
--- a/src/phLibNfc_Ioctl.c
+++ b/src/phLibNfc_Ioctl.c
@@ -238,11 +238,8 @@
NFCSTATUS status )
{
phLibNfc_Ioctl_Cntx_t *pIoctlCntx=NULL;
- if(PHNFCSTATUS(status) == NFCSTATUS_FEATURE_NOT_SUPPORTED)
- {
- status = NFCSTATUS_FEATURE_NOT_SUPPORTED;
- }
- else if(PHNFCSTATUS(status)!=NFCSTATUS_SUCCESS)
+
+ if(PHNFCSTATUS(status)!=NFCSTATUS_SUCCESS)
{
status = NFCSTATUS_FAILED;
}
diff --git a/src/phLibNfc_SE.c b/src/phLibNfc_SE.c
index 4e839cf..5fa4e08 100644
--- a/src/phLibNfc_SE.c
+++ b/src/phLibNfc_SE.c
@@ -204,51 +204,6 @@
status);
break;
}
-
- case NFC_EVT_APDU_RECEIVED:
- {
- if ((pEvtInfo->eventInfo.aid.length != 0) && ((pEvtInfo->eventInfo.aid.length <= 16)))
- {
- /* Copy received APDU to aid buffer. */
- Se_Trans_Info.UiccEvtInfo.aid.buffer = pEvtInfo->eventInfo.aid.buffer;
- Se_Trans_Info.UiccEvtInfo.aid.length = pEvtInfo->eventInfo.aid.length;
- }
-
- (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
- pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
- phLibNfc_eSE_EvtApduReceived,
- pSeInfo->hSecureElement,
- &Se_Trans_Info,
- status);
- break;
- }
-
- case NFC_EVT_MIFARE_ACCESS:
- {
- /* copy the Block MIFARE accessed */
- Se_Trans_Info.UiccEvtInfo.aid.buffer = pEvtInfo->eventInfo.aid.buffer;
- Se_Trans_Info.UiccEvtInfo.aid.length = pEvtInfo->eventInfo.aid.length;
-
- (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
- pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
- phLibNfc_eSE_EvtMifareAccess,
- pSeInfo->hSecureElement,
- &Se_Trans_Info,
- status);
- break;
- }
-
- case NFC_EVT_EMV_CARD_REMOVAL:
- {
- (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
- pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
- phLibNfc_eSE_EvtCardRemoval,
- pSeInfo->hSecureElement,
- &Se_Trans_Info,
- status);
- break;
- }
-
case NFC_EVT_END_OF_TRANSACTION:
{
(*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
diff --git a/src/phLibNfc_initiator.c b/src/phLibNfc_initiator.c
index 2a03c05..340af78 100644
--- a/src/phLibNfc_initiator.c
+++ b/src/phLibNfc_initiator.c
@@ -548,9 +548,6 @@
gpphLibContext->CBInfo.pClientConCntx = pContext;
gpphLibContext->status.GenCb_pending_status = TRUE;
gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect;
-
- gpphLibContext->Prev_Connected_handle = gpphLibContext->Connected_handle;
-
gpphLibContext->Connected_handle = hRemoteDevice;
}
else if (NFCSTATUS_INVALID_REMOTE_DEVICE == PHNFCSTATUS(ret_val))
@@ -636,7 +633,6 @@
gpphLibContext->CBInfo.pClientConCntx = pContext;
gpphLibContext->status.GenCb_pending_status=TRUE;
gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect;
- gpphLibContext->Prev_Connected_handle = gpphLibContext->Connected_handle;
gpphLibContext->Connected_handle = hRemoteDevice;
}
else if(PHNFCSTATUS(RetVal) == NFCSTATUS_INVALID_REMOTE_DEVICE)
@@ -761,7 +757,6 @@
/* If remote device is invalid return as TARGET LOST to upper layer*/
/* If error code is other than SUCCESS return NFCSTATUS_TARGET_LOST */
Connect_status = NFCSTATUS_TARGET_LOST;
- gpphLibContext->Connected_handle = gpphLibContext->Prev_Connected_handle ;
}
gpphLibContext->ndef_cntx.is_ndef = CHK_NDEF_NOT_DONE;
/* Update the Current Sate*/
@@ -901,9 +896,6 @@
gpphLibContext->LastTrancvSuccess = FALSE;
/*Reset Connected handle */
gpphLibContext->Connected_handle=0x0000;
- /*Reset previous Connected handle */
- gpphLibContext->Prev_Connected_handle = 0x0000;
-
if(gpphLibContext->sSeContext.eActivatedMode == phLibNfc_SE_ActModeWired)
{
gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault;