-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in CRC32 calculation #1
Comments
Hi @josesimoes, Thank you for your report. May I ask you to provide us with the test case that allowed you to obtain an incorrect CRC32? Thank you, |
@ALABSTM I haven't added any test case… just found out about it when using the code on my app. |
Hi @josesimoes, Do you confirm you obtain a wrong CRC32 even though member With regards, |
That is correct. On our project the CRC32 only applies to byte arrays and we set the |
Hi @josesimoes, Thank you for your answer. In order to be sure I correctly understood your request, you suggest the following implementation? - *(__IO uint8_t *)(__IO void *)(&hcrc->Instance->DR) = pBuffer[4U * i];
+ *(__IO uint8_t *)(__IO void *)(&hcrc->Instance->DR) = (uint8_t) pBuffer[4U * i]; May I also ask you whether you obtained a correct CRC once you added the cast? Thank you for your answers once more. With regards, |
Basically yes. On both lines 453 and 467. That cast is all that's needed to fix this. Actually inline with the other casts there on the other data sizes cases. |
Hi @josesimoes, Please excuse my insistence. Do you confirm you updated the two lines above by adding the I ask the question because the With regards, |
Hi again, That is correct. I agree that this sounds weird but it is what it is... I guess that's probably because of the way the compiler is handling that. The cast makes sure that the proper data and size are feed to the CRC32 register. All that code feeding the registers looks over engineered and there are notes about that. |
Hi @josesimoes, Shall I understand you tested the fix you are proposing and it solved the issue? With regards, |
Hi @ALABSTM yes, of course. Otherwise I wouldn't be reporting this and offering the fix I've used. |
Hi @josesimoes, Thank you for the confirmation. Your request has been forwarded to our development teams. I will be back to you as soon as they provide me with their feedback. Thank you once again for having reported this point. Thank you also for having introduced the "nanoframework" initiative I have not knew about before reading your message. The project looks promising and really interesting. I wish you the best of lucks. With regards, |
Hi @josesimoes, I hope you are fine. Our development teams could not reproduce the issue you are describing. They used a STM32L5 Discovery board and the STM32Cube ID3 v1.4.0 (with the GCC compiler version 7_2018_q2_update). The CRC computation of a 5-byte long stream returned the expected result. Their recommendation is to migrate to the last compiler version. Please allow me to close this issue now. Thank you again for your contribution and patience. With regards, |
Hi @ALABSTM doing fine thanks. I have to say that I'm a bit puzzled with your reply... I specifically mentioned that this was happening on an F7 target and that I was seeing this with GCC 8-2019-q3-update. Now you tell me that your development team tried to reproduce this on a L5 target with GCC 7_2018_q2_update... I don't get it... We'll stick with our local fix then. |
Hi @josesimoes, "Mea culpa" for the inconsistent details in my last comment. With some colleague, we ran the CRC_Bytes_Stream_7bit_CRC example:
The CRC calculations passed in both cases. May I ask you to send us a modified version of the above mentioned example allowing to reproduce the issue? With regards, |
Hi @josesimoes, Please allow me to close this issue as no reply has been received since a couple of months. With regards, |
Hi,
On this line:
https://github.com/STMicroelectronics/stm32f7xx_hal_driver/blob/8a83a680a5c0c678df3897ae41b430444abb3cb7/Src/stm32f7xx_hal_crc.c#L453
and on this one too:
https://github.com/STMicroelectronics/stm32f7xx_hal_driver/blob/8a83a680a5c0c678df3897ae41b430444abb3cb7/Src/stm32f7xx_hal_crc.c#L467
it's missing a cast to
(uint8_t)
when loading the DR register, otherwise it won't compute the correct CRC32.The text was updated successfully, but these errors were encountered: