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

Overview

Data Structures

struct  _flexnvm_config
 Flexnvm driver state information. More...
 

Typedefs

typedef enum _flexnvm_property_tag flexnvm_property_tag_t
 Enumeration for various flexnvm properties.
 
typedef struct _flexnvm_config flexnvm_config_t
 Flexnvm driver state information. More...
 

Enumerations

enum  _flexnvm_property_tag {
  kFLEXNVM_PropertyDflashSectorSize = 0x00U,
  kFLEXNVM_PropertyDflashTotalSize = 0x01U,
  kFLEXNVM_PropertyDflashBlockSize = 0x02U,
  kFLEXNVM_PropertyDflashBlockCount = 0x03U,
  kFLEXNVM_PropertyDflashBlockBaseAddr = 0x04U,
  kFLEXNVM_PropertyAliasDflashBlockBaseAddr = 0x05U,
  kFLEXNVM_PropertyFlexRamBlockBaseAddr = 0x06U,
  kFLEXNVM_PropertyFlexRamTotalSize = 0x07U,
  kFLEXNVM_PropertyEepromTotalSize = 0x08U
}
 Enumeration for various flexnvm properties. More...
 

Functions

status_t FLEXNVM_EepromWrite (flexnvm_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)
 Programs the EEPROM with data at locations passed in through parameters. More...
 

Initialization

status_t FLEXNVM_Init (flexnvm_config_t *config)
 Initializes the global flash properties structure members. More...
 

Erasing

status_t FLEXNVM_DflashErase (flexnvm_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
 Erases the Dflash sectors encompassed by parameters passed into function. More...
 
status_t FLEXNVM_EraseAll (flexnvm_config_t *config, uint32_t key)
 Erases entire flexnvm. More...
 
status_t FLEXNVM_EraseAllUnsecure (flexnvm_config_t *config, uint32_t key)
 Erases the entire flexnvm, including protected sectors. More...
 

Programming

status_t FLEXNVM_DflashProgram (flexnvm_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)
 Programs flash with data at locations passed in through parameters. More...
 
status_t FLEXNVM_DflashProgramSection (flexnvm_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)
 Programs flash with data at locations passed in through parameters via the Program Section command. More...
 
status_t FLEXNVM_ProgramPartition (flexnvm_config_t *config, ftfx_partition_flexram_load_opt_t option, uint32_t eepromDataSizeCode, uint32_t flexnvmPartitionCode)
 Prepares the FlexNVM block for use as data flash, EEPROM backup, or a combination of both and initializes the FlexRAM. More...
 

Verification

status_t FLEXNVM_DflashVerifyErase (flexnvm_config_t *config, uint32_t start, uint32_t lengthInBytes, ftfx_margin_value_t margin)
 Verifies an erasure of the desired flash area at a specified margin level. More...
 
status_t FLEXNVM_VerifyEraseAll (flexnvm_config_t *config, ftfx_margin_value_t margin)
 Verifies erasure of the entire flash at a specified margin level. More...
 
status_t FLEXNVM_DflashVerifyProgram (flexnvm_config_t *config, uint32_t start, uint32_t lengthInBytes, const uint8_t *expectedData, ftfx_margin_value_t margin, uint32_t *failedAddress, uint32_t *failedData)
 Verifies programming of the desired flash area at a specified margin level. More...
 

Security

status_t FLEXNVM_GetSecurityState (flexnvm_config_t *config, ftfx_security_state_t *state)
 Returns the security state via the pointer passed into the function. More...
 
status_t FLEXNVM_SecurityBypass (flexnvm_config_t *config, const uint8_t *backdoorKey)
 Allows users to bypass security with a backdoor key. More...
 

Flash Protection Utilities

status_t FLEXNVM_DflashSetProtection (flexnvm_config_t *config, uint8_t protectStatus)
 Sets the DFlash protection to the intended protection status. More...
 
status_t FLEXNVM_DflashGetProtection (flexnvm_config_t *config, uint8_t *protectStatus)
 Gets the DFlash protection status. More...
 
status_t FLEXNVM_EepromSetProtection (flexnvm_config_t *config, uint8_t protectStatus)
 Sets the EEPROM protection to the intended protection status. More...
 
status_t FLEXNVM_EepromGetProtection (flexnvm_config_t *config, uint8_t *protectStatus)
 Gets the EEPROM protection status. More...
 

Properties

status_t FLEXNVM_GetProperty (flexnvm_config_t *config, flexnvm_property_tag_t whichProperty, uint32_t *value)
 Returns the desired flexnvm property. More...
 

Data Structure Documentation

struct _flexnvm_config

An instance of this structure is allocated by the user of the Flexnvm driver and passed into each of the driver APIs.

Typedef Documentation

An instance of this structure is allocated by the user of the Flexnvm driver and passed into each of the driver APIs.

Enumeration Type Documentation

Enumerator
kFLEXNVM_PropertyDflashSectorSize 

Dflash sector size property.

kFLEXNVM_PropertyDflashTotalSize 

Dflash total size property.

kFLEXNVM_PropertyDflashBlockSize 

Dflash block size property.

kFLEXNVM_PropertyDflashBlockCount 

Dflash block count property.

kFLEXNVM_PropertyDflashBlockBaseAddr 

Dflash block base address property.

kFLEXNVM_PropertyAliasDflashBlockBaseAddr 

Dflash block base address Alias property.

kFLEXNVM_PropertyFlexRamBlockBaseAddr 

FlexRam block base address property.

kFLEXNVM_PropertyFlexRamTotalSize 

FlexRam total size property.

kFLEXNVM_PropertyEepromTotalSize 

EEPROM total size property.

Function Documentation

status_t FLEXNVM_Init ( flexnvm_config_t config)

This function checks and initializes the Flash module for the other Flash APIs.

Parameters
configPointer to the storage for the driver runtime state.
Return values
kStatus_FTFx_SuccessAPI was executed successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_PartitionStatusUpdateFailureFailed to update the partition status.
status_t FLEXNVM_DflashErase ( flexnvm_config_t config,
uint32_t  start,
uint32_t  lengthInBytes,
uint32_t  key 
)

This function erases the appropriate number of flash sectors based on the desired start address and length.

Parameters
configThe pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be erased. The start address does not need to be sector-aligned but must be word-aligned.
lengthInBytesThe length, given in bytes (not words or long-words) to be erased. Must be word-aligned.
keyThe value used to validate all flash erase APIs.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the appropriate number of date flash sectors based on the desired start address and length were erased successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_AlignmentErrorThe parameter is not aligned with the specified baseline.
kStatus_FTFx_AddressErrorThe address is out of range.
kStatus_FTFx_EraseKeyErrorThe API erase key is invalid.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during the command execution.
status_t FLEXNVM_EraseAll ( flexnvm_config_t config,
uint32_t  key 
)
Parameters
configPointer to the storage for the driver runtime state.
keyA value used to validate all flash erase APIs.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the entire flexnvm has been erased successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_EraseKeyErrorAPI erase key is invalid.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during command execution.
kStatus_FTFx_PartitionStatusUpdateFailureFailed to update the partition status.
status_t FLEXNVM_EraseAllUnsecure ( flexnvm_config_t config,
uint32_t  key 
)
Parameters
configPointer to the storage for the driver runtime state.
keyA value used to validate all flash erase APIs.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the flexnvm is not in securityi state.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_EraseKeyErrorAPI erase key is invalid.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during command execution.
kStatus_FTFx_PartitionStatusUpdateFailureFailed to update the partition status.
status_t FLEXNVM_DflashProgram ( flexnvm_config_t config,
uint32_t  start,
uint8_t *  src,
uint32_t  lengthInBytes 
)

This function programs the flash memory with the desired data for a given flash area as determined by the start address and the length.

Parameters
configA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be programmed. Must be word-aligned.
srcA pointer to the source buffer of data that is to be programmed into the flash.
lengthInBytesThe length, given in bytes (not words or long-words), to be programmed. Must be word-aligned.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the desired date have been successfully programed into specified date flash region.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_AlignmentErrorParameter is not aligned with the specified baseline.
kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during the command execution.
status_t FLEXNVM_DflashProgramSection ( flexnvm_config_t config,
uint32_t  start,
uint8_t *  src,
uint32_t  lengthInBytes 
)

This function programs the flash memory with the desired data for a given flash area as determined by the start address and length.

Parameters
configA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be programmed. Must be word-aligned.
srcA pointer to the source buffer of data that is to be programmed into the flash.
lengthInBytesThe length, given in bytes (not words or long-words), to be programmed. Must be word-aligned.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the desired date have been successfully programed into specified date flash area.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_AlignmentErrorParameter is not aligned with specified baseline.
kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FTFx_SetFlexramAsRamErrorFailed to set flexram as RAM.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during command execution.
kStatus_FTFx_RecoverFlexramAsEepromErrorFailed to recover FlexRAM as EEPROM.
status_t FLEXNVM_ProgramPartition ( flexnvm_config_t config,
ftfx_partition_flexram_load_opt_t  option,
uint32_t  eepromDataSizeCode,
uint32_t  flexnvmPartitionCode 
)
Parameters
configPointer to storage for the driver runtime state.
optionThe option used to set FlexRAM load behavior during reset.
eepromDataSizeCodeDetermines the amount of FlexRAM used in each of the available EEPROM subsystems.
flexnvmPartitionCodeSpecifies how to split the FlexNVM block between data flash memory and EEPROM backup memory supporting EEPROM functions.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the FlexNVM block for use as data flash, EEPROM backup, or a combination of both have been Prepared.
kStatus_FTFx_InvalidArgumentInvalid argument is provided.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during command execution.
status_t FLEXNVM_DflashVerifyErase ( flexnvm_config_t config,
uint32_t  start,
uint32_t  lengthInBytes,
ftfx_margin_value_t  margin 
)

This function checks the appropriate number of flash sectors based on the desired start address and length to check whether the flash is erased to the specified read margin level.

Parameters
configA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be verified. The start address does not need to be sector-aligned but must be word-aligned.
lengthInBytesThe length, given in bytes (not words or long-words), to be verified. Must be word-aligned.
marginRead margin choice.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the specified data flash region is in erased state.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_AlignmentErrorParameter is not aligned with specified baseline.
kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during the command execution.
status_t FLEXNVM_VerifyEraseAll ( flexnvm_config_t config,
ftfx_margin_value_t  margin 
)

This function checks whether the flash is erased to the specified read margin level.

Parameters
configA pointer to the storage for the driver runtime state.
marginRead margin choice.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the entire flexnvm region is in erased state.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during the command execution.
status_t FLEXNVM_DflashVerifyProgram ( flexnvm_config_t config,
uint32_t  start,
uint32_t  lengthInBytes,
const uint8_t *  expectedData,
ftfx_margin_value_t  margin,
uint32_t *  failedAddress,
uint32_t *  failedData 
)

This function verifies the data programmed in the flash memory using the Flash Program Check Command and compares it to the expected data for a given flash area as determined by the start address and length.

Parameters
configA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be verified. Must be word-aligned.
lengthInBytesThe length, given in bytes (not words or long-words), to be verified. Must be word-aligned.
expectedDataA pointer to the expected data that is to be verified against.
marginRead margin choice.
failedAddressA pointer to the returned failing address.
failedDataA pointer to the returned failing data. Some derivatives do not include failed data as part of the FCCOBx registers. In this case, zeros are returned upon failure.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the desired data hve been programed successfully into specified data flash region.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_AlignmentErrorParameter is not aligned with specified baseline.
kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during the command execution.
status_t FLEXNVM_GetSecurityState ( flexnvm_config_t config,
ftfx_security_state_t state 
)

This function retrieves the current flash security status, including the security enabling state and the backdoor key enabling state.

Parameters
configA pointer to storage for the driver runtime state.
stateA pointer to the value returned for the current security status code:
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the security state of flexnvm was stored to state.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
status_t FLEXNVM_SecurityBypass ( flexnvm_config_t config,
const uint8_t *  backdoorKey 
)

If the MCU is in secured state, this function unsecures the MCU by comparing the provided backdoor key with ones in the flash configuration field.

Parameters
configA pointer to the storage for the driver runtime state.
backdoorKeyA pointer to the user buffer containing the backdoor key.
Return values
kStatus_FTFx_SuccessAPI was executed successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
kStatus_FTFx_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_CommandFailureRun-time error during the command execution.
status_t FLEXNVM_EepromWrite ( flexnvm_config_t config,
uint32_t  start,
uint8_t *  src,
uint32_t  lengthInBytes 
)

This function programs the emulated EEPROM with the desired data for a given flash area as determined by the start address and length.

Parameters
configA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be programmed. Must be word-aligned.
srcA pointer to the source buffer of data that is to be programmed into the flash.
lengthInBytesThe length, given in bytes (not words or long-words), to be programmed. Must be word-aligned.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the desires data have been successfully programed into specified eeprom region.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_AddressErrorAddress is out of range.
kStatus_FTFx_SetFlexramAsEepromErrorFailed to set flexram as eeprom.
kStatus_FTFx_ProtectionViolationThe program/erase operation is requested to execute on protected areas.
kStatus_FTFx_RecoverFlexramAsRamErrorFailed to recover the FlexRAM as RAM.
status_t FLEXNVM_DflashSetProtection ( flexnvm_config_t config,
uint8_t  protectStatus 
)
Parameters
configA pointer to the storage for the driver runtime state.
protectStatusThe expected protect status to set to the DFlash protection register. Each bit corresponds to the protection of the 1/8 of the total DFlash. The least significant bit corresponds to the lowest address area of the DFlash. The most significant bit corresponds to the highest address area of the DFlash. There are two possible cases as shown below: 0: this area is protected. 1: this area is unprotected.
Return values
kStatus_FTFx_SuccessAPI was executed successfully; the specified DFlash region is protected.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_CommandNotSupportedFlash API is not supported.
kStatus_FTFx_CommandFailureRun-time error during command execution.
status_t FLEXNVM_DflashGetProtection ( flexnvm_config_t config,
uint8_t *  protectStatus 
)
Parameters
configA pointer to the storage for the driver runtime state.
protectStatusDFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the 1/8 of the total DFlash. The least significant bit corresponds to the lowest address area of the DFlash. The most significant bit corresponds to the highest address area of the DFlash, and so on. There are two possible cases as below: 0: this area is protected. 1: this area is unprotected.
Return values
kStatus_FTFx_SuccessAPI was executed successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_CommandNotSupportedFlash API is not supported.
status_t FLEXNVM_EepromSetProtection ( flexnvm_config_t config,
uint8_t  protectStatus 
)
Parameters
configA pointer to the storage for the driver runtime state.
protectStatusThe expected protect status to set to the EEPROM protection register. Each bit corresponds to the protection of the 1/8 of the total EEPROM. The least significant bit corresponds to the lowest address area of the EEPROM. The most significant bit corresponds to the highest address area of EEPROM, and so on. There are two possible cases as shown below: 0: this area is protected. 1: this area is unprotected.
Return values
kStatus_FTFx_SuccessAPI was executed successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_CommandNotSupportedFlash API is not supported.
kStatus_FTFx_CommandFailureRun-time error during command execution.
status_t FLEXNVM_EepromGetProtection ( flexnvm_config_t config,
uint8_t *  protectStatus 
)
Parameters
configA pointer to the storage for the driver runtime state.
protectStatusDFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the 1/8 of the total EEPROM. The least significant bit corresponds to the lowest address area of the EEPROM. The most significant bit corresponds to the highest address area of the EEPROM. There are two possible cases as below: 0: this area is protected. 1: this area is unprotected.
Return values
kStatus_FTFx_SuccessAPI was executed successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_CommandNotSupportedFlash API is not supported.
status_t FLEXNVM_GetProperty ( flexnvm_config_t config,
flexnvm_property_tag_t  whichProperty,
uint32_t *  value 
)
Parameters
configA pointer to the storage for the driver runtime state.
whichPropertyThe desired property from the list of properties in enum flexnvm_property_tag_t
valueA pointer to the value returned for the desired flexnvm property.
Return values
kStatus_FTFx_SuccessAPI was executed successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_UnknownPropertyAn unknown property tag.