Skip to content

Commit 245d4b8

Browse files
authored
Merge pull request #2003 from rgrover/PR
minor fix for a warning when compiling with ARMCC
2 parents 3923f3c + b12f0c2 commit 245d4b8

File tree

1 file changed

+44
-45
lines changed

1 file changed

+44
-45
lines changed

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K64F/storage_driver.c

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ const uint8_t *currentOperatingData;
156156
#define OPTIMAL_PROGRAM_UNIT (1024UL)
157157
#define PROGRAM_PHRASE_SIZEOF_INLINE_DATA (8)
158158
#define SIZEOF_DOUBLE_PHRASE (FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT)
159-
#else
159+
#else /* ifdef USING_KSDK2 */
160160
#define ERASE_UNIT (4096)
161161
#define BLOCK1_START_ADDR (0x80000UL)
162162
#define BLOCK1_SIZE (0x80000UL)
@@ -221,31 +221,31 @@ static const ARM_STORAGE_CAPABILITIES caps = {
221221
/* Enable chip-erase functionality if we own all of block-1. */
222222
#if ((!defined (YOTTA_CFG_CONFIG_HARDWARE_MTD_START_ADDR) || (YOTTA_CFG_CONFIG_HARDWARE_MTD_START_ADDR == BLOCK1_START_ADDR)) && \
223223
(!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. */
225225
#else
226-
.erase_all = 0, /**< Supports EraseChip operation. */
226+
.erase_all = 0, /**< Supports EraseChip operation. */
227227
#endif
228228
};
229229

230230
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. */
232232

233233
.program_unit = PROGRAM_UNIT,
234234
.optimal_program_unit = OPTIMAL_PROGRAM_UNIT,
235235

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. */
238238

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,
241241

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. */
249249

250250
.software_attacks = 0,
251251
.board_level_attacks = 0,
@@ -254,7 +254,6 @@ static const ARM_STORAGE_INFO info = {
254254
}
255255
};
256256

257-
258257
/**
259258
* This is the command code written into the first FCCOB register, FCCOB0.
260259
*/
@@ -288,9 +287,9 @@ static inline bool failedWithAccessError(void)
288287

289288
/* checking access error */
290289
return registerValue & FTFx_FSTAT_ACCERR_MASK;
291-
#else
290+
#else /* ifdef USING_KSDK2 */
292291
return BR_FTFE_FSTAT_ACCERR(FTFE);
293-
#endif
292+
#endif /* ifdef USING_KSDK2 */
294293
}
295294

296295
static inline bool failedWithProtectionError()
@@ -301,9 +300,9 @@ static inline bool failedWithProtectionError()
301300

302301
/* checking protection error */
303302
return registerValue & FTFx_FSTAT_FPVIOL_MASK;
304-
#else
303+
#else /* ifdef USING_KSDK2 */
305304
return BR_FTFE_FSTAT_FPVIOL(FTFE);
306-
#endif
305+
#endif /* ifdef USING_KSDK2 */
307306
}
308307

309308
static inline bool failedWithRunTimeError()
@@ -314,9 +313,9 @@ static inline bool failedWithRunTimeError()
314313

315314
/* checking MGSTAT0 non-correctable error */
316315
return registerValue & FTFx_FSTAT_MGSTAT0_MASK;
317-
#else
316+
#else /* ifdef USING_KSDK2 */
318317
return BR_FTFE_FSTAT_MGSTAT0(FTFE);
319-
#endif
318+
#endif /* ifdef USING_KSDK2 */
320319
}
321320

322321
static inline void clearAccessError(void)
@@ -415,7 +414,7 @@ static inline void setupAddressInCCOB123(uint64_t addr)
415414
BW_FTFE_FCCOB2_CCOBn((uintptr_t)FTFE, (addr >> 8) & 0xFFUL); /* bits [15:8] of the address. */
416415
BW_FTFE_FCCOB3_CCOBn((uintptr_t)FTFE, (addr >> 0) & 0xFFUL); /* bits [7:0] of the address. */
417416
}
418-
#endif
417+
#endif /* ifndef USING_KSDK2 */
419418

420419
static inline void setupEraseSector(uint64_t addr)
421420
{
@@ -446,7 +445,7 @@ static inline void setup8ByteWrite(uint64_t addr, const void *data)
446445
/* Program 8 bytes of data into FCCOB(4..11)_CCOBn */
447446
kFCCOBx[1] = ((const uint32_t *)data)[0];
448447
kFCCOBx[2] = ((const uint32_t *)data)[1];
449-
#else
448+
#else /* ifdef USING_KSDK2 */
450449
BW_FTFE_FCCOB0_CCOBn((uintptr_t)FTFE, PGM8);
451450
setupAddressInCCOB123(addr);
452451

@@ -458,7 +457,7 @@ static inline void setup8ByteWrite(uint64_t addr, const void *data)
458457
BW_FTFE_FCCOB9_CCOBn((uintptr_t)FTFE, ((const uint8_t *)data)[6]); /* byte 6 of program value. */
459458
BW_FTFE_FCCOBA_CCOBn((uintptr_t)FTFE, ((const uint8_t *)data)[5]); /* byte 5 of program value. */
460459
BW_FTFE_FCCOBB_CCOBn((uintptr_t)FTFE, ((const uint8_t *)data)[4]); /* byte 4 of program value. */
461-
#endif
460+
#endif /* ifdef USING_KSDK2 */
462461
}
463462

464463
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
469468

470469
kFCCOBx[0] = BYTES_JOIN_TO_WORD_1_3(PGMSEC, addr);
471470
kFCCOBx[1] = BYTES_JOIN_TO_WORD_2_2(cnt >> 4, 0xFFFFU);
472-
#else
471+
#else /* ifdef USING_KSDK2 */
473472
static const uintptr_t FlexRAMBase = 0x14000000;
474473
memcpy((void *)FlexRAMBase, (const uint8_t *)data, cnt);
475474

@@ -478,7 +477,7 @@ static inline void setupProgramSection(uint64_t addr, const void *data, size_t c
478477

479478
BW_FTFE_FCCOB4_CCOBn((uintptr_t)FTFE, ((((uint32_t)(cnt >> 4)) & (0x0000FF00)) >> 8)); /* number of 128-bits to program [15:8] */
480479
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 */
482481
}
483482

484483
/**
@@ -760,7 +759,7 @@ static int32_t initialize(ARM_Storage_Callback_t callback)
760759
if (rc != kStatus_FLASH_Success) {
761760
return ARM_DRIVER_ERROR;
762761
}
763-
#endif
762+
#endif /* ifdef USING_KSDK2 */
764763

765764
if (controllerCurrentlyBusy()) {
766765
/* The user cannot initiate any further FTFE commands until notified that the
@@ -944,7 +943,7 @@ static int32_t eraseAll(void)
944943
static ARM_STORAGE_STATUS getStatus(void)
945944
{
946945
ARM_STORAGE_STATUS status = {
947-
.busy = 0,
946+
.busy = 0,
948947
.error = 0,
949948
};
950949

@@ -972,7 +971,7 @@ static uint32_t resolveAddress(uint64_t addr) {
972971
return (uint32_t)addr;
973972
}
974973

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)
976975
{
977976
if (prevP == NULL) {
978977
/* fetching the first block (instead of next) */
@@ -983,7 +982,7 @@ int32_t nextBlock(const ARM_STORAGE_BLOCK* prevP, ARM_STORAGE_BLOCK *nextP)
983982
}
984983

985984
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++) {
987986
if ((blockTable[index].addr == prevP->addr) && (blockTable[index].size == prevP->size)) {
988987
if (nextP) {
989988
memcpy(nextP, &blockTable[index + 1], sizeof(ARM_STORAGE_BLOCK));
@@ -1021,20 +1020,20 @@ int32_t getBlock(uint64_t addr, ARM_STORAGE_BLOCK *blockP)
10211020
}
10221021

10231022
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
10381037
};
10391038

10401039
#endif /* #if DEVICE_STORAGE */

0 commit comments

Comments
 (0)