cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the STM32 Hardware CRC to calculate Ethernet/GFP CRC

DBark.2
Associate III

I've managed to configure the STM32 CRC such that it can create the standard CRC-32 as per this article - https://stackoverflow.com/questions/39646441/how-to-set-stm32-to-generate-standard-crc32. However, this CRC does not match Ethernet spec.

Is there a way to configure the STM32 Hardware CRC peripheral such that it can create valid Ethernet/GFP crc values?

I already have software that can generate the CRC. I'm specifically looking to see if there is a way to utilize the faster speeds of the CRC hardware generation.

3 REPLIES 3
TDK
Guru

Which STM32? Some are configurable, some are not. Non-configurable uses 0x04C11DB7 as the polynomial, at least for STM32F4, which is ethernet. You'd have to explain your input, what you're getting, and what you're expecting. There are some details since STM32 processes bytes assuming little-endian format.

If you feel a post has answered your question, please click "Accept as Solution".
DBark.2
Associate III

Both CRC-32 in question are using a polynomial of 0x04C11DB7. I'm using byte input data inversion mode to handle the endian problem.

My current configuration is on an STM32L5

  hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE;
  hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE;
  hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_BYTE;
  hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_ENABLE;
  hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;
  if (HAL_CRC_Init(&hcrc) != HAL_OK)

I'm inverting the data after receiving it to get values that match other expected CRC.

My input is a binary file, my output matches different non-ethernet CRC32

I want my output to match ethernet CRC-32.

If you give a complete example with data, received values, and expected values, I will track it down for you, but I’m not going to guess at what you want. Preferably an example with 4 bytes of input data.
If you feel a post has answered your question, please click "Accept as Solution".