MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
IAP_FFR Driver

Overview

Files

file  fsl_flash_ffr.h
 

Macros

#define ALIGN_DOWN(x, a)   ((x) & (uint32_t)(-((int32_t)(a))))
 Alignment(down) utility. More...
 
#define ALIGN_UP(x, a)   (-((int32_t)((uint32_t)(-((int32_t)(x))) & (uint32_t)(-((int32_t)(a))))))
 Alignment(up) utility. More...
 

Enumerations

enum  flash_ffr_page_offset {
  kFfrPageOffset_CFPA = 0U,
  kFfrPageOffset_CFPA_Scratch = 0U,
  kFfrPageOffset_CFPA_CfgPing = 1U,
  kFfrPageOffset_CFPA_CfgPong = 2U,
  kFfrPageOffset_CMPA = 3U,
  kFfrPageOffset_CMPA_Cfg = 3U,
  kFfrPageOffset_CMPA_Key = 4U,
  kFfrPageOffset_NMPA = 7U,
  kFfrPageOffset_NMPA_Romcp = 7U,
  kFfrPageOffset_NMPA_Repair = 9U,
  kFfrPageOffset_NMPA_Cfg = 15U,
  kFfrPageOffset_NMPA_End = 16U
}
 
enum  flash_ffr_page_num {
  kFfrPageNum_CFPA = 3U,
  kFfrPageNum_CMPA = 4U,
  kFfrPageNum_NMPA = 13U
}
 

FFR APIs

status_t FFR_Init (flash_config_t *config)
 Initializes the global FFR properties structure members. More...
 
status_t FFR_Lock (flash_config_t *config)
 Enable firewall for all flash banks. More...
 
status_t FFR_SecLibInit (flash_config_t *config, uint32_t *context)
 Initialize the Security Library for FFR driver. More...
 
status_t FFR_GetCustKeystoreData (flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
 The API is used for getting the customer key store data from the customer key store region(0x3e400 ¨C 0x3e600), and the API should be called after the FLASH_Init and FFR_Init. More...
 
status_t FFR_CustomerPagesInit (flash_config_t *config)
 APIs to access CFPA pages. More...
 
status_t FFR_InfieldPageWrite (flash_config_t *config, uint8_t *page_data, uint32_t valid_len)
 APIs to access CFPA pages. More...
 
status_t FFR_GetCustomerInfieldData (flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
 APIs to access CFPA pages. More...
 
status_t FFR_CustFactoryPageWrite (flash_config_t *config, uint8_t *page_data, bool seal_part)
 APIs to access CMPA pages. More...
 
status_t FFR_GetCustomerData (flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
 APIs to access CMPA page. More...
 
status_t FFR_CustKeystoreWrite (flash_config_t *config, ffr_key_store_t *pKeyStore)
 This routine writes the 3 pages allocated for Key store data. More...
 
status_t FFR_GetUUID (flash_config_t *config, uint8_t *uuid)
 APIs to access CMPA page. More...
 

Macro Definition Documentation

#define ALIGN_DOWN (   x,
 
)    ((x) & (uint32_t)(-((int32_t)(a))))
#define ALIGN_UP (   x,
 
)    (-((int32_t)((uint32_t)(-((int32_t)(x))) & (uint32_t)(-((int32_t)(a))))))

Enumeration Type Documentation

Enumerator
kFfrPageOffset_CFPA 

Customer In-Field programmed area.

kFfrPageOffset_CFPA_Scratch 

CFPA Scratch page.

kFfrPageOffset_CFPA_CfgPing 

CFPA Configuration area (Ping page)

kFfrPageOffset_CFPA_CfgPong 

Same as CFPA page (Pong page)

kFfrPageOffset_CMPA 

Customer Manufacturing programmed area.

kFfrPageOffset_CMPA_Cfg 

CMPA Configuration area (Part of CMPA)

kFfrPageOffset_CMPA_Key 

Key Store area (Part of CMPA)

kFfrPageOffset_NMPA 

NXP Manufacturing programmed area.

kFfrPageOffset_NMPA_Romcp 

ROM patch area (Part of NMPA)

kFfrPageOffset_NMPA_Repair 

Repair area (Part of NMPA)

kFfrPageOffset_NMPA_Cfg 

NMPA configuration area (Part of NMPA)

kFfrPageOffset_NMPA_End 

Reserved (Part of NMPA)

Enumerator
kFfrPageNum_CFPA 

Customer In-Field programmed area.

kFfrPageNum_CMPA 

Customer Manufacturing programmed area.

kFfrPageNum_NMPA 

NXP Manufacturing programmed area.

Function Documentation

status_t FFR_Init ( flash_config_t config)
Parameters
configA pointer to the storage for the driver runtime state.
Return values
kStatus_FLASH_SuccessAPI was executed successfully.
status_t FFR_Lock ( flash_config_t config)

CFPA, CMPA, and NMPA flash areas region will be locked, After this function executed; Unless the board is reset again.

Parameters
configA pointer to the storage for the driver runtime state.
Return values
kStatus_FLASH_SuccessAn invalid argument is provided.
status_t FFR_SecLibInit ( flash_config_t config,
uint32_t *  context 
)
Parameters
configA pointer to the storage for the driver runtime state.
contextA pointer to the storage for the nboot data.
Return values
kStatus_FLASH_SuccessAn invalid argument is provided.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
status_t FFR_GetCustKeystoreData ( flash_config_t config,
uint8_t *  pData,
uint32_t  offset,
uint32_t  len 
)
Parameters
configA pointer to the storage for the driver runtime state.
pDataA pointer to the dest buffer of data that is to be read from the Customer Factory CFG Page.
offsetAddress offset relative to the CMPA area.
lenThe length, given in bytes to be read.
Return values
kStatus_FLASH_SuccessGet data from 'Customer Factory CFG Page'.
kStatus_FLASH_InvalidArgumentParameter is not aligned with the specified baseline.
#kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_AddressErrorAddress is out of range
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline.
kStatus_FLASH_ReadHidingAreaDisallowedFlash hiding read is not allowed
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
kStatus_FLASH_RegulationLossA loss of regulation during read.
status_t FFR_CustomerPagesInit ( flash_config_t config)

This routine will erase CFPA and program the CFPA page with passed data.

Parameters
configA pointer to the storage for the driver runtime state.
Return values
kStatus_FLASH_SuccessThe desire page-data were programed successfully into CFPA.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
kStatus_FLASH_FfrBankIsLockedThe FFR bank region is locked.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
#kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_ReadHidingAreaDisallowedFlash hiding read is not allowed
kStatus_FLASH_CfpaScratchPageInvalidCFPA Scratch Page is invalid
kStatus_FLASH_CfpaVersionRollbackDisallowedCFPA version rollback is not allowed
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline
kStatus_FLASH_EraseKeyErrorAPI erase key is invalid.
kStatus_FLASH_ModifyProtectedAreaDisallowedFlash firewall page locked erase and program are not allowed
kStatus_FLASH_FfrBankIsLockedThe CFPA was locked.
kStatus_FLASH_OutOfDateCfpaPageIt is not newest CFPA page.
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
kStatus_FLASH_RegulationLossA loss of regulation during read.
status_t FFR_InfieldPageWrite ( flash_config_t config,
uint8_t *  page_data,
uint32_t  valid_len 
)

This routine will erase CFPA and program the CFPA page with passed data.

Parameters
configA pointer to the storage for the driver runtime state.
page_dataA pointer to the source buffer of data that is to be programmed into the CFPA.
valid_lenThe length, given in bytes, to be programmed.
Return values
kStatus_FLASH_SuccessThe desire page-data were programed successfully into CFPA.
kStatus_FLASH_SizeErrorError size
kStatus_FLASH_ReadHidingAreaDisallowedFlash hiding read is not allowed
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline
kStatus_FLASH_ModifyProtectedAreaDisallowedFlash firewall page locked erase and program are not allowed
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
#kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_FfrBankIsLockedThe CFPA was locked.
kStatus_FLASH_OutOfDateCfpaPageIt is not newest CFPA page.
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
kStatus_FLASH_RegulationLossA loss of regulation during read.
status_t FFR_GetCustomerInfieldData ( flash_config_t config,
uint8_t *  pData,
uint32_t  offset,
uint32_t  len 
)

Generic read function, used by customer to read data stored in 'Customer In-field Page'.

Parameters
configA pointer to the storage for the driver runtime state.
pDataA pointer to the dest buffer of data that is to be read from 'Customer In-field Page'.
offsetAn offset from the 'Customer In-field Page' start address.
lenThe length, given in bytes, to be read.
Return values
kStatus_FLASH_SuccessGet data from 'Customer In-field Page'.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
#kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline.
kStatus_FLASH_ReadHidingAreaDisallowedFlash hiding read is not allowed
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
kStatus_FLASH_RegulationLossA loss of regulation during read.
status_t FFR_CustFactoryPageWrite ( flash_config_t config,
uint8_t *  page_data,
bool  seal_part 
)

This routine will erase "customer factory page" and program the page with passed data. If 'seal_part' parameter is TRUE then the routine will compute SHA256 hash of the page contents and then programs the pages. 1.During development customer code uses this API with 'seal_part' set to FALSE. 2.During manufacturing this parameter should be set to TRUE to seal the part from further modifications 3.This routine checks if the page is sealed or not. A page is said to be sealed if the SHA256 value in the page has non-zero value. On boot ROM locks the firewall for the region if hash is programmed anyways. So, write/erase commands will fail eventually.

Parameters
configA pointer to the storage for the driver runtime state.
page_dataA pointer to the source buffer of data that is to be programmed into the "customer factory page".
seal_partSet fasle for During development customer code.
Return values
kStatus_FLASH_SuccessThe desire page-data were programed successfully into CMPA.
kStatus_FLASH_InvalidArgumentParameter is not aligned with the specified baseline.
#kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline.
kStatus_FLASH_EraseKeyErrorAPI erase key is invalid.
kStatus_FLASH_ModifyProtectedAreaDisallowedFlash firewall page locked erase and program are not allowed
kStatus_FailGeneric status for Fail.
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
kStatus_FLASH_RegulationLossA loss of regulation during read.
status_t FFR_GetCustomerData ( flash_config_t config,
uint8_t *  pData,
uint32_t  offset,
uint32_t  len 
)

Read data stored in 'Customer Factory CFG Page'.

Parameters
configA pointer to the storage for the driver runtime state.
pDataA pointer to the dest buffer of data that is to be read from the Customer Factory CFG Page.
offsetAddress offset relative to the CMPA area.
lenThe length, given in bytes to be read.
Return values
kStatus_FLASH_SuccessGet data from 'Customer Factory CFG Page'.
kStatus_FLASH_InvalidArgumentParameter is not aligned with the specified baseline.
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline.
#kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
kStatus_FLASH_RegulationLossA loss of regulation during read.
kStatus_FLASH_ReadHidingAreaDisallowedFlash hiding read is not allowed
status_t FFR_CustKeystoreWrite ( flash_config_t config,
ffr_key_store_t *  pKeyStore 
)

This routine writes the 3 pages allocated for Key store data,.

Parameters
configA pointer to the storage for the driver runtime state.
pKeyStoreA pointer to the source buffer of data that is to be programmed into the "Key store".
Return values
kStatus_FLASH_SuccessGet data from 'Customer Factory CFG Page'.
kStatus_FLASH_InvalidArgumentParameter is not aligned with the specified baseline.
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
kStatus_FLASH_RegulationLossA loss of regulation during read.
kStatus_FLASH_SealedFfrRegionThe FFR region is sealed.
kStatus_FLASH_FfrBankIsLockedThe FFR bank region is locked.
kStatus_FLASH_AddressErrorAddress is out of range
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline.
kStatus_FLASH_ModifyProtectedAreaDisallowedFlash firewall page locked erase and program are not allowed

1.Used during manufacturing. Should write pages when 'customer factory page' is not in sealed state. 2.Optional routines to set individual data members (activation code, key codes etc) to construct the key store structure in RAM before committing it to IFR/FFR.

Parameters
configA pointer to the storage for the driver runtime state.
pKeyStoreA Pointer to the 3 pages allocated for Key store data. that will be written to 'customer factory page'.
Return values
kStatus_FLASH_SuccessThe key were programed successfully into FFR.
kStatus_FLASH_InvalidArgumentParameter is not aligned with the specified baseline.
#kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_CommandFailureaccess error.
kStatus_FLASH_SealedFfrRegionThe FFR region is sealed.
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline.
kStatus_FLASH_AddressErrorAddress is out of range
kStatus_FLASH_EraseKeyErrorAPI erase key is invalid.
kStatus_FLASH_ModifyProtectedAreaDisallowedFlash firewall page locked erase and program are not allowed
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_RegulationLossA loss of regulation during read.
status_t FFR_GetUUID ( flash_config_t config,
uint8_t *  uuid 
)

1.SW should use this API routine to get the UUID of the chip. 2.Calling routine should pass a pointer to buffer which can hold 128-bit value.

Return values
kStatus_FLASH_SuccessGet data from 'Customer Factory CFG Page'.
kStatus_FLASH_InvalidArgumentParameter is not aligned with the specified baseline.
kStatus_FLASH_ReadHidingAreaDisallowedFlash hiding read is not allowed
kStatus_FLASH_CommandFailureRun-time error during command execution.
kStatus_FLASH_CommandNotSupportedFlash API is not supported
kStatus_FLASH_RegulationLossA loss of regulation during read.