![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the flash driver module of MCUXpresso SDK devices.
Files | |
file | flash_header.h |
file | fsl_flash.h |
Data Structures | |
struct | IMG_HEADER_T |
Image header. More... | |
struct | BOOT_BLOCK_T |
Boot block. More... | |
struct | flash_config_t |
Flash configuration information. More... | |
Macros | |
#define | FLASH_FAIL (1 << 0) |
FLASH INT_STATUS register definitions. More... | |
#define | FLASH_FAIL (1 << 0) |
FLASH INT_STATUS register definitions. More... | |
#define | FLASH_ERR (1 << 1) |
Illegal command. | |
#define | FLASH_ERR (1 << 1) |
Illegal command. | |
#define | FLASH_DONE (1 << 2) |
Command complete. | |
#define | FLASH_DONE (1 << 2) |
Command complete. | |
#define | FLASH_ECC_ERR (1 << 3) |
ECC error detected. | |
#define | FLASH_ECC_ERR (1 << 3) |
ECC error detected. | |
Enumerations | |
enum | flash_status_t { kStatus_FLASH_Success = FLASH_DONE, kStatus_FLASH_Fail = FLASH_DONE | FLASH_FAIL, kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroup_Generic, 4), kStatus_FLASH_AlignmentError = MAKE_STATUS(kStatusGroup_FLASH, 6), kStatus_FLASH_EccError = FLASH_DONE | FLASH_ECC_ERR, kStatus_FLASH_Error = FLASH_DONE | FLASH_ERR } |
enum | flash_read_mode_t { , FLASH_ReadModeNormalEccOff = (FLASH_READ_MODE_NORMAL << FLASH_READ_MODE_SHIFT)|(1<<FLASH_READ_MODE_ECC_OFF_SHIFT) } |
Functions | |
void | FLASH_Init (FLASH_Type *pFLASH) |
Enable the FLASH. More... | |
void | FLASH_Powerdown (FLASH_Type *pFLASH) |
Power down the FLASH. More... | |
int | FLASH_Wait (FLASH_Type *pFLASH) |
Wait for FLASH command to complete. More... | |
int | FLASH_Erase (FLASH_Type *pFLASH, uint8_t *pu8Start, uint8_t *pu8End) |
Erase page. More... | |
int | FLASH_ErasePages (FLASH_Type *pFLASH, uint32_t u32StartPage, uint32_t u32PageCount) |
Erase multiple pages. More... | |
int | FLASH_BlankCheck (FLASH_Type *pFLASH, uint8_t *pu8Start, uint8_t *pu8End) |
Page Blank check. More... | |
int | FLASH_MarginCheck (FLASH_Type *pFLASH, uint8_t *pu8Start, uint8_t *pu8End) |
Margin Check. More... | |
int | FLASH_Program (FLASH_Type *pFLASH, uint32_t *pu32Start, uint32_t *pu32Data, uint32_t u32Length) |
Program page. More... | |
int | FLASH_Checksum (FLASH_Type *pFLASH, uint8_t *pu8Start, uint8_t *pu8End, uint32_t au32Checksum[4]) |
Page Checksum. More... | |
int | FLASH_Read (FLASH_Type *pFLASH, uint8_t *pu8Start, uint32_t u32ReadMode, uint32_t au32Data[4]) |
Read flash word (16 byte worth of data) More... | |
void | FLASH_SetReadMode (FLASH_Type *pFLASH, bool freq_48M_not_32M) |
Configure the flash wait state depending of the elwe mode and CPU frequency. When the CPU clock frequency is decreased, the Set Read command shall be called after the frequency change. When the CPU clock frequency is increased, the Set Read command shall be called before the frequency change. More... | |
void | FLASH_CalculateChecksum (const uint32_t *input, size_t nb_128b_words, uint32_t *misr, int init) |
Calculate checksum using the same checksum algorithm as the CMD_CHECKSUM implementation of the Flash controller. When executed over a 512 byte page (page size) must return the same value as FLASH_Checksum. More... | |
int | FLASH_ConfigPageVerifyPageChecksum (const uint32_t *page_buffer, uint32_t *misr) |
Calculate checksum over page (N-2) aka CONFIG page and check it matches the expected value. More... | |
int | FLASH_ConfigPageVerifyGpoChecksum (const uint32_t *page_buffer, uint32_t *misr) |
Calculate checksum over GPO array of CONFIG page and check it matches the expected value. More... | |
void | FLASH_ConfigPageUpdate (uint32_t *page_ram_buffer, uint32_t *gpo_chksum, uint32_t *page_chksum) |
Configure the flash wait state depending of the elwe mode and CPU frequency. When the CPU clock frequency is decreased, the Set Read command shall be called after the frequency change. When the CPU clock frequency is increased, the Set Read command shall be called before the frequency change. More... | |
int | FLASH_GetStatus (FLASH_Type *pFLASH) |
Return unfiltered FLASH INT_STATUS. In normal operation FLASH_DONE rises systematically but other status bits may rise at the same time or have risen before to notify of an error. Usually testing the value returned by FLASH_Wait is sufficionet but in some special cases the raw value may be needed. More... | |
Variables | |
uint32_t | IMG_HEADER_T::vectors [NUMBER_CCSUM_VECTORS] |
critical vectors protected by csum | |
uint32_t | IMG_HEADER_T::vectorCsum |
csum of vectors 0-7 | |
uint32_t | IMG_HEADER_T::imageSignature |
image signature | |
uint32_t | IMG_HEADER_T::bootBlockOffset |
offset of boot block structure | |
uint32_t | IMG_HEADER_T::header_crc |
the CRC of header | |
uint32_t | BOOT_BLOCK_T::header_marker |
Image header marker should always be set to 0xbb0110bb+/-2. | |
uint32_t | BOOT_BLOCK_T::img_type |
Image check type, with or without optional CRC. | |
uint32_t | BOOT_BLOCK_T::target_addr |
Target address. | |
uint32_t | BOOT_BLOCK_T::img_len |
Image length or the length of image CRC check should be done. More... | |
uint32_t | BOOT_BLOCK_T::stated_size |
max size of any subsequent image : AppSize0 = 2 x stated_size | |
uint32_t | BOOT_BLOCK_T::certificate_offset |
Offset of the certificate list. | |
uint32_t | BOOT_BLOCK_T::compatibility_offset |
Offset of the compatibility list. | |
uint32_t | BOOT_BLOCK_T::version |
Image version for multi-image support. | |
struct IMG_HEADER_T |
Be very cautious when modifying the IMG_HEADER_T and the BOOT_BLOCK_T structures (alignment) as these structures are used in the image_tool.py (which does not take care of alignment).
Data Fields | |
uint32_t | vectors [NUMBER_CCSUM_VECTORS] |
critical vectors protected by csum | |
uint32_t | vectorCsum |
csum of vectors 0-7 | |
uint32_t | imageSignature |
image signature | |
uint32_t | bootBlockOffset |
offset of boot block structure | |
uint32_t | header_crc |
the CRC of header | |
struct BOOT_BLOCK_T |
For some ADC16 channels, there are two pin selections in channel multiplexer. For example, ADC0_SE4a and ADC0_SE4b are the different channels that share the same channel number.
Data Fields | |
uint32_t | header_marker |
Image header marker should always be set to 0xbb0110bb+/-2. | |
uint32_t | img_type |
Image check type, with or without optional CRC. | |
uint32_t | target_addr |
Target address. | |
uint32_t | img_len |
Image length or the length of image CRC check should be done. More... | |
uint32_t | stated_size |
max size of any subsequent image : AppSize0 = 2 x stated_size | |
uint32_t | certificate_offset |
Offset of the certificate list. | |
uint32_t | compatibility_offset |
Offset of the compatibility list. | |
uint32_t | version |
Image version for multi-image support. | |
struct flash_config_t |
An instance of this structure is allocated by the user of the flash driver and at initialization.
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 | PFlashSectorSize |
The size in bytes of a sector of PFlash. More... | |
uint32_t flash_config_t::PFlashTotalSize |
uint32_t flash_config_t::PFlashSectorSize |
#define FLASH_FAIL (1 << 0) |
FLASH INT_ENABLE register definitions.
Command failed
#define FLASH_FAIL (1 << 0) |
FLASH INT_ENABLE register definitions.
Command failed
enum flash_status_t |
enum flash_read_mode_t |
void FLASH_Init | ( | FLASH_Type * | pFLASH | ) |
pFLASH | Pointer to selected FLASHx peripheral |
void FLASH_Powerdown | ( | FLASH_Type * | pFLASH | ) |
pFLASH | Pointer to selected FLASHx peripheral |
int FLASH_Wait | ( | FLASH_Type * | pFLASH | ) |
pFLASH | Pointer to selected FLASHx peripheral |
int FLASH_Erase | ( | FLASH_Type * | pFLASH, |
uint8_t * | pu8Start, | ||
uint8_t * | pu8End | ||
) |
pFLASH | Pointer to selected FLASH peripheral | |
[in] | pu8Start | Start address with page to inspect |
[in] | pu8End | End address (included in check) |
int FLASH_ErasePages | ( | FLASH_Type * | pFLASH, |
uint32_t | u32StartPage, | ||
uint32_t | u32PageCount | ||
) |
pFLASH | Pointer to selected FLASH peripheral | |
[in] | u32StartPage | Index of page to start erasing from |
[in] | u32PageCount | Number of pages to erase |
int FLASH_BlankCheck | ( | FLASH_Type * | pFLASH, |
uint8_t * | pu8Start, | ||
uint8_t * | pu8End | ||
) |
pFLASH | Pointer to selected FLASH peripheral | |
[in] | pu8Start | Start address with page to inspect |
[in] | pu8End | End address (included in check) |
int FLASH_MarginCheck | ( | FLASH_Type * | pFLASH, |
uint8_t * | pu8Start, | ||
uint8_t * | pu8End | ||
) |
pFLASH | Pointer to selected FLASH peripheral | |
[in] | pu8Start | Start address with page to inspect |
[in] | pu8End | End address (included in check) |
int FLASH_Program | ( | FLASH_Type * | pFLASH, |
uint32_t * | pu32Start, | ||
uint32_t * | pu32Data, | ||
uint32_t | u32Length | ||
) |
[in] | pFLASH | Pointer to selected FLASH peripheral |
[out] | pu32Start | Pointer location that must be programmed in flash |
[in] | pu32Data | Pointer to source buffer being written to flash |
[in] | u32Length | Number of bytes to be programmed |
int FLASH_Checksum | ( | FLASH_Type * | pFLASH, |
uint8_t * | pu8Start, | ||
uint8_t * | pu8End, | ||
uint32_t | au32Checksum[4] | ||
) |
pFLASH | Pointer to selected FLASH peripheral | |
[in] | pu8Start | Pointer to data within starting page page checksum must be computed |
[in] | pu8End | Pointer to data whose page is the last of the checksum calculation |
[out] | au32Checksum | Four 32bit word array to store checksum calculation result |
int FLASH_Read | ( | FLASH_Type * | pFLASH, |
uint8_t * | pu8Start, | ||
uint32_t | u32ReadMode, | ||
uint32_t | au32Data[4] | ||
) |
pFLASH | Pointer to selected FLASH peripheral | |
[in] | pu8Start | Pointer to data to be read |
[in] | u32ReadMode | Read mode see also flash_read_mode_t |
[out] | au32Data | Four 32bit word array to store read result |
void FLASH_SetReadMode | ( | FLASH_Type * | pFLASH, |
bool | freq_48M_not_32M | ||
) |
pFLASH | Pointer to selected FLASHx peripheral |
freq_48M_not_32M | CPU clock frequency @48MHz - lower or equal to 32Mhz if 0 |
void FLASH_CalculateChecksum | ( | const uint32_t * | input, |
size_t | nb_128b_words, | ||
uint32_t * | misr, | ||
int | init | ||
) |
[in] | input | Pointer to data over which checksum calculation must be executed. |
[in] | nb_128b_words | Number of 16 byte words on flash. |
[out] | misr | Pointer on a four 32bit word array to store calculated checksum. |
[in] | init | Set to true to clear the misr buffer. |
int FLASH_ConfigPageVerifyPageChecksum | ( | const uint32_t * | page_buffer, |
uint32_t * | misr | ||
) |
[in] | page_buffer | Pointer to data over which checksum calculation must be executed. |
[out] | misr | Pointer on a four 32bit word array to store calculated checksum. Note: this buffer is only useful for debugging purposes. |
int FLASH_ConfigPageVerifyGpoChecksum | ( | const uint32_t * | page_buffer, |
uint32_t * | misr | ||
) |
[in] | page_buffer | Pointer to data over which checksum calculation must be executed. |
[out] | misr | Pointer on a 4 32bit word array to store calculated checksum. Note: this buffer is only useful for debugging purposes. |
void FLASH_ConfigPageUpdate | ( | uint32_t * | page_ram_buffer, |
uint32_t * | gpo_chksum, | ||
uint32_t * | page_chksum | ||
) |
page_ram_buffer | Pointer to RAM page buffer in which the read-modify-write of page (N-2) is performed |
gpo_chksum | Pointer on a four 32bit word array to store calculated checksum. |
page_chksum | Pointer on a four 32bit word array to store calculated checksum. |
int FLASH_GetStatus | ( | FLASH_Type * | pFLASH | ) |
pFLASH | Pointer to selected FLASHx peripheral. |
uint32_t BOOT_BLOCK_T::img_len |
For faster boot application could set a smaller length than actual image. For Secure boot images, this MUST be the entire image length