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

Overview

The ROMAPI driver provides the functionalities to operate the internal Flash.

The ROMAPI driver provides the functionalities to operate the Flash and ROM.

Data Structures

struct  flash_ffr_config_t
 Flash controller paramter config. More...
 
struct  flash_config_t
 Flash driver state information. More...
 
struct  flash_driver_interface_t
 Interface for the flash driver. More...
 
struct  bootloader_tree_t
 Root of the bootloader API tree. More...
 

Macros

#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...
 
#define ROM_API_BASE   (0x03003fe0u)
 
#define ROM_API   ((bootloader_tree_t *)ROM_API_BASE)
 
#define FLASH_API   (ROM_API->flash_driver)
 

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_driver_api_keys { kFLASH_ApiEraseKey = FOUR_CHAR_CODE('l', 'f', 'e', 'k') }
 Enumeration for Flash driver API keys. More...
 

Driver version

#define FSL_ROMAPI_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 romapi driver version 2.0.0. More...
 

Flash status

enum  {
  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)
}
 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

static status_t FLASH_Init (flash_config_t *config)
 Initializes the global flash properties structure members. More...
 
static status_t FLASH_EraseSector (flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
 Erases the flash sectors encompassed by parameters passed into function. More...
 
static status_t FLASH_ProgramPhrase (flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)
 Programs flash phrases with data at locations passed in through parameters. More...
 
static status_t FLASH_ProgramPage (flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)
 Programs flash page with data at locations passed in through parameters. More...
 
static 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. More...
 
static status_t FLASH_VerifyErasePhrase (flash_config_t *config, uint32_t start, uint32_t lengthInBytes)
 Verify that the flash phrases are erased. More...
 
static status_t FLASH_VerifyErasePage (flash_config_t *config, uint32_t start, uint32_t lengthInBytes)
 Verify that the flash pages are erased. More...
 
static status_t FLASH_VerifyEraseSector (flash_config_t *config, uint32_t start, uint32_t lengthInBytes)
 Verify that the flash sectors are erased. More...
 
static status_t FLASH_GetProperty (flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value)
 Returns the desired flash property. More...
 
static status_t IFR_VerifyErasePhrase (flash_config_t *config, uint32_t start, uint32_t lengthInBytes)
 Verify that the IFR0 phrases are erased. More...
 
static status_t IFR_VerifyErasePage (flash_config_t *config, uint32_t start, uint32_t lengthInBytes)
 Verify that the IFR0 pages are erased. More...
 
static status_t IFR_VerifyEraseSector (flash_config_t *config, uint32_t start, uint32_t lengthInBytes)
 Verify that the IFR0 sectors are erased. More...
 
static status_t FLASH_Read (flash_config_t *config, uint32_t start, uint8_t *dest, uint32_t lengthInBytes)
 Reads flash at locations passed in through parameters. More...
 
static uint32_t ROMAPI_GetVersion (void)
 Get ROM API version. More...
 
static void ROMAPI_RunBootloader (void *arg)
 Run the Bootloader API to force into the ISP mode base on the user arg. More...
 
static void ROMAPI_GetUUID (uint8_t *uuid)
 Get the UUID. More...
 

Data Structure Documentation

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...
 

Field 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
struct flash_driver_interface_t
struct bootloader_tree_t

An instance of this struct resides in read-only memory in the bootloader. It provides a user application access to APIs exported by the bootloader.

Data Fields

void(* run_bootloader )(void *arg)
 Function to start the bootloader executing. More...
 
const flash_driver_interface_tflash_driver
 Internal Flash driver API. More...
 

Field Documentation

void(* bootloader_tree_t::run_bootloader)(void *arg)
const flash_driver_interface_t* bootloader_tree_t::flash_driver

Macro Definition Documentation

#define FSL_ROMAPI_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
#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)))
#define ROM_API_BASE   (0x03003fe0u)

ROM API base address

#define ROM_API   ((bootloader_tree_t *)ROM_API_BASE)

ROM API base pointer

#define FLASH_API   (ROM_API->flash_driver)

FLASH API base pointer

Enumeration Type Documentation

anonymous enum
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.

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 property.

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.

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.

Function Documentation

static status_t FLASH_Init ( flash_config_t config)
inlinestatic

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

Parameters
configPointer to the storage for the driver runtime state.
static status_t FLASH_EraseSector ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes,
uint32_t  key 
)
inlinestatic

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. NOTE: The start address need to be 4 Bytes-aligned.
lengthInBytesThe length, given in bytes need be 4 Bytes-aligned.
keyThe value used to validate all flash erase APIs.
static status_t FLASH_ProgramPhrase ( flash_config_t config,
uint32_t  start,
uint8_t *  src,
uint32_t  lengthInBytes 
)
inlinestatic

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.
static status_t FLASH_ProgramPage ( flash_config_t config,
uint32_t  start,
uint8_t *  src,
uint32_t  lengthInBytes 
)
inlinestatic

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.
static status_t FLASH_VerifyProgram ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes,
const uint8_t *  expectedData,
uint32_t *  failedAddress,
uint32_t *  failedData 
)
inlinestatic

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.
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.
static status_t FLASH_VerifyErasePhrase ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes 
)
inlinestatic

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

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.
static status_t FLASH_VerifyErasePage ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes 
)
inlinestatic

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

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.
static status_t FLASH_VerifyEraseSector ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes 
)
inlinestatic

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

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.
static status_t FLASH_GetProperty ( flash_config_t config,
flash_property_tag_t  whichProperty,
uint32_t *  value 
)
inlinestatic
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.
static status_t IFR_VerifyErasePhrase ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes 
)
inlinestatic

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

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.
static status_t IFR_VerifyErasePage ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes 
)
inlinestatic

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

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.
static status_t IFR_VerifyEraseSector ( flash_config_t config,
uint32_t  start,
uint32_t  lengthInBytes 
)
inlinestatic

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

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.
static status_t FLASH_Read ( flash_config_t config,
uint32_t  start,
uint8_t *  dest,
uint32_t  lengthInBytes 
)
inlinestatic

This function read the flash memory from 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 read.
destA pointer to the dest buffer of data that is to be read from the flash.
lengthInBytesThe length, given in bytes (not words or long-words), to be read.
static uint32_t ROMAPI_GetVersion ( void  )
inlinestatic

This function read the ROM API version.

static void ROMAPI_RunBootloader ( void *  arg)
inlinestatic
Parameters
argIndicates API prototype fields definition. Refer to the above #user_app_boot_invoke_option_t structure
static void ROMAPI_GetUUID ( uint8_t *  uuid)
inlinestatic
Parameters
uuidUUID data array