I'm using the MKW41Z Connectivity Software v1.0.2 and I'm seeing something in Flash_Adapter.c that doesn't make sense. In the NV_WriteHWParameters() function it's computing and storing the CRC in the pHwParams variable and then it's setting the identificationWord element, which causes the calculated CRC to (probably) no longer be valid. Is this a bug, or am I missing something? Here's the code (observe the order of operations on lines 3 and 4):
if(!FLib_MemCmp(pHwParams, (void*)FREESCALE_PROD_DATA_BASE_ADDR, sizeof(hardwareParameters_t)))
{
pHwParams->hardwareParamsCrc = NV_ComputeCrcOverHWParameters(pHwParams);
FLib_MemCpy(pHwParams->identificationWord, (void*)mProdDataIdentifier, sizeof(mProdDataIdentifier));
status = NV_FlashEraseSector((uint32_t)FREESCALE_PROD_DATA_BASE_ADDR, FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE);
if( 0 == status )
{
status = NV_FlashProgramUnaligned((uint32_t)FREESCALE_PROD_DATA_BASE_ADDR,
sizeof(hardwareParameters_t),
(uint8_t*)pHwParams);
}
}