rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Enumerator | Variables
Ftfx_flexnvm_driver

Data Structures

struct  _flexnvm_config
 Flexnvm driver state information. More...
 

Variables

ftfx_config_t _flexnvm_config::ftfxConfig
 

Flexnvm version

enum  _flexnvm_property_tag {
  kFLEXNVM_PropertyDflashSectorSize = 0x00U , kFLEXNVM_PropertyDflashTotalSize = 0x01U , kFLEXNVM_PropertyDflashBlockSize = 0x02U , kFLEXNVM_PropertyDflashBlockCount = 0x03U ,
  kFLEXNVM_PropertyDflashBlockBaseAddr = 0x04U , kFLEXNVM_PropertyFlexRamBlockBaseAddr = 0x05U , kFLEXNVM_PropertyFlexRamTotalSize = 0x06U , kFLEXNVM_PropertyEepromTotalSize = 0x07U
}
 Enumeration for various flexnvm properties. More...
 
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.
 

Initialization

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

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.
 
status_t FLEXNVM_EraseAll (flexnvm_config_t *config, uint32_t key)
 Erases entire flexnvm.
 
status_t FLEXNVM_EraseAllUnsecure (flexnvm_config_t *config, uint32_t key)
 Erases the entire flexnvm, including protected sectors.
 

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

Reading

status_t FLEXNVM_ReadResource (flexnvm_config_t *config, uint32_t start, uint8_t *dst, uint32_t lengthInBytes, ftfx_read_resource_opt_t option)
 Reads the resource with data at locations passed in through parameters.
 

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.
 
status_t FLEXNVM_VerifyEraseAll (flexnvm_config_t *config, ftfx_margin_value_t margin)
 Verifies erasure of the entire flash at a specified margin level.
 
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.
 

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.
 
status_t FLEXNVM_SecurityBypass (flexnvm_config_t *config, const uint8_t *backdoorKey)
 Allows users to bypass security with a backdoor key.
 

FlexRAM

status_t FLEXNVM_SetFlexramFunction (flexnvm_config_t *config, ftfx_flexram_func_opt_t option)
 Sets the FlexRAM function command.
 
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.
 

Flash Protection Utilities

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

Properties

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

Detailed Description

Typedef Documentation

◆ flexnvm_config_t

Flexnvm driver state information.

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

◆ flexnvm_property_tag_t

Enumeration for various flexnvm properties.

Enumeration Type Documentation

◆ _flexnvm_property_tag

Enumeration for various flexnvm properties.

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_PropertyFlexRamBlockBaseAddr 

FlexRam block base address property.

kFLEXNVM_PropertyFlexRamTotalSize 

FlexRam total size property.

kFLEXNVM_PropertyEepromTotalSize 

EEPROM total size property.

Definition at line 62 of file fsl_ftfx_flexnvm.h.

63{
64 kFLEXNVM_PropertyDflashSectorSize = 0x00U, /*!< Dflash sector size property.*/
65 kFLEXNVM_PropertyDflashTotalSize = 0x01U, /*!< Dflash total size property.*/
66 kFLEXNVM_PropertyDflashBlockSize = 0x02U, /*!< Dflash block size property.*/
67 kFLEXNVM_PropertyDflashBlockCount = 0x03U, /*!< Dflash block count property.*/
68 kFLEXNVM_PropertyDflashBlockBaseAddr = 0x04U, /*!< Dflash block base address property.*/
69 kFLEXNVM_PropertyFlexRamBlockBaseAddr = 0x05U, /*!< FlexRam block base address property.*/
70 kFLEXNVM_PropertyFlexRamTotalSize = 0x06U, /*!< FlexRam total size property.*/
71 kFLEXNVM_PropertyEepromTotalSize = 0x07U, /*!< EEPROM total size property.*/
enum _flexnvm_property_tag flexnvm_property_tag_t
Enumeration for various flexnvm properties.
@ kFLEXNVM_PropertyDflashBlockSize
@ kFLEXNVM_PropertyDflashBlockCount
@ kFLEXNVM_PropertyEepromTotalSize
@ kFLEXNVM_PropertyFlexRamBlockBaseAddr
@ kFLEXNVM_PropertyDflashSectorSize
@ kFLEXNVM_PropertyFlexRamTotalSize
@ kFLEXNVM_PropertyDflashTotalSize
@ kFLEXNVM_PropertyDflashBlockBaseAddr

Function Documentation

◆ FLEXNVM_DflashErase()

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.

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

Definition at line 104 of file fsl_ftfx_flexnvm.c.

105{
106 status_t returnCode;
107 returnCode = flexnvm_convert_start_address(config, start);
108 if (returnCode != kStatus_FTFx_Success)
109 {
110 return returnCode;
111 }
112
113 return FTFx_CMD_Erase(&config->ftfxConfig, start, lengthInBytes, key);
114}
static constexpr persistent_config_s * config
status_t FTFx_CMD_Erase(ftfx_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
Erases the flash sectors encompassed by parameters passed into function.
@ kStatus_FTFx_Success
static status_t flexnvm_convert_start_address(flexnvm_config_t *config, uint32_t start)
Convert address for Flexnvm dflash.
int32_t status_t
Type used for all status and error return values.
Definition fsl_common.h:169

Referenced by intFlashErase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLEXNVM_DflashGetProtection()

status_t FLEXNVM_DflashGetProtection ( flexnvm_config_t config,
uint8_t *  protectStatus 
)

Gets the DFlash protection status.

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.

Definition at line 327 of file fsl_ftfx_flexnvm.c.

328{
329 if ((config == NULL) || (protectStatus == NULL))
330 {
332 }
333
334 if ((config->ftfxConfig.flashDesc.totalSize == 0) || (config->ftfxConfig.flashDesc.totalSize == 0xFFFFFFFFU))
335 {
337 }
338
339 *protectStatus = FTFx->FDPROT;
340
342}
@ kStatus_FTFx_InvalidArgument
@ kStatus_FTFx_CommandNotSupported
static status_t protectStatus
Definition flash_int.cpp:27

Referenced by flashInit().

Here is the caller graph for this function:

◆ FLEXNVM_DflashProgram()

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.

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

Definition at line 128 of file fsl_ftfx_flexnvm.c.

129{
130 status_t returnCode;
131 returnCode = flexnvm_convert_start_address(config, start);
132 if (returnCode != kStatus_FTFx_Success)
133 {
134 return returnCode;
135 }
136
137 return FTFx_CMD_Program(&config->ftfxConfig, start, src, lengthInBytes);
138}
status_t FTFx_CMD_Program(ftfx_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)
Programs flash with data at locations passed in through parameters.

Referenced by intFlashWrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLEXNVM_DflashProgramSection()

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.

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

Definition at line 141 of file fsl_ftfx_flexnvm.c.

142{
143 status_t returnCode;
144 returnCode = flexnvm_convert_start_address(config, start);
145 if (returnCode != kStatus_FTFx_Success)
146 {
147 return returnCode;
148 }
149
150 return FTFx_CMD_ProgramSection(&config->ftfxConfig, start, src, lengthInBytes);
151}
status_t FTFx_CMD_ProgramSection(ftfx_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.
Here is the call graph for this function:

◆ FLEXNVM_DflashSetProtection()

status_t FLEXNVM_DflashSetProtection ( flexnvm_config_t config,
uint8_t  protectStatus 
)

Sets the DFlash protection to the intended protection status.

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.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_CommandNotSupportedFlash API is not supported.
kStatus_FTFx_CommandFailureRun-time error during command execution.

Definition at line 305 of file fsl_ftfx_flexnvm.c.

306{
307 if (config == NULL)
308 {
310 }
311
312 if ((config->ftfxConfig.flashDesc.totalSize == 0) || (config->ftfxConfig.flashDesc.totalSize == 0xFFFFFFFFU))
313 {
315 }
316
317 FTFx->FDPROT = protectStatus;
318
319 if (FTFx->FDPROT != protectStatus)
320 {
322 }
323
325}
@ kStatus_FTFx_CommandFailure

◆ FLEXNVM_DflashVerifyErase()

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.

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

Definition at line 173 of file fsl_ftfx_flexnvm.c.

174{
175 status_t returnCode;
176 returnCode = flexnvm_convert_start_address(config, start);
177 if (returnCode != kStatus_FTFx_Success)
178 {
179 return returnCode;
180 }
181
182 return FTFx_CMD_VerifyErase(&config->ftfxConfig, start, lengthInBytes, margin);
183}
status_t FTFx_CMD_VerifyErase(ftfx_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.
Here is the call graph for this function:

◆ FLEXNVM_DflashVerifyProgram()

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.

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_FTFx_SuccessAPI was executed successfully.
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.

Definition at line 190 of file fsl_ftfx_flexnvm.c.

197{
198 status_t returnCode;
199 returnCode = flexnvm_convert_start_address(config, start);
200 if (returnCode != kStatus_FTFx_Success)
201 {
202 return returnCode;
203 }
204
205 return FTFx_CMD_VerifyProgram(&config->ftfxConfig, start, lengthInBytes, expectedData, margin, failedAddress, failedData);
206}
status_t FTFx_CMD_VerifyProgram(ftfx_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.

Referenced by intFlashCompare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLEXNVM_EepromGetProtection()

status_t FLEXNVM_EepromGetProtection ( flexnvm_config_t config,
uint8_t *  protectStatus 
)

Gets the EEPROM protection status.

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.

Definition at line 366 of file fsl_ftfx_flexnvm.c.

367{
368 if ((config == NULL) || (protectStatus == NULL))
369 {
371 }
372
373 if ((config->ftfxConfig.eepromTotalSize == 0) || (config->ftfxConfig.eepromTotalSize == 0xFFFFU))
374 {
376 }
377
378 *protectStatus = FTFx->FEPROT;
379
381}

◆ FLEXNVM_EepromSetProtection()

status_t FLEXNVM_EepromSetProtection ( flexnvm_config_t config,
uint8_t  protectStatus 
)

Sets the EEPROM protection to the intended protection status.

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.

Definition at line 344 of file fsl_ftfx_flexnvm.c.

345{
346 if (config == NULL)
347 {
349 }
350
351 if ((config->ftfxConfig.eepromTotalSize == 0) || (config->ftfxConfig.eepromTotalSize == 0xFFFFU))
352 {
354 }
355
356 FTFx->FEPROT = protectStatus;
357
358 if (FTFx->FEPROT != protectStatus)
359 {
361 }
362
364}

◆ FLEXNVM_EepromWrite()

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.

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

Definition at line 225 of file fsl_ftfx_flexnvm.c.

226{
227 status_t returnCode;
228 bool needSwitchFlexRamMode = false;
229
230 if (config == NULL)
231 {
233 }
234
235 /* Validates the range of the given address */
236 if ((start < config->ftfxConfig.flexramBlockBase) ||
237 ((start + lengthInBytes) > (config->ftfxConfig.flexramBlockBase + config->ftfxConfig.eepromTotalSize)))
238 {
240 }
241
242 returnCode = kStatus_FTFx_Success;
243
244 /* Switch function of FlexRAM if needed */
245 if (!(FTFx->FCNFG & FTFx_FCNFG_EEERDY_MASK))
246 {
247 needSwitchFlexRamMode = true;
248
250 if (returnCode != kStatus_FTFx_Success)
251 {
253 }
254 }
255
256 /* Write data to FlexRAM when it is used as EEPROM emulator */
257 while (lengthInBytes > 0)
258 {
259 if ((!(start & 0x3U)) && (lengthInBytes >= 4))
260 {
261 *(uint32_t *)start = *(uint32_t *)src;
262 start += 4;
263 src += 4;
264 lengthInBytes -= 4;
265 }
266 else if ((!(start & 0x1U)) && (lengthInBytes >= 2))
267 {
268 *(uint16_t *)start = *(uint16_t *)src;
269 start += 2;
270 src += 2;
271 lengthInBytes -= 2;
272 }
273 else
274 {
275 *(uint8_t *)start = *src;
276 start += 1;
277 src += 1;
278 lengthInBytes -= 1;
279 }
280 /* Wait till EEERDY bit is set */
281 while (!(FTFx->FCNFG & FTFx_FCNFG_EEERDY_MASK))
282 {
283 }
284
285 /* Check for protection violation error */
286 if (FTFx->FSTAT & FTFx_FSTAT_FPVIOL_MASK)
287 {
289 }
290 }
291
292 /* Switch function of FlexRAM if needed */
293 if (needSwitchFlexRamMode)
294 {
296 if (returnCode != kStatus_FTFx_Success)
297 {
299 }
300 }
301
302 return returnCode;
303}
status_t FTFx_CMD_SetFlexramFunction(ftfx_config_t *config, ftfx_flexram_func_opt_t option)
Sets the FlexRAM function command.
@ kStatus_FTFx_RecoverFlexramAsRamError
@ kStatus_FTFx_AddressError
@ kStatus_FTFx_ProtectionViolation
@ kStatus_FTFx_SetFlexramAsEepromError
@ kFTFx_FlexramFuncOptAvailableForEeprom
@ kFTFx_FlexramFuncOptAvailableAsRam
Here is the call graph for this function:

◆ FLEXNVM_EraseAll()

status_t FLEXNVM_EraseAll ( flexnvm_config_t config,
uint32_t  key 
)

Erases entire flexnvm.

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

Definition at line 116 of file fsl_ftfx_flexnvm.c.

117{
118 return FTFx_CMD_EraseAll(&config->ftfxConfig, key);
119}
status_t FTFx_CMD_EraseAll(ftfx_config_t *config, uint32_t key)
Erases entire flash.
Here is the call graph for this function:

◆ FLEXNVM_EraseAllUnsecure()

status_t FLEXNVM_EraseAllUnsecure ( flexnvm_config_t config,
uint32_t  key 
)

Erases the entire flexnvm, including protected sectors.

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

Definition at line 122 of file fsl_ftfx_flexnvm.c.

123{
124 return FTFx_CMD_EraseAllUnsecure(&config->ftfxConfig, key);
125}
status_t FTFx_CMD_EraseAllUnsecure(ftfx_config_t *config, uint32_t key)
Erases the entire flash, including protected sectors.
Here is the call graph for this function:

◆ FLEXNVM_GetProperty()

status_t FLEXNVM_GetProperty ( flexnvm_config_t config,
flexnvm_property_tag_t  whichProperty,
uint32_t *  value 
)

Returns the desired flexnvm property.

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.

Definition at line 383 of file fsl_ftfx_flexnvm.c.

384{
385 if ((config == NULL) || (value == NULL))
386 {
388 }
389
390 switch (whichProperty)
391 {
393 *value = config->ftfxConfig.flashDesc.sectorSize;
394 break;
396 *value = config->ftfxConfig.flashDesc.totalSize;
397 break;
399 *value = config->ftfxConfig.flashDesc.totalSize / config->ftfxConfig.flashDesc.blockCount;
400 break;
402 *value = config->ftfxConfig.flashDesc.blockCount;
403 break;
405 *value = config->ftfxConfig.flashDesc.blockBase;
406 break;
408 *value = config->ftfxConfig.flexramBlockBase;
409 break;
411 *value = config->ftfxConfig.flexramTotalSize;
412 break;
414 *value = config->ftfxConfig.eepromTotalSize;
415 break;
416
417 default: /* catch inputs that are not recognized */
419 }
420
422}
@ kStatus_FTFx_UnknownProperty

Referenced by flashPrintStatus().

Here is the caller graph for this function:

◆ FLEXNVM_GetSecurityState()

status_t FLEXNVM_GetSecurityState ( flexnvm_config_t config,
ftfx_security_state_t state 
)

Returns the security state via the pointer passed into the function.

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.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.

Definition at line 208 of file fsl_ftfx_flexnvm.c.

209{
210 return FTFx_REG_GetSecurityState(&config->ftfxConfig, state);
211}
status_t FTFx_REG_GetSecurityState(ftfx_config_t *config, ftfx_security_state_t *state)
Returns the security state via the pointer passed into the function.
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")

Referenced by flashInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLEXNVM_Init()

status_t FLEXNVM_Init ( flexnvm_config_t config)

Initializes the global flash properties structure members.

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.

Definition at line 64 of file fsl_ftfx_flexnvm.c.

65{
66 status_t returnCode;
67
68 if (config == NULL)
69 {
71 }
72
73 config->ftfxConfig.flashDesc.type = kFTFx_MemTypeFlexnvm;
74 config->ftfxConfig.flashDesc.index = 0;
75
76 /* Set Flexnvm memory operation parameters */
77 config->ftfxConfig.opsConfig.addrAligment.blockWriteUnitSize = FSL_FEATURE_FLASH_FLEX_NVM_BLOCK_WRITE_UNIT_SIZE;
78 config->ftfxConfig.opsConfig.addrAligment.sectorCmd = FSL_FEATURE_FLASH_FLEX_NVM_SECTOR_CMD_ADDRESS_ALIGMENT;
79 config->ftfxConfig.opsConfig.addrAligment.sectionCmd = FSL_FEATURE_FLASH_FLEX_NVM_SECTION_CMD_ADDRESS_ALIGMENT;
80 config->ftfxConfig.opsConfig.addrAligment.resourceCmd = FSL_FEATURE_FLASH_FLEX_NVM_RESOURCE_CMD_ADDRESS_ALIGMENT;
81 config->ftfxConfig.opsConfig.addrAligment.checkCmd = FSL_FEATURE_FLASH_FLEX_NVM_CHECK_CMD_ADDRESS_ALIGMENT;
82
83 /* Set Flexnvm memory properties */
84 config->ftfxConfig.flashDesc.blockBase = FSL_FEATURE_FLASH_FLEX_NVM_START_ADDRESS;
85 config->ftfxConfig.flashDesc.sectorSize = FSL_FEATURE_FLASH_FLEX_NVM_BLOCK_SECTOR_SIZE;
86 config->ftfxConfig.flashDesc.blockCount = FSL_FEATURE_FLASH_FLEX_NVM_BLOCK_COUNT;
87
88 /* Init FTFx Kernel */
89 returnCode = FTFx_API_Init(&config->ftfxConfig);
90 if (returnCode != kStatus_FTFx_Success)
91 {
92 return returnCode;
93 }
94
95 returnCode = FTFx_API_UpdateFlexnvmPartitionStatus(&config->ftfxConfig);
96 if (returnCode != kStatus_FTFx_Success)
97 {
98 return returnCode;
99 }
100
102}
status_t FTFx_API_UpdateFlexnvmPartitionStatus(ftfx_config_t *config)
Updates FlexNVM memory partition status according to data flash 0 IFR.
status_t FTFx_API_Init(ftfx_config_t *config)
Initializes the global flash properties structure members.
@ kFTFx_MemTypeFlexnvm

Referenced by flashInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLEXNVM_ProgramPartition()

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.

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

Definition at line 154 of file fsl_ftfx_flexnvm.c.

158{
159 return FTFx_CMD_ProgramPartition(&config->ftfxConfig, option, eepromDataSizeCode, flexnvmPartitionCode);
160}
status_t FTFx_CMD_ProgramPartition(ftfx_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 initial...
Here is the call graph for this function:

◆ FLEXNVM_ReadResource()

status_t FLEXNVM_ReadResource ( flexnvm_config_t config,
uint32_t  start,
uint8_t *  dst,
uint32_t  lengthInBytes,
ftfx_read_resource_opt_t  option 
)

Reads the resource with data at locations passed in through parameters.

This function reads the flash memory with the desired location 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.
dstA pointer to the destination buffer of data that is used to store data to be read.
lengthInBytesThe length, given in bytes (not words or long-words), to be read. Must be word-aligned.
optionThe resource option which indicates which area should be read back.
Return values
kStatus_FTFx_SuccessAPI was executed successfully.
kStatus_FTFx_InvalidArgumentAn invalid argument is provided.
kStatus_FTFx_AlignmentErrorParameter is not aligned with the specified baseline.
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.

Definition at line 163 of file fsl_ftfx_flexnvm.c.

168{
169 return FTFx_CMD_ReadResource(&config->ftfxConfig, start, dst, lengthInBytes, option);
170}
status_t FTFx_CMD_ReadResource(ftfx_config_t *config, uint32_t start, uint8_t *dst, uint32_t lengthInBytes, ftfx_read_resource_opt_t option)
Reads the resource with data at locations passed in through parameters.
Here is the call graph for this function:

◆ FLEXNVM_SecurityBypass()

status_t FLEXNVM_SecurityBypass ( flexnvm_config_t config,
const uint8_t *  backdoorKey 
)

Allows users to bypass security with a backdoor key.

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.

Definition at line 213 of file fsl_ftfx_flexnvm.c.

214{
215 return FTFx_CMD_SecurityBypass(&config->ftfxConfig, backdoorKey);
216}
status_t FTFx_CMD_SecurityBypass(ftfx_config_t *config, const uint8_t *backdoorKey)
Allows users to bypass security with a backdoor key.
Here is the call graph for this function:

◆ FLEXNVM_SetFlexramFunction()

status_t FLEXNVM_SetFlexramFunction ( flexnvm_config_t config,
ftfx_flexram_func_opt_t  option 
)

Sets the FlexRAM function command.

Parameters
configA pointer to the storage for the driver runtime state.
optionThe option used to set the work mode of FlexRAM.
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.

Definition at line 219 of file fsl_ftfx_flexnvm.c.

220{
221 return FTFx_CMD_SetFlexramFunction(&config->ftfxConfig, option);
222}
Here is the call graph for this function:

◆ FLEXNVM_VerifyEraseAll()

status_t FLEXNVM_VerifyEraseAll ( flexnvm_config_t config,
ftfx_margin_value_t  margin 
)

Verifies erasure of the entire flash at a specified margin level.

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

Definition at line 185 of file fsl_ftfx_flexnvm.c.

186{
187 return FTFx_CMD_VerifyEraseAll(&config->ftfxConfig, margin);
188}
status_t FTFx_CMD_VerifyEraseAll(ftfx_config_t *config, ftfx_margin_value_t margin)
Verifies erasure of the entire flash at a specified margin level.
Here is the call graph for this function:

Variable Documentation

◆ ftfxConfig

ftfx_config_t _flexnvm_config::ftfxConfig

Definition at line 81 of file fsl_ftfx_flexnvm.h.