41 #if FSL_FEATURE_FLASH_HAS_FLEX_NVM
74 config->ftfxConfig.flashDesc.index = 0;
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;
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;
121 #if defined(FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD) && FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD
140 #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD
156 uint32_t eepromDataSizeCode,
157 uint32_t flexnvmPartitionCode)
162 #if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
166 uint32_t lengthInBytes,
192 uint32_t lengthInBytes,
193 const uint8_t *expectedData,
195 uint32_t *failedAddress,
196 uint32_t *failedData)
218 #if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
228 bool needSwitchFlexRamMode =
false;
236 if ((start < config->ftfxConfig.flexramBlockBase) ||
237 ((start + lengthInBytes) > (
config->ftfxConfig.flexramBlockBase +
config->ftfxConfig.eepromTotalSize)))
245 if (!(FTFx->FCNFG & FTFx_FCNFG_EEERDY_MASK))
247 needSwitchFlexRamMode =
true;
257 while (lengthInBytes > 0)
259 if ((!(start & 0x3U)) && (lengthInBytes >= 4))
261 *(uint32_t *)start = *(uint32_t *)src;
266 else if ((!(start & 0x1U)) && (lengthInBytes >= 2))
268 *(uint16_t *)start = *(uint16_t *)src;
275 *(uint8_t *)start = *src;
281 while (!(FTFx->FCNFG & FTFx_FCNFG_EEERDY_MASK))
286 if (FTFx->FSTAT & FTFx_FSTAT_FPVIOL_MASK)
293 if (needSwitchFlexRamMode)
312 if ((
config->ftfxConfig.flashDesc.totalSize == 0) || (
config->ftfxConfig.flashDesc.totalSize == 0xFFFFFFFFU))
334 if ((
config->ftfxConfig.flashDesc.totalSize == 0) || (
config->ftfxConfig.flashDesc.totalSize == 0xFFFFFFFFU))
351 if ((
config->ftfxConfig.eepromTotalSize == 0) || (
config->ftfxConfig.eepromTotalSize == 0xFFFFU))
373 if ((
config->ftfxConfig.eepromTotalSize == 0) || (
config->ftfxConfig.eepromTotalSize == 0xFFFFU))
385 if ((
config == NULL) || (value == NULL))
390 switch (whichProperty)
393 *value =
config->ftfxConfig.flashDesc.sectorSize;
396 *value =
config->ftfxConfig.flashDesc.totalSize;
399 *value =
config->ftfxConfig.flashDesc.totalSize /
config->ftfxConfig.flashDesc.blockCount;
402 *value =
config->ftfxConfig.flashDesc.blockCount;
405 *value =
config->ftfxConfig.flashDesc.blockBase;
408 *value =
config->ftfxConfig.flexramBlockBase;
411 *value =
config->ftfxConfig.flexramTotalSize;
414 *value =
config->ftfxConfig.eepromTotalSize;
433 config->ftfxConfig.opsConfig.convertedAddress = start -
config->ftfxConfig.flashDesc.blockBase + 0x800000U;
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_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_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_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.
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.
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_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_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.
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_SecurityBypass(ftfx_config_t *config, const uint8_t *backdoorKey)
Allows users to bypass security with a backdoor key.
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_SetFlexramFunction(ftfx_config_t *config, ftfx_flexram_func_opt_t option)
Sets the FlexRAM function 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 initial...
enum _ftfx_read_resource_opt ftfx_read_resource_opt_t
Enumeration for the two possible options of flash read resource command.
@ kStatus_FTFx_CommandFailure
@ kStatus_FTFx_UnknownProperty
@ kStatus_FTFx_RecoverFlexramAsRamError
@ kStatus_FTFx_InvalidArgument
@ kStatus_FTFx_AddressError
@ kStatus_FTFx_CommandNotSupported
@ kStatus_FTFx_ProtectionViolation
@ kStatus_FTFx_SetFlexramAsEepromError
enum _ftfx_margin_value ftfx_margin_value_t
Enumeration for supported FTFx margin levels.
@ 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.
enum _ftfx_security_state ftfx_security_state_t
Enumeration for the three possible FTFx security states.
enum _ftfx_partition_flexram_load_option ftfx_partition_flexram_load_opt_t
Enumeration for the FlexRAM load during reset option.
static status_t flexnvm_convert_start_address(flexnvm_config_t *config, uint32_t start)
Convert address for Flexnvm dflash.
status_t FLEXNVM_EraseAllUnsecure(flexnvm_config_t *config, uint32_t key)
Erases the entire flexnvm, including protected sectors.
status_t FLEXNVM_SecurityBypass(flexnvm_config_t *config, const uint8_t *backdoorKey)
Allows users to bypass security with a backdoor key.
status_t FLEXNVM_DflashSetProtection(flexnvm_config_t *config, uint8_t protectStatus)
Sets the DFlash protection to the intended protection status.
enum _flexnvm_property_tag flexnvm_property_tag_t
Enumeration for various flexnvm properties.
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.
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.
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_GetSecurityState(flexnvm_config_t *config, ftfx_security_state_t *state)
Returns the security state via the pointer passed into the function.
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_EepromSetProtection(flexnvm_config_t *config, uint8_t protectStatus)
Sets the EEPROM protection to the intended protection status.
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_EraseAll(flexnvm_config_t *config, uint32_t key)
Erases entire flexnvm.
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 initial...
status_t FLEXNVM_Init(flexnvm_config_t *config)
Initializes the global flash properties structure members.
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.
status_t FLEXNVM_GetProperty(flexnvm_config_t *config, flexnvm_property_tag_t whichProperty, uint32_t *value)
Returns the desired flexnvm property.
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_EepromGetProtection(flexnvm_config_t *config, uint8_t *protectStatus)
Gets the EEPROM protection status.
status_t FLEXNVM_DflashGetProtection(flexnvm_config_t *config, uint8_t *protectStatus)
Gets the DFlash protection status.
status_t FLEXNVM_SetFlexramFunction(flexnvm_config_t *config, ftfx_flexram_func_opt_t option)
Sets the FlexRAM function command.
@ kFLEXNVM_PropertyDflashBlockSize
@ kFLEXNVM_PropertyDflashBlockCount
@ kFLEXNVM_PropertyEepromTotalSize
@ kFLEXNVM_PropertyFlexRamBlockBaseAddr
@ kFLEXNVM_PropertyDflashSectorSize
@ kFLEXNVM_PropertyFlexRamTotalSize
@ kFLEXNVM_PropertyDflashTotalSize
@ kFLEXNVM_PropertyDflashBlockBaseAddr
int32_t status_t
Type used for all status and error return values.
static status_t protectStatus
persistent_config_s * config
Flexnvm driver state information.