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

Overview

Files

file  fsl_iap.h
 

Data Structures

struct  flash_ecc_log_t
 Flash ECC log info. More...
 
struct  flash_mode_config_t
 Flash controller paramter config. More...
 
struct  flash_ffr_config_t
 Flash controller paramter config. More...
 
struct  flash_config_t
 Flash driver state information. More...
 

Enumerations

enum  flash_property_tag_t {
  kFLASH_PropertyPflashSectorSize = 0x00U,
  kFLASH_PropertyPflashTotalSize = 0x01U,
  kFLASH_PropertyPflashBlockSize = 0x02U,
  kFLASH_PropertyPflashBlockCount = 0x03U,
  kFLASH_PropertyPflashBlockBaseAddr = 0x04U,
  kFLASH_PropertyPflashPageSize = 0x30U,
  kFLASH_PropertyPflashSystemFreq = 0x31U,
  kFLASH_PropertyFfrSectorSize = 0x40U,
  kFLASH_PropertyFfrTotalSize = 0x41U,
  kFLASH_PropertyFfrBlockBaseAddr = 0x42U,
  kFLASH_PropertyFfrPageSize = 0x43U
}
 Enumeration for various flash properties. More...
 
enum  _flash_max_erase_page_value { kFLASH_MaxPagesToErase = 100U }
 Enumeration for flash max pages to erase. More...
 
enum  _flash_alignment_property {
  kFLASH_AlignementUnitVerifyErase = 4,
  kFLASH_AlignementUnitProgram = 512,
  kFLASH_AlignementUnitSingleWordRead = 16
}
 Enumeration for flash alignment property. More...
 
enum  _flash_read_ecc_option { , kFLASH_ReadWithEccOff = 1 }
 Enumeration for flash read ecc option. More...
 
enum  _flash_read_margin_option {
  kFLASH_ReadMarginNormal = 0,
  kFLASH_ReadMarginVsProgram = 1,
  kFLASH_ReadMarginVsErase = 2,
  kFLASH_ReadMarginIllegalBitCombination = 3
}
 Enumeration for flash read margin option. More...
 
enum  _flash_read_dmacc_option {
  kFLASH_ReadDmaccDisabled = 0,
  kFLASH_ReadDmaccEnabled = 1
}
 Enumeration for flash read dmacc option. More...
 
enum  _flash_ramp_control_option {
  kFLASH_RampControlDivisionFactorReserved = 0,
  kFLASH_RampControlDivisionFactor256 = 1,
  kFLASH_RampControlDivisionFactor128 = 2,
  kFLASH_RampControlDivisionFactor64 = 3
}
 Enumeration for flash ramp control option. More...
 

Variables

uint32_t flash_config_t::PFlashBlockBase
 A base address of the first PFlash block.
 
uint32_t flash_config_t::PFlashTotalSize
 The size of the combined PFlash block. More...
 
uint32_t flash_config_t::PFlashBlockCount
 A number of PFlash blocks. More...
 
uint32_t flash_config_t::PFlashPageSize
 The size in bytes of a page of PFlash. More...
 
uint32_t flash_config_t::PFlashSectorSize
 The size in bytes of a sector of PFlash. More...
 

Flash version

enum  _flash_driver_version_constants {
  kFLASH_DriverVersionName = 'F',
  kFLASH_DriverVersionMajor = 2,
  kFLASH_DriverVersionMinor = 0,
  kFLASH_DriverVersionBugfix = 0
}
 Flash driver version for ROM. More...
 
#define MAKE_VERSION(major, minor, bugfix)   (((major) << 16) | ((minor) << 8) | (bugfix))
 Constructs the version number for drivers. More...
 
#define FSL_FLASH_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 Flash driver version for SDK. More...
 

Flash configuration

#define FSL_FEATURE_FLASH_IP_IS_C040HD_ATFC   (1)
 Flash IP Type. More...
 
#define FSL_FEATURE_FLASH_IP_IS_C040HD_FC   (0)
 

Flash status

enum  _flash_status {
  kStatus_FLASH_Success = MAKE_STATUS(kStatusGroupGeneric, 0),
  kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4),
  kStatus_FLASH_SizeError = MAKE_STATUS(kStatusGroupFlashDriver, 0),
  kStatus_FLASH_AlignmentError,
  kStatus_FLASH_AddressError = MAKE_STATUS(kStatusGroupFlashDriver, 2),
  kStatus_FLASH_AccessError,
  kStatus_FLASH_ProtectionViolation,
  kStatus_FLASH_CommandFailure,
  kStatus_FLASH_UnknownProperty = MAKE_STATUS(kStatusGroupFlashDriver, 6),
  kStatus_FLASH_EraseKeyError = MAKE_STATUS(kStatusGroupFlashDriver, 7),
  kStatus_FLASH_RegionExecuteOnly,
  kStatus_FLASH_ExecuteInRamFunctionNotReady,
  kStatus_FLASH_CommandNotSupported = MAKE_STATUS(kStatusGroupFlashDriver, 11),
  kStatus_FLASH_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFlashDriver, 12),
  kStatus_FLASH_InvalidPropertyValue,
  kStatus_FLASH_InvalidSpeculationOption,
  kStatus_FLASH_EccError,
  kStatus_FLASH_CompareError,
  kStatus_FLASH_RegulationLoss = MAKE_STATUS(kStatusGroupFlashDriver, 0x12),
  kStatus_FLASH_InvalidWaitStateCycles,
  kStatus_FLASH_OutOfDateCfpaPage,
  kStatus_FLASH_BlankIfrPageData = MAKE_STATUS(kStatusGroupFlashDriver, 0x21),
  kStatus_FLASH_EncryptedRegionsEraseNotDoneAtOnce,
  kStatus_FLASH_ProgramVerificationNotAllowed,
  kStatus_FLASH_HashCheckError,
  kStatus_FLASH_SealedFfrRegion = MAKE_STATUS(kStatusGroupFlashDriver, 0x25),
  kStatus_FLASH_FfrRegionWriteBroken,
  kStatus_FLASH_NmpaAccessNotAllowed,
  kStatus_FLASH_CmpaCfgDirectEraseNotAllowed,
  kStatus_FLASH_FfrBankIsLocked = MAKE_STATUS(kStatusGroupFlashDriver, 0x29)
}
 Flash driver status codes. More...
 
#define kStatusGroupGeneric   0
 Flash driver status group. More...
 
#define kStatusGroupFlashDriver   1
 
#define MAKE_STATUS(group, code)   ((((group)*100) + (code)))
 Constructs a status code value from a group and a code number. More...
 

Flash API key

enum  _flash_driver_api_keys { kFLASH_ApiEraseKey = FOUR_CHAR_CODE('l', 'f', 'e', 'k') }
 Enumeration for Flash driver API keys. More...
 
#define FOUR_CHAR_CODE(a, b, c, d)   (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a)))
 Constructs the four character code for the Flash driver API key. More...
 

Initialization

status_t FLASH_Init (flash_config_t *config)
 Initializes the global flash properties structure members. More...
 

Erasing

status_t FLASH_Erase (flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
 Erases the flash sectors encompassed by parameters passed into function. More...
 

Programming

status_t FLASH_Program (flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)
 Programs flash with data at locations passed in through parameters. More...
 

Verification

status_t FLASH_VerifyErase (flash_config_t *config, uint32_t start, uint32_t lengthInBytes)
 Verifies an erasure of the desired flash area at a specified margin level. More...
 
status_t FLASH_VerifyProgram (flash_config_t *config, uint32_t start, uint32_t lengthInBytes, const uint8_t *expectedData, uint32_t *failedAddress, uint32_t *failedData)
 Verifies programming of the desired flash area at a specified margin level. More...
 

Properties

status_t FLASH_GetProperty (flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value)
 Returns the desired flash property. More...
 

Data Structure Documentation

struct flash_ecc_log_t
struct flash_mode_config_t
struct flash_ffr_config_t
struct flash_config_t

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

Data Fields

uint32_t PFlashBlockBase
 A base address of the first PFlash block.
 
uint32_t PFlashTotalSize
 The size of the combined PFlash block. More...
 
uint32_t PFlashBlockCount
 A number of PFlash blocks. More...
 
uint32_t PFlashPageSize
 The size in bytes of a page of PFlash. More...
 
uint32_t PFlashSectorSize
 The size in bytes of a sector of PFlash. More...
 

Macro Definition Documentation

#define MAKE_VERSION (   major,
  minor,
  bugfix 
)    (((major) << 16) | ((minor) << 8) | (bugfix))
#define FSL_FLASH_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Version 2.0.0.

#define FSL_FEATURE_FLASH_IP_IS_C040HD_ATFC   (1)
#define kStatusGroupGeneric   0
#define MAKE_STATUS (   group,
  code 
)    ((((group)*100) + (code)))
#define FOUR_CHAR_CODE (   a,
  b,
  c,
 
)    (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a)))

Enumeration Type Documentation

Enumerator
kFLASH_DriverVersionName 

Flash driver version name.

kFLASH_DriverVersionMajor 

Major flash driver version.

kFLASH_DriverVersionMinor 

Minor flash driver version.

kFLASH_DriverVersionBugfix 

Bugfix for flash driver version.

Enumerator
kStatus_FLASH_Success 

API is executed successfully.

kStatus_FLASH_InvalidArgument 

Invalid argument.

kStatus_FLASH_SizeError 

Error size.

kStatus_FLASH_AlignmentError 

Parameter is not aligned with the specified baseline.

kStatus_FLASH_AddressError 

Address is out of range.

kStatus_FLASH_AccessError 

Invalid instruction codes and out-of bound addresses.

kStatus_FLASH_ProtectionViolation 

The program/erase operation is requested to execute on protected areas.

kStatus_FLASH_CommandFailure 

Run-time error during command execution.

kStatus_FLASH_UnknownProperty 

Unknown property.

kStatus_FLASH_EraseKeyError 

API erase key is invalid.

kStatus_FLASH_RegionExecuteOnly 

The current region is execute-only.

kStatus_FLASH_ExecuteInRamFunctionNotReady 

Execute-in-RAM function is not available.

kStatus_FLASH_CommandNotSupported 

Flash API is not supported.

kStatus_FLASH_ReadOnlyProperty 

The flash property is read-only.

kStatus_FLASH_InvalidPropertyValue 

The flash property value is out of range.

kStatus_FLASH_InvalidSpeculationOption 

The option of flash prefetch speculation is invalid.

kStatus_FLASH_EccError 

A correctable or uncorrectable error during command execution.

kStatus_FLASH_CompareError 

Destination and source memory contents do not match.

kStatus_FLASH_RegulationLoss 

A loss of regulation during read.

kStatus_FLASH_InvalidWaitStateCycles 

The wait state cycle set to r/w mode is invalid.

kStatus_FLASH_OutOfDateCfpaPage 

CFPA page version is out of date.

kStatus_FLASH_BlankIfrPageData 

Blank page cannnot be read.

kStatus_FLASH_EncryptedRegionsEraseNotDoneAtOnce 

Encrypted flash subregions are not erased at once.

kStatus_FLASH_ProgramVerificationNotAllowed 

Program verification is not allowed when the encryption is enabled.

kStatus_FLASH_HashCheckError 

Hash check of page data is failed.

kStatus_FLASH_SealedFfrRegion 

The FFR region is sealed.

kStatus_FLASH_FfrRegionWriteBroken 

The FFR Spec region is not allowed to be written discontinuously.

kStatus_FLASH_NmpaAccessNotAllowed 

The NMPA region is not allowed to be read/written/erased.

kStatus_FLASH_CmpaCfgDirectEraseNotAllowed 

The CMPA Cfg region is not allowed to be erased directly.

kStatus_FLASH_FfrBankIsLocked 

The FFR bank region is locked.

Note
The resulting value is built with a byte order such that the string being readable in expected order when viewed in a hex editor, if the value is treated as a 32-bit little endian value.
Enumerator
kFLASH_ApiEraseKey 

Key value used to validate all flash erase APIs.

Enumerator
kFLASH_PropertyPflashSectorSize 

Pflash sector size property.

kFLASH_PropertyPflashTotalSize 

Pflash total size property.

kFLASH_PropertyPflashBlockSize 

Pflash block size property.

kFLASH_PropertyPflashBlockCount 

Pflash block count property.

kFLASH_PropertyPflashBlockBaseAddr 

Pflash block base address property.

kFLASH_PropertyPflashPageSize 

Pflash page size property.

kFLASH_PropertyPflashSystemFreq 

System Frequency System Frequency.

kFLASH_PropertyFfrSectorSize 

FFR sector size property.

kFLASH_PropertyFfrTotalSize 

FFR total size property.

kFLASH_PropertyFfrBlockBaseAddr 

FFR block base address property.

kFLASH_PropertyFfrPageSize 

FFR page size property.

Enumerator
kFLASH_MaxPagesToErase 

The max value in pages to erase.

Enumerator
kFLASH_AlignementUnitVerifyErase 

The alignment unit in bytes used for verify erase operation.

kFLASH_AlignementUnitProgram 

The alignment unit in bytes used for program operation.

kFLASH_AlignementUnitSingleWordRead 

The alignment unit in bytes used for verify program operation.

The alignment unit in bytes used for SingleWordRead command.

Enumerator
kFLASH_ReadWithEccOff 

ECC is on.

Enumerator
kFLASH_ReadMarginNormal 

Normal read.

kFLASH_ReadMarginVsProgram 

Margin vs.

program

kFLASH_ReadMarginVsErase 

Margin vs.

erase

kFLASH_ReadMarginIllegalBitCombination 

Illegal bit combination.

Enumerator
kFLASH_ReadDmaccDisabled 

Memory word.

kFLASH_ReadDmaccEnabled 

DMACC word.

Enumerator
kFLASH_RampControlDivisionFactorReserved 

Reserved.

kFLASH_RampControlDivisionFactor256 

clk48mhz / 256 = 187.5KHz

kFLASH_RampControlDivisionFactor128 

clk48mhz / 128 = 375KHz

kFLASH_RampControlDivisionFactor64 

clk48mhz / 64 = 750KHz

Function Documentation

status_t FLASH_Init ( flash_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_FLASH_SuccessAPI was executed successfully.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandNotSupportedFlash API is not supported.
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
status_t FLASH_Erase ( flash_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.
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_FLASH_SuccessAPI was executed successfully.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
kStatus_FLASH_AlignmentErrorThe parameter is not aligned with the specified baseline.
kStatus_FLASH_AddressErrorThe address is out of range.
kStatus_FLASH_EraseKeyErrorThe API erase key is invalid.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandNotSupportedFlash API is not supported.
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
status_t FLASH_Program ( flash_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_FLASH_SuccessAPI was executed successfully.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
kStatus_FLASH_AlignmentErrorParameter is not aligned with the specified baseline.
kStatus_FLASH_AddressErrorAddress is out of range.
kStatus_FLASH_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandNotSupportedFlash API is not supported.
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
status_t FLASH_VerifyErase ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes 
)

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_FLASH_SuccessAPI was executed successfully.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
kStatus_FLASH_AlignmentErrorParameter is not aligned with specified baseline.
kStatus_FLASH_AddressErrorAddress is out of range.
kStatus_FLASH_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandNotSupportedFlash API is not supported.
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
status_t FLASH_VerifyProgram ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes,
const uint8_t *  expectedData,
uint32_t *  failedAddress,
uint32_t *  failedData 
)

This function verifies the data programed 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_FLASH_SuccessAPI was executed successfully.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
kStatus_FLASH_AlignmentErrorParameter is not aligned with specified baseline.
kStatus_FLASH_AddressErrorAddress is out of range.
kStatus_FLASH_AccessErrorInvalid instruction codes and out-of bounds addresses.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandFailureRun-time error during the command execution.
kStatus_FLASH_CommandNotSupportedFlash API is not supported.
kStatus_FLASH_EccErrorA correctable or uncorrectable error during command execution.
status_t FLASH_GetProperty ( flash_config_t config,
flash_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 flash_property_tag_t
valueA pointer to the value returned for the desired flash property.
Return values
kStatus_FLASH_SuccessAPI was executed successfully.
kStatus_FLASH_InvalidArgumentAn invalid argument is provided.
kStatus_FLASH_UnknownPropertyAn unknown property tag.

Variable Documentation

uint32_t flash_config_t::PFlashTotalSize
uint32_t flash_config_t::PFlashBlockCount
uint32_t flash_config_t::PFlashPageSize
uint32_t flash_config_t::PFlashSectorSize