Skip to content

Commit

Permalink
R2.1 release update
Browse files Browse the repository at this point in the history
  • Loading branch information
jgeslin committed Jul 6, 2016
1 parent 2a9df38 commit 81995a4
Show file tree
Hide file tree
Showing 12 changed files with 425 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Further details about the stack [here](https://github.com/NXPNFCLinux/linux_libn

Release version
---------------
R2.1 includes support for PN7150 NFC Controller IC
R2.1 includes support for PN7150 NFC Controller IC and some bug fixes (refer to the [documentation](https://github.com/NXPNFCLinux/linux_libnfc-nci/blob/master/doc/AN11697%20-%20PN71x0%20Linux%20Software%20Stack%20Integration%20Guidelines.pdf) for more details).

R2.0 includes LLCP1.3 support and some bug fixes (refer to the [documentation](https://github.com/NXPNFCLinux/linux_libnfc-nci/blob/master/doc/AN11697%20-%20PN71x0%20Linux%20Software%20Stack%20Integration%20Guidelines.pdf) for more details).

Expand Down
33 changes: 29 additions & 4 deletions conf/PN7150/libnfc-nxp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ NXP_EXT_TVDD_CFG_2={20, 02, 07, 01, A0, 0E, 03, 06, 64, 00}
###############################################################################
# NXP Proprietary core configuration extensions
# For more details refer to the NFC Controller User Manual
NXP_CORE_CONF_EXTN={20, 02, 10, 03,
NXP_CORE_CONF_EXTN={20, 02, 24, 04,
A0, 5E, 01, 01,
A0, 40, 01, 00,
A0, 0D, 04, 34, 44, 22, 00
}
A0, 0D, 04, 34, 44, 22, 00,
A0, 1D, 11, 57, 33, 14, 17, 00, AA, 85, 00, 80, 55, 2A, 04, 00, 63, 00, 00, 00
}

###############################################################################
# To enable i2c fragmentation set i2c fragmentation enable 0x01 to disable set to 0x00
Expand All @@ -101,4 +102,28 @@ NXP_CORE_CONF={ 20, 02, 2B, 0D,
81, 01, 01,
82, 01, 0E,
18, 01, 01
}
}

###############################################################################
# RF configuration settings
NXP_RF_CONF_BLK_1={ 20, 02, A3, 13,
A0, 0D, 06, 04, 35, 90, 01, F4, 01,
A0, 0D, 06, 06, 44, 01, 90, 03, 00,
A0, 0D, 06, 06, 30, B0, 01, 10, 00,
A0, 0D, 06, 06, 42, 02, 00, FF, FF,
A0, 0D, 03, 06, 3F, 06,
A0, 0D, 06, 20, 42, 88, 00, FF, FF,
A0, 0D, 04, 22, 44, 23, 00,
A0, 0D, 06, 22, 2D, 50, 34, 0C, 00,
A0, 0D, 06, 32, 42, F8, 00, FF, FF,
A0, 0D, 06, 34, 2D, 24, 37, 0C, 00,
A0, 0D, 06, 34, 33, 86, 80, 00, 70,
A0, 0D, 04, 34, 44, 22, 00,
A0, 0D, 06, 42, 2D, 15, 45, 0D, 00,
A0, 0D, 04, 46, 44, 22, 00,
A0, 0D, 06, 46, 2D, 05, 59, 0E, 00,
A0, 0D, 06, 44, 42, 88, 00, FF, FF,
A0, 0D, 06, 56, 2D, 05, 9F, 0C, 00,
A0, 0D, 06, 54, 42, 88, 00, FF, FF,
A0, 0D, 06, 0A, 33, 80, 86, 00, 70
}
Binary file not shown.
8 changes: 8 additions & 0 deletions src/halimpl/pn54x/common/phNfcStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@
*/
#define NFCSTATUS_NOT_ALLOWED (0x003A)

/*
* FW version error while performing FW download,
* FW major version mismatch (cannot downgrade FW major version) or FW version already upto date
* User may be trying to flash Mobile FW on top of Infra FW, which is not allowed
* Download appropriate version of FW
*/
#define NFCSTATUS_FW_VERSION_ERROR (0x003C)

/*
* The system is busy with the previous operation.
*/
Expand Down
94 changes: 90 additions & 4 deletions src/halimpl/pn54x/dnld/phDnldNfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
static void *pFwLibHandle; /* Global firmware lib handle used in this file only */
uint16_t wMwVer = 0; /* Middleware version no */
uint16_t wFwVer = 0; /* Firmware version no */
#if(NFC_NXP_CHIP_TYPE == PN548C2)
uint8_t gRecFWDwnld; // flag set to true to indicate dummy FW download
#endif
static pphDnldNfc_DlContext_t gpphDnldContext = NULL; /* Download contex */
static pphDnldNfc_RspCb_t UserCb; /* Upper layer call back function */
static void* UserCtxt; /* Pointer to upper layer context */
Expand Down Expand Up @@ -869,7 +872,12 @@ NFCSTATUS phDnldNfc_InitImgInfo(void)
phDnldNfc_SetHwDevHandle();

/* load the library and get the image info pointer */
wStatus = phDnldNfc_LoadFW(FW_LIB_PATH, &pImageInfo, &ImageInfoLen);
#if(NFC_NXP_CHIP_TYPE == PN548C2)
if (gRecFWDwnld == TRUE)
wStatus = phDnldNfc_LoadRecoveryFW (FW_LIB_PATH, &pImageInfo, &ImageInfoLen);
else
#endif
wStatus = phDnldNfc_LoadFW (FW_LIB_PATH, &pImageInfo, &ImageInfoLen);

NXPLOG_FWDNLD_D("FW Image Length - ImageInfoLen %d",ImageInfoLen);
NXPLOG_FWDNLD_D("FW Image Info Pointer - pImageInfo %x",(uintptr_t)pImageInfo);
Expand Down Expand Up @@ -940,7 +948,12 @@ NFCSTATUS phDnldNfc_LoadRecInfo(void)
/* if memory is not allocated then allocate memory for donwload context structure */
phDnldNfc_SetHwDevHandle();

wStatus = phDnldNfc_LoadFW(PLATFORM_LIB_PATH, &pImageInfo, &ImageInfoLen);
#if(NFC_NXP_CHIP_TYPE == PN548C2)
if (gRecFWDwnld == TRUE)
wStatus = phDnldNfc_LoadRecoveryFW (PLATFORM_LIB_PATH, &pImageInfo, &ImageInfoLen);
else
#endif
wStatus = phDnldNfc_LoadFW (PLATFORM_LIB_PATH, &pImageInfo, &ImageInfoLen);

if((pImageInfo == NULL) || (ImageInfoLen == 0))
{
Expand Down Expand Up @@ -997,8 +1010,12 @@ NFCSTATUS phDnldNfc_LoadPKInfo(void)
phDnldNfc_SetHwDevHandle();

/* load the PKU image library */
wStatus = phDnldNfc_LoadFW(PKU_LIB_PATH, &pImageInfo, &ImageInfoLen);

#if(NFC_NXP_CHIP_TYPE == PN548C2)
if (gRecFWDwnld == TRUE)
wStatus = phDnldNfc_LoadRecoveryFW (PKU_LIB_PATH, &pImageInfo, &ImageInfoLen);
else
#endif
wStatus = phDnldNfc_LoadFW (PKU_LIB_PATH, &pImageInfo, &ImageInfoLen);
if((pImageInfo == NULL) || (ImageInfoLen == 0))
{
NXPLOG_FWDNLD_E("Image extraction Failed - invalid imginfo or imginfolen!!");
Expand Down Expand Up @@ -1167,6 +1184,75 @@ NFCSTATUS phDnldNfc_UnloadFW(void)
return wStatus;
}

#if(NFC_NXP_CHIP_TYPE == PN548C2)
/*******************************************************************************
**
** Function phDnldNfc_LoadRecoveryFW
**
** Description Load the dummy firmware version form firmware lib for recovery
** This will change the FW version of the NFCC firmware
** and enable flashing of firmware of same version.
**
** Parameters pathName - Firmware image path
** pImgInfo - Firmware image handle
** pImgInfoLen - Firmware image length
**
** Returns NFCSTATUS
**
*******************************************************************************/
NFCSTATUS phDnldNfc_LoadRecoveryFW (const char* pathName, uint8_t **pImgInfo, uint16_t* pImgInfoLen)
{
void* pImageInfo = NULL;
void* pImageInfoLen = NULL;

/* check for path name */
if (pathName == NULL)
{
pathName = "/system/vendor/firmware/libpn548ad_fw.so";
}

/* check if the handle is not NULL then free the library */
if (pFwLibHandle != NULL)
{
phDnldNfc_UnloadFW ();
pFwLibHandle = NULL;
}
/* load the DLL file */
pFwLibHandle = dlopen (pathName, RTLD_LAZY);
NXPLOG_FWDNLD_D ("phDnldNfc_LoadRecoveryFW %s ", pathName);

/* if library load failed then handle will be NULL */
if (pFwLibHandle == NULL)
{
NXPLOG_FWDNLD_E("NULL handler : unable to load the library file, specify correct path");
return NFCSTATUS_FAILED;
}

dlerror (); /* Clear any existing error */

/* load the address of download image pointer and image size */
pImageInfo = (void*)dlsym (pFwLibHandle, "gphDnldNfc_DummyDlSeq");

if (dlerror() || (NULL == pImageInfo))
{
NXPLOG_FWDNLD_E ("Problem loading symbol : gphDnldNfc_DummyDlSeq");
return NFCSTATUS_FAILED;
}

(*pImgInfo) = (*(uint8_t**)pImageInfo);
pImageInfoLen = (void*)dlsym (pFwLibHandle, "gphDnldNfc_DlSeqDummyFwSz");
if (dlerror() ||(NULL == pImageInfoLen))
{
NXPLOG_FWDNLD_E ("Problem loading symbol : gphDnldNfc_DlSeqDummyFwSz");
return NFCSTATUS_FAILED;
}

(*pImgInfoLen) = (uint16_t)(*((uint16_t*)pImageInfoLen));

return NFCSTATUS_SUCCESS;
}
#endif

#ifdef EEPROM_Read_Mem_IMP
/*******************************************************************************
**
Expand Down
3 changes: 3 additions & 0 deletions src/halimpl/pn54x/dnld/phDnldNfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,8 @@ extern NFCSTATUS phDnldNfc_LoadRecInfo(void);
extern NFCSTATUS phDnldNfc_LoadPKInfo(void);
extern void phDnldNfc_CloseFwLibHandle(void);
extern NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t **pImgInfo, uint16_t* pImgInfoLen);
#if(NFC_NXP_CHIP_TYPE == PN548C2)
extern NFCSTATUS phDnldNfc_LoadRecoveryFW (const char* pathName, uint8_t **pImgInfo, uint16_t* pImgInfoLen);
#endif
extern NFCSTATUS phDnldNfc_UnloadFW(void);
#endif /* PHDNLDNFC_H */
8 changes: 6 additions & 2 deletions src/halimpl/pn54x/dnld/phDnldNfc_Internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ static void phDnldNfc_ProcessSeqState(void *pContext, phTmlNfc_TransactInfo_t *p
(pphTmlNfc_TransactCompletionCb_t)&phDnldNfc_ProcessSeqState,
(void *)pDlCtxt);

/* set read status to pDlCtxt->wCmdSendStatus to enable callback */
pDlCtxt->wCmdSendStatus = wStatus;
break;
}
else
Expand Down Expand Up @@ -454,6 +456,8 @@ static void phDnldNfc_ProcessRWSeqState(void *pContext, phTmlNfc_TransactInfo_t
(pphTmlNfc_TransactCompletionCb_t)&phDnldNfc_ProcessRWSeqState,
(void *)pDlCtxt);

/* set read status to pDlCtxt->wCmdSendStatus to enable callback */
pDlCtxt->wCmdSendStatus = wStatus;
break;
}
else
Expand Down Expand Up @@ -1232,12 +1236,12 @@ static NFCSTATUS phDnldNfc_UpdateRsp(pphDnldNfc_DlContext_t pDlContext, phTmlN
}
else if(PH_DL_STATUS_FIRMWARE_VERSION_ERROR == (pInfo->pBuff[PHDNLDNFC_FRAMESTATUS_OFFSET]))
{
NXPLOG_FWDNLD_E("Firmware Already Up To Date!!");
NXPLOG_FWDNLD_E("FW version Error !!!could be either due to FW major version mismatch or Firmware Already Up To Date !!");
(pDlContext->tRWInfo.bFirstWrReq) = FALSE;
/* resetting wRemBytes to 0 to avoid any further write frames send */
(pDlContext->tRWInfo.wRemBytes) = 0;
(pDlContext->tRWInfo.wOffset) = 0;
wStatus = NFCSTATUS_SUCCESS;
wStatus = NFCSTATUS_FW_VERSION_ERROR;
}
else if(PH_DL_STATUS_PLL_ERROR == (pInfo->pBuff[PHDNLDNFC_FRAMESTATUS_OFFSET]))
{
Expand Down
36 changes: 34 additions & 2 deletions src/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
/* External global variable to get FW version */
extern uint16_t wFwVer;
extern uint16_t wMwVer;
#if(NFC_NXP_CHIP_TYPE == PN548C2)
extern uint8_t gRecFWDwnld;
#endif

/* RF Configuration structure */
typedef struct phLibNfc_IoctlSetRfConfig
Expand Down Expand Up @@ -179,6 +182,20 @@ static NFCSTATUS (*phNxpNciHal_dwnld_seqhandler[])(
NULL
};

#if(NFC_NXP_CHIP_TYPE == PN548C2)
/* Array of pointers to start dummy fw download seq */
static NFCSTATUS (*phNxpNciHal_dummy_rec_dwnld_seqhandler[])(
void* pContext, NFCSTATUS status, void* pInfo) = {
phNxpNciHal_fw_dnld_normal,
phNxpNciHal_fw_dnld_normal,
phNxpNciHal_fw_dnld_get_sessn_state,
phNxpNciHal_fw_dnld_get_version,
phNxpNciHal_fw_dnld_log_read,
phNxpNciHal_fw_dnld_write,
NULL
};
#endif

/* Download Recovery Sequence */
static NFCSTATUS (*phNxpNciHal_dwnld_rec_seqhandler[])(
void* pContext, NFCSTATUS status, void* pInfo) = {
Expand Down Expand Up @@ -1671,6 +1688,12 @@ static NFCSTATUS phNxpNciHal_fw_dnld_complete(void* pContext,NFCSTATUS status,
(gphNxpNciHal_fw_IoctlCtx.bDnldInitiated) = FALSE;
/* Perform the Logging sequence */
wStatus = phNxpNciHal_fw_seq_handler(phNxpNciHal_dwnld_log_seqhandler);
if (NFCSTATUS_SUCCESS != gphNxpNciHal_fw_IoctlCtx.bLastStatus)
{
/* update the previous Download Write status to upper layer and not the status of Log command */
wStatus = gphNxpNciHal_fw_IoctlCtx.bLastStatus;
NXPLOG_FWDNLD_E ("phNxpNciHal_fw_dnld_complete: Last Download Write Status before Log command bLastStatus = 0x%x", gphNxpNciHal_fw_IoctlCtx.bLastStatus);
}
status = phNxpNciHal_fw_dnld_complete(pContext, wStatus, &pInfo);
if (NFCSTATUS_SUCCESS == status)
{
Expand All @@ -1680,7 +1703,6 @@ static NFCSTATUS phNxpNciHal_fw_dnld_complete(void* pContext,NFCSTATUS status,
{
NXPLOG_FWDNLD_E(" phNxpNciHal_fw_dnld_complete : FAILED");
}

}
else if(TRUE == (gphNxpNciHal_fw_IoctlCtx.bDnldRecovery))
{
Expand Down Expand Up @@ -1727,6 +1749,7 @@ static NFCSTATUS phNxpNciHal_fw_dnld_complete(void* pContext,NFCSTATUS status,
}
else
{
NXPLOG_FWDNLD_D ("phNxpNciHal_fw_dnld_complete: Download Status = 0x%x", status);
if(FALSE == (gphNxpNciHal_fw_IoctlCtx.bSkipSeq))
{
if(NFCSTATUS_SUCCESS == status)
Expand Down Expand Up @@ -1854,7 +1877,16 @@ NFCSTATUS phNxpNciHal_fw_download_seq(uint8_t bClkSrcVal, uint8_t bClkFreqVal)
if (NFCSTATUS_SUCCESS == phDnldNfc_InitImgInfo())
{
NXPLOG_FWDNLD_D("phDnldNfc_InitImgInfo:SUCCESS");
status = phNxpNciHal_fw_seq_handler(phNxpNciHal_dwnld_seqhandler);
#if(NFC_NXP_CHIP_TYPE == PN548C2)
if (gRecFWDwnld == TRUE)
{
status = phNxpNciHal_fw_seq_handler (phNxpNciHal_dummy_rec_dwnld_seqhandler);
}
else
#endif
{
status = phNxpNciHal_fw_seq_handler (phNxpNciHal_dwnld_seqhandler);
}
}
else
{
Expand Down
Loading

0 comments on commit 81995a4

Please sign in to comment.