rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures
fsl_ftfx_controller.h File Reference

Data Structures

struct  _ftfx_swap_state_config
 Flash Swap information. More...
 
struct  _ftfx_special_mem
 ftfx special memory access information. More...
 
struct  _ftfx_mem_descriptor
 Flash memory descriptor. More...
 
struct  _ftfx_ops_config
 Active FTFx information for the current operation. More...
 
struct  _ftfx_ifr_descriptor
 Flash IFR memory descriptor. More...
 
struct  _ftfx_config
 Flash driver state information. More...
 

Enumerations

FTFx status
enum  _ftfx_status {
  kStatus_FTFx_Success = MAKE_STATUS(kStatusGroupGeneric, 0) , kStatus_FTFx_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4) , kStatus_FTFx_SizeError = MAKE_STATUS(kStatusGroupFtfxDriver, 0) , kStatus_FTFx_AlignmentError ,
  kStatus_FTFx_AddressError = MAKE_STATUS(kStatusGroupFtfxDriver, 2) , kStatus_FTFx_AccessError , kStatus_FTFx_ProtectionViolation , kStatus_FTFx_CommandFailure ,
  kStatus_FTFx_UnknownProperty = MAKE_STATUS(kStatusGroupFtfxDriver, 6) , kStatus_FTFx_EraseKeyError = MAKE_STATUS(kStatusGroupFtfxDriver, 7) , kStatus_FTFx_RegionExecuteOnly , kStatus_FTFx_ExecuteInRamFunctionNotReady ,
  kStatus_FTFx_PartitionStatusUpdateFailure , kStatus_FTFx_SetFlexramAsEepromError , kStatus_FTFx_RecoverFlexramAsRamError , kStatus_FTFx_SetFlexramAsRamError = MAKE_STATUS(kStatusGroupFtfxDriver, 13) ,
  kStatus_FTFx_RecoverFlexramAsEepromError , kStatus_FTFx_CommandNotSupported = MAKE_STATUS(kStatusGroupFtfxDriver, 15) , kStatus_FTFx_SwapSystemNotInUninitialized , kStatus_FTFx_SwapIndicatorAddressError ,
  kStatus_FTFx_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFtfxDriver, 18) , kStatus_FTFx_InvalidPropertyValue , kStatus_FTFx_InvalidSpeculationOption
}
 FTFx driver status codes. More...
 

Functions

Initialization
status_t FTFx_API_Init (ftfx_config_t *config)
 Initializes the global flash properties structure members.
 
status_t FTFx_API_UpdateFlexnvmPartitionStatus (ftfx_config_t *config)
 Updates FlexNVM memory partition status according to data flash 0 IFR.
 
Erasing
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.
 
status_t FTFx_CMD_EraseAll (ftfx_config_t *config, uint32_t key)
 Erases entire flash.
 
status_t FTFx_CMD_EraseAllUnsecure (ftfx_config_t *config, uint32_t key)
 Erases the entire flash, including protected sectors.
 
status_t FTFx_CMD_EraseAllExecuteOnlySegments (ftfx_config_t *config, uint32_t key)
 Erases all program flash execute-only segments defined by the FXACC registers.
 
Programming
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.
 
status_t FTFx_CMD_ProgramOnce (ftfx_config_t *config, uint32_t index, uint8_t *src, uint32_t lengthInBytes)
 Programs Program Once Field through parameters.
 
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.
 
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 initializes the FlexRAM.
 
Reading
status_t FTFx_CMD_ReadOnce (ftfx_config_t *config, uint32_t index, uint8_t *dst, uint32_t lengthInBytes)
 Reads the Program Once Field through parameters.
 
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.
 
Verification
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.
 
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.
 
status_t FTFx_CMD_VerifyEraseAllExecuteOnlySegments (ftfx_config_t *config, ftfx_margin_value_t margin)
 Verifies whether the program flash execute-only segments have been erased to the specified read margin level.
 
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.
 
Security
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.
 
status_t FTFx_CMD_SecurityBypass (ftfx_config_t *config, const uint8_t *backdoorKey)
 Allows users to bypass security with a backdoor key.
 
FlexRAM
status_t FTFx_CMD_SetFlexramFunction (ftfx_config_t *config, ftfx_flexram_func_opt_t option)
 Sets the FlexRAM function command.
 
Swap
status_t FTFx_CMD_SwapControl (ftfx_config_t *config, uint32_t address, ftfx_swap_control_opt_t option, ftfx_swap_state_config_t *returnInfo)
 Configures the Swap function or checks the swap state of the Flash module.
 

FTFx API key

enum  _ftfx_driver_api_keys { kFTFx_ApiEraseKey = FOUR_CHAR_CODE('k', 'f', 'e', 'k') }
 Enumeration for FTFx driver API keys. More...
 
enum  _ftfx_partition_flexram_load_option { kFTFx_PartitionFlexramLoadOptLoadedWithValidEepromData , kFTFx_PartitionFlexramLoadOptNotLoaded = 0x01U }
 Enumeration for the FlexRAM load during reset option. More...
 
enum  _ftfx_read_resource_opt { kFTFx_ResourceOptionFlashIfr , kFTFx_ResourceOptionVersionId = 0x01U }
 Enumeration for the two possible options of flash read resource command. More...
 
enum  _ftfx_margin_value { kFTFx_MarginValueNormal , kFTFx_MarginValueUser , kFTFx_MarginValueFactory , kFTFx_MarginValueInvalid }
 Enumeration for supported FTFx margin levels. More...
 
enum  _ftfx_security_state { kFTFx_SecurityStateNotSecure = 0xc33cc33cU , kFTFx_SecurityStateBackdoorEnabled = 0x5aa55aa5U , kFTFx_SecurityStateBackdoorDisabled = 0x5ac33ca5U }
 Enumeration for the three possible FTFx security states. More...
 
enum  _ftfx_flexram_function_option { kFTFx_FlexramFuncOptAvailableAsRam = 0xFFU , kFTFx_FlexramFuncOptAvailableForEeprom = 0x00U }
 Enumeration for the two possilbe options of set FlexRAM function command. More...
 
enum  _ftfx_swap_control_option {
  kFTFx_SwapControlOptionIntializeSystem = 0x01U , kFTFx_SwapControlOptionSetInUpdateState = 0x02U , kFTFx_SwapControlOptionSetInCompleteState = 0x04U , kFTFx_SwapControlOptionReportStatus = 0x08U ,
  kFTFx_SwapControlOptionDisableSystem = 0x10U
}
 Enumeration for the possible options of Swap control commands. More...
 
enum  _ftfx_swap_state {
  kFTFx_SwapStateUninitialized = 0x00U , kFTFx_SwapStateReady = 0x01U , kFTFx_SwapStateUpdate = 0x02U , kFTFx_SwapStateUpdateErased = 0x03U ,
  kFTFx_SwapStateComplete = 0x04U , kFTFx_SwapStateDisabled = 0x05U
}
 Enumeration for the possible flash Swap status. More...
 
enum  _ftfx_swap_block_status { kFTFx_SwapBlockStatusLowerHalfProgramBlocksAtZero , kFTFx_SwapBlockStatusUpperHalfProgramBlocksAtZero }
 
enum  _ftfx_memory_type { kFTFx_MemTypePflash = 0x00U , kFTFx_MemTypeFlexnvm = 0x01U }
 Enumeration for FTFx memory type. More...
 
typedef enum _ftfx_partition_flexram_load_option ftfx_partition_flexram_load_opt_t
 Enumeration for the FlexRAM load during reset option.
 
typedef enum _ftfx_read_resource_opt ftfx_read_resource_opt_t
 Enumeration for the two possible options of flash read resource command.
 
typedef enum _ftfx_margin_value ftfx_margin_value_t
 Enumeration for supported FTFx margin levels.
 
typedef enum _ftfx_security_state ftfx_security_state_t
 Enumeration for the three possible FTFx security states.
 
typedef enum _ftfx_flexram_function_option ftfx_flexram_func_opt_t
 Enumeration for the two possilbe options of set FlexRAM function command.
 
typedef enum _ftfx_swap_control_option ftfx_swap_control_opt_t
 Enumeration for the possible options of Swap control commands.
 
typedef enum _ftfx_swap_state ftfx_swap_state_t
 Enumeration for the possible flash Swap status.
 
typedef enum _ftfx_swap_block_status ftfx_swap_block_status_t
 
typedef struct _ftfx_swap_state_config ftfx_swap_state_config_t
 Flash Swap information.
 
typedef struct _ftfx_special_mem ftfx_spec_mem_t
 ftfx special memory access information.
 
typedef struct _ftfx_mem_descriptor ftfx_mem_desc_t
 Flash memory descriptor.
 
typedef struct _ftfx_ops_config ftfx_ops_config_t
 Active FTFx information for the current operation.
 
typedef struct _ftfx_ifr_descriptor ftfx_ifr_desc_t
 Flash IFR memory descriptor.
 
typedef struct _ftfx_config ftfx_config_t
 Flash driver state information.
 

Typedef Documentation

◆ ftfx_config_t

typedef struct _ftfx_config ftfx_config_t

Flash driver state information.

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

◆ ftfx_flexram_func_opt_t

Enumeration for the two possilbe options of set FlexRAM function command.

◆ ftfx_ifr_desc_t

Flash IFR memory descriptor.

◆ ftfx_margin_value_t

Enumeration for supported FTFx margin levels.

◆ ftfx_mem_desc_t

Flash memory descriptor.

◆ ftfx_ops_config_t

Active FTFx information for the current operation.

◆ ftfx_partition_flexram_load_opt_t

Enumeration for the FlexRAM load during reset option.

◆ ftfx_read_resource_opt_t

Enumeration for the two possible options of flash read resource command.

◆ ftfx_security_state_t

Enumeration for the three possible FTFx security states.

◆ ftfx_spec_mem_t

ftfx special memory access information.

◆ ftfx_swap_block_status_t

@breif Enumeration for the possible flash Swap block status

◆ ftfx_swap_control_opt_t

Enumeration for the possible options of Swap control commands.

◆ ftfx_swap_state_config_t

Flash Swap information.

◆ ftfx_swap_state_t

Enumeration for the possible flash Swap status.

Enumeration Type Documentation

◆ _ftfx_driver_api_keys

Enumeration for FTFx driver API keys.

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
kFTFx_ApiEraseKey 

Key value used to validate all FTFx erase APIs.

Definition at line 125 of file fsl_ftfx_controller.h.

126{
127 kFTFx_ApiEraseKey = FOUR_CHAR_CODE('k', 'f', 'e', 'k') /*!< Key value used to validate all FTFx erase APIs.*/
128};
@ kFTFx_ApiEraseKey

◆ _ftfx_flexram_function_option

Enumeration for the two possilbe options of set FlexRAM function command.

Enumerator
kFTFx_FlexramFuncOptAvailableAsRam 

An option used to make FlexRAM available as RAM

kFTFx_FlexramFuncOptAvailableForEeprom 

An option used to make FlexRAM available for EEPROM

Definition at line 175 of file fsl_ftfx_controller.h.

176{
177 kFTFx_FlexramFuncOptAvailableAsRam = 0xFFU, /*!< An option used to make FlexRAM available as RAM */
178 kFTFx_FlexramFuncOptAvailableForEeprom = 0x00U /*!< An option used to make FlexRAM available for EEPROM */
@ kFTFx_FlexramFuncOptAvailableForEeprom
@ kFTFx_FlexramFuncOptAvailableAsRam
enum _ftfx_flexram_function_option ftfx_flexram_func_opt_t
Enumeration for the two possilbe options of set FlexRAM function command.

◆ _ftfx_margin_value

Enumeration for supported FTFx margin levels.

Enumerator
kFTFx_MarginValueNormal 

Use the 'normal' read level for 1s.

kFTFx_MarginValueUser 

Apply the 'User' margin to the normal read-1 level.

kFTFx_MarginValueFactory 

Apply the 'Factory' margin to the normal read-1 level.

kFTFx_MarginValueInvalid 

Not real margin level, Used to determine the range of valid margin level.

Definition at line 154 of file fsl_ftfx_controller.h.

155{
156 kFTFx_MarginValueNormal, /*!< Use the 'normal' read level for 1s.*/
157 kFTFx_MarginValueUser, /*!< Apply the 'User' margin to the normal read-1 level.*/
158 kFTFx_MarginValueFactory, /*!< Apply the 'Factory' margin to the normal read-1 level.*/
159 kFTFx_MarginValueInvalid /*!< Not real margin level, Used to determine the range of valid margin level. */
enum _ftfx_margin_value ftfx_margin_value_t
Enumeration for supported FTFx margin levels.
@ kFTFx_MarginValueNormal
@ kFTFx_MarginValueInvalid
@ kFTFx_MarginValueFactory
@ kFTFx_MarginValueUser

◆ _ftfx_memory_type

Enumeration for FTFx memory type.

Enumerator
kFTFx_MemTypePflash 
kFTFx_MemTypeFlexnvm 

Definition at line 230 of file fsl_ftfx_controller.h.

231{
232 kFTFx_MemTypePflash = 0x00U,
234} ;
@ kFTFx_MemTypeFlexnvm
@ kFTFx_MemTypePflash

◆ _ftfx_partition_flexram_load_option

Enumeration for the FlexRAM load during reset option.

Enumerator
kFTFx_PartitionFlexramLoadOptLoadedWithValidEepromData 

FlexRAM is loaded with valid EEPROM data during reset sequence.

kFTFx_PartitionFlexramLoadOptNotLoaded 

FlexRAM is not loaded during reset sequence.

Definition at line 134 of file fsl_ftfx_controller.h.

135{
137 0x00U, /*!< FlexRAM is loaded with valid EEPROM data during reset sequence.*/
138 kFTFx_PartitionFlexramLoadOptNotLoaded = 0x01U /*!< FlexRAM is not loaded during reset sequence.*/
@ kFTFx_PartitionFlexramLoadOptNotLoaded
@ kFTFx_PartitionFlexramLoadOptLoadedWithValidEepromData
enum _ftfx_partition_flexram_load_option ftfx_partition_flexram_load_opt_t
Enumeration for the FlexRAM load during reset option.

◆ _ftfx_read_resource_opt

Enumeration for the two possible options of flash read resource command.

Enumerator
kFTFx_ResourceOptionFlashIfr 

Select code for Program flash 0 IFR, Program flash swap 0 IFR, Data flash 0 IFR

kFTFx_ResourceOptionVersionId 

Select code for the version ID

Definition at line 144 of file fsl_ftfx_controller.h.

145{
147 0x00U, /*!< Select code for Program flash 0 IFR, Program flash swap 0 IFR, Data flash 0 IFR */
148 kFTFx_ResourceOptionVersionId = 0x01U /*!< Select code for the version ID*/
enum _ftfx_read_resource_opt ftfx_read_resource_opt_t
Enumeration for the two possible options of flash read resource command.
@ kFTFx_ResourceOptionVersionId
@ kFTFx_ResourceOptionFlashIfr

◆ _ftfx_security_state

Enumeration for the three possible FTFx security states.

Enumerator
kFTFx_SecurityStateNotSecure 

Flash is not secure.

kFTFx_SecurityStateBackdoorEnabled 

Flash backdoor is enabled.

kFTFx_SecurityStateBackdoorDisabled 

Flash backdoor is disabled.

Definition at line 165 of file fsl_ftfx_controller.h.

166{
167 kFTFx_SecurityStateNotSecure = 0xc33cc33cU, /*!< Flash is not secure.*/
168 kFTFx_SecurityStateBackdoorEnabled = 0x5aa55aa5U, /*!< Flash backdoor is enabled.*/
169 kFTFx_SecurityStateBackdoorDisabled = 0x5ac33ca5U /*!< Flash backdoor is disabled.*/
@ kFTFx_SecurityStateBackdoorEnabled
@ kFTFx_SecurityStateNotSecure
@ kFTFx_SecurityStateBackdoorDisabled
enum _ftfx_security_state ftfx_security_state_t
Enumeration for the three possible FTFx security states.

◆ _ftfx_status

FTFx driver status codes.

Enumerator
kStatus_FTFx_Success 

API is executed successfully

kStatus_FTFx_InvalidArgument 

Invalid argument

kStatus_FTFx_SizeError 

Error size

kStatus_FTFx_AlignmentError 

Parameter is not aligned with the specified baseline

kStatus_FTFx_AddressError 

Address is out of range

kStatus_FTFx_AccessError 

Invalid instruction codes and out-of bound addresses

kStatus_FTFx_ProtectionViolation 

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

kStatus_FTFx_CommandFailure 

Run-time error during command execution.

kStatus_FTFx_UnknownProperty 

Unknown property.

kStatus_FTFx_EraseKeyError 

API erase key is invalid.

kStatus_FTFx_RegionExecuteOnly 

The current region is execute-only.

kStatus_FTFx_ExecuteInRamFunctionNotReady 

Execute-in-RAM function is not available.

kStatus_FTFx_PartitionStatusUpdateFailure 

Failed to update partition status.

kStatus_FTFx_SetFlexramAsEepromError 

Failed to set FlexRAM as EEPROM.

kStatus_FTFx_RecoverFlexramAsRamError 

Failed to recover FlexRAM as RAM.

kStatus_FTFx_SetFlexramAsRamError 

Failed to set FlexRAM as RAM.

kStatus_FTFx_RecoverFlexramAsEepromError 

Failed to recover FlexRAM as EEPROM.

kStatus_FTFx_CommandNotSupported 

Flash API is not supported.

kStatus_FTFx_SwapSystemNotInUninitialized 

Swap system is not in an uninitialzed state.

kStatus_FTFx_SwapIndicatorAddressError 

The swap indicator address is invalid.

kStatus_FTFx_ReadOnlyProperty 

The flash property is read-only.

kStatus_FTFx_InvalidPropertyValue 

The flash property value is out of range.

kStatus_FTFx_InvalidSpeculationOption 

The option of flash prefetch speculation is invalid.

Definition at line 72 of file fsl_ftfx_controller.h.

73{
74 kStatus_FTFx_Success = MAKE_STATUS(kStatusGroupGeneric, 0), /*!< API is executed successfully*/
75 kStatus_FTFx_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4), /*!< Invalid argument*/
76 kStatus_FTFx_SizeError = MAKE_STATUS(kStatusGroupFtfxDriver, 0), /*!< Error size*/
78 MAKE_STATUS(kStatusGroupFtfxDriver, 1), /*!< Parameter is not aligned with the specified baseline*/
79 kStatus_FTFx_AddressError = MAKE_STATUS(kStatusGroupFtfxDriver, 2), /*!< Address is out of range */
81 MAKE_STATUS(kStatusGroupFtfxDriver, 3), /*!< Invalid instruction codes and out-of bound addresses */
83 kStatusGroupFtfxDriver, 4), /*!< The program/erase operation is requested to execute on protected areas */
85 MAKE_STATUS(kStatusGroupFtfxDriver, 5), /*!< Run-time error during command execution. */
86 kStatus_FTFx_UnknownProperty = MAKE_STATUS(kStatusGroupFtfxDriver, 6), /*!< Unknown property.*/
87 kStatus_FTFx_EraseKeyError = MAKE_STATUS(kStatusGroupFtfxDriver, 7), /*!< API erase key is invalid.*/
89 MAKE_STATUS(kStatusGroupFtfxDriver, 8), /*!< The current region is execute-only.*/
91 MAKE_STATUS(kStatusGroupFtfxDriver, 9), /*!< Execute-in-RAM function is not available.*/
93 MAKE_STATUS(kStatusGroupFtfxDriver, 10), /*!< Failed to update partition status.*/
95 MAKE_STATUS(kStatusGroupFtfxDriver, 11), /*!< Failed to set FlexRAM as EEPROM.*/
97 MAKE_STATUS(kStatusGroupFtfxDriver, 12), /*!< Failed to recover FlexRAM as RAM.*/
98 kStatus_FTFx_SetFlexramAsRamError = MAKE_STATUS(kStatusGroupFtfxDriver, 13), /*!< Failed to set FlexRAM as RAM.*/
100 MAKE_STATUS(kStatusGroupFtfxDriver, 14), /*!< Failed to recover FlexRAM as EEPROM.*/
101 kStatus_FTFx_CommandNotSupported = MAKE_STATUS(kStatusGroupFtfxDriver, 15), /*!< Flash API is not supported.*/
103 MAKE_STATUS(kStatusGroupFtfxDriver, 16), /*!< Swap system is not in an uninitialzed state.*/
105 MAKE_STATUS(kStatusGroupFtfxDriver, 17), /*!< The swap indicator address is invalid.*/
106 kStatus_FTFx_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFtfxDriver, 18), /*!< The flash property is read-only.*/
108 MAKE_STATUS(kStatusGroupFtfxDriver, 19), /*!< The flash property value is out of range.*/
110 MAKE_STATUS(kStatusGroupFtfxDriver, 20), /*!< The option of flash prefetch speculation is invalid.*/
111};
@ kStatus_FTFx_AlignmentError
@ kStatus_FTFx_SetFlexramAsRamError
@ kStatus_FTFx_RegionExecuteOnly
@ kStatus_FTFx_SizeError
@ kStatus_FTFx_CommandFailure
@ kStatus_FTFx_UnknownProperty
@ kStatus_FTFx_RecoverFlexramAsRamError
@ kStatus_FTFx_EraseKeyError
@ kStatus_FTFx_RecoverFlexramAsEepromError
@ kStatus_FTFx_Success
@ kStatus_FTFx_InvalidArgument
@ kStatus_FTFx_AddressError
@ kStatus_FTFx_ReadOnlyProperty
@ kStatus_FTFx_ExecuteInRamFunctionNotReady
@ kStatus_FTFx_SwapSystemNotInUninitialized
@ kStatus_FTFx_InvalidPropertyValue
@ kStatus_FTFx_InvalidSpeculationOption
@ kStatus_FTFx_PartitionStatusUpdateFailure
@ kStatus_FTFx_CommandNotSupported
@ kStatus_FTFx_SwapIndicatorAddressError
@ kStatus_FTFx_ProtectionViolation
@ kStatus_FTFx_AccessError
@ kStatus_FTFx_SetFlexramAsEepromError

◆ _ftfx_swap_block_status

@breif Enumeration for the possible flash Swap block status

Enumerator
kFTFx_SwapBlockStatusLowerHalfProgramBlocksAtZero 

Swap block status is that lower half program block at zero.

kFTFx_SwapBlockStatusUpperHalfProgramBlocksAtZero 

Swap block status is that upper half program block at zero.

Definition at line 209 of file fsl_ftfx_controller.h.

210{
212 0x00U, /*!< Swap block status is that lower half program block at zero.*/
214 0x01U, /*!< Swap block status is that upper half program block at zero.*/
enum _ftfx_swap_block_status ftfx_swap_block_status_t
@ kFTFx_SwapBlockStatusUpperHalfProgramBlocksAtZero
@ kFTFx_SwapBlockStatusLowerHalfProgramBlocksAtZero

◆ _ftfx_swap_control_option

Enumeration for the possible options of Swap control commands.

Enumerator
kFTFx_SwapControlOptionIntializeSystem 

An option used to initialize the Swap system

kFTFx_SwapControlOptionSetInUpdateState 

An option used to set the Swap in an update state

kFTFx_SwapControlOptionSetInCompleteState 

An option used to set the Swap in a complete state

kFTFx_SwapControlOptionReportStatus 

An option used to report the Swap status

kFTFx_SwapControlOptionDisableSystem 

An option used to disable the Swap status

Definition at line 184 of file fsl_ftfx_controller.h.

185{
186 kFTFx_SwapControlOptionIntializeSystem = 0x01U, /*!< An option used to initialize the Swap system */
187 kFTFx_SwapControlOptionSetInUpdateState = 0x02U, /*!< An option used to set the Swap in an update state */
188 kFTFx_SwapControlOptionSetInCompleteState = 0x04U, /*!< An option used to set the Swap in a complete state */
189 kFTFx_SwapControlOptionReportStatus = 0x08U, /*!< An option used to report the Swap status */
190 kFTFx_SwapControlOptionDisableSystem = 0x10U /*!< An option used to disable the Swap status */
enum _ftfx_swap_control_option ftfx_swap_control_opt_t
Enumeration for the possible options of Swap control commands.
@ kFTFx_SwapControlOptionReportStatus
@ kFTFx_SwapControlOptionSetInCompleteState
@ kFTFx_SwapControlOptionDisableSystem
@ kFTFx_SwapControlOptionSetInUpdateState
@ kFTFx_SwapControlOptionIntializeSystem

◆ _ftfx_swap_state

Enumeration for the possible flash Swap status.

Enumerator
kFTFx_SwapStateUninitialized 

Flash Swap system is in an uninitialized state.

kFTFx_SwapStateReady 

Flash Swap system is in a ready state.

kFTFx_SwapStateUpdate 

Flash Swap system is in an update state.

kFTFx_SwapStateUpdateErased 

Flash Swap system is in an updateErased state.

kFTFx_SwapStateComplete 

Flash Swap system is in a complete state.

kFTFx_SwapStateDisabled 

Flash Swap system is in a disabled state.

Definition at line 196 of file fsl_ftfx_controller.h.

197{
198 kFTFx_SwapStateUninitialized = 0x00U, /*!< Flash Swap system is in an uninitialized state.*/
199 kFTFx_SwapStateReady = 0x01U, /*!< Flash Swap system is in a ready state.*/
200 kFTFx_SwapStateUpdate = 0x02U, /*!< Flash Swap system is in an update state.*/
201 kFTFx_SwapStateUpdateErased = 0x03U, /*!< Flash Swap system is in an updateErased state.*/
202 kFTFx_SwapStateComplete = 0x04U, /*!< Flash Swap system is in a complete state.*/
203 kFTFx_SwapStateDisabled = 0x05U /*!< Flash Swap system is in a disabled state.*/
enum _ftfx_swap_state ftfx_swap_state_t
Enumeration for the possible flash Swap status.
@ kFTFx_SwapStateReady
@ kFTFx_SwapStateUninitialized
@ kFTFx_SwapStateUpdate
@ kFTFx_SwapStateComplete
@ kFTFx_SwapStateDisabled
@ kFTFx_SwapStateUpdateErased

Function Documentation

◆ FTFx_API_Init()

status_t FTFx_API_Init ( ftfx_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.

Definition at line 240 of file fsl_ftfx_controller.c.

241{
242 if (config == NULL)
243 {
245 }
246
247 config->flexramBlockBase = FSL_FEATURE_FLASH_FLEX_RAM_START_ADDRESS;
248 config->flexramTotalSize = FSL_FEATURE_FLASH_FLEX_RAM_SIZE;
249
250 /* copy required flash command to RAM */
251#if FTFx_DRIVER_IS_FLASH_RESIDENT
252 if (NULL == config->runCmdFuncAddr)
253 {
254#if FTFx_DRIVER_IS_EXPORTED
256#else
257 config->runCmdFuncAddr = s_ftfxRunCommand;
258#endif /* FTFx_DRIVER_IS_EXPORTED */
259 }
260 ftfx_copy_run_command_to_ram(config->runCmdFuncAddr);
261#endif /* FTFx_DRIVER_IS_FLASH_RESIDENT */
262
264
266}
static constexpr persistent_config_s * config
static uint32_t s_ftfxRunCommand[kFTFx_RamFuncMaxSizeInWords]
A static buffer used to hold flash_run_command()
static status_t ftfx_init_ifr(ftfx_config_t *config)
Init IFR memory related info.
static void ftfx_copy_run_command_to_ram(uint32_t *ftfxRunCommand)
Copy flash_run_command() to RAM.

Referenced by FLEXNVM_Init().

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

◆ FTFx_API_UpdateFlexnvmPartitionStatus()

status_t FTFx_API_UpdateFlexnvmPartitionStatus ( ftfx_config_t config)

Updates FlexNVM memory partition status according to data flash 0 IFR.

This function updates FlexNVM memory partition status.

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_PartitionStatusUpdateFailureFailed to update the partition status.

Definition at line 269 of file fsl_ftfx_controller.c.

270{
271 struct _dflash_ifr_field_config
272 {
273 uint32_t reserved0;
274 uint8_t FlexNVMPartitionCode;
275 uint8_t EEPROMDataSetSize;
276 uint16_t reserved1;
277 } dataIFRReadOut;
278 uint32_t flexnvmInfoIfrAddr;
279 status_t returnCode;
280
281 if (config == NULL)
282 {
284 }
285
286 flexnvmInfoIfrAddr = config->ifrDesc.resRange.dflashIfrStart + config->ifrDesc.resRange.ifrMemSize - sizeof(dataIFRReadOut);
287
288#if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
289 /* Get FlexNVM memory partition info from data flash IFR */
290 returnCode = FTFx_CMD_ReadResource(config, flexnvmInfoIfrAddr, (uint8_t *)&dataIFRReadOut,
291 sizeof(dataIFRReadOut), kFTFx_ResourceOptionFlashIfr);
292 if (returnCode != kStatus_FTFx_Success)
293 {
295 }
296#else
297#error "Cannot get FlexNVM memory partition info"
298#endif
299
300 /* Fill out partitioned EEPROM size */
301 dataIFRReadOut.EEPROMDataSetSize &= 0x0FU;
302 config->eepromTotalSize = kEepromDensities[dataIFRReadOut.EEPROMDataSetSize];
303
304 /* Fill out partitioned DFlash size */
305 dataIFRReadOut.FlexNVMPartitionCode &= 0x0FU;
306 config->flashDesc.totalSize = kDflashDensities[dataIFRReadOut.FlexNVMPartitionCode];
307
309}
static const uint16_t kEepromDensities[16]
Table of eeprom sizes.
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.
static const uint32_t kDflashDensities[16]
Table of dflash sizes.
int32_t status_t
Type used for all status and error return values.
Definition fsl_common.h:169

Referenced by FLEXNVM_Init(), FTFx_CMD_EraseAll(), and FTFx_CMD_EraseAllUnsecure().

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

◆ FTFx_CMD_Erase()

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.

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 312 of file fsl_ftfx_controller.c.

316{
317 uint32_t sectorSize;
318 uint32_t endAddress; /* storing end address */
319 uint32_t numberOfSectors; /* number of sectors calculated by endAddress */
320 status_t returnCode;
321
322 /* Check the supplied address range. */
323 returnCode = ftfx_check_mem_range(config, start, lengthInBytes, config->opsConfig.addrAligment.sectorCmd);
324 if (returnCode)
325 {
326 return returnCode;
327 }
328
329 /* Validate the user key */
330 returnCode = ftfx_check_user_key(key);
331 if (returnCode)
332 {
333 return returnCode;
334 }
335
336 start = config->opsConfig.convertedAddress;
337 sectorSize = config->flashDesc.sectorSize;
338
339 /* calculating Flash end address */
340 endAddress = start + lengthInBytes - 1;
341
342 /* re-calculate the endAddress and align it to the start of the next sector
343 * which will be used in the comparison below */
344 if (endAddress % sectorSize)
345 {
346 numberOfSectors = endAddress / sectorSize + 1;
347 endAddress = numberOfSectors * sectorSize - 1;
348 }
349
350 /* the start address will increment to the next sector address
351 * until it reaches the endAdddress */
352 while (start <= endAddress)
353 {
354 /* preparing passing parameter to erase a flash block */
355 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_SECTOR, start);
356
357 /* calling flash command sequence function to execute the command */
358 returnCode = ftfx_command_sequence(config);
359
360 /* checking the success of command execution */
361 if (kStatus_FTFx_Success != returnCode)
362 {
363 break;
364 }
365 else
366 {
367 /* Increment to the next sector */
368 start += sectorSize;
369 }
370 }
371
372 return (returnCode);
373}
static volatile uint32_t *const kFCCOBx
Access to FTFx Registers.
static status_t ftfx_command_sequence(ftfx_config_t *config)
Internal function Flash command sequence. Called by driver APIs only.
static status_t ftfx_check_mem_range(ftfx_config_t *config, uint32_t startAddress, uint32_t lengthInBytes, uint8_t alignmentBaseline)
Validates the range and alignment of the given address range.
static status_t ftfx_check_user_key(uint32_t key)
Validates the given user key for flash erase APIs.

Referenced by FLEXNVM_DflashErase().

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

◆ FTFx_CMD_EraseAll()

status_t FTFx_CMD_EraseAll ( ftfx_config_t config,
uint32_t  key 
)

Erases entire flash.

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 375 of file fsl_ftfx_controller.c.

376{
377 status_t returnCode;
378
379 if (config == NULL)
380 {
382 }
383
384 /* preparing passing parameter to erase all flash blocks */
385 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_ALL_BLOCK, 0xFFFFFFU);
386
387 /* Validate the user key */
388 returnCode = ftfx_check_user_key(key);
389 if (returnCode)
390 {
391 return returnCode;
392 }
393
394 /* calling flash command sequence function to execute the command */
395 returnCode = ftfx_command_sequence(config);
396
397#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
398 /* Data flash IFR will be erased by erase all command, so we need to
399 * update FlexNVM memory partition status synchronously */
400 if (returnCode == kStatus_FTFx_Success)
401 {
403 }
404#endif
405
406 return returnCode;
407}
status_t FTFx_API_UpdateFlexnvmPartitionStatus(ftfx_config_t *config)
Updates FlexNVM memory partition status according to data flash 0 IFR.

Referenced by FLEXNVM_EraseAll().

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

◆ FTFx_CMD_EraseAllExecuteOnlySegments()

status_t FTFx_CMD_EraseAllExecuteOnlySegments ( ftfx_config_t config,
uint32_t  key 
)

Erases all program flash execute-only segments defined by the FXACC registers.

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 the command execution.

Definition at line 445 of file fsl_ftfx_controller.c.

446{
447 status_t returnCode;
448
449 if (config == NULL)
450 {
452 }
453
454 /* preparing passing parameter to erase all execute-only segments
455 * 1st element for the FCCOB register */
456 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_ALL_EXECUTE_ONLY_SEGMENT, 0xFFFFFFU);
457
458 /* Validate the user key */
459 returnCode = ftfx_check_user_key(key);
460 if (returnCode)
461 {
462 return returnCode;
463 }
464
465 /* calling flash command sequence function to execute the command */
466 returnCode = ftfx_command_sequence(config);
467
468 return returnCode;
469}
Here is the call graph for this function:

◆ FTFx_CMD_EraseAllUnsecure()

status_t FTFx_CMD_EraseAllUnsecure ( ftfx_config_t config,
uint32_t  key 
)

Erases the entire flash, 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 410 of file fsl_ftfx_controller.c.

411{
412 status_t returnCode;
413
414 if (config == NULL)
415 {
417 }
418
419 /* Prepare passing parameter to erase all flash blocks (unsecure). */
420 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_ALL_BLOCK_UNSECURE, 0xFFFFFFU);
421
422 /* Validate the user key */
423 returnCode = ftfx_check_user_key(key);
424 if (returnCode)
425 {
426 return returnCode;
427 }
428
429 /* calling flash command sequence function to execute the command */
430 returnCode = ftfx_command_sequence(config);
431
432#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
433 /* Data flash IFR will be erased by erase all unsecure command, so we need to
434 * update FlexNVM memory partition status synchronously */
435 if (returnCode == kStatus_FTFx_Success)
436 {
438 }
439#endif
440
441 return returnCode;
442}

Referenced by FLEXNVM_EraseAllUnsecure().

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

◆ FTFx_CMD_Program()

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.

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 471 of file fsl_ftfx_controller.c.

475{
476 status_t returnCode;
477 uint8_t blockWriteUnitSize = config->opsConfig.addrAligment.blockWriteUnitSize;
478
479 if (src == NULL)
480 {
482 }
483
484 /* Check the supplied address range. */
485 returnCode = ftfx_check_mem_range(config, start, lengthInBytes, blockWriteUnitSize);
486 if (returnCode)
487 {
488 return returnCode;
489 }
490
491 start = config->opsConfig.convertedAddress;
492
493 while (lengthInBytes > 0)
494 {
495 /* preparing passing parameter to program the flash block */
496 kFCCOBx[1] = ftfx_read_word_from_byte_address((const uint8_t*)src);
497 src += 4;
498
499 if (4 == blockWriteUnitSize)
500 {
501 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_LONGWORD, start);
502 }
503 else if (8 == blockWriteUnitSize)
504 {
505 kFCCOBx[2] = ftfx_read_word_from_byte_address((const uint8_t*)src);
506 src += 4;
507 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_PHRASE, start);
508 }
509 else
510 {
511 }
512
513 /* calling flash command sequence function to execute the command */
514 returnCode = ftfx_command_sequence(config);
515
516 /* checking for the success of command execution */
517 if (kStatus_FTFx_Success != returnCode)
518 {
519 break;
520 }
521 else
522 {
523 /* update start address for next iteration */
524 start += blockWriteUnitSize;
525
526 /* update lengthInBytes for next iteration */
527 lengthInBytes -= blockWriteUnitSize;
528 }
529 }
530
531 return (returnCode);
532}
static uint32_t ftfx_read_word_from_byte_address(const uint8_t *src)
Reads word from byte address.

Referenced by FLEXNVM_DflashProgram().

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

◆ FTFx_CMD_ProgramOnce()

status_t FTFx_CMD_ProgramOnce ( ftfx_config_t config,
uint32_t  index,
uint8_t *  src,
uint32_t  lengthInBytes 
)

Programs Program Once Field through parameters.

This function programs the Program Once Field with the desired data for a given flash area as determined by the index and length.

Parameters
configA pointer to the storage for the driver runtime state.
indexThe index indicating which area of the Program Once Field to be programmed.
srcA pointer to the source buffer of data that is to be programmed into the Program Once Field.
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_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 534 of file fsl_ftfx_controller.c.

535{
536 status_t returnCode;
537
538 if ((config == NULL) || (src == NULL))
539 {
541 }
542
543 /* pass paramters to FTFx */
544 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_PROGRAM_ONCE, index, 0xFFFFU);
545
546 kFCCOBx[1] = ftfx_read_word_from_byte_address((const uint8_t*)src);
547
548 /* Note: Have to seperate the first index from the rest if it equals 0
549 * to avoid a pointless comparison of unsigned int to 0 compiler warning */
550 if (config->ifrDesc.feature.has8ByteIdxSupport)
551 {
552 if (config->ifrDesc.feature.has4ByteIdxSupport)
553 {
554 if (((index == config->ifrDesc.idxInfo.mix8byteIdxStart) ||
555 ((index >= config->ifrDesc.idxInfo.mix8byteIdxStart + 1) && (index <= config->ifrDesc.idxInfo.mix8byteIdxStart))) &&
556 (lengthInBytes == 8))
557 {
558 kFCCOBx[2] = ftfx_read_word_from_byte_address((const uint8_t*)src + 4);
559 }
560 }
561 else
562 {
563 kFCCOBx[2] = ftfx_read_word_from_byte_address((const uint8_t*)src + 4);
564 }
565 }
566
567 /* calling flash command sequence function to execute the command */
568 returnCode = ftfx_command_sequence(config);
569
570 return returnCode;
571}
Here is the call graph for this function:

◆ FTFx_CMD_ProgramPartition()

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 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 695 of file fsl_ftfx_controller.c.

699{
700 status_t returnCode;
701
702 if (config == NULL)
703 {
705 }
706
707 /* eepromDataSizeCode[7:6], flexnvmPartitionCode[7:4] should be all 1'b0
708 * or it will cause access error. */
709 /* eepromDataSizeCode &= 0x3FU; */
710 /* flexnvmPartitionCode &= 0x0FU; */
711
712 /* preparing passing parameter to program the flash block */
713 kFCCOBx[0] = BYTE2WORD_1_2_1(FTFx_PROGRAM_PARTITION, 0xFFFFU, option);
714 kFCCOBx[1] = BYTE2WORD_1_1_2(eepromDataSizeCode, flexnvmPartitionCode, 0xFFFFU);
715
716 /* calling flash command sequence function to execute the command */
717 returnCode = ftfx_command_sequence(config);
718
719#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
720 /* Data flash IFR will be updated by program partition command during reset sequence,
721 * so we just set reserved values for partitioned FlexNVM size here */
722 config->eepromTotalSize = 0xFFFFU;
723 config->flashDesc.totalSize = 0xFFFFFFFFU;
724#endif
725
726 return (returnCode);
727}

Referenced by FLEXNVM_ProgramPartition().

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

◆ FTFx_CMD_ProgramSection()

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.

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 574 of file fsl_ftfx_controller.c.

578{
579 status_t returnCode;
580 uint32_t sectorSize;
581 uint8_t aligmentInBytes = config->opsConfig.addrAligment.sectionCmd;
582#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
583 bool needSwitchFlexRamMode = false;
584#endif /* FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD */
585
586 if (src == NULL)
587 {
589 }
590
591 /* Check the supplied address range. */
592 returnCode = ftfx_check_mem_range(config, start, lengthInBytes, aligmentInBytes);
593 if (returnCode)
594 {
595 return returnCode;
596 }
597
598 start = config->opsConfig.convertedAddress;
599 sectorSize = config->flashDesc.sectorSize;
600
601#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
602 /* Switch function of FlexRAM if needed */
603 if (!(FTFx->FCNFG & FTFx_FCNFG_RAMRDY_MASK))
604 {
605 needSwitchFlexRamMode = true;
606
608 if (returnCode != kStatus_FTFx_Success)
609 {
611 }
612 }
613#endif /* FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD */
614
615 while (lengthInBytes > 0)
616 {
617 /* Make sure the write operation doesn't span two sectors */
618 uint32_t endAddressOfCurrentSector = ALIGN_UP(start, sectorSize);
619 uint32_t lengthTobeProgrammedOfCurrentSector;
620 uint32_t currentOffset = 0;
621
622 if (endAddressOfCurrentSector == start)
623 {
624 endAddressOfCurrentSector += sectorSize;
625 }
626
627 if (lengthInBytes + start > endAddressOfCurrentSector)
628 {
629 lengthTobeProgrammedOfCurrentSector = endAddressOfCurrentSector - start;
630 }
631 else
632 {
633 lengthTobeProgrammedOfCurrentSector = lengthInBytes;
634 }
635
636 /* Program Current Sector */
637 while (lengthTobeProgrammedOfCurrentSector > 0)
638 {
639 /* Make sure the program size doesn't exceeds Acceleration RAM size */
640 uint32_t programSizeOfCurrentPass;
641 uint32_t numberOfPhases;
642
643 if (lengthTobeProgrammedOfCurrentSector > config->flexramTotalSize)
644 {
645 programSizeOfCurrentPass = config->flexramTotalSize;
646 }
647 else
648 {
649 programSizeOfCurrentPass = lengthTobeProgrammedOfCurrentSector;
650 }
651
652 /* Copy data to FlexRAM */
653 memcpy((void *)config->flexramBlockBase, src + currentOffset, programSizeOfCurrentPass);
654 /* Set start address of the data to be programmed */
655 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_SECTION, start + currentOffset);
656 /* Set program size in terms of FEATURE_FLASH_SECTION_CMD_ADDRESS_ALIGMENT */
657 numberOfPhases = programSizeOfCurrentPass / aligmentInBytes;
658
659 kFCCOBx[1] = BYTE2WORD_2_2(numberOfPhases, 0xFFFFU);
660
661 /* Peform command sequence */
662 returnCode = ftfx_command_sequence(config);
663
664 if (returnCode != kStatus_FTFx_Success)
665 {
666 return returnCode;
667 }
668
669 lengthTobeProgrammedOfCurrentSector -= programSizeOfCurrentPass;
670 currentOffset += programSizeOfCurrentPass;
671 }
672
673 src += currentOffset;
674 start += currentOffset;
675 lengthInBytes -= currentOffset;
676 }
677
678#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
679 /* Restore function of FlexRAM if needed. */
680 if (needSwitchFlexRamMode)
681 {
683 if (returnCode != kStatus_FTFx_Success)
684 {
686 }
687 }
688#endif /* FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD */
689
690 return returnCode;
691}
status_t FTFx_CMD_SetFlexramFunction(ftfx_config_t *config, ftfx_flexram_func_opt_t option)
Sets the FlexRAM function command.

Referenced by FLEXNVM_DflashProgramSection().

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

◆ FTFx_CMD_ReadOnce()

status_t FTFx_CMD_ReadOnce ( ftfx_config_t config,
uint32_t  index,
uint8_t *  dst,
uint32_t  lengthInBytes 
)

Reads the Program Once Field through parameters.

This function reads the read once feild with given index and length.

Parameters
configA pointer to the storage for the driver runtime state.
indexThe index indicating the area of program once field to be read.
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 programmed. Must be word-aligned.
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 730 of file fsl_ftfx_controller.c.

731{
732 status_t returnCode;
733
734 if ((config == NULL) || (dst == NULL))
735 {
737 }
738
739 /* pass paramters to FTFx */
740 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_READ_ONCE, index, 0xFFFFU);
741
742 /* calling flash command sequence function to execute the command */
743 returnCode = ftfx_command_sequence(config);
744
745 if (kStatus_FTFx_Success == returnCode)
746 {
748 /* Note: Have to seperate the first index from the rest if it equals 0
749 * to avoid a pointless comparison of unsigned int to 0 compiler warning */
750 if (config->ifrDesc.feature.has8ByteIdxSupport)
751 {
752 if (config->ifrDesc.feature.has4ByteIdxSupport)
753 {
754 if (((index == config->ifrDesc.idxInfo.mix8byteIdxStart) ||
755 ((index >= config->ifrDesc.idxInfo.mix8byteIdxStart + 1) && (index <= config->ifrDesc.idxInfo.mix8byteIdxStart))) &&
756 (lengthInBytes == 8))
757 {
759 }
760 }
761 else
762 {
764 }
765 }
766 }
767
768 return returnCode;
769}
static void ftfx_write_word_to_byte_address(uint8_t *dst, uint32_t word)
Writes word to byte address.
Here is the call graph for this function:

◆ FTFx_CMD_ReadResource()

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.

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 772 of file fsl_ftfx_controller.c.

777{
778 status_t returnCode;
779
780 if ((config == NULL) || (dst == NULL))
781 {
783 }
784
785 uint8_t aligmentInBytes = config->opsConfig.addrAligment.resourceCmd;
786
787 /* Check the supplied address range. */
788 returnCode = ftfx_check_resource_range(config, start, lengthInBytes, aligmentInBytes, option);
789 if (returnCode != kStatus_FTFx_Success)
790 {
791 return returnCode;
792 }
793
794 while (lengthInBytes > 0)
795 {
796 /* preparing passing parameter */
797 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_READ_RESOURCE, start);
798 if (aligmentInBytes == 4)
799 {
800 kFCCOBx[2] = BYTE2WORD_1_3(option, 0xFFFFFFU);
801 }
802 else if (aligmentInBytes == 8)
803 {
804 kFCCOBx[1] = BYTE2WORD_1_3(option, 0xFFFFFFU);
805 }
806 else
807 {
808 }
809
810 /* calling flash command sequence function to execute the command */
811 returnCode = ftfx_command_sequence(config);
812
813 if (kStatus_FTFx_Success != returnCode)
814 {
815 break;
816 }
817
818 /* fetch data */
820 dst += 4;
821 if (aligmentInBytes == 8)
822 {
824 dst += 4;
825 }
826 /* update start address for next iteration */
827 start += aligmentInBytes;
828 /* update lengthInBytes for next iteration */
829 lengthInBytes -= aligmentInBytes;
830 }
831
832 return (returnCode);
833}
static status_t ftfx_check_resource_range(ftfx_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t alignmentBaseline, ftfx_read_resource_opt_t option)
Validates the range of the given resource address.

Referenced by FLEXNVM_ReadResource(), and FTFx_API_UpdateFlexnvmPartitionStatus().

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

◆ FTFx_CMD_SecurityBypass()

status_t FTFx_CMD_SecurityBypass ( ftfx_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 978 of file fsl_ftfx_controller.c.

979{
980 uint8_t registerValue; /* registerValue */
981 status_t returnCode; /* return code variable */
982
983 if ((config == NULL) || (backdoorKey == NULL))
984 {
986 }
987
988 /* set the default return code as kStatus_Success */
989 returnCode = kStatus_FTFx_Success;
990
991 /* Get flash security register value */
992 registerValue = FTFx->FSEC;
993
994 /* Check to see if flash is in secure state (any state other than 0x2)
995 * If not, then skip this since flash is not secure */
996 if (0x02 != (registerValue & 0x03))
997 {
998 /* preparing passing parameter to erase a flash block */
999 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_SECURITY_BY_PASS, 0xFFFFFFU);
1000 kFCCOBx[1] = BYTE2WORD_1_1_1_1(backdoorKey[0], backdoorKey[1], backdoorKey[2], backdoorKey[3]);
1001 kFCCOBx[2] = BYTE2WORD_1_1_1_1(backdoorKey[4], backdoorKey[5], backdoorKey[6], backdoorKey[7]);
1002
1003 /* calling flash command sequence function to execute the command */
1004 returnCode = ftfx_command_sequence(config);
1005 }
1006
1007 return (returnCode);
1008}

Referenced by FLEXNVM_SecurityBypass().

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

◆ FTFx_CMD_SetFlexramFunction()

status_t FTFx_CMD_SetFlexramFunction ( ftfx_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 1049 of file fsl_ftfx_controller.c.

1050 {
1051 status_t status;
1052
1053 if (config == NULL)
1054 {
1056 }
1057
1058 status = ftfx_check_flexram_function_option(option);
1059 if (status != kStatus_FTFx_Success)
1060 {
1061 return status;
1062 }
1063
1064 /* preparing passing parameter to verify all block command */
1065 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_SET_FLEXRAM_FUNCTION, option, 0xFFFFU);
1066
1067 /* calling flash command sequence function to execute the command */
1069 }
static status_t ftfx_check_flexram_function_option(ftfx_flexram_func_opt_t option)
Validates the gived flexram function option.

Referenced by FLEXNVM_EepromWrite(), FLEXNVM_SetFlexramFunction(), and FTFx_CMD_ProgramSection().

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

◆ FTFx_CMD_SwapControl()

status_t FTFx_CMD_SwapControl ( ftfx_config_t config,
uint32_t  address,
ftfx_swap_control_opt_t  option,
ftfx_swap_state_config_t returnInfo 
)

Configures the Swap function or checks the swap state of the Flash module.

Parameters
configA pointer to the storage for the driver runtime state.
addressAddress used to configure the flash Swap function.
optionThe possible option used to configure Flash Swap function or check the flash Swap status
returnInfoA pointer to the data which is used to return the information of flash Swap.
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_SwapIndicatorAddressErrorSwap indicator address 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 1073 of file fsl_ftfx_controller.c.

1077{
1078 status_t returnCode;
1079
1080 if ((config == NULL) || (returnInfo == NULL))
1081 {
1083 }
1084
1085 if (address & (FSL_FEATURE_FLASH_PFLASH_SWAP_CONTROL_CMD_ADDRESS_ALIGMENT - 1))
1086 {
1088 }
1089
1090 /* Make sure address provided is in the lower half of Program flash but not in the Flash Configuration Field */
1091 if ((address >= (config->flashDesc.totalSize / 2)) ||
1092 ((address >= kFTFx_PflashConfigAreaStart) && (address <= kFTFx_PflashConfigAreaEnd)))
1093 {
1095 }
1096
1097 /* Check the option. */
1098 returnCode = ftfx_check_swap_control_option(option);
1099 if (returnCode)
1100 {
1101 return returnCode;
1102 }
1103
1104 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_SWAP_CONTROL, address);
1105 kFCCOBx[1] = BYTE2WORD_1_3(option, 0xFFFFFFU);
1106
1107 returnCode = ftfx_command_sequence(config);
1108
1109 returnInfo->flashSwapState = (ftfx_swap_state_t)FTFx_FCCOB5_REG;
1110 returnInfo->currentSwapBlockStatus = (ftfx_swap_block_status_t)FTFx_FCCOB6_REG;
1111 returnInfo->nextSwapBlockStatus = (ftfx_swap_block_status_t)FTFx_FCCOB7_REG;
1112
1113 return returnCode;
1114}
@ kFTFx_PflashConfigAreaEnd
@ kFTFx_PflashConfigAreaStart
static status_t ftfx_check_swap_control_option(ftfx_swap_control_opt_t option)
Validates the gived swap control option.
ftfx_swap_block_status_t nextSwapBlockStatus
ftfx_swap_state_t flashSwapState
ftfx_swap_block_status_t currentSwapBlockStatus
Here is the call graph for this function:

◆ FTFx_CMD_VerifyErase()

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.

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 836 of file fsl_ftfx_controller.c.

840{
841 /* Check arguments. */
842 uint32_t blockSize;
843 uint32_t nextBlockStartAddress;
844 uint32_t remainingBytes;
845 uint8_t aligmentInBytes = config->opsConfig.addrAligment.sectionCmd;
846 status_t returnCode;
847
848 returnCode = ftfx_check_mem_range(config, start, lengthInBytes, aligmentInBytes);
849 if (returnCode)
850 {
851 return returnCode;
852 }
853
854 start = config->opsConfig.convertedAddress;
855 blockSize = config->flashDesc.totalSize / config->flashDesc.blockCount;
856
857 nextBlockStartAddress = ALIGN_UP(start, blockSize);
858 if (nextBlockStartAddress == start)
859 {
860 nextBlockStartAddress += blockSize;
861 }
862
863 remainingBytes = lengthInBytes;
864
865 while (remainingBytes)
866 {
867 uint32_t numberOfPhrases;
868 uint32_t verifyLength = nextBlockStartAddress - start;
869 if (verifyLength > remainingBytes)
870 {
871 verifyLength = remainingBytes;
872 }
873
874 numberOfPhrases = verifyLength / aligmentInBytes;
875
876 /* Fill in verify section command parameters. */
877 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_VERIFY_SECTION, start);
878 kFCCOBx[1] = BYTE2WORD_2_1_1(numberOfPhrases, margin, 0xFFU);
879
880 /* calling flash command sequence function to execute the command */
881 returnCode = ftfx_command_sequence(config);
882 if (returnCode)
883 {
884 return returnCode;
885 }
886
887 remainingBytes -= verifyLength;
888 start += verifyLength;
889 nextBlockStartAddress += blockSize;
890 }
891
893}

Referenced by FLEXNVM_DflashVerifyErase().

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

◆ FTFx_CMD_VerifyEraseAll()

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.

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 895 of file fsl_ftfx_controller.c.

896{
897 if (config == NULL)
898 {
900 }
901
902 /* preparing passing parameter to verify all block command */
903 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_VERIFY_ALL_BLOCK, margin, 0xFFFFU);
904
905 /* calling flash command sequence function to execute the command */
907}

Referenced by FLEXNVM_VerifyEraseAll().

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

◆ FTFx_CMD_VerifyEraseAllExecuteOnlySegments()

status_t FTFx_CMD_VerifyEraseAllExecuteOnlySegments ( ftfx_config_t config,
ftfx_margin_value_t  margin 
)

Verifies whether the program flash execute-only segments have been 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 909 of file fsl_ftfx_controller.c.

910{
911 if (config == NULL)
912 {
914 }
915
916 /* preparing passing parameter to verify erase all execute-only segments command */
917 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_VERIFY_ALL_EXECUTE_ONLY_SEGMENT, margin, 0xFFFFU);
918
919 /* calling flash command sequence function to execute the command */
921}
Here is the call graph for this function:

◆ FTFx_CMD_VerifyProgram()

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.

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 923 of file fsl_ftfx_controller.c.

930{
931 status_t returnCode;
932 uint8_t aligmentInBytes = config->opsConfig.addrAligment.checkCmd;
933 if (expectedData == NULL)
934 {
936 }
937
938 returnCode = ftfx_check_mem_range(config, start, lengthInBytes, aligmentInBytes);
939 if (returnCode)
940 {
941 return returnCode;
942 }
943
944 start = config->opsConfig.convertedAddress;
945
946 while (lengthInBytes)
947 {
948 /* preparing passing parameter to program check the flash block */
949 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_CHECK, start);
950 kFCCOBx[1] = BYTE2WORD_1_3(margin, 0xFFFFFFU);
951 kFCCOBx[2] = ftfx_read_word_from_byte_address((const uint8_t*)expectedData);
952
953 /* calling flash command sequence function to execute the command */
954 returnCode = ftfx_command_sequence(config);
955
956 /* checking for the success of command execution */
957 if (kStatus_FTFx_Success != returnCode)
958 {
959 if (failedAddress)
960 {
961 *failedAddress = start;
962 }
963 if (failedData)
964 {
965 *failedData = 0;
966 }
967 break;
968 }
969
970 lengthInBytes -= aligmentInBytes;
971 expectedData += aligmentInBytes;
972 start += aligmentInBytes;
973 }
974
975 return (returnCode);
976}

Referenced by FLEXNVM_DflashVerifyProgram().

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

◆ FTFx_REG_GetSecurityState()

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.

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 1010 of file fsl_ftfx_controller.c.

1011{
1012 /* store data read from flash register */
1013 uint8_t registerValue;
1014
1015 if ((config == NULL) || (state == NULL))
1016 {
1018 }
1019
1020 /* Get flash security register value */
1021 registerValue = FTFx->FSEC;
1022
1023 /* check the status of the flash security bits in the security register */
1024 if (kFTFx_FsecRegCode_SEC_Unsecured == (registerValue & FTFx_FSEC_SEC_MASK))
1025 {
1026 /* Flash in unsecured state */
1028 }
1029 else
1030 {
1031 /* Flash in secured state
1032 * check for backdoor key security enable bit */
1033 if (kFTFx_FsecRegCode_KEYEN_Enabled == (registerValue & FTFx_FSEC_KEYEN_MASK))
1034 {
1035 /* Backdoor key security enabled */
1037 }
1038 else
1039 {
1040 /* Backdoor key security disabled */
1042 }
1043 }
1044
1045 return (kStatus_FTFx_Success);
1046}
@ kFTFx_FsecRegCode_SEC_Unsecured
@ kFTFx_FsecRegCode_KEYEN_Enabled
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")

Referenced by FLEXNVM_GetSecurityState().

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

Go to the source code of this file.