@@ -156,7 +156,7 @@ const uint8_t *currentOperatingData;
156
156
#define OPTIMAL_PROGRAM_UNIT (1024UL)
157
157
#define PROGRAM_PHRASE_SIZEOF_INLINE_DATA (8)
158
158
#define SIZEOF_DOUBLE_PHRASE (FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT)
159
- #else
159
+ #else /* ifdef USING_KSDK2 */
160
160
#define ERASE_UNIT (4096)
161
161
#define BLOCK1_START_ADDR (0x80000UL)
162
162
#define BLOCK1_SIZE (0x80000UL)
@@ -221,31 +221,31 @@ static const ARM_STORAGE_CAPABILITIES caps = {
221
221
/* Enable chip-erase functionality if we own all of block-1. */
222
222
#if ((!defined (YOTTA_CFG_CONFIG_HARDWARE_MTD_START_ADDR ) || (YOTTA_CFG_CONFIG_HARDWARE_MTD_START_ADDR == BLOCK1_START_ADDR )) && \
223
223
(!defined (YOTTA_CFG_CONFIG_HARDWARE_MTD_SIZE ) || (YOTTA_CFG_CONFIG_HARDWARE_MTD_SIZE == BLOCK1_SIZE )))
224
- .erase_all = 1 , /**< Supports EraseChip operation. */
224
+ .erase_all = 1 , /**< Supports EraseChip operation. */
225
225
#else
226
- .erase_all = 0 , /**< Supports EraseChip operation. */
226
+ .erase_all = 0 , /**< Supports EraseChip operation. */
227
227
#endif
228
228
};
229
229
230
230
static const ARM_STORAGE_INFO info = {
231
- .total_storage = 512 * 1024 , /**< Total available storage, in units of octets. */
231
+ .total_storage = BLOCK1_SIZE , /**< Total available storage, in units of octets. By default, BLOCK0 is reserved to hold program code . */
232
232
233
233
.program_unit = PROGRAM_UNIT ,
234
234
.optimal_program_unit = OPTIMAL_PROGRAM_UNIT ,
235
235
236
- .program_cycles = ARM_STORAGE_PROGRAM_CYCLES_INFINITE , /**< A measure of endurance for reprogramming.
237
- * Use ARM_STOR_PROGRAM_CYCLES_INFINITE for infinite or unknown endurance. */
236
+ .program_cycles = ARM_STORAGE_PROGRAM_CYCLES_INFINITE , /**< A measure of endurance for reprogramming.
237
+ * Use ARM_STOR_PROGRAM_CYCLES_INFINITE for infinite or unknown endurance. */
238
238
239
- .erased_value = 0x1 , /**< Contents of erased memory (1 to indicate erased octets with state 0xFF). */
240
- .memory_mapped = 1 ,
239
+ .erased_value = 0x1 , /**< Contents of erased memory (1 to indicate erased octets with state 0xFF). */
240
+ .memory_mapped = 1 ,
241
241
242
- .programmability = ARM_STORAGE_PROGRAMMABILITY_ERASABLE , /**< A value of type enum ARM_STOR_PROGRAMMABILITY. */
243
- .retention_level = ARM_RETENTION_NVM ,
244
- .security = {
245
- .acls = 0 , /**< against internal software attacks using ACLs. */
246
- .rollback_protection = 0 , /**< roll-back protection. */
247
- .tamper_proof = 0 , /**< tamper-proof memory (will be deleted on tamper-attempts using board level or chip level sensors). */
248
- .internal_flash = 1 , /**< Internal flash. */
242
+ .programmability = ARM_STORAGE_PROGRAMMABILITY_ERASABLE , /**< A value of type enum ARM_STOR_PROGRAMMABILITY. */
243
+ .retention_level = ARM_RETENTION_NVM ,
244
+ .security = {
245
+ .acls = 0 , /**< against internal software attacks using ACLs. */
246
+ .rollback_protection = 0 , /**< roll-back protection. */
247
+ .tamper_proof = 0 , /**< tamper-proof memory (will be deleted on tamper-attempts using board level or chip level sensors). */
248
+ .internal_flash = 1 , /**< Internal flash. */
249
249
250
250
.software_attacks = 0 ,
251
251
.board_level_attacks = 0 ,
@@ -254,7 +254,6 @@ static const ARM_STORAGE_INFO info = {
254
254
}
255
255
};
256
256
257
-
258
257
/**
259
258
* This is the command code written into the first FCCOB register, FCCOB0.
260
259
*/
@@ -288,9 +287,9 @@ static inline bool failedWithAccessError(void)
288
287
289
288
/* checking access error */
290
289
return registerValue & FTFx_FSTAT_ACCERR_MASK ;
291
- #else
290
+ #else /* ifdef USING_KSDK2 */
292
291
return BR_FTFE_FSTAT_ACCERR (FTFE );
293
- #endif
292
+ #endif /* ifdef USING_KSDK2 */
294
293
}
295
294
296
295
static inline bool failedWithProtectionError ()
@@ -301,9 +300,9 @@ static inline bool failedWithProtectionError()
301
300
302
301
/* checking protection error */
303
302
return registerValue & FTFx_FSTAT_FPVIOL_MASK ;
304
- #else
303
+ #else /* ifdef USING_KSDK2 */
305
304
return BR_FTFE_FSTAT_FPVIOL (FTFE );
306
- #endif
305
+ #endif /* ifdef USING_KSDK2 */
307
306
}
308
307
309
308
static inline bool failedWithRunTimeError ()
@@ -314,9 +313,9 @@ static inline bool failedWithRunTimeError()
314
313
315
314
/* checking MGSTAT0 non-correctable error */
316
315
return registerValue & FTFx_FSTAT_MGSTAT0_MASK ;
317
- #else
316
+ #else /* ifdef USING_KSDK2 */
318
317
return BR_FTFE_FSTAT_MGSTAT0 (FTFE );
319
- #endif
318
+ #endif /* ifdef USING_KSDK2 */
320
319
}
321
320
322
321
static inline void clearAccessError (void )
@@ -415,7 +414,7 @@ static inline void setupAddressInCCOB123(uint64_t addr)
415
414
BW_FTFE_FCCOB2_CCOBn ((uintptr_t )FTFE , (addr >> 8 ) & 0xFFUL ); /* bits [15:8] of the address. */
416
415
BW_FTFE_FCCOB3_CCOBn ((uintptr_t )FTFE , (addr >> 0 ) & 0xFFUL ); /* bits [7:0] of the address. */
417
416
}
418
- #endif
417
+ #endif /* ifndef USING_KSDK2 */
419
418
420
419
static inline void setupEraseSector (uint64_t addr )
421
420
{
@@ -446,7 +445,7 @@ static inline void setup8ByteWrite(uint64_t addr, const void *data)
446
445
/* Program 8 bytes of data into FCCOB(4..11)_CCOBn */
447
446
kFCCOBx [1 ] = ((const uint32_t * )data )[0 ];
448
447
kFCCOBx [2 ] = ((const uint32_t * )data )[1 ];
449
- #else
448
+ #else /* ifdef USING_KSDK2 */
450
449
BW_FTFE_FCCOB0_CCOBn ((uintptr_t )FTFE , PGM8 );
451
450
setupAddressInCCOB123 (addr );
452
451
@@ -458,7 +457,7 @@ static inline void setup8ByteWrite(uint64_t addr, const void *data)
458
457
BW_FTFE_FCCOB9_CCOBn ((uintptr_t )FTFE , ((const uint8_t * )data )[6 ]); /* byte 6 of program value. */
459
458
BW_FTFE_FCCOBA_CCOBn ((uintptr_t )FTFE , ((const uint8_t * )data )[5 ]); /* byte 5 of program value. */
460
459
BW_FTFE_FCCOBB_CCOBn ((uintptr_t )FTFE , ((const uint8_t * )data )[4 ]); /* byte 4 of program value. */
461
- #endif
460
+ #endif /* ifdef USING_KSDK2 */
462
461
}
463
462
464
463
static inline void setupProgramSection (uint64_t addr , const void * data , size_t cnt )
@@ -469,7 +468,7 @@ static inline void setupProgramSection(uint64_t addr, const void *data, size_t c
469
468
470
469
kFCCOBx [0 ] = BYTES_JOIN_TO_WORD_1_3 (PGMSEC , addr );
471
470
kFCCOBx [1 ] = BYTES_JOIN_TO_WORD_2_2 (cnt >> 4 , 0xFFFFU );
472
- #else
471
+ #else /* ifdef USING_KSDK2 */
473
472
static const uintptr_t FlexRAMBase = 0x14000000 ;
474
473
memcpy ((void * )FlexRAMBase , (const uint8_t * )data , cnt );
475
474
@@ -478,7 +477,7 @@ static inline void setupProgramSection(uint64_t addr, const void *data, size_t c
478
477
479
478
BW_FTFE_FCCOB4_CCOBn ((uintptr_t )FTFE , ((((uint32_t )(cnt >> 4 )) & (0x0000FF00 )) >> 8 )); /* number of 128-bits to program [15:8] */
480
479
BW_FTFE_FCCOB5_CCOBn ((uintptr_t )FTFE , (((uint32_t )(cnt >> 4 )) & (0x000000FF ))); /* number of 128-bits to program [7:0] */
481
- #endif
480
+ #endif /* ifdef USING_KSDK2 */
482
481
}
483
482
484
483
/**
@@ -760,7 +759,7 @@ static int32_t initialize(ARM_Storage_Callback_t callback)
760
759
if (rc != kStatus_FLASH_Success ) {
761
760
return ARM_DRIVER_ERROR ;
762
761
}
763
- #endif
762
+ #endif /* ifdef USING_KSDK2 */
764
763
765
764
if (controllerCurrentlyBusy ()) {
766
765
/* The user cannot initiate any further FTFE commands until notified that the
@@ -944,7 +943,7 @@ static int32_t eraseAll(void)
944
943
static ARM_STORAGE_STATUS getStatus (void )
945
944
{
946
945
ARM_STORAGE_STATUS status = {
947
- .busy = 0 ,
946
+ .busy = 0 ,
948
947
.error = 0 ,
949
948
};
950
949
@@ -972,7 +971,7 @@ static uint32_t resolveAddress(uint64_t addr) {
972
971
return (uint32_t )addr ;
973
972
}
974
973
975
- int32_t nextBlock (const ARM_STORAGE_BLOCK * prevP , ARM_STORAGE_BLOCK * nextP )
974
+ int32_t nextBlock (const ARM_STORAGE_BLOCK * prevP , ARM_STORAGE_BLOCK * nextP )
976
975
{
977
976
if (prevP == NULL ) {
978
977
/* fetching the first block (instead of next) */
@@ -983,7 +982,7 @@ int32_t nextBlock(const ARM_STORAGE_BLOCK* prevP, ARM_STORAGE_BLOCK *nextP)
983
982
}
984
983
985
984
static const size_t NUM_SEGMENTS = sizeof (blockTable ) / sizeof (ARM_STORAGE_BLOCK );
986
- for (size_t index = 0 ; index < (NUM_SEGMENTS - 1 ); index ++ ) {
985
+ for (size_t index = 0 ; ( NUM_SEGMENTS > 1 ) && ( index < (NUM_SEGMENTS - 1 ) ); index ++ ) {
987
986
if ((blockTable [index ].addr == prevP -> addr ) && (blockTable [index ].size == prevP -> size )) {
988
987
if (nextP ) {
989
988
memcpy (nextP , & blockTable [index + 1 ], sizeof (ARM_STORAGE_BLOCK ));
@@ -1021,20 +1020,20 @@ int32_t getBlock(uint64_t addr, ARM_STORAGE_BLOCK *blockP)
1021
1020
}
1022
1021
1023
1022
ARM_DRIVER_STORAGE ARM_Driver_Storage_ (0 ) = {
1024
- .GetVersion = getVersion ,
1025
- .GetCapabilities = getCapabilities ,
1026
- .Initialize = initialize ,
1027
- .Uninitialize = uninitialize ,
1028
- .PowerControl = powerControl ,
1029
- .ReadData = readData ,
1030
- .ProgramData = programData ,
1031
- .Erase = erase ,
1032
- .EraseAll = eraseAll ,
1033
- .GetStatus = getStatus ,
1034
- .GetInfo = getInfo ,
1035
- .ResolveAddress = resolveAddress ,
1036
- .GetNextBlock = nextBlock ,
1037
- .GetBlock = getBlock
1023
+ .GetVersion = getVersion ,
1024
+ .GetCapabilities = getCapabilities ,
1025
+ .Initialize = initialize ,
1026
+ .Uninitialize = uninitialize ,
1027
+ .PowerControl = powerControl ,
1028
+ .ReadData = readData ,
1029
+ .ProgramData = programData ,
1030
+ .Erase = erase ,
1031
+ .EraseAll = eraseAll ,
1032
+ .GetStatus = getStatus ,
1033
+ .GetInfo = getInfo ,
1034
+ .ResolveAddress = resolveAddress ,
1035
+ .GetNextBlock = nextBlock ,
1036
+ .GetBlock = getBlock
1038
1037
};
1039
1038
1040
1039
#endif /* #if DEVICE_STORAGE */
0 commit comments