Skip to main content
Priyadarshini Solanki
Associate III
January 25, 2018
Question

32- bit CRC Calculation of flash for STM32F070xB

  • January 25, 2018
  • 1 reply
  • 2542 views
Posted on January 25, 2018 at 06:42

I am using

, where I tried to calculate the 32- bit CRC of my flash using

register.

How I can ensure if the CRC calculation of my flash is correct.

CRC Configuration I used is :

hcrc.Instance = CRC;

hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE;

hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE;

hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE;

hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE;

hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_WORDS;

/*ROM address*/

&sharpdefine ROM_START (( uint32_t * ) 0x08000000 )

&sharpdefine ROM_END (( uint32_t * ) 0x0801FFFB )

Calculated CRC is stored in the variable.

#flash #crc #stm32f070xb #crc->dr #crc-32
This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
January 25, 2018
Posted on January 25, 2018 at 16:48

>>How I can ensure if the CRC calculation of my flash is correct.

Load the binary externally, and do the computation?

https://www.iar.com/support/tech-notes/general/calculate-crc32-as-in-stm32-hardware-v.5.50-and-later/

 

 

https://community.st.com/0D50X00009XkWntSAF

 
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Priyadarshini Solanki
Associate III
January 29, 2018
Posted on January 29, 2018 at 07:31

0690X00000609WfQAI.png

ROM_END = 0x08000000

ROM_START = 0x0801FFFB

ROM_SIZE = ROM_END -ROM_START

FLASH_WORD_SIZE = 4

CRC_Calculate(&hcrc, (uint32_*) 

pBuffer[index]

,uint32_t BufferLength){

   uint32_t index = 0U;

   uint32_t temp = 0U;

    CRC_DR_RESET(hcrc);

   for(index = 0U; index <

ROM_SIZE / FLASH_WORD_SIZE

; index++){

      hcrc->Instance->DR = pBuffer[index];

   }

   temp = hcrc->Instance->DR;

}

void main(void){

   .....

   uint32_t currentRomDataCrc;

   currentRomDataCrc = CRC_Calculate(&hcrc,

0x08000000,(uint32_t)( ROM_SIZE / FLASH_WORD_SIZE));

   if (currentRomDataCrc == __checksum)

   {

         //TODO

   }

   else

   {

         //TODO

   }

}

RESULT:

      

currentRomDataCrc  = 

0x3BE8893E      //Location: 0x200001B8

       __checksum = 0x49354A9E                  //Location: 0x08003578

I am not getting the same result in calculated CRC and __checksum.

Tesla DeLorean
Guru
January 29, 2018
Posted on January 29, 2018 at 18:19

So make sure it is going over exactly the same words. Check the computation externally with your own code reading the binary. I could check it but you'd need to provide the binary for me to inspect.

The size should be computed like this

ROM_SIZE = ((ROM_END - ROM_START) + 1) // The way you describe the start/end points describes N-1 rather than N bytes

If you CRC the 0x20000/4 words the residual should by ZERO, at 0x1FFFC/4 words the CRC computed by both sides should match the word at 0x0801FFFC

I'm not using IAR.

I'm open to reasonable offers for my time to work on this.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..