![]() |
Energy Micro IEC60355 Library Example Project 1.0 (internal use only!) GCC-Version
Example project demonstrating POST and BIST library functions
|
The FLASH test checks reliability and consistency of FLASH data
and code.
More...
|
Modules | |
| Library Configuration | |
This modules are prepared for specific devices and compilers.
| |
Defines | |
| #define | DO1(src) crc = crc_table[((uint32_t) crc ^ (*src++)) & 0xff] ^ (crc >> 8); |
| #define | DO2(src) DO1(src); DO1(src); |
| #define | DO4(src) DO2(src); DO2(src); |
| #define | DO8(src) DO4(src); DO4(src); |
| #define | SIZE32K 0x00007FFF |
| #define | SIZE64K 0x0000FFFF |
| #define | SIZE128K 0x0001FFFF |
| #define | FLASHSIZE SIZE128K |
| #define | FLASH_SIGN1 1 |
| #define | FLASH_SIGN2 2 |
| #define | CRC_block_size 1024 |
| #define | FLASH_CRC_Done 1 |
| #define | FLASH_CRC_InProg 2 |
| #define | FLASH_CRC_Missing 3 |
| #define | FLASH_CRC_Valid 4 |
| #define | FLASH_CRC_Restart 5 |
Functions | |
| uint32_t | crc32 (uint32_t crc, uint8_t **const pp_src, uint32_t len) |
| private function calculating CRC32 table based checksum by POST and BIST tests | |
| testResult_t | IEC60335_ClassB_FLASHtest_POST (void) |
| public function to check the Flash content POST only by recalculation and comparison with Flash stored CRC32 value | |
| testResult_t | IEC60335_ClassB_FLASHtest_BIST (uint8_t StartMode) |
| public function (competitive) to check a part of the Flash content | |
The FLASH test checks reliability and consistency of FLASH data
and code.
using POST and BIST Flash test algorithm enables consistency checking features
on the nonvolatile memory of the chip. all tests references to a predefined CRCValue
calculated outside the runtime of the application. The CRCValue is stored in a structure
outside the checked code.
| #define CRC_block_size 1024 |
Definition at line 62 of file iec60335_class_b_flash_test.h.
Referenced by IEC60335_ClassB_FLASHtest_BIST().
| #define DO1 | ( | src | ) | crc = crc_table[((uint32_t) crc ^ (*src++)) & 0xff] ^ (crc >> 8); |
Definition at line 181 of file iec60335_class_b_flash_test.c.
Referenced by crc32().
| #define DO2 | ( | src | ) | DO1(src); DO1(src); |
Definition at line 182 of file iec60335_class_b_flash_test.c.
| #define DO4 | ( | src | ) | DO2(src); DO2(src); |
Definition at line 183 of file iec60335_class_b_flash_test.c.
| #define DO8 | ( | src | ) | DO4(src); DO4(src); |
Definition at line 184 of file iec60335_class_b_flash_test.c.
Referenced by crc32().
| #define FLASH_CRC_Done 1 |
status information of this struct
Definition at line 64 of file iec60335_class_b_flash_test.h.
Referenced by IEC60335_ClassB_FLASHtest_BIST(), and IEC60335_ClassB_FLASHtest_POST().
| #define FLASH_CRC_InProg 2 |
Definition at line 65 of file iec60335_class_b_flash_test.h.
Referenced by IEC60335_ClassB_FLASHtest_BIST().
| #define FLASH_CRC_Missing 3 |
Definition at line 66 of file iec60335_class_b_flash_test.h.
Referenced by IEC60335_ClassB_FLASHtest_BIST().
| #define FLASH_CRC_Restart 5 |
Definition at line 68 of file iec60335_class_b_flash_test.h.
Referenced by IEC60335_ClassB_FLASHtest_BIST(), and main().
| #define FLASH_CRC_Valid 4 |
Definition at line 67 of file iec60335_class_b_flash_test.h.
Referenced by IEC60335_ClassB_FLASHtest_POST().
| #define FLASH_SIGN1 1 |
Definition at line 59 of file iec60335_class_b_flash_test.h.
| #define FLASH_SIGN2 2 |
Definition at line 60 of file iec60335_class_b_flash_test.h.
| #define FLASHSIZE SIZE128K |
Definition at line 57 of file iec60335_class_b_flash_test.h.
Referenced by IEC60335_ClassB_FLASHtest_BIST(), and IEC60335_ClassB_FLASHtest_POST().
| #define SIZE128K 0x0001FFFF |
Definition at line 55 of file iec60335_class_b_flash_test.h.
| #define SIZE32K 0x00007FFF |
Definition at line 53 of file iec60335_class_b_flash_test.h.
| #define SIZE64K 0x0000FFFF |
Definition at line 54 of file iec60335_class_b_flash_test.h.
| uint32_t crc32 | ( | uint32_t | crc, |
| uint8_t **const | pp_src, | ||
| uint32_t | len | ||
| ) |
private function calculating CRC32 table based checksum by POST and BIST tests
| crc | start CRC32 value if partial usage |
| src | pointer to start of the memory to check |
| len | length of processed memory in byte |
Definition at line 187 of file iec60335_class_b_flash_test.c.
Referenced by IEC60335_ClassB_FLASHtest_BIST(), and IEC60335_ClassB_FLASHtest_POST().
{
uint8_t * src = (*pp_src);
#if (dynamic_CRC_table == 1)
if (crc_table_empty)
make_crc_table();
#endif
crc = crc ^ 0xffffffffL;
while (len > 7)
{
DO8(src);
len -= 8;
}
if (len) do
{
DO1(src);
} while (--len);
*pp_src = src;
return(crc ^ 0xffffffffL);
}

| testResult_t IEC60335_ClassB_FLASHtest_BIST | ( | uint8_t | StartMode | ) |
public function (competitive) to check a part of the Flash content
| StartMode | flag to restart the BIST test available values are : FLASH_CRC_Restart restarts the calculation all other will continue to test next addresses |
Definition at line 232 of file iec60335_class_b_flash_test.c.
References IEC60335_FlashSign::BlockSize, crc32(), IEC60335_FlashSign::CRC32Val, CRC_block_size, FLASH_CRC_Done, FLASH_CRC_InProg, FLASH_CRC_Missing, FLASH_CRC_Restart, FLASH_SIZE, FLASHSIZE, IEC60335_testFailed, IEC60335_testInProgress, IEC60335_testPassed, IEC60335_FlashSign::NextAddress, and IEC60335_FlashSign::Status.
Referenced by main().
{
testResult_t Result = IEC60335_testFailed;
/* CRC32Val,MemLenght,NextAddress,BlockSize,Status; */
static FlashCRC_t bistFlashCRC = { 0, FLASH_SIZE, 0, CRC_block_size, FLASH_CRC_Restart };
if (StartMode >= FLASH_CRC_Restart)
{
bistFlashCRC.Status = FLASH_CRC_Restart;
Result = IEC60335_testInProgress;
}
if (StartMode == FLASH_CRC_Missing)
{
return(Result);
}
/* consecutive addressing based on the struct content */
/* check parts of the Flash memory */
/* determine restart condition of FlashTest */
if (bistFlashCRC.NextAddress <= (uint32_t) __STEXT)
{
bistFlashCRC.Status = FLASH_CRC_Restart;
}
/* determine failure condition of FlashTest */
if (bistFlashCRC.NextAddress > FLASHSIZE)
{
bistFlashCRC.Status = FLASH_CRC_Restart;
}
if (bistFlashCRC.Status == FLASH_CRC_Restart)
{
bistFlashCRC.CRC32Val = 0;
bistFlashCRC.NextAddress = (uint32_t) __STEXT;
bistFlashCRC.BlockSize = CRC_block_size;
}
/* determine next length exceeding FlasSize */
if ((bistFlashCRC.NextAddress + bistFlashCRC.BlockSize) > FLASHSIZE)
{
bistFlashCRC.BlockSize = FLASHSIZE - bistFlashCRC.NextAddress;
}
/* calculate next part */
bistFlashCRC.CRC32Val = crc32(bistFlashCRC.CRC32Val, (uint8_t ** )&bistFlashCRC.NextAddress, bistFlashCRC.BlockSize);
bistFlashCRC.Status = FLASH_CRC_InProg;
if (bistFlashCRC.NextAddress == FLASHSIZE)
{
bistFlashCRC.Status = FLASH_CRC_Done;
}
/* state when memory block is processed completely */
if (bistFlashCRC.Status == FLASH_CRC_Done)
{
if (bistFlashCRC.CRC32Val == IEC60335_Flash_CRC_REF.CRC32Val)
{
Result = IEC60335_testPassed;
}
}
if (bistFlashCRC.Status == FLASH_CRC_InProg)
{
Result = IEC60335_testInProgress;
}
/* return value if the part or all is done */
return(Result);
}


| testResult_t IEC60335_ClassB_FLASHtest_POST | ( | void | ) |
public function to check the Flash content POST only by recalculation and comparison with Flash stored CRC32 value
Definition at line 209 of file iec60335_class_b_flash_test.c.
References crc32(), IEC60335_FlashSign::CRC32Val, FLASH_CRC_Done, FLASH_CRC_Valid, FLASHSIZE, IEC60335_testFailed, IEC60335_testPassed, and IEC60335_FlashSign::Status.
Referenced by IEC60335_ClassB_POST().
{
FlashCRC_t TestCRC;
uint32_t TestAddr = (uint32_t)__STEXT;
testResult_t Result = IEC60335_testFailed;
/* Do the POST signature generation according to the various flash sizes */
/* check the complete Flash memory */
TestCRC.CRC32Val = crc32(0, (uint8_t ** )&TestAddr, FLASHSIZE - (int32_t) __STEXT);
TestCRC.Status = FLASH_CRC_Done;
/* check status flag and CRC value */
if (IEC60335_Flash_CRC_REF.Status == FLASH_CRC_Valid)
{
if (TestCRC.CRC32Val == IEC60335_Flash_CRC_REF.CRC32Val)
{
Result = IEC60335_testPassed;
}
}
return(Result);
}

