cancel
Showing results for 
Search instead for 
Did you mean: 

CLASS-B STL Run-time FLASH CRC Error, the test staus is TEST_RUNNING mode only not comming to Test_OK

Ssiva.2
Associate II

i have integrated STL XCUBE class-B 2.2.0 Packages with STM32L433 controller here iam facing the test its always TEST_RUNNING not comming to Test_OK stauts, i am getting Run-time FLASH CRC Error, what could be the issue.

 #define ROM_START ((uint32_t *)0x08000000uL)

 #define ROM_END  ((uint32_t *)&_Check_Sum)   

 #define ROM_SIZE ((uint32_t)ROM_END - (uint32_t)ROM_START)

 #define ROM_SIZEinWORDS (uint32_t) (ROM_SIZE/4u)

 #define STEPS_NUMBER     ((uint32_t)ROM_SIZE/64u)

 #define FLASH_BLOCK_WORDS   (uint32_t)((ROM_SIZEinWORDS)/STEPS_NUMBER)

  rom_test = STL_crc32Run(); /* Requires the control flow check to be modified */

   switch ( rom_test )

   {

    case TEST_RUNNING:

      control_flow_resume(FLASH_TEST_CALLER);

     break;

  

    case TEST_OK:

break;

 case TEST_FAILURE:

    case CLASS_B_DATA_FAIL:

    default:

     #ifdef STL_VERBOSE

      printf(" Run-time FLASH CRC Error\n\r");

     #endif /* STL_VERBOSE */

     FailSafePOR();

     break;

ClassBTestStatus STL_crc32Run(void)

{

 ClassBTestStatus result = CTRL_FLW_ERROR; /* In case of abnormal func exit*/

 CtrlFlowCnt += CRC32_RUN_TEST_CALLEE;

 /* Check Class B var integrity */

 if ((((uint32_t)pRunCrc32Chk) ^ ((uint32_t)pRunCrc32ChkInv)) == 0xFFFFFFFFuL)

 {

  if (pRunCrc32Chk < (uint32_t *)ROM_END)

  {

  /* the next lines replaces the HAL function call

   HAL_CRC_Accumulate(&CrcHandle, (uint32_t *)pRunCrc32Chk, (uint32_t)FLASH_BLOCK_WORDS);

   due to bug at IAR linker - check sum computation can't support both big & little endian */

  

   uint32_t index;

   for(index = 0; index < (uint32_t)FLASH_BLOCK_WORDS; index++)

   {

    CRC->DR = __REV(*(pRunCrc32Chk + index));

   }

   pRunCrc32Chk += FLASH_BLOCK_WORDS;   /* Increment pointer to next block */

   pRunCrc32ChkInv = ((uint32_t *)~((uint32_t)pRunCrc32Chk));

   result = TEST_RUNNING;

  }

  else

  {

   if ((RefCrc32 ^ RefCrc32Inv) == 0xFFFFFFFFuL)

   {

    CtrlFlowCnt += CRC32_INIT_CALLER;

    if(CRC->DR == *(uint32_t *)(&REF_CRC32))

    {

     result = TEST_OK;

     __io_putchar((int16_t)'S');

    }

    else

    {

     result = TEST_FAILURE;

    }

    STL_FlashCrc32Init(); /* Prepare next test (or redo it if this one failed) */

     

    CtrlFlowCntInv -= CRC32_INIT_CALLER;

   }

   else /* Class B error on RefCrc32 */

   {

  __io_putchar((int16_t)'F');

    result = CLASS_B_DATA_FAIL;

   }

  }

 }

 else /* Class B error pRunCrc32Chk */

 {

  printf("CRC CHK FAIL\rn");

  result = CLASS_B_DATA_FAIL;

 }

 CtrlFlowCntInv -= CRC32_RUN_TEST_CALLEE;

 return (result);

}

if any help it would be grateful

3 REPLIES 3
Petr Sladecek
ST Employee

Hello,

the crucial point is to setup end point of the test (ROM_END) not to the address of the check sum pattern but any lower one aligned with size (end) of the Flash block involved in the test (FLASH_BLOCK_WORDS - number of words included at partial step of the test) additionally. Check sum pattern itself can be never included at the calculation cycle. Note number of partial steps makes correct control flow constant value, too. Then it depends on the compiler how the check sum pattern is integrated at the code. Only the IAR supports CRC calculation, for the other compilers a proper post build batch command has to be applied to compute the check sum and modify the output file of the compiler.

I suggest to trace upper code cycles to monitor the end of the cycle and its result especially (when the pRunCrc32Chk reaches the ROM_END)

Best regards,

Petr

Hi Petr,

Thanks for your response.

As per project requirement i am using STM32CubeIDE v1.6.1, GCC Compiler. I am post build procedure to generate check sum ,In the start up level i am able to see immediately Flash test OK. But in the Application level i figured out the flash test its taking around 7 sec to complete test. Here we are checking word by word (FLASH_BLOCK_WORDS), is it same time will take in IAR IDE also ? Self test libaries will run periodically in the main loop normally how much time will take complete this FLASH CRC test at the Application level ?

for(index = 0; index < (uint32_t)FLASH_BLOCK_WORDS; index++)

   {

    CRC->DR = __REV(*(pRunCrc32Chk + index));

   }

   pRunCrc32Chk += FLASH_BLOCK_WORDS;   /* Increment pointer to next block */

   pRunCrc32ChkInv = ((uint32_t *)~((uint32_t)pRunCrc32Chk));

   result = TEST_RUNNING;

Best regards,

Naresh.

Petr Sladecek
ST Employee

Hi Naresh,

the startup flash integrity test is done in one shot overall the space so it is fast. As the test is done word by word, it is independent on the memory size (only potential limitation could be watchdog timeout when the size of the tested memory is extreme). The run time test is done in steps per parts (flash blocks) so it is slower. It depends how do you setup block size and how frequently do you apply the run time check procedure call (each single call just checks single block of the flash only), of course. The checked area has to be aligned with the block size here else it doesn't work. Note it depends on the proper filling of the unused gaps of the memory, too.

Rgds,

Petr