From 6141c4b7a438cacda2a54aa20c83700cd6f314a7 Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Fri, 8 Jun 2012 17:24:36 -0700 Subject: Remove some logs in case of abort(). This allows us to see more context of HCI timeout crashes. Change-Id: I5cf1f829f3d0db5afd8d2c753fba7c3f8ad70365 --- Linux_x86/phOsalNfc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Linux_x86/phOsalNfc.c b/Linux_x86/phOsalNfc.c index 83b4e6e..e906b0d 100644 --- a/Linux_x86/phOsalNfc.c +++ b/Linux_x86/phOsalNfc.c @@ -142,14 +142,13 @@ void phOsalNfc_DbgTrace(uint8_t data[], uint32_t size) */ void phOsalNfc_RaiseException(phOsalNfc_ExceptionType_t eExceptionType, uint16_t reason) { - ALOGD("phOsalNfc_RaiseException() called"); - if(eExceptionType == phOsalNfc_e_UnrecovFirmwareErr) { - ALOGE("HCI Timeout - Exception raised"); + ALOGE("HCI Timeout - Exception raised - Force restart of NFC service"); phLibNfc_Mgt_Recovery(); - ALOGE("Force restart of NFC Service"); abort(); + } else { + ALOGD("phOsalNfc_RaiseException() called"); } } -- cgit v1.1 From 2e2afadd535ad3a92246fd3482f39a9174d814e9 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Tue, 17 Jul 2012 09:28:13 -0700 Subject: phFriNfc_OvrHal: fix memcpy overlap Don't use the API workaround when OvrHal->TranceiveInfo.sRecvData.buffer == pRecvdata->buffer. When memcpy overlap detection is enabled, this causes the NFC process to crash and burn. memcpy is undefined when src=dest. Bug: 6826770 Change-Id: Iebc8f82a4f86d560e764cef2229a7f86fa642783 --- src/phFriNfc_OvrHal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/phFriNfc_OvrHal.c b/src/phFriNfc_OvrHal.c index 539210e..9efff94 100644 --- a/src/phFriNfc_OvrHal.c +++ b/src/phFriNfc_OvrHal.c @@ -323,7 +323,10 @@ static void phFriNfc_OvrHal_CB_Transceive(void *context, if(NULL != pRecvdata && OvrHal->TranceiveInfo.sRecvData.buffer != NULL && pRecvdata->buffer != NULL) { /* Work-around for the NFCIP Tranceive API */ - memcpy(OvrHal->TranceiveInfo.sRecvData.buffer, pRecvdata->buffer, pRecvdata->length); + if (OvrHal->TranceiveInfo.sRecvData.buffer != pRecvdata->buffer) + { + memcpy(OvrHal->TranceiveInfo.sRecvData.buffer, pRecvdata->buffer, pRecvdata->length); + } if (OvrHal->pndef_recv_length != NULL) { *OvrHal->pndef_recv_length = (uint16_t) pRecvdata->length; -- cgit v1.1 From 9acc2486787ee83b436b2999cd27f7b1ffb9fd69 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Tue, 17 Jul 2012 10:32:07 -0700 Subject: phHal4Nfc_ADD: fix memcpy overlap Don't call memcpy when src==dest. It's undefined. When memcpy overlap detection is enabled, this causes the NFC process to crash and burn. Bug: 6826770 Change-Id: I199af98e453953de288964f47248cb59af4deecb --- src/phHal4Nfc_ADD.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/phHal4Nfc_ADD.c b/src/phHal4Nfc_ADD.c index 0a3303c..727b7c4 100644 --- a/src/phHal4Nfc_ADD.c +++ b/src/phHal4Nfc_ADD.c @@ -671,11 +671,14 @@ void phHal4Nfc_TargetDiscoveryComplete( if(phHal_eNfcIP1_Target == Hal4Ctxt->rem_dev_list[Count-1]->RemDevType) { - (void)memcpy( - (void *)Hal4Ctxt->rem_dev_list[0], - (void *)Hal4Ctxt->rem_dev_list[Count-1], - sizeof(phHal_sRemoteDevInformation_t) - ); + if (Count != 1) + { + (void)memcpy( + (void *)Hal4Ctxt->rem_dev_list[0], + (void *)Hal4Ctxt->rem_dev_list[Count-1], + sizeof(phHal_sRemoteDevInformation_t) + ); + } NfcIpDeviceCount = 1; break; } -- cgit v1.1 From bc2d3c02e53ac97e6708356baae431889f92ce1d Mon Sep 17 00:00:00 2001 From: Dejan REBRACA Date: Fri, 27 Apr 2012 09:45:44 +0200 Subject: Support of topaz tag NFC Forum version number 1.1 The latest version of NFC forum Tag type 1 spec is 1.1. This version number needs to be supported by libnfc to support Topaz tags V1.1 with dynamic content. Version number is part of capability container which resides in segment 1 of EEPROM memory of the tag. For older versions of Tag type 1, NFC device may be backward compatible. Change-Id: Ibbfa720d2e34c2f2612579e368f31f4a5c66b465 Author: Dejan REBRACA Signed-off-by: Dejan REBRACA Signed-off-by: Sebastian Niciarz Singed-off-by: Shuo Gao Signed-off-by: Bruce Beare Signed-off-by: Jack Ren Author-tracking-BZ: 33236 --- src/phFriNfc_TopazDynamicMap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/phFriNfc_TopazDynamicMap.c b/src/phFriNfc_TopazDynamicMap.c index 2aa29ea..e9d1529 100644 --- a/src/phFriNfc_TopazDynamicMap.c +++ b/src/phFriNfc_TopazDynamicMap.c @@ -199,6 +199,9 @@ so there are 4 segements in the card */ ((((block_no) + 1) == TOPAZ_STATIC_LOCK_FIRST_BLOCK_NO) ? \ (((block_no) + 1) + TOPAZ_STATIC_LOCK_BLOCK_AREAS) : \ ((block_no) + 1)) +/* Check topaz spec version number */ +#define TOPAZ_COMPARE_VERSION(device_ver, tag_ver) \ + ((device_ver & 0xF0) >= (tag_ver & 0xF0)) #ifdef FRINFC_READONLY_NDEF @@ -2368,7 +2371,7 @@ phFriNfc_Tpz_H_CheckCCBytesForWrite ( { check_index = (uint8_t)(check_index + 1); - if ((check_cc_rw[0] != ps_tpz_info->CCByteBuf[1]) || + if ((!TOPAZ_COMPARE_VERSION(check_cc_rw[0], ps_tpz_info->CCByteBuf[1])) || (check_cc_rw[1] != ps_tpz_info->CCByteBuf[2]) || (check_cc_rw[2] != ps_tpz_info->CCByteBuf[3])) { -- cgit v1.1 From f0096a6bac78ff99f255332771867f59b2d6d73b Mon Sep 17 00:00:00 2001 From: Dejan REBRACA Date: Wed, 20 Jun 2012 11:33:17 +0200 Subject: HCI ANY_OPEN_PIPE on identity management gate crash fix Apparently, host identity management gate does not support HCI commands coming from another host (including host controller). This patch fixes a tombstone when receiving an HCI command from another host, but still doesn't have a mechanism to treat the command. Change-Id: Ib72df6bac8f503f2b66998ee6e687ae99c15d17b Author: Dejan Rebraca Signed-off-by: Dejan Rebraca Signed-off-by: Sebastian Niciarz Singed-off-by: Shuo Gao Signed-off-by: Bruce Beare Signed-off-by: Jack Ren Author-tracking-BZ: 42426 --- src/phHciNfc_AdminMgmt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/phHciNfc_AdminMgmt.c b/src/phHciNfc_AdminMgmt.c index b65abf2..45298a1 100644 --- a/src/phHciNfc_AdminMgmt.c +++ b/src/phHciNfc_AdminMgmt.c @@ -997,6 +997,7 @@ static pipe_id = hcp_message->payload[RESPONSE_PIPEID_OFFSET]; p_pipe_info = (phHciNfc_Pipe_Info_t *) phOsalNfc_GetMemory(sizeof(phHciNfc_Pipe_Info_t)); + memset(p_pipe_info, 0, sizeof(phHciNfc_Pipe_Info_t)); if(NULL != p_pipe_info) { /* The Source Host is the UICC Host */ -- cgit v1.1 From 95696b8de4657f02ba1f75d7592e0670810d807f Mon Sep 17 00:00:00 2001 From: Sebastian Niciarz Date: Sat, 17 Mar 2012 19:26:21 +0100 Subject: Add support for target-customized NFC stack configuration This patch allows inclusion of target-customized configuration of NFC stack. The target-specific configuration will be stored in a header file, outside of AOSP. To have it icluded, define TARGET_HAS_NFC_CUSTOM_CONFIG macro and export your header file using BUILD_COPY_HEADERS macro. Change-Id: Ifa2d08c2ae8860c3f0690a04c517025892bd4c16 Author: Sebastian Niciarz Signed-off-by: Sebastian Niciarz Singed-off-by: Shuo Gao Signed-off-by: Bruce Beare Signed-off-by: Jack Ren Author-tracking-BZ: 23071 --- Android.mk | 5 + inc/nfc_custom_config.h | 201 ---------------------------------------- inc/nfc_custom_config_example.h | 200 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 201 deletions(-) delete mode 100644 inc/nfc_custom_config.h create mode 100644 inc/nfc_custom_config_example.h diff --git a/Android.mk b/Android.mk index b45f78b..bed9e07 100644 --- a/Android.mk +++ b/Android.mk @@ -106,6 +106,11 @@ LOCAL_SRC_FILES += Linux_x86/phDal4Nfc_messageQueueLib.c LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DNFC_TIMER_CONTEXT -fno-strict-aliasing +ifeq ($(TARGET_HAS_NFC_CUSTOM_CONFIG),true) +LOCAL_CFLAGS += -DNFC_CUSTOM_CONFIG_INCLUDE +LOCAL_CFLAGS += -I$(TARGET_OUT_HEADERS)/libnfc-nxp +endif + # Uncomment for Chipset command/responses # Or use "setprop debug.nfc.LOW_LEVEL_TRACES" at run-time # LOCAL_CFLAGS += -DLOW_LEVEL_TRACES diff --git a/inc/nfc_custom_config.h b/inc/nfc_custom_config.h deleted file mode 100644 index 0b4455a..0000000 --- a/inc/nfc_custom_config.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** -* \file nfc_custom_config.h -* \brief HAL Custom Configurations -* -* -* \note This is the configuration header file of the HAL 4.0. custom configurable -* parameters of the HAL 4.0 are provided in this file -* -* Project: NFC-FRI-1.1 / HAL4.0 -* -* $Date: Fri Jun 11 16:44:31 2010 $ -* $Author: ing04880 $ -* $Revision: 1.11 $ -* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - - -/*@{*/ -#ifndef NFC_CUSTOM_CONFIG_H -#define NFC_CUSTOM_CONFIG_H -/*@}*/ - - -/** -* \name Hal -* -* File: \ref nfc_custom_config.h -* -*/ - - -/* - ***************************************************************** - ********************** CUSTOM MACROS ************************** - ***************************************************************** - */ - -/**< Max number of remote devices supported*/ -#define MAX_REMOTE_DEVICES 0x10 - - -/**< Default Session ID for Initialisation */ -#define DEFAULT_SESSION "NXP-NFC2" - -/** Resolution value for the timer, here the - timer resolution is 100 milliseconds */ -#define TIMER_RESOLUTION 100U - -/**< Defines connection time out value for LLC timer, - 500 is in milliseconds */ -#define LINK_CONNECTION_TIMEOUT 500U - -/**< Defines guard time out value for LLC timer, - 250 is in milliseconds */ -#define LINK_GUARD_TIMEOUT 250U - -/**< Macro to Enable SMX Feature During - * Initialisation */ - - -/* PLEASE NOTE: This Macro should be only enabled if there is a SMART_MX - * Chip attached to the PN544. - */ -/* #define NXP_HAL_ENABLE_SMX */ - - - -/* PLEASE NOTE: Kindly change the DEFAULT_SESSION Macro for each of the - * configuration change done for the below Macros - */ - -/**< External Clock Request Configuration for the NFC Device, - 0x00U -> No Clock Request, - 0x01U -> Clock Request through CLKREQ pin (GPIO pin 2), - 0x02U -> Clock Request through NXP_EVT_CLK_REQUEST Event, - */ -#define NXP_DEFAULT_CLK_REQUEST 0x00U - -/**< External Input Clock Setting for the NFC Device, - 0x00U -> No Input Clock Required (Use the Xtal), - 0x01U -> 13 MHZ, - 0x02U -> 19.2 MHZ, - 0x03U -> 26 MHZ, - 0x04U -> 38.4 MHZ, - 0x05U -> Custom (Set the Custome Clock Registry), - */ -#define NXP_DEFAULT_INPUT_CLK 0x00U - - - -#define NFC_DEV_HWCONF_DEFAULT 0xBCU - -/**< TX LDO Configuration - 0x00 -> 00b 3.0 V, - 0x01 -> 01b 3.0 V, - 0x02 -> 10b 2.7 V, - 0x03 -> 11b 3.3 V, - - */ -#define NXP_DEFAULT_TX_LDO 0x00U - - -/**< External Clock Request Configuration for the NFC Device, - 0x00U -> No Power Request, - 0x01U -> Power Request through CLKREQ pin (GPIO pin 2), - 0x02U -> Power Request through PWR_REQUEST (GPIO Pin 3), - */ -#define NXP_UICC_PWR_REQUEST 0x00U - -/**< UICC Bit Rate Configuration - 0x02U -> 212Kbits/Sec - 0x04U -> 424Kbits/Sec - 0x08U -> 828Kbits/Sec - */ - -#define NXP_UICC_BIT_RATE 0x08U - -/**< Indicates PN544 Power Modes Configuration for the NFC Device, - 0x00U -> PN544 stays in active bat mode - (except when generating RF field) - 0x01U -> PN544 goes in standby when possible otherwise - stays in active bat mode - 0x02U -> PN544 goes in idle mode as soon as it can - (otherwise it is in active bat except when generating RF field) - 0x03U -> PN544 goes in standby when possible otherwise goes in idle mode - as soon as it can (otherwise it is in active bat except when - generating RF field) - */ - -#define NXP_SYSTEM_PWR_STATUS 0x01U - - -/**< System Event Notification - 0x01 Overcurrent - 0x02 PMUVCC Switch - 0x04 External RF Field - 0x08 Memory Violation - 0x10 Temperature Overheat - */ - -#define NXP_SYSTEM_EVT_INFO 0x10U - -/**< NFCIP Active Mode Configuration - 0x01 106 kbps - 0x02 212 kbps - 0x04 424 kbps - */ - -#define NXP_NFCIP_ACTIVE_DEFAULT 0x01U - - - -/* Reset the Default values of Host Link Timers */ -/* Macro to Enable the Host Side Link Timeout Configuration - * 0x00 ----> Default Pre-defined Configuration; - * 0x01 ----> Update only the Host Link Guard Timeout Configuration; - * 0x03 ----> Update Both the Host Link Guard Timeout - and ACK Timeout Configuration; - */ -#define HOST_LINK_TIMEOUT 0x00U - - -#define NXP_NFC_LINK_GRD_CFG_DEFAULT 0x0032U - - -#define NXP_NFC_LINK_ACK_CFG_DEFAULT 0x0005U - - -/* Macro to Enable the Interface Character Timeout Configuration - * 0x00 ----> Default Pre-defined Configuration; - * 0x01 ----> Update the IFC Timeout Default Configuration; - */ -#define NXP_NFC_IFC_TIMEOUT 0x00 - - -#define NXP_NFC_IFC_CONFIG_DEFAULT 0x203AU - - -#define NXP_NFCIP_PSL_BRS_DEFAULT 0x00U - - -#endif /* NFC_CUSTOM_CONFIG_H */ - diff --git a/inc/nfc_custom_config_example.h b/inc/nfc_custom_config_example.h new file mode 100644 index 0000000..d400bcc --- /dev/null +++ b/inc/nfc_custom_config_example.h @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2010 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** +* \file nfc_custom_config.h +* \brief HAL Custom Configurations +* +* +* \note This is the configuration header file of the HAL 4.0. custom configurable +* parameters of the HAL 4.0 are provided in this file +* +* Project: NFC-FRI-1.1 / HAL4.0 +* +* $Date: Fri Jun 11 16:44:31 2010 $ +* $Author: ing04880 $ +* $Revision: 1.11 $ +* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ +* +*/ + + +/*@{*/ +#ifndef NFC_CUSTOM_CONFIG_H +#define NFC_CUSTOM_CONFIG_H +/*@}*/ + + +/** +* \name Hal +* +* File: \ref nfc_custom_config.h +* +*/ + + +/* + ***************************************************************** + ********************** CUSTOM MACROS ************************** + ***************************************************************** + */ + +/**< Max number of remote devices supported*/ +#define MAX_REMOTE_DEVICES 0x10 + + +/**< Default Session ID for Initialisation */ +#define DEFAULT_SESSION "NXP-NFC2" + +/** Resolution value for the timer, here the + timer resolution is 100 milliseconds */ +#define TIMER_RESOLUTION 100U + +/**< Defines connection time out value for LLC timer, + 500 is in milliseconds */ +#define LINK_CONNECTION_TIMEOUT 500U + +/**< Defines guard time out value for LLC timer, + 250 is in milliseconds */ +#define LINK_GUARD_TIMEOUT 250U + +/**< Macro to Enable SMX Feature During + * Initialisation */ + + +/* PLEASE NOTE: This Macro should be only enabled if there is a SMART_MX + * Chip attached to the PN544. + */ +/* #define NXP_HAL_ENABLE_SMX */ + + + +/* PLEASE NOTE: Kindly change the DEFAULT_SESSION Macro for each of the + * configuration change done for the below Macros + */ + +/**< External Clock Request Configuration for the NFC Device, + 0x00U -> No Clock Request, + 0x01U -> Clock Request through CLKREQ pin (GPIO pin 2), + 0x02U -> Clock Request through NXP_EVT_CLK_REQUEST Event, + */ +#define NXP_DEFAULT_CLK_REQUEST 0x00U + +/**< External Input Clock Setting for the NFC Device, + 0x00U -> No Input Clock Required (Use the Xtal), + 0x01U -> 13 MHZ, + 0x02U -> 19.2 MHZ, + 0x03U -> 26 MHZ, + 0x04U -> 38.4 MHZ, + 0x05U -> Custom (Set the Custome Clock Registry), + */ +#define NXP_DEFAULT_INPUT_CLK 0x00U + + + +#define NFC_DEV_HWCONF_DEFAULT 0xBCU + +/**< TX LDO Configuration + 0x00 -> 00b 3.0 V, + 0x01 -> 01b 3.0 V, + 0x02 -> 10b 2.7 V, + 0x03 -> 11b 3.3 V, + + */ +#define NXP_DEFAULT_TX_LDO 0x00U + + +/**< External Clock Request Configuration for the NFC Device, + 0x00U -> No Power Request, + 0x01U -> Power Request through CLKREQ pin (GPIO pin 2), + 0x02U -> Power Request through PWR_REQUEST (GPIO Pin 3), + */ +#define NXP_UICC_PWR_REQUEST 0x00U + +/**< UICC Bit Rate Configuration + 0x02U -> 212Kbits/Sec + 0x04U -> 424Kbits/Sec + 0x08U -> 828Kbits/Sec + */ + +#define NXP_UICC_BIT_RATE 0x08U + +/**< Indicates PN544 Power Modes Configuration for the NFC Device, + 0x00U -> PN544 stays in active bat mode + (except when generating RF field) + 0x01U -> PN544 goes in standby when possible otherwise + stays in active bat mode + 0x02U -> PN544 goes in idle mode as soon as it can + (otherwise it is in active bat except when generating RF field) + 0x03U -> PN544 goes in standby when possible otherwise goes in idle mode + as soon as it can (otherwise it is in active bat except when + generating RF field) + */ + +#define NXP_SYSTEM_PWR_STATUS 0x01U + + +/**< System Event Notification + 0x01 Overcurrent + 0x02 PMUVCC Switch + 0x04 External RF Field + 0x08 Memory Violation + 0x10 Temperature Overheat + */ + +#define NXP_SYSTEM_EVT_INFO 0x10U + +/**< NFCIP Active Mode Configuration + 0x01 106 kbps + 0x02 212 kbps + 0x04 424 kbps + */ + +#define NXP_NFCIP_ACTIVE_DEFAULT 0x01U + + + +/* Reset the Default values of Host Link Timers */ +/* Macro to Enable the Host Side Link Timeout Configuration + * 0x00 ----> Default Pre-defined Configuration; + * 0x01 ----> Update only the Host Link Guard Timeout Configuration; + * 0x03 ----> Update Both the Host Link Guard Timeout + and ACK Timeout Configuration; + */ +#define HOST_LINK_TIMEOUT 0x00U + + +#define NXP_NFC_LINK_GRD_CFG_DEFAULT 0x0032U + + +#define NXP_NFC_LINK_ACK_CFG_DEFAULT 0x0005U + + +/* Macro to Enable the Interface Character Timeout Configuration + * 0x00 ----> Default Pre-defined Configuration; + * 0x01 ----> Update the IFC Timeout Default Configuration; + */ +#define NXP_NFC_IFC_TIMEOUT 0x00 + + +#define NXP_NFC_IFC_CONFIG_DEFAULT 0x203AU + + +#define NXP_NFCIP_PSL_BRS_DEFAULT 0x00U + + +#endif /* NFC_CUSTOM_CONFIG_H */ -- cgit v1.1