summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJizhou Liao <Jizhou.Liao@nxp.com>2016-02-29 16:39:30 -0800
committerMartijn Coenen <maco@google.com>2016-04-26 15:06:28 +0200
commit3ec16ee778ece1efed269fbbd5c7b95cab613e5f (patch)
treecbbafd1cf987f74e76ec0faa7779bd04dd8c61f2
parentad8c70257e822168bf0fdccba5700d22faa4b18a (diff)
downloadlibnfc-nci-3ec16ee778ece1efed269fbbd5c7b95cab613e5f.tar.gz
Abort NFC initialization if chip type doesn't match to HAL implemetation.
Compare firmware versions on chip and HAL implemetation, if mismatch, abort nfc initialization. Change-Id: If9bdf3d38750131ac18175d791f176288b8bcec2
-rw-r--r--halimpl/pn54x/common/phNfcCommon.h6
-rw-r--r--halimpl/pn54x/hal/phNxpNciHal.c32
-rw-r--r--halimpl/pn54x/hal/phNxpNciHal_ext.c4
3 files changed, 42 insertions, 0 deletions
diff --git a/halimpl/pn54x/common/phNfcCommon.h b/halimpl/pn54x/common/phNfcCommon.h
index 8e040d4..c0700b7 100644
--- a/halimpl/pn54x/common/phNfcCommon.h
+++ b/halimpl/pn54x/common/phNfcCommon.h
@@ -53,6 +53,12 @@
#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw_pku" FW_DLL_EXTENSION
#endif
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#define COMPILATION_MW "PN548C2"
+#else
+#define COMPILATION_MW "PN547C2"
+#endif
+
/* HAL Version number (Updated as per release) */
#define NXP_MW_VERSION_MAJ (1U)
#define NXP_MW_VERSION_MIN (0U)
diff --git a/halimpl/pn54x/hal/phNxpNciHal.c b/halimpl/pn54x/hal/phNxpNciHal.c
index 55e72ec..15f74af 100644
--- a/halimpl/pn54x/hal/phNxpNciHal.c
+++ b/halimpl/pn54x/hal/phNxpNciHal.c
@@ -52,6 +52,9 @@ extern void phTmlNfc_set_fragmentation_enabled(phTmlNfc_i2cfragmentation_t resul
uint32_t wFwVerRsp;
/* External global variable to get FW version */
extern uint16_t wFwVer;
+
+extern uint16_t fw_maj_ver;
+extern uint16_t rom_version;
extern int send_to_upper_kovio;
extern int kovio_detected;
extern int disable_kovio;
@@ -92,6 +95,7 @@ static NFCSTATUS phNxpNciHal_CheckValidFwVersion(void);
static void phNxpNciHal_enable_i2c_fragmentation();
static NFCSTATUS phNxpNciHal_get_mw_eeprom (void);
static NFCSTATUS phNxpNciHal_set_mw_eeprom (void);
+static int phNxpNciHal_fw_mw_ver_check ();
NFCSTATUS phNxpNciHal_check_clock_config(void);
NFCSTATUS phNxpNciHal_china_tianjin_rf_setting(void);
#if(NFC_NXP_CHIP_TYPE == PN548C2)
@@ -579,6 +583,11 @@ force_download:
status = phNxpNciHal_fw_download();
if (status != NFCSTATUS_SUCCESS)
{
+ if (NFCSTATUS_SUCCESS != phNxpNciHal_fw_mw_ver_check ())
+ {
+ NXPLOG_NCIHAL_D ("Chip Version Middleware Version mismatch!!!!");
+ goto clean_and_return;
+ }
NXPLOG_NCIHAL_E ("FW Download failed - NFCC init will continue");
}
else
@@ -625,6 +634,29 @@ force_download:
}
/******************************************************************************
+ * Function phNxpNciHal_fw_mw_check
+ *
+ * Description This function inform the status of phNxpNciHal_fw_mw_check
+ * function to libnfc-nci.
+ *
+ * Returns int.
+ *
+ ******************************************************************************/
+int phNxpNciHal_fw_mw_ver_check()
+{
+ NFCSTATUS status = NFCSTATUS_FAILED;
+
+ if (!strcmp (COMPILATION_MW, "PN548C2") && (rom_version == 0x10) && (fw_maj_ver == 0x01))
+ {
+ status = NFCSTATUS_SUCCESS;
+ }
+ else if (!strcmp (COMPILATION_MW, "PN547C2") && (rom_version == 0x08) && (fw_maj_ver == 0x01))
+ {
+ status = NFCSTATUS_SUCCESS;
+ }
+ return status;
+}
+/******************************************************************************
* Function phNxpNciHal_open_complete
*
* Description This function inform the status of phNxpNciHal_open
diff --git a/halimpl/pn54x/hal/phNxpNciHal_ext.c b/halimpl/pn54x/hal/phNxpNciHal_ext.c
index 8957e44..19ed71f 100644
--- a/halimpl/pn54x/hal/phNxpNciHal_ext.c
+++ b/halimpl/pn54x/hal/phNxpNciHal_ext.c
@@ -50,6 +50,8 @@ extern uint32_t wFwVerRsp;
/* External global variable to get FW version from FW file*/
extern uint16_t wFwVer;
+uint16_t fw_maj_ver;
+uint16_t rom_version;
/* local buffer to store CORE_INIT response */
static uint32_t bCoreInitRsp[40];
static uint32_t iCoreInitRspLen;
@@ -351,6 +353,8 @@ NFCSTATUS phNxpNciHal_process_ext_rsp (uint8_t *p_ntf, uint16_t *p_len)
iCoreInitRspLen = *p_len;
memcpy(bCoreInitRsp, p_ntf, *p_len);
NXPLOG_NCIHAL_D ("NxpNci> FW Version: %x.%x.%x", p_ntf[len-2], p_ntf[len-1], p_ntf[len]);
+ fw_maj_ver = p_ntf[len-1];
+ rom_version = p_ntf[len-2];
}
//4200 02 00 01
else if(p_ntf[0] == 0x42 && p_ntf[1] == 0x00 && ee_disc_done == 0x01)