#define SHADOW_ROW_SIZE 0x00008000\r
#define FLASH_PAGE_SIZE H7FB_PAGE_SIZE\r
\r
+#define FLASH_TOTAL_BLOCKS ( 20 )\r
+\r
#if 0\r
#define VFLAGS_ADDR_SECT (1<<0)\r
#define VFLAGS_ADDR_PAGE (1<<1)\r
}\r
\r
#define FLS_VALIDATE_PARAM_DATA_W_RV(_ptr,_api, _rv) \\r
- if( (_ptr)==((void *)0)) { \\r
+ if(( (uint32)(_ptr)%FLS_READ_PAGE_SIZE != 0 ) || ( (_ptr)==((void *)0))) { \
Det_ReportError(MODULE_ID_FLS,0,_api,FLS_E_PARAM_DATA); \\r
return _rv; \\r
}\r
endBlock = address_to_block( addr + size - 1,&rem );\r
\r
// Check so our implementation holds..\r
- assert( endBlock<=32 );\r
+ assert( endBlock <= FLASH_TOTAL_BLOCKS );\r
\r
#define BLOCK_MASK 0x0003ffffUL\r
\r
\r
\r
// shift things in to make freescale driver happy\r
- eraseBlocks->lowEnabledBlocks = mask&0x3f; // ????\r
- eraseBlocks->midEnabledBlocks = (mask>>10)&3; // ????\r
- eraseBlocks->highEnabledBlocks = mask>>12;\r
+ eraseBlocks->lowEnabledBlocks = mask&0x3ff; // Bits 0..9 indicats low blocks
+ eraseBlocks->midEnabledBlocks = (mask>>10)&3; // Bits 10..11 indicats mid blocks
+ eraseBlocks->highEnabledBlocks = mask>>12; // Bits 12..19 indicats high blocks
\r
\r
return ;\r
Std_ReturnType Fls_Erase( Fls_AddressType TargetAddress,\r
Fls_LengthType Length )\r
{\r
- uint32 block;\r
- uint32 sBlock;\r
+ uint32 endBlock;\r
+ uint32 startBlock;\r
uint32 rem;\r
Fls_EraseBlockType eraseBlock;\r
Fls_EraseInfoType eraseInfo;\r
return E_NOT_OK;\r
\r
// TargetAddress\r
- sBlock = address_to_block(TargetAddress,&rem);\r
+ startBlock = address_to_block(TargetAddress,&rem);\r
\r
- if( (sBlock == (-1)) || (rem!=0) ) {\r
+ if( (startBlock == (-1)) || (rem!=0) ) {\r
DET_REPORTERROR(MODULE_ID_FLS,0,0x0,FLS_E_PARAM_ADDRESS );\r
return E_NOT_OK;\r
}\r
\r
- block = address_to_block(TargetAddress+Length,&rem);\r
+ endBlock = address_to_block(TargetAddress+Length,&rem);\r
\r
// Check if we trying to erase a partition that we are executing in\r
pc = Fls_GetPc();\r
uint32 pcBlock = address_to_block(pc,&rem);\r
uint8 *partMap = Fls_Global.config->FlsBlockToPartitionMap;\r
\r
- if( (partMap[pcBlock] >= partMap[sBlock]) && (partMap[pcBlock] <= partMap[block]) ) {\r
-// if( address_to_block(pc,&rem) == Fls_Global.config->FlsBlockToPartitionMap[block] ) {\r
+ if( (partMap[pcBlock] >= partMap[startBlock]) && (partMap[pcBlock] <= partMap[endBlock]) ) {\r
// Can't erase and in the same partition we are executing\r
assert(0);\r
}\r
memcpy(VersioninfoPtr, &_Fls_VersionInfo, sizeof(Std_VersionInfoType));\r
}\r
\r
+void Fls_Check( uint32 flsBaseAddress, uint32 flsTotalSize )\r
+{\r
+ // ECC checking is always on by default.\r
+ // If a non correctable error is discovered\r
+ // we will get an IVOR2 exception.\r
+\r
+ // Enable Flash Non_Correctible Reporting,\r
+ // Not really necessary but makes more information\r
+ // available in the MCM registers if an error occurs.\r
+ MCM.ECR.B.EFNCR = 1;\r
+\r
+ // Read flash in 32bit chunks, it's most efficient.\r
+ uint32* memoryChunkPtr = (uint32*)flsBaseAddress;\r
+ uint32* flsTotalSizePtr = (uint32*)flsTotalSize;\r
+ uint32 memoryChunk = *memoryChunkPtr; // The first read\r
+\r
+ // Read the rest of the flash, chunk by chunk\r
+ while(memoryChunkPtr < flsTotalSizePtr)\r
+ {\r
+ memoryChunk=*(memoryChunkPtr++);\r
+ }\r
+}\r
\r
\r