MCUXpresso SDK API Reference Manual  Rev 2.15.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

Files

file  fsl_iap_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 = 0,
  kFfrPageOffset_CFPA_Scratch = 0,
  kFfrPageOffset_CFPA_Cfg = 1,
  kFfrPageOffset_CFPA_CfgPong = 2,
  kFfrPageOffset_CMPA = 3,
  kFfrPageOffset_CMPA_Cfg = 3,
  kFfrPageOffset_CMPA_Key = 4,
  kFfrPageOffset_NMPA = 7,
  kFfrPageOffset_NMPA_Romcp = 7,
  kFfrPageOffset_NMPA_Repair = 9,
  kFfrPageOffset_NMPA_Cfg = 15,
  kFfrPageOffset_NMPA_End = 16
}
 flash ffr page offset. More...
 
enum  _flash_ffr_page_num {
  kFfrPageNum_CFPA = 3,
  kFfrPageNum_CMPA = 4,
  kFfrPageNum_NMPA = 10
}
 flash ffr page number. More...
 

Flash IFR version

#define FSL_FLASH_IFR_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))
 Flash IFR driver version for SDK. More...
 

FFR APIs

status_t FFR_Init (flash_config_t *config)
 Initializes the global FFR properties structure members. More...
 
status_t FFR_Lock_All (flash_config_t *config)
 Enable firewall for all flash banks. 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_GetUUID (flash_config_t *config, uint8_t *uuid)
 APIs to access CMPA page. More...
 
status_t FFR_KeystoreWrite (flash_config_t *config, ffr_key_store_t *pKeyStore)
 This routine writes the 3 pages allocated for Key store data,. More...
 
status_t FFR_KeystoreGetAC (flash_config_t *config, uint8_t *pActivationCode)
 Get/Read Key store code routines. More...
 
status_t FFR_KeystoreGetKC (flash_config_t *config, uint8_t *pKeyCode, ffr_key_type_t keyIndex)
 Get/Read Key store code routines. More...
 

Macro Definition Documentation

#define FSL_FLASH_IFR_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))

Version 2.1.0.

#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_Cfg 

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.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
status_t FFR_Lock_All ( 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.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
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_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.
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_CommandFailureaccess error.
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_CommandFailureaccess error.
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_FTFx_AddressErrorAddress is out of range.
kStatus_FLASH_CommandFailureaccess error.
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.

status_t FFR_KeystoreWrite ( flash_config_t config,
ffr_key_store_t *  pKeyStore 
)

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.
status_t FFR_KeystoreGetAC ( flash_config_t config,
uint8_t *  pActivationCode 
)
  1. Calling code should pass buffer pointer which can hold activation code 1192 bytes.
  2. Check if flash aperture is small or regular and read the data appropriately.
status_t FFR_KeystoreGetKC ( flash_config_t config,
uint8_t *  pKeyCode,
ffr_key_type_t  keyIndex 
)
  1. Calling code should pass buffer pointer which can hold key code 52 bytes.
  2. Check if flash aperture is small or regular and read the data appropriately.
  3. keyIndex specifies which key code is read.