MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The flash driver provides general APIs to handle specific operations on chip flash; The user can use those APIs directly in the application. The flash supports:
Driver Overview | |
Driver Change Log | |
The current FLASH driver version is 3.0.0. | |
Data Structures | |
struct | flash_swap_state_config_t |
Flash Swap information. More... | |
struct | flash_spec_mem_t |
ftfx special memory access information. More... | |
struct | flash_mem_desc_t |
Flash memory descriptor. More... | |
struct | flash_ops_config_t |
Active FTFx information for the current operation. More... | |
struct | flash_ifr_desc_t |
Flash IFR memory descriptor. More... | |
struct | ftfx_config_t |
Flash driver state information. More... | |
Macros | |
#define | MAKE_STATUS(group, code) ((((group)*100) + (code))) |
Construct a status code value from a group and code number. More... | |
#define | FTFx_FLASH_COUNT 1 |
Flash driver state information. More... | |
Flash version | |
enum | _flash_driver_version_constants { kFLASH_DriverVersionName = 'F', kFLASH_DriverVersionMajor = 3, kFLASH_DriverVersionMinor = 0, kFLASH_DriverVersionBugfix = 0 } |
Flash driver version for ROM. More... | |
#define | FSL_FLASH_DRIVER_VERSION (MAKE_VERSION(3U, 0U, 0U)) |
Flash driver version for SDK. More... | |
#define | FSL_FLASH_DRIVER_VERSION_ROM (MAKE_VERSION(3U, 0U, 0U)) |
Flash driver version for ROM. More... | |
Initialization | |
flash_status_t | FLASH_Init (flash_config_t *config) |
Initializes the global flash properties structure members. More... | |
Properties | |
flash_status_t | FLASH_GetProperty (flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value) |
Returns the desired flash property. More... | |
Erasing | |
flash_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... | |
flash_status_t | FLASH_EraseAll (flash_config_t *config, uint32_t key) |
Erases entire flash, after done flash is on security status. More... | |
flash_status_t | FLASH_EraseAllUnsecure (flash_config_t *config, uint32_t key) |
Erases the entire flash, after done flash is on unsecurity status. More... | |
Programming | |
flash_status_t | FLASH_ProgramSection (flash_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... | |
flash_status_t | FLASH_ProgramOnce (ftfx_config_t *config, uint32_t index, uint8_t *src, uint32_t lengthInBytes) |
Programs Program Once Field through parameters. More... | |
Verification | |
flash_status_t | FLASH_VerifyErase (flash_config_t *config, uint32_t start, uint32_t lengthInBytes, flash_margin_value_t margin) |
Verifies an erasure of the desired flash area at a specified margin level. More... | |
flash_status_t | FLASH_VerifyEraseAll (flash_config_t *config, flash_margin_value_t margin) |
Verifies erasure of the entire flash at a specified margin level. More... | |
flash_status_t | FLASH_VerifyProgram (flash_config_t *config, uint32_t start, uint32_t lengthInBytes, const uint8_t *expectedData, flash_margin_value_t margin, uint32_t *failedAddress, uint32_t *failedData) |
Verifies programming of the desired flash area at a specified margin level. More... | |
Security | |
flash_status_t | FLASH_GetSecurityState (flash_config_t *config, flash_security_state_t *state) |
Returns the security state via the pointer passed into the function. More... | |
flash_status_t | FLASH_SecurityBypass (flash_config_t *config, const uint8_t *backdoorKey) |
Allows users to bypass security with a backdoor key. More... | |
Reading | |
flash_status_t | FLASH_ReadOnce (ftfx_config_t *config, uint32_t index, uint8_t *dst, uint32_t lengthInBytes) |
Reads the Program Once Field through parameters. More... | |
flash_status_t | FLASH_ReadResource (flash_config_t *config, uint32_t start, uint8_t *dst, uint32_t lengthInBytes, flash_read_resource_opt_t option) |
Reads the resource with data at locations passed in through parameters. More... | |
Swap | |
flash_status_t | FLASH_Swap (flash_config_t *config, uint32_t address, uint8_t isSetEnable) |
Swaps the lower half flash with the higher half flash. More... | |
struct flash_swap_state_config_t |
Data Fields | |
flash_swap_state_t | flashSwapState |
The current Swap system status. More... | |
flash_swap_block_status_t | currentSwapBlockStatus |
The current Swap block status. More... | |
flash_swap_block_status_t | nextSwapBlockStatus |
The next Swap block status. More... | |
flash_swap_state_t flash_swap_state_config_t::flashSwapState |
flash_swap_block_status_t flash_swap_state_config_t::currentSwapBlockStatus |
flash_swap_block_status_t flash_swap_state_config_t::nextSwapBlockStatus |
struct flash_spec_mem_t |
struct flash_mem_desc_t |
Data Fields | |
uint8_t | type |
Type of flash block. More... | |
uint8_t | index |
Index of flash block. More... | |
uint32_t | blockBase |
A base address of the flash block. | |
uint32_t | totalSize |
The size of the flash block. More... | |
uint32_t | sectorSize |
The size in bytes of a sector of flash. More... | |
uint32_t | blockCount |
A number of flash blocks. More... | |
uint8_t flash_mem_desc_t::type |
uint8_t flash_mem_desc_t::index |
uint32_t flash_mem_desc_t::totalSize |
uint32_t flash_mem_desc_t::sectorSize |
uint32_t flash_mem_desc_t::blockCount |
struct flash_ops_config_t |
Data Fields | |
uint32_t | convertedAddress |
A converted address for the current flash type. More... | |
uint32_t flash_ops_config_t::convertedAddress |
struct flash_ifr_desc_t |
struct ftfx_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 | flexramBlockBase |
The base address of the FlexRAM/acceleration RAM. | |
uint32_t | flexramTotalSize |
The size of the FlexRAM/acceleration RAM. | |
uint16_t | eepromTotalSize |
The size of EEPROM area which was partitioned from FlexRAM. | |
uint32_t * | runCmdFuncAddr |
An buffer point to the flash execute-in-RAM function. More... | |
uint32_t* ftfx_config_t::runCmdFuncAddr |
#define FSL_FLASH_DRIVER_VERSION (MAKE_VERSION(3U, 0U, 0U)) |
Version 3.0.0.
#define FSL_FLASH_DRIVER_VERSION_ROM (MAKE_VERSION(3U, 0U, 0U)) |
Version 3.0.0.
#define MAKE_STATUS | ( | group, | |
code | |||
) | ((((group)*100) + (code))) |
#define FTFx_FLASH_COUNT 1 |
An instance of this structure is allocated by the user of the flash driver and passed into each of the driver APIs.
enum flash_margin_value_t |
enum flash_swap_state_t |
enum flash_property_tag_t |
enum _flash_status |
flash_status_t FLASH_Init | ( | flash_config_t * | config | ) |
This function checks and initializes the Flash module for the other Flash APIs.
config | Pointer to the storage for the driver runtime state. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
flash_status_t FLASH_GetProperty | ( | flash_config_t * | config, |
flash_property_tag_t | whichProperty, | ||
uint32_t * | value | ||
) |
config | A pointer to the storage for the driver runtime state. |
whichProperty | The desired property from the list of properties in enum flash_property_tag_t |
value | A pointer to the value returned for the desired flash property. |
kStatus_FLASH_Success | API was executed successfully; the flash property was stored to value. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_UnknownProperty | An unknown property tag. |
config | A pointer to the storage for the driver runtime state. |
whichProperty | The desired property from the list of properties in enum flash_property_tag_t |
value | A pointer to the value returned for the desired flash property. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_UnknownProperty | An unknown property tag. |
flash_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.
config | The pointer to the storage for the driver runtime state. |
start | The start address of the desired flash memory to be erased. The start address does not need to be sector-aligned but must be phrase-aligned (64 bits). |
lengthInBytes | The length, given in bytes (not words or long-words) to be erased. Must be phrase-aligned (64 bits). |
key | The value used to validate all flash erase APIs. Use kFLASH_ApiEraseKey here. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AlignmentError | The parameter is not aligned with the specified baseline. |
kStatus_FLASH_AddressError | The address is out of range. |
kStatus_FLASH_EraseKeyError | The API erase key is invalid. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_EraseAll | ( | flash_config_t * | config, |
uint32_t | key | ||
) |
config | Pointer to the storage for the driver runtime state. |
key | A value used to validate all flash erase APIs. Use kFLASH_ApiEraseKey here. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_EraseKeyError | API erase key is invalid. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during command execution. |
flash_status_t FLASH_EraseAllUnsecure | ( | flash_config_t * | config, |
uint32_t | key | ||
) |
config | Pointer to the storage for the driver runtime state. |
key | A value used to validate all flash erase APIs. Use kFLASH_ApiEraseKey here. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_EraseKeyError | API erase key is invalid. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during command execution. |
flash_status_t FLASH_ProgramSection | ( | 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 length.
config | A pointer to the storage for the driver runtime state. |
start | The start address of the desired flash memory to be programmed. Must be phrase-aligned (64 bits). |
src | A pointer to the source buffer of data that is to be programmed into the flash. |
lengthInBytes | The length, given in bytes (not words or long-words), to be programmed. Must be phrase-aligned (64 bits). |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AlignmentError | Parameter is not aligned with specified baseline. |
kStatus_FLASH_AddressError | Address is out of range. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during command execution. |
flash_status_t FLASH_ProgramOnce | ( | ftfx_config_t * | config, |
uint32_t | index, | ||
uint8_t * | src, | ||
uint32_t | lengthInBytes | ||
) |
This function programs the Program Once Field with the desired data for a given flash area as determined by the index and length.
config | A pointer to the storage for the driver runtime state. |
index | The index indicating which area of the Program Once Field to be programmed.Index is 0~7. |
src | A pointer to the source buffer of data that is to be programmed into the Program Once Field. |
lengthInBytes | The length, given in bytes (not words or long-words), to be programmed. Must be phrase-aligned (64 bits). This value is ignored, it's always 8 bytes that are written into specified IFR area. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_VerifyErase | ( | flash_config_t * | config, |
uint32_t | start, | ||
uint32_t | lengthInBytes, | ||
flash_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.
config | A pointer to the storage for the driver runtime state. |
start | The start address of the desired flash memory to be verified. The start address does not need to be sector-aligned but must be phrase-aligned (64 bits). |
lengthInBytes | The length, given in bytes (not words or long-words), to be verified. Must be phrase-aligned (64 bits). |
margin | Read margin choice. Choose from the members in flash_margin_value_t. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AlignmentError | Parameter is not aligned with specified baseline. |
kStatus_FLASH_AddressError | Address is out of range. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_VerifyEraseAll | ( | flash_config_t * | config, |
flash_margin_value_t | margin | ||
) |
This function checks whether the flash is erased to the specified read margin level.
config | A pointer to the storage for the driver runtime state. |
margin | Read margin choice. Choose from the members in flash_margin_value_t. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_VerifyProgram | ( | flash_config_t * | config, |
uint32_t | start, | ||
uint32_t | lengthInBytes, | ||
const uint8_t * | expectedData, | ||
flash_margin_value_t | margin, | ||
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.
config | A pointer to the storage for the driver runtime state. |
start | The start address of the desired flash memory to be verified. Must be longword-aligned (32 bits). |
lengthInBytes | The length, given in bytes (not words or long-words), to be verified. Must be longword-aligned (32 bits). |
expectedData | A pointer to the expected data that is to be verified against. |
margin | Read margin choice. Choose from the members in flash_margin_value_t. "kFLASH_MarginValueNormal" is not for this command. |
failedAddress | A pointer to the returned failing address, which is used by PGMCHK command. So it's always longword-aligned. |
failedData | A 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. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AlignmentError | Parameter is not aligned with specified baseline. |
kStatus_FLASH_AddressError | Address is out of range. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_GetSecurityState | ( | flash_config_t * | config, |
flash_security_state_t * | state | ||
) |
This function retrieves the current flash security status, including the security enabling state and the backdoor key enabling state.
config | A pointer to storage for the driver runtime state. |
state | A pointer to the value returned for the current security status code: one of the members in flash_security_state_t. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
flash_status_t FLASH_SecurityBypass | ( | flash_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.
config | A pointer to the storage for the driver runtime state. |
backdoorKey | A pointer to the user buffer containing the backdoor key. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_ReadOnce | ( | ftfx_config_t * | config, |
uint32_t | index, | ||
uint8_t * | dst, | ||
uint32_t | lengthInBytes | ||
) |
This function reads the read once feild with given index and length.
config | A pointer to the storage for the driver runtime state. |
index | The index indicating the area of program once field to be read. Index is 0~7. |
dst | A pointer to the destination buffer of data that is used to store data to be read. |
lengthInBytes | The length, given in bytes (not words or long-words), to be programmed. This value is ignored, it's always 8 bytes that are read out from the specified IFR area. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_ReadResource | ( | flash_config_t * | config, |
uint32_t | start, | ||
uint8_t * | dst, | ||
uint32_t | lengthInBytes, | ||
flash_read_resource_opt_t | option | ||
) |
This function reads the flash memory with the desired location for a given flash area as determined by the start address and length.
config | A pointer to the storage for the driver runtime state. |
start | The start address of the desired flash memory resource to be read. Must be phrase-aligned (64 bits). |
dst | A pointer to the destination buffer of data that is used to store data to be read. |
lengthInBytes | The length, given in bytes (not words or long-words), to be read. Must be phrase-aligned (64 bits). When option is "kFLASH_ResourceOptionFlashIfr", lengthInBytes can't be larger than 64. When option is "kFLASH_ResourceOptionVersionId", lengthInBytes should be set to 8. |
option | The resource option which indicates which area should be read back. Choose from "kFLASH_ResourceOptionFlashIfr" and "kFLASH_ResourceOptionVersionId". |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AlignmentError | Parameter is not aligned with the specified baseline. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds addresses. |
kStatus_FLASH_ProtectionViolation | The program/erase operation is requested to execute on protected areas. |
kStatus_FLASH_CommandFailure | Run-time error during the command execution. |
flash_status_t FLASH_Swap | ( | flash_config_t * | config, |
uint32_t | address, | ||
uint8_t | isSetEnable | ||
) |
config | A pointer to the storage for the driver runtime state. |
address | Address used to configure the flash swap function |
isSetEnable | The possible option used to configure the Flash Swap function or check the flash Swap status. |
kStatus_FLASH_Success | API was executed successfully. |
kStatus_FLASH_InvalidArgument | An invalid argument is provided. |
kStatus_FLASH_AlignmentError | Parameter is not aligned with specified baseline. |
kStatus_FLASH_SwapIndicatorAddressError | Swap indicator address is invalid. |
kStatus_FLASH_AccessError | Invalid instruction codes and out-of bounds 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_SwapSystemNotInUninitialized | Swap system is not in an uninitialzed state. |