49#define FTFx_VERIFY_BLOCK 0x00U
50#define FTFx_VERIFY_SECTION 0x01U
51#define FTFx_PROGRAM_CHECK 0x02U
52#define FTFx_READ_RESOURCE 0x03U
53#define FTFx_PROGRAM_LONGWORD 0x06U
54#define FTFx_PROGRAM_PHRASE 0x07U
55#define FTFx_ERASE_BLOCK 0x08U
56#define FTFx_ERASE_SECTOR 0x09U
57#define FTFx_PROGRAM_SECTION 0x0BU
58#define FTFx_GENERATE_CRC 0x0CU
59#define FTFx_VERIFY_ALL_BLOCK 0x40U
60#define FTFx_READ_ONCE 0x41U
61#define FTFx_PROGRAM_ONCE 0x43U
62#define FTFx_ERASE_ALL_BLOCK 0x44U
63#define FTFx_SECURITY_BY_PASS 0x45U
64#define FTFx_SWAP_CONTROL 0x46U
65#define FTFx_ERASE_ALL_BLOCK_UNSECURE 0x49U
66#define FTFx_VERIFY_ALL_EXECUTE_ONLY_SEGMENT 0x4AU
67#define FTFx_ERASE_ALL_EXECUTE_ONLY_SEGMENT 0x4BU
68#define FTFx_PROGRAM_PARTITION 0x80U
69#define FTFx_SET_FLEXRAM_FUNCTION 0x81U
111#if FTFx_DRIVER_IS_FLASH_RESIDENT
121 uint32_t startAddress,
122 uint32_t lengthInBytes,
123 uint8_t alignmentBaseline);
134#if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
138 uint32_t lengthInBytes,
139 uint32_t alignmentBaseline,
143#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
148#if defined(FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD) && FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD
157#if FTFx_DRIVER_IS_FLASH_RESIDENT
186#if (!FTFx_DRIVER_IS_EXPORTED)
193static volatile uint32_t *
const kFCCOBx = (
volatile uint32_t *)&FTFx_FCCOB3_REG;
195#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
198 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0000,
199 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0001,
200 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0010,
201 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0011,
202 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0100,
203 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0101,
204 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0110,
205 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_0111,
206 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1000,
207 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1001,
208 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1010,
209 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1011,
210 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1100,
211 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1101,
212 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1110,
213 FSL_FEATURE_FLASH_FLEX_NVM_EEPROM_SIZE_FOR_EEESIZE_1111
217 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0000,
218 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0001,
219 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0010,
220 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0011,
221 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0100,
222 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0101,
223 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0110,
224 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_0111,
225 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1000,
226 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1001,
227 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1010,
228 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1011,
229 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1100,
230 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1101,
231 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1110,
232 FSL_FEATURE_FLASH_FLEX_NVM_DFLASH_SIZE_FOR_DEPART_1111
247 config->flexramBlockBase = FSL_FEATURE_FLASH_FLEX_RAM_START_ADDRESS;
248 config->flexramTotalSize = FSL_FEATURE_FLASH_FLEX_RAM_SIZE;
251#if FTFx_DRIVER_IS_FLASH_RESIDENT
252 if (NULL ==
config->runCmdFuncAddr)
254#if FTFx_DRIVER_IS_EXPORTED
268#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
271 struct _dflash_ifr_field_config
274 uint8_t FlexNVMPartitionCode;
275 uint8_t EEPROMDataSetSize;
278 uint32_t flexnvmInfoIfrAddr;
286 flexnvmInfoIfrAddr =
config->ifrDesc.resRange.dflashIfrStart +
config->ifrDesc.resRange.ifrMemSize -
sizeof(dataIFRReadOut);
288#if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
297#error "Cannot get FlexNVM memory partition info"
301 dataIFRReadOut.EEPROMDataSetSize &= 0x0FU;
305 dataIFRReadOut.FlexNVMPartitionCode &= 0x0FU;
314 uint32_t lengthInBytes,
319 uint32_t numberOfSectors;
336 start =
config->opsConfig.convertedAddress;
337 sectorSize =
config->flashDesc.sectorSize;
340 endAddress = start + lengthInBytes - 1;
344 if (endAddress % sectorSize)
346 numberOfSectors = endAddress / sectorSize + 1;
347 endAddress = numberOfSectors * sectorSize - 1;
352 while (start <= endAddress)
355 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_SECTOR, start);
385 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_ALL_BLOCK, 0xFFFFFFU);
397#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
409#if defined(FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD) && FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD
420 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_ALL_BLOCK_UNSECURE, 0xFFFFFFU);
432#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
456 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_ERASE_ALL_EXECUTE_ONLY_SEGMENT, 0xFFFFFFU);
474 uint32_t lengthInBytes)
477 uint8_t blockWriteUnitSize =
config->opsConfig.addrAligment.blockWriteUnitSize;
491 start =
config->opsConfig.convertedAddress;
493 while (lengthInBytes > 0)
499 if (4 == blockWriteUnitSize)
501 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_LONGWORD, start);
503 else if (8 == blockWriteUnitSize)
507 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_PHRASE, start);
524 start += blockWriteUnitSize;
527 lengthInBytes -= blockWriteUnitSize;
538 if ((
config == NULL) || (src == NULL))
544 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_PROGRAM_ONCE, index, 0xFFFFU);
550 if (
config->ifrDesc.feature.has8ByteIdxSupport)
552 if (
config->ifrDesc.feature.has4ByteIdxSupport)
554 if (((index ==
config->ifrDesc.idxInfo.mix8byteIdxStart) ||
555 ((index >=
config->ifrDesc.idxInfo.mix8byteIdxStart + 1) && (index <= config->ifrDesc.idxInfo.mix8byteIdxStart))) &&
556 (lengthInBytes == 8))
573#if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD
577 uint32_t lengthInBytes)
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;
598 start =
config->opsConfig.convertedAddress;
599 sectorSize =
config->flashDesc.sectorSize;
601#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
603 if (!(FTFx->FCNFG & FTFx_FCNFG_RAMRDY_MASK))
605 needSwitchFlexRamMode =
true;
615 while (lengthInBytes > 0)
618 uint32_t endAddressOfCurrentSector = ALIGN_UP(start, sectorSize);
619 uint32_t lengthTobeProgrammedOfCurrentSector;
620 uint32_t currentOffset = 0;
622 if (endAddressOfCurrentSector == start)
624 endAddressOfCurrentSector += sectorSize;
627 if (lengthInBytes + start > endAddressOfCurrentSector)
629 lengthTobeProgrammedOfCurrentSector = endAddressOfCurrentSector - start;
633 lengthTobeProgrammedOfCurrentSector = lengthInBytes;
637 while (lengthTobeProgrammedOfCurrentSector > 0)
640 uint32_t programSizeOfCurrentPass;
641 uint32_t numberOfPhases;
643 if (lengthTobeProgrammedOfCurrentSector >
config->flexramTotalSize)
645 programSizeOfCurrentPass =
config->flexramTotalSize;
649 programSizeOfCurrentPass = lengthTobeProgrammedOfCurrentSector;
653 memcpy((
void *)
config->flexramBlockBase, src + currentOffset, programSizeOfCurrentPass);
655 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_SECTION, start + currentOffset);
657 numberOfPhases = programSizeOfCurrentPass / aligmentInBytes;
659 kFCCOBx[1] = BYTE2WORD_2_2(numberOfPhases, 0xFFFFU);
669 lengthTobeProgrammedOfCurrentSector -= programSizeOfCurrentPass;
670 currentOffset += programSizeOfCurrentPass;
673 src += currentOffset;
674 start += currentOffset;
675 lengthInBytes -= currentOffset;
678#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
680 if (needSwitchFlexRamMode)
694#if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD
697 uint32_t eepromDataSizeCode,
698 uint32_t flexnvmPartitionCode)
713 kFCCOBx[0] = BYTE2WORD_1_2_1(FTFx_PROGRAM_PARTITION, 0xFFFFU, option);
714 kFCCOBx[1] = BYTE2WORD_1_1_2(eepromDataSizeCode, flexnvmPartitionCode, 0xFFFFU);
719#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
722 config->eepromTotalSize = 0xFFFFU;
723 config->flashDesc.totalSize = 0xFFFFFFFFU;
734 if ((
config == NULL) || (dst == NULL))
740 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_READ_ONCE, index, 0xFFFFU);
750 if (
config->ifrDesc.feature.has8ByteIdxSupport)
752 if (
config->ifrDesc.feature.has4ByteIdxSupport)
754 if (((index ==
config->ifrDesc.idxInfo.mix8byteIdxStart) ||
755 ((index >=
config->ifrDesc.idxInfo.mix8byteIdxStart + 1) && (index <= config->ifrDesc.idxInfo.mix8byteIdxStart))) &&
756 (lengthInBytes == 8))
771#if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
775 uint32_t lengthInBytes,
780 if ((
config == NULL) || (dst == NULL))
785 uint8_t aligmentInBytes =
config->opsConfig.addrAligment.resourceCmd;
794 while (lengthInBytes > 0)
797 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_READ_RESOURCE, start);
798 if (aligmentInBytes == 4)
800 kFCCOBx[2] = BYTE2WORD_1_3(option, 0xFFFFFFU);
802 else if (aligmentInBytes == 8)
804 kFCCOBx[1] = BYTE2WORD_1_3(option, 0xFFFFFFU);
821 if (aligmentInBytes == 8)
827 start += aligmentInBytes;
829 lengthInBytes -= aligmentInBytes;
838 uint32_t lengthInBytes,
843 uint32_t nextBlockStartAddress;
844 uint32_t remainingBytes;
845 uint8_t aligmentInBytes =
config->opsConfig.addrAligment.sectionCmd;
854 start =
config->opsConfig.convertedAddress;
855 blockSize =
config->flashDesc.totalSize /
config->flashDesc.blockCount;
857 nextBlockStartAddress = ALIGN_UP(start, blockSize);
858 if (nextBlockStartAddress == start)
860 nextBlockStartAddress += blockSize;
863 remainingBytes = lengthInBytes;
865 while (remainingBytes)
867 uint32_t numberOfPhrases;
868 uint32_t verifyLength = nextBlockStartAddress - start;
869 if (verifyLength > remainingBytes)
871 verifyLength = remainingBytes;
874 numberOfPhrases = verifyLength / aligmentInBytes;
877 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_VERIFY_SECTION, start);
878 kFCCOBx[1] = BYTE2WORD_2_1_1(numberOfPhrases, margin, 0xFFU);
887 remainingBytes -= verifyLength;
888 start += verifyLength;
889 nextBlockStartAddress += blockSize;
903 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_VERIFY_ALL_BLOCK, margin, 0xFFFFU);
917 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_VERIFY_ALL_EXECUTE_ONLY_SEGMENT, margin, 0xFFFFU);
925 uint32_t lengthInBytes,
926 const uint8_t *expectedData,
928 uint32_t *failedAddress,
929 uint32_t *failedData)
932 uint8_t aligmentInBytes =
config->opsConfig.addrAligment.checkCmd;
933 if (expectedData == NULL)
944 start =
config->opsConfig.convertedAddress;
946 while (lengthInBytes)
949 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_PROGRAM_CHECK, start);
950 kFCCOBx[1] = BYTE2WORD_1_3(margin, 0xFFFFFFU);
961 *failedAddress = start;
970 lengthInBytes -= aligmentInBytes;
971 expectedData += aligmentInBytes;
972 start += aligmentInBytes;
980 uint8_t registerValue;
983 if ((
config == NULL) || (backdoorKey == NULL))
992 registerValue = FTFx->FSEC;
996 if (0x02 != (registerValue & 0x03))
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]);
1007 return (returnCode);
1013 uint8_t registerValue;
1021 registerValue = FTFx->FSEC;
1048#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
1065 kFCCOBx[0] = BYTE2WORD_1_1_2(FTFx_SET_FLEXRAM_FUNCTION, option, 0xFFFFU);
1072#if defined(FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD) && FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD
1080 if ((
config == NULL) || (returnInfo == NULL))
1085 if (address & (FSL_FEATURE_FLASH_PFLASH_SWAP_CONTROL_CMD_ADDRESS_ALIGMENT - 1))
1091 if ((address >= (
config->flashDesc.totalSize / 2)) ||
1104 kFCCOBx[0] = BYTE2WORD_1_3(FTFx_SWAP_CONTROL, address);
1105 kFCCOBx[1] = BYTE2WORD_1_3(option, 0xFFFFFFU);
1124#if FSL_FEATURE_FLASH_IS_FTFA
1126 config->ifrDesc.feature.has4ByteIdxSupport = 1;
1127 config->ifrDesc.feature.has8ByteIdxSupport = 1;
1128 config->ifrDesc.idxInfo.mix8byteIdxStart = 0x10U;
1129 config->ifrDesc.idxInfo.mix8byteIdxEnd = 0x13U;
1130#elif FSL_FEATURE_FLASH_IS_FTFE
1132 config->ifrDesc.feature.has4ByteIdxSupport = 0;
1133 config->ifrDesc.feature.has8ByteIdxSupport = 1;
1134#elif FSL_FEATURE_FLASH_IS_FTFL
1136 config->ifrDesc.feature.has4ByteIdxSupport = 1;
1137 config->ifrDesc.feature.has8ByteIdxSupport = 0;
1140 config->ifrDesc.resRange.pflashIfrStart = 0x0000U;
1141 config->ifrDesc.resRange.versionIdSize = 0x08U;
1142#if FSL_FEATURE_FLASH_IS_FTFE
1143 config->ifrDesc.resRange.versionIdStart = 0x08U;
1144 config->ifrDesc.resRange.ifrMemSize = 0x0400U;
1146 config->ifrDesc.resRange.versionIdStart = 0x00U;
1147 config->ifrDesc.resRange.ifrMemSize = 0x0100U;
1150#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
1151 config->ifrDesc.resRange.dflashIfrStart = 0x800000U;
1154#if FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD
1155#if FSL_FEATURE_FLASH_IS_FTFE
1156 config->ifrDesc.resRange.pflashSwapIfrStart = 0x40000U;
1158 config->ifrDesc.resRange.pflashSwapIfrStart =
config->flashDesc.totalSize / 4;
1165#if FTFx_DRIVER_IS_FLASH_RESIDENT
1189 uint8_t registerValue;
1191#if FTFx_DRIVER_IS_FLASH_RESIDENT
1193 FTFx->FSTAT = FTFx_FSTAT_RDCOLERR_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_FPVIOL_MASK;
1202 callFtfxRunCommand((FTFx_REG8_ACCESS_TYPE)(&FTFx->FSTAT));
1205 FTFx->FSTAT = FTFx_FSTAT_RDCOLERR_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_FPVIOL_MASK;
1208 FTFx->FSTAT = FTFx_FSTAT_CCIF_MASK;
1212 while (!(FTFx->FSTAT & FTFx_FSTAT_CCIF_MASK))
1219 registerValue = FTFx->FSTAT;
1222 if (registerValue & FTFx_FSTAT_ACCERR_MASK)
1227 else if (registerValue & FTFx_FSTAT_FPVIOL_MASK)
1232 else if (registerValue & FTFx_FSTAT_MGSTAT0_MASK)
1244 uint32_t startAddress,
1245 uint32_t lengthInBytes,
1246 uint8_t alignmentBaseline)
1254 if ((startAddress & (alignmentBaseline - 1)) || (lengthInBytes & (alignmentBaseline - 1)))
1260 if ((startAddress >=
config->flashDesc.blockBase) &&
1261 ((startAddress + lengthInBytes) <= (
config->flashDesc.blockBase +
config->flashDesc.totalSize)))
1286 if (!((uint32_t)src % 4))
1288 word = *(
const uint32_t *)src;
1292 for (uint32_t i = 0; i < 4; i++)
1294 word |= (uint32_t)(*src) << (i * 8);
1305 if (!((uint32_t)dst % 4))
1307 *(uint32_t *)dst = word;
1311 for (uint32_t i = 0; i < 4; i++)
1313 *dst = (uint8_t)((word >> (i * 8)) & 0xFFU);
1319#if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
1323 uint32_t lengthInBytes,
1324 uint32_t alignmentBaseline,
1328 uint32_t maxReadbleAddress;
1330 if ((start & (alignmentBaseline - 1)) || (lengthInBytes & (alignmentBaseline - 1)))
1337 maxReadbleAddress = start + lengthInBytes - 1;
1340 if ((start !=
config->ifrDesc.resRange.versionIdStart) ||
1341 (lengthInBytes !=
config->ifrDesc.resRange.versionIdSize))
1348 if ((start >=
config->ifrDesc.resRange.pflashIfrStart) &&
1349 (maxReadbleAddress < (
config->ifrDesc.resRange.pflashIfrStart +
config->ifrDesc.resRange.ifrMemSize)))
1352#if FSL_FEATURE_FLASH_HAS_FLEX_NVM
1353 else if ((start >=
config->ifrDesc.resRange.dflashIfrStart) &&
1354 (maxReadbleAddress < (
config->ifrDesc.resRange.dflashIfrStart +
config->ifrDesc.resRange.ifrMemSize)))
1358#if FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD
1359 else if ((start >=
config->ifrDesc.resRange.pflashSwapIfrStart) &&
1360 (maxReadbleAddress < (
config->ifrDesc.resRange.pflashSwapIfrStart +
config->ifrDesc.resRange.ifrMemSize)))
1378#if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
1392#if defined(FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD) && FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD
static constexpr persistent_config_s * config
_ftfx_pflash_config_area_range
Enumeration for flash config area.
@ kFTFx_PflashConfigAreaEnd
@ kFTFx_PflashConfigAreaStart
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.
@ kFTFx_FsecRegCode_SEC_Unsecured
@ kFTFx_FsecRegCode_KEYEN_Enabled
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.
static volatile uint32_t *const kFCCOBx
Access to FTFx Registers.
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.
static uint32_t ftfx_read_word_from_byte_address(const uint8_t *src)
Reads word from byte address.
status_t FTFx_API_UpdateFlexnvmPartitionStatus(ftfx_config_t *config)
Updates FlexNVM memory partition status according to data flash 0 IFR.
void(* callFtfxRunCommand_t)(FTFx_REG8_ACCESS_TYPE ftfx_fstat)
A function pointer used to point to relocated flash_run_command()
static status_t ftfx_command_sequence(ftfx_config_t *config)
Internal function Flash command sequence. Called by driver APIs only.
status_t FTFx_CMD_ProgramOnce(ftfx_config_t *config, uint32_t index, uint8_t *src, uint32_t lengthInBytes)
Programs Program Once Field through parameters.
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.
status_t FTFx_API_Init(ftfx_config_t *config)
Initializes the global flash properties structure members.
static status_t ftfx_check_flexram_function_option(ftfx_flexram_func_opt_t option)
Validates the gived flexram function option.
static const uint16_t kEepromDensities[16]
Table of eeprom sizes.
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.
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.
_ftfx_ram_func_constants
Constants for execute-in-RAM flash function.
@ kFTFx_RamFuncMaxSizeInWords
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 margi...
static uint32_t s_ftfxRunCommand[kFTFx_RamFuncMaxSizeInWords]
A static buffer used to hold flash_run_command()
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.
static status_t ftfx_check_user_key(uint32_t key)
Validates the given user key for flash erase APIs.
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.
static status_t ftfx_init_ifr(ftfx_config_t *config)
Init IFR memory related info.
static const uint32_t kDflashDensities[16]
Table of dflash sizes.
static void ftfx_copy_run_command_to_ram(uint32_t *ftfxRunCommand)
Copy flash_run_command() to RAM.
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.
static void ftfx_write_word_to_byte_address(uint8_t *dst, uint32_t word)
Writes word to byte address.
status_t FTFx_CMD_SetFlexramFunction(ftfx_config_t *config, ftfx_flexram_func_opt_t option)
Sets the FlexRAM function command.
static const uint16_t s_ftfxRunCommandFunctionCode[]
Position independent code of flash_run_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...
static status_t ftfx_check_swap_control_option(ftfx_swap_control_opt_t option)
Validates the gived swap control option.
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_EraseAllExecuteOnlySegments(ftfx_config_t *config, uint32_t key)
Erases all program flash execute-only segments defined by the FXACC registers.
enum _ftfx_read_resource_opt ftfx_read_resource_opt_t
Enumeration for the two possible options of flash read resource command.
@ kFTFx_SecurityStateBackdoorEnabled
@ kFTFx_SecurityStateNotSecure
@ kFTFx_SecurityStateBackdoorDisabled
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
@ kStatus_FTFx_AlignmentError
@ kStatus_FTFx_SetFlexramAsRamError
@ kStatus_FTFx_CommandFailure
@ kStatus_FTFx_EraseKeyError
@ kStatus_FTFx_RecoverFlexramAsEepromError
@ kStatus_FTFx_InvalidArgument
@ kStatus_FTFx_AddressError
@ kStatus_FTFx_ExecuteInRamFunctionNotReady
@ kStatus_FTFx_PartitionStatusUpdateFailure
@ kStatus_FTFx_SwapIndicatorAddressError
@ kStatus_FTFx_ProtectionViolation
@ kStatus_FTFx_AccessError
enum _ftfx_swap_block_status ftfx_swap_block_status_t
enum _ftfx_margin_value ftfx_margin_value_t
Enumeration for supported FTFx margin levels.
@ kFTFx_FlexramFuncOptAvailableForEeprom
@ kFTFx_FlexramFuncOptAvailableAsRam
enum _ftfx_swap_state ftfx_swap_state_t
Enumeration for the possible flash Swap status.
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.
@ kFTFx_ResourceOptionVersionId
@ kFTFx_ResourceOptionFlashIfr
enum _ftfx_partition_flexram_load_option ftfx_partition_flexram_load_opt_t
Enumeration for the FlexRAM load during reset option.
int32_t status_t
Type used for all status and error return values.
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
Flash driver state information.
ftfx_swap_block_status_t nextSwapBlockStatus
ftfx_swap_state_t flashSwapState
ftfx_swap_block_status_t currentSwapBlockStatus