1 /* 2 * Copyright 2021,2024 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef _FSL_FLASH_API_H_ 9 #define _FSL_FLASH_API_H_ 10 11 #include "fsl_common.h" 12 13 /*! 14 * @addtogroup flash_driver_api 15 * @{ 16 */ 17 /******************************************************************************* 18 * Definitions 19 ******************************************************************************/ 20 21 /*! 22 * @name Flash version 23 * @{ 24 */ 25 /*! @brief Flash driver version for SDK*/ 26 #define FSL_FLASH_DRIVER_VERSION (MAKE_VERSION(1, 2, 0)) /*!< Version 1.2.0. */ 27 /*@}*/ 28 29 /*! @brief Constructs the four character code for the Flash driver API key. */ 30 #if !defined(FOUR_CHAR_CODE) 31 #define FOUR_CHAR_CODE(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a))) 32 #endif 33 34 /*! @brief Alignment(down) utility. */ 35 #if !defined(ALIGN_DOWN) 36 #define ALIGN_DOWN(x, a) (((uint32_t)(x)) & ~((uint32_t)(a)-1u)) 37 #endif 38 39 /*! @brief Flash driver version for ROM*/ 40 enum _flash_driver_version_constants 41 { 42 kFLASH_DriverVersionName = 'F', /*!< Flash driver version name.*/ 43 kFLASH_DriverVersionMajor = 1, /*!< Major flash driver version.*/ 44 kFLASH_DriverVersionMinor = 1, /*!< Minor flash driver version.*/ 45 kFLASH_DriverVersionBugfix = 0 /*!< Bugfix for flash driver version.*/ 46 }; 47 48 /*! 49 * @name FLASH status 50 * @{ 51 */ 52 /*! @brief FLASH driver status group. */ 53 enum 54 { 55 kStatusGroupGeneric = 0, 56 kStatusGroupFlashDriver = 1, 57 }; 58 59 /*! 60 * @brief FLASH driver status codes. 61 */ 62 enum 63 { 64 kStatus_FLASH_Success = MAKE_STATUS(kStatusGroupGeneric, 0), /*!< API is executed successfully*/ 65 kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4), /*!< Invalid argument*/ 66 kStatus_FLASH_SizeError = MAKE_STATUS(kStatusGroupFlashDriver, 0), /*!< Error size*/ 67 kStatus_FLASH_AlignmentError = 68 MAKE_STATUS(kStatusGroupFlashDriver, 1), /*!< Parameter is not aligned with the specified baseline*/ 69 kStatus_FLASH_AddressError = MAKE_STATUS(kStatusGroupFlashDriver, 2), /*!< Address is out of range */ 70 kStatus_FLASH_AccessError = 71 MAKE_STATUS(kStatusGroupFlashDriver, 3), /*!< Invalid instruction codes and out-of bound addresses */ 72 kStatus_FLASH_ProtectionViolation = MAKE_STATUS( 73 kStatusGroupFlashDriver, 4), /*!< The program/erase operation is requested to execute on protected areas */ 74 kStatus_FLASH_CommandFailure = 75 MAKE_STATUS(kStatusGroupFlashDriver, 5), /*!< Run-time error during command execution. */ 76 kStatus_FLASH_UnknownProperty = MAKE_STATUS(kStatusGroupFlashDriver, 6), /*!< Unknown property.*/ 77 kStatus_FLASH_EraseKeyError = MAKE_STATUS(kStatusGroupFlashDriver, 7), /*!< API erase key is invalid.*/ 78 kStatus_FLASH_RegionExecuteOnly = 79 MAKE_STATUS(kStatusGroupFlashDriver, 8), /*!< The current region is execute-only.*/ 80 kStatus_FLASH_ExecuteInRamFunctionNotReady = 81 MAKE_STATUS(kStatusGroupFlashDriver, 9), /*!< Execute-in-RAM function is not available.*/ 82 kStatus_FLASH_PartitionStatusUpdateFailure = 83 MAKE_STATUS(kStatusGroupFlashDriver, 10), /*!< Failed to update partition status.*/ 84 kStatus_FLASH_SetFlexramAsEepromError = 85 MAKE_STATUS(kStatusGroupFlashDriver, 11), /*!< Failed to set FlexRAM as EEPROM.*/ 86 kStatus_FLASH_RecoverFlexramAsRamError = 87 MAKE_STATUS(kStatusGroupFlashDriver, 12), /*!< Failed to recover FlexRAM as RAM.*/ 88 kStatus_FLASH_SetFlexramAsRamError = MAKE_STATUS(kStatusGroupFlashDriver, 13), /*!< Failed to set FlexRAM as RAM.*/ 89 kStatus_FLASH_RecoverFlexramAsEepromError = 90 MAKE_STATUS(kStatusGroupFlashDriver, 14), /*!< Failed to recover FlexRAM as EEPROM.*/ 91 kStatus_FLASH_CommandNotSupported = MAKE_STATUS(kStatusGroupFlashDriver, 15), /*!< Flash API is not supported.*/ 92 kStatus_FLASH_SwapSystemNotInUninitialized = 93 MAKE_STATUS(kStatusGroupFlashDriver, 16), /*!< Swap system is not in an uninitialzed state.*/ 94 kStatus_FLASH_SwapIndicatorAddressError = 95 MAKE_STATUS(kStatusGroupFlashDriver, 17), /*!< The swap indicator address is invalid.*/ 96 kStatus_FLASH_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFlashDriver, 18), /*!< The flash property is read-only.*/ 97 kStatus_FLASH_InvalidPropertyValue = 98 MAKE_STATUS(kStatusGroupFlashDriver, 19), /*!< The flash property value is out of range.*/ 99 kStatus_FLASH_InvalidSpeculationOption = 100 MAKE_STATUS(kStatusGroupFlashDriver, 20), /*!< The option of flash prefetch speculation is invalid.*/ 101 kStatus_FLASH_CommandAborOption = 102 MAKE_STATUS(kStatusGroupFlashDriver, 21), /*!< The option of flash prefetch speculation is invalid.*/ 103 }; 104 /*@}*/ 105 106 /*! 107 * @brief Enumeration for various flash properties. 108 */ 109 typedef enum _flash_property_tag 110 { 111 kFLASH_PropertyPflash0SectorSize = 0x00U, /*!< Pflash sector size property.*/ 112 kFLASH_PropertyPflash0TotalSize = 0x01U, /*!< Pflash total size property.*/ 113 kFLASH_PropertyPflash0BlockSize = 0x02U, /*!< Pflash block size property.*/ 114 kFLASH_PropertyPflash0BlockCount = 0x03U, /*!< Pflash block count property.*/ 115 kFLASH_PropertyPflash0BlockBaseAddr = 0x04U, /*!< Pflash block base address property.*/ 116 kFLASH_PropertyPflash0FacSupport = 0x05U, /*!< Pflash fac support property.*/ 117 kFLASH_PropertyPflash0AccessSegmentSize = 0x06U, /*!< Pflash access segment size property.*/ 118 kFLASH_PropertyPflash0AccessSegmentCount = 0x07U, /*!< Pflash access segment count property.*/ 119 120 kFLASH_PropertyPflash1SectorSize = 0x10U, /*!< Pflash sector size property.*/ 121 kFLASH_PropertyPflash1TotalSize = 0x11U, /*!< Pflash total size property.*/ 122 kFLASH_PropertyPflash1BlockSize = 0x12U, /*!< Pflash block size property.*/ 123 kFLASH_PropertyPflash1BlockCount = 0x13U, /*!< Pflash block count property.*/ 124 kFLASH_PropertyPflash1BlockBaseAddr = 0x14U, /*!< Pflash block base address property.*/ 125 kFLASH_PropertyPflash1FacSupport = 0x15U, /*!< Pflash fac support property.*/ 126 kFLASH_PropertyPflash1AccessSegmentSize = 0x16U, /*!< Pflash access segment size property.*/ 127 kFLASH_PropertyPflash1AccessSegmentCount = 0x17U, /*!< Pflash access segment count property.*/ 128 129 kFLASH_PropertyFlexRamBlockBaseAddr = 0x20U, /*!< FlexRam block base address property.*/ 130 kFLASH_PropertyFlexRamTotalSize = 0x21U, /*!< FlexRam total size property.*/ 131 } flash_property_tag_t; 132 133 /*! 134 * @name Flash API key 135 * @{ 136 */ 137 /*! 138 * @brief Enumeration for Flash driver API keys. 139 * 140 * @note The resulting value is built with a byte order such that the string 141 * being readable in expected order when viewed in a hex editor, if the value 142 * is treated as a 32-bit little endian value. 143 */ 144 enum _flash_driver_api_keys 145 { 146 kFLASH_ApiEraseKey = FOUR_CHAR_CODE('l', 'f', 'e', 'k') /*!< Key value used to validate all flash erase APIs.*/ 147 }; 148 /*@}*/ 149 150 /*! 151 * @brief Flash memory descriptor. 152 */ 153 typedef struct _flash_mem_descriptor 154 { 155 uint32_t blockBase; /*!< A base address of the flash block */ 156 uint32_t totalSize; /*!< The size of the flash block. */ 157 uint32_t blockCount; /*!< A number of flash blocks. */ 158 } flash_mem_desc_t; 159 160 typedef struct _flash_ifr_desc 161 { 162 uint32_t pflashIfr0Start; 163 uint32_t pflashIfr0MemSize; 164 } flash_ifr_desc_t; 165 166 typedef struct _msf1_config 167 { 168 flash_mem_desc_t flashDesc; 169 flash_ifr_desc_t ifrDesc; 170 } msf1_config_t; 171 172 /*! @brief Flash driver state information. 173 * 174 * An instance of this structure is allocated by the user of the flash driver and 175 * passed into each of the driver APIs. 176 */ 177 typedef struct _flash_config 178 { 179 msf1_config_t msf1Config[2]; 180 } flash_config_t; 181 182 /*! @brief Interface for the flash driver.*/ 183 typedef struct FlashDriverInterface 184 { 185 status_t (*flash_init)(flash_config_t *config); 186 status_t (*flash_erase_sector)( 187 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes, uint32_t key); 188 status_t (*flash_program_phrase)( 189 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t *src, uint32_t lengthInBytes); 190 status_t (*flash_program_page)( 191 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t *src, uint32_t lengthInBytes); 192 status_t (*flash_verify_erase_all)(FMU_Type *base); 193 status_t *reserved; 194 status_t (*flash_verify_erase_phrase)(flash_config_t *config, 195 FMU_Type *base, 196 uint32_t start, 197 uint32_t lengthInBytes); 198 status_t (*flash_verify_erase_page)(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 199 status_t (*flash_verify_erase_sector)(flash_config_t *config, 200 FMU_Type *base, 201 uint32_t start, 202 uint32_t lengthInBytes); 203 status_t (*flash_read_into_misr)( 204 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t end, uint32_t *seed, uint32_t *signature); 205 status_t (*flash_get_property)(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value); 206 // IFR driver 207 status_t (*ifr_verify_erase_phrase)(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 208 status_t (*ifr_verify_erase_page)(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 209 status_t (*ifr_verify_erase_sector)(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 210 status_t (*ifr_read_into_misr)( 211 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t end, uint32_t *seed, uint32_t *signature); 212 } flash_driver_interface_t; 213 214 /******************************************************************************* 215 * API 216 ******************************************************************************/ 217 218 #if defined(__cplusplus) 219 extern "C" { 220 #endif 221 222 /*! 223 * @name Initialization 224 * @{ 225 */ 226 227 /*! 228 * @brief Initializes the global flash properties structure members. 229 * 230 * This function checks and initializes the Flash module for the other Flash APIs. 231 * 232 * @param config Pointer to the storage for the driver runtime state. 233 * 234 * @retval #kStatus_FLASH_Success API was executed successfully. 235 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 236 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 237 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported. 238 */ 239 status_t FLASH_Init(flash_config_t *config); 240 241 /*@}*/ 242 243 /*! 244 * @name Erasing 245 * @{ 246 */ 247 248 /*! 249 * @brief Erases the Dflash sectors encompassed by parameters passed into function. 250 * 251 * This function erases the appropriate number of flash sectors based on the 252 * desired start address and length. 253 * 254 * @param config The pointer to the storage for the driver runtime state. 255 * @param start The start address of the desired flash memory to be erased, 256 * Must be phrase-aligned. 257 * @param lengthInBytes The length, given in bytes to be erased, It is recommended 258 * that the length is aligned with the sector. 259 * @param base FMU base address. 260 * @param key The value used to validate all flash erase APIs. 261 * 262 * @retval #kStatus_FLASH_Success API was executed successfully. 263 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 264 * @retval #kStatus_FLASH_AlignmentError The parameter is not aligned with the specified baseline. 265 * @retval #kStatus_FLASH_AddressError The address is out of range. 266 * @retval #kStatus_FLASH_EraseKeyError The API erase key is invalid. 267 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 268 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 269 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 270 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 271 */ 272 status_t FLASH_Erase(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes, uint32_t key); 273 274 /*@}*/ 275 276 /*! 277 * @name Programming 278 * @{ 279 */ 280 281 /*! 282 * @brief Programs flash phrases with data at locations passed in through parameters. 283 * 284 * This function programs the flash memory with the desired data for a given 285 * flash area as determined by the start address and the length. 286 * 287 * @param config A pointer to the storage for the driver runtime state. 288 * @param base FMU base address. 289 * @param start The start address of the desired flash memory to be programmed, 290 * Must be phrase-aligned. 291 * @param src A pointer to the source buffer of data that is to be programmed 292 * into the flash. 293 * @param lengthInBytes The length, given in bytes must be phrase-aligned. 294 * 295 * @retval #kStatus_FLASH_Success API was executed successfully. 296 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 297 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline. 298 * @retval #kStatus_FLASH_AddressError Address is out of range. 299 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 300 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 301 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 302 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 303 */ 304 status_t FLASH_Program(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t *src, uint32_t lengthInBytes); 305 306 /*! 307 * @brief Programs flash pages with data at locations passed in through parameters. 308 * 309 * @param config A pointer to the storage for the driver runtime state. 310 * @param base FMU base address. 311 * @param start The start address of the desired flash memory to be programmed. Must be 312 * page-aligned. 313 * @param src A pointer to the source buffer of data that is to be programmed 314 * into the flash. 315 * @param lengthInBytes The length, given in bytes (not words or long-words), 316 * to be programmed. Must be page-aligned. 317 * 318 * @retval #kStatus_FLASH_Success API was executed successfully. 319 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 320 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline. 321 * @retval #kStatus_FLASH_AddressError Address is out of range. 322 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 323 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 324 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 325 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 326 */ 327 status_t FLASH_ProgramPage( 328 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t *src, uint32_t lengthInBytes); 329 330 /*@}*/ 331 332 /*! 333 * @name Verification 334 * @{ 335 */ 336 /*! 337 * @brief Verify that all flash and IFR space is erased 338 * 339 * @param base FMU base address. 340 * 341 * @retval #kStatus_FLASH_Success API was executed successfully. 342 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 343 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 344 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 345 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 346 * @retval #kStatus_FLASH_CommandAborOption 347 */ 348 status_t FLASH_VerifyEraseAll(FMU_Type *base); 349 350 /*! 351 * @brief Verify that the flash phrases are erased 352 * 353 * @param config A pointer to the storage for the driver runtime state. 354 * @param base FMU base address. 355 * @param start The start address of the desired flash memory to be verified. 356 * The start address need to be phrase-aligned. 357 * @param lengthInBytes The length, It is recommended that the length is aligned with the phrase. 358 * 359 * @retval #kStatus_FLASH_Success API was executed successfully. 360 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 361 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 362 * @retval #kStatus_FLASH_AddressError Address is out of range. 363 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 364 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 365 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 366 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 367 */ 368 status_t FLASH_VerifyErasePhrase(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 369 370 /*! 371 * @brief Verify that the flash pages are erased 372 * 373 * @param config A pointer to the storage for the driver runtime state. 374 * @param base FMU base address. 375 * @param start The start address of the desired flash memory to be verified. 376 * The start address must be page-aligned. 377 * @param lengthInBytes The length, It is recommended that the length is aligned with the page. 378 * 379 * @retval #kStatus_FLASH_Success API was executed successfully. 380 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 381 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 382 * @retval #kStatus_FLASH_AddressError Address is out of range. 383 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 384 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 385 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 386 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 387 */ 388 status_t FLASH_VerifyErasePage(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 389 390 /*! 391 * @brief Verify that the flash sector are erased 392 * 393 * @param config A pointer to the storage for the driver runtime state. 394 * @param base FMU base address. 395 * @param start The start address of the desired flash memory to be verified. 396 * The start address need to be sector-aligned. 397 * @param lengthInBytes The length, It is recommended that the length is aligned with the page. 398 * 399 * @retval #kStatus_FLASH_Success API was executed successfully. 400 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 401 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 402 * @retval #kStatus_FLASH_AddressError Address is out of range. 403 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 404 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 405 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 406 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 407 */ 408 status_t FLASH_VerifyEraseSector(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 409 410 /*! 411 * @brief Verify that the ifr phrases are erased 412 * 413 * @param config A pointer to the storage for the driver runtime state. 414 * @param base FMU base address. 415 * @param start The start address of the desired ifr memory to be verified. 416 * The start address need to be phrase-aligned. 417 * @param lengthInBytes The length, it is recommended that the length is aligned with the phrase. 418 * 419 * @retval #kStatus_FLASH_Success API was executed successfully. 420 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 421 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 422 * @retval #kStatus_FLASH_AddressError Address is out of range. 423 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 424 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 425 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 426 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 427 */ 428 status_t FLASH_VerifyEraseIFRPhrase(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 429 430 /*! 431 * @brief Verify that the ifr pages are erased 432 * 433 * @param config A pointer to the storage for the driver runtime state. 434 * @param base FMU base address. 435 * @param start The start address of the desired ifr memory to be verified. 436 * The start address need to be page-aligned. 437 * @param lengthInBytes The length, it is recommended that the length is aligned with the page. 438 * 439 * @retval #kStatus_FLASH_Success API was executed successfully. 440 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 441 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 442 * @retval #kStatus_FLASH_AddressError Address is out of range. 443 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 444 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 445 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 446 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 447 */ 448 status_t FLASH_VerifyEraseIFRPage(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 449 450 /*! 451 * @brief Verify that the ifr sectors are erased 452 * 453 * @param config A pointer to the storage for the driver runtime state. 454 * @param base FMU base address. 455 * @param start The start address of the desired ifr memory to be verified. 456 * The start address need to be sector-aligned. 457 * @param lengthInBytes The length, it is recommended that the length is aligned with the page. 458 * 459 * @retval #kStatus_FLASH_Success API was executed successfully. 460 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 461 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 462 * @retval #kStatus_FLASH_AddressError Address is out of range. 463 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 464 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 465 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 466 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 467 */ 468 status_t FLASH_VerifyEraseIFRSector(flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t lengthInBytes); 469 470 /*@}*/ 471 472 /*! 473 * @name Properties 474 * @{ 475 */ 476 477 /*! 478 * @brief Returns the desired flash property. 479 * 480 * @param config A pointer to the storage for the driver runtime state. 481 * @param whichProperty The desired property from the list of properties in 482 * enum flash_property_tag_t 483 * @param value A pointer to the value returned for the desired flash property. 484 * 485 * @retval #kStatus_FLASH_Success API was executed successfully. 486 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 487 * @retval #kStatus_FLASH_UnknownProperty An unknown property tag. 488 */ 489 status_t FLASH_GetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value); 490 491 /*@}*/ 492 493 /*! 494 * @name Read (Main Array or IFR) Into MISR 495 * @{ 496 */ 497 /*! 498 * @brief Read into MISR 499 * 500 * The Read into MISR operation generates a signature based on the contents of the selected 501 * flash memory using an embedded MISR. 502 * 503 * @param config A pointer to the storage for the driver runtime state. 504 * @param base FMU base address. 505 * @param start The start address of the desired flash memory to be programed. 506 * The start address need to be page-aligned. 507 * @param endAddr The end address of the desired flash memory to be programed. 508 * @param seed A pointer to the source buffer of seed that is to be programmed 509 * into the signature register . 510 * @param signature Returns the generated signature frome the flash specified area. 511 * 512 * @retval #kStatus_FLASH_Success API was executed successfully. 513 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 514 * @retval #kStatus_FLASH_UnknownProperty An unknown property tag. 515 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 516 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bound addresses 517 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 518 * @retval #kStatus_FLASH_CommandAborOption The option of flash prefetch speculation is invalid. 519 */ 520 status_t FLASH_ReadIntoMisr( 521 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t endAddr, uint32_t *seed, uint32_t *signature); 522 523 /*! 524 * @brief Read IFR into MISR 525 * 526 * The Read IFR into MISR operation generates a signature based on the contents of the 527 * selected IFR space using an embedded MISR. 528 * 529 * @param config A pointer to the storage for the driver runtime state. 530 * @param base FMU base address. 531 * @param start The start address of the desired ifr memory to be programed. 532 * The start address need to be page-aligned. 533 * @param endAddr The end address of the desired ifr memory to be programed. 534 * @param seed A pointer to the source buffer of seed that is to be programmed 535 * into the signature register . 536 * @param signature Returns the generated signature frome the ifr specified area. 537 * 538 * @retval #kStatus_FLASH_Success API was executed successfully. 539 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 540 * @retval #kStatus_FLASH_UnknownProperty An unknown property tag. 541 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 542 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bound addresses. 543 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 544 * @retval #kStatus_FLASH_CommandAborOption The option of flash prefetch speculation is invalid. 545 */ 546 status_t FLASH_ReadIFRIntoMisr( 547 flash_config_t *config, FMU_Type *base, uint32_t start, uint32_t endAddr, uint32_t *seed, uint32_t *signature); 548 549 /*@}*/ 550 551 /*! 552 * @brief FLASH_CACHE_Disable 553 * 554 * FLASH_CACHE_Disable disables the cache of FMU0, but not radio FMU 555 */ 556 void FLASH_CACHE_Disable(void); 557 558 /*! 559 * @brief FLASH_CACHE_Clear 560 * 561 * FLASH_CACHE_Clear clears cache of FMU0, but not radio FMU 562 * 563 * @param isPreProcess, set to true if it's before program/erase execution, 564 set ti false if it's after the program/erase execution 565 */ 566 void FLASH_CACHE_Clear(bool isPreProcess); 567 568 #if defined(__cplusplus) 569 } 570 #endif 571 572 /*! @}*/ 573 574 #endif /* _FSL_FLASH_API_H_ */ 575