2024-04-11 08:16 AM - edited 2024-04-11 08:18 AM
Premises:
- built with gcc version 11.3.1 20220712 (GNU Tools for STM32 11.3.rel1.20230912-1600)
- verified on STM32L151RC
- cross reference to crc: https://reveng.sourceforge.io/
STM32L1xxxx CRC module can compute crcs compliant to the following 4 standards:
- CRC-32/ISO-HDLC*
- CRC-32/JAMCRC
- CRC-32/BZIP2
- CRC-32/MPEG-2
(*) ISO-HDLC is implemented in these softwares: WinRar, ExamDiff, FreeCommander, HashMyFiles.
CRC module digests one int32 at a time, it doesn't digest byte-per-byte, so the input data must be a stream of m bytes, where m is multiple of 4: m == n * 4, having its base address aligned to uint32_t. That's why the byte stream is passed as uint32_t data[] in the examples.
Given the MCU endianness and the CRC module implementation, in order to meet the wanted results each dword must be bit-reflected for ISO-HDLC/JAMCRC while it must be byte-reversed for BZIP2/MPEG-2. Once all the data has been digested, crc must be finalized (except for MPEG-2):
- ISO-HDLC -> bit-reflect then xor with 0xFFFFFFFF
- JAMCRC -> bit-reflect
- BZIP2 -> xor with 0xFFFFFFFF
Attached an implementation, here're the prototypes:
uint32_t CalcCrc32_ISO_HDLC(uint32_t data[], unsigned n);
uint32_t CalcCrc32_JAMCRC(uint32_t data[], unsigned n);
uint32_t CalcCrc32_BZIP2(uint32_t data[], unsigned n);
uint32_t CalcCrc32_MPEG_2(uint32_t data[], unsigned n);
Solved! Go to Solution.
2024-04-12 09:52 AM - edited 2024-04-12 09:53 AM
It's a signature line, like accept my answer to feed the broken metrics algorithm, or buy me coffee..
2024-04-12 09:28 AM
Hello @elKarro ,
I can't seem to get your message here "MCU speaks VHDL and CPU speaks assembly. Neither of them speaks HAL."
booth speak different assembly depending on the cortex architecture for ARM based CPUs and MCUs.
can you please explain your issue so i can try to help you through it.
BR
2024-04-12 09:52 AM - edited 2024-04-12 09:53 AM
It's a signature line, like accept my answer to feed the broken metrics algorithm, or buy me coffee..
2024-04-12 10:05 AM
Thanks Tesla DeLorean, it seems it needed to be clarified :D
2024-04-12 10:07 AM
Thanks STea, I don't need any help about that.
But since you offered to, you could please answer to a previous question I asked:
https://community.st.com/t5/stm32-mcus-embedded-software/usart-sr-clearing-sequence-of-idle-ore-nf-fe-pe-a-silicon-level/td-p/647799
I guess you have access to that kind of documentation, as a ST Employee.
Thanks in advance.
2024-04-15 07:07 AM
Hello @elKarro ,
Thanks @Tesla DeLorean for pointing that out I didn't see the separator in the question, so I thought it was a part of your question :p .
regarding the question that you shared I'll take a look and see what I can do.
BR