cancel
Showing results for 
Search instead for 
Did you mean: 

using the CRC calculation unit in STM32F205

Barbie
Associate II
Posted on October 27, 2014 at 22:47

I need to do a CRC calculation. So I want to use the CRC calculation unit in the MCU.

It is pretty easy one. Just active the CRC clk and then invoke word into CRC->DR .

I want to see if it work O.K. so I reset it to 0xFFFFFFFF and make

  CRC->DR = (uint32_t)* FLASH_word_ADD; 

where the pointer point to a word on the FLASH. 

I check the result also on the CRC->DR and open an application do the CRC32 with the some polynomial: 0x4C11DB7 (standard). I reset also the unit there to 0xFFFFFFFF and put the some number show by the pointer use before to calculate.

 I get a different result. I check it in several CRC32 calculators but the some. I also try to enter the number LSB first but didn't help. 

Where am I wrong?

Bar.

#crc-iar-stm32f205 #crc-unit-stm32f205
3 REPLIES 3
Posted on October 28, 2014 at 03:05

The STM32F1/2/4 work on 32-bit words at a time, the endian handling and shift direction are rather awkward compared to some of the simplified calculators out there.

I've covered this material several dozen times here.

Try about half way down this thread for PC based calculation example

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/flash%20CRC%20integrity&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=621]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2Fflash%20CRC%20integrity&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=621
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Barbie
Associate II
Posted on October 29, 2014 at 18:16

Hi.

I see that in the pass you refer to IAR example 

Calculate CRC32 as in STM32 hardware (v.5.50 and later)  http://supp.iar.com/Support/?note=64424&from=note+11927 but you didn't mention it now. 1. Does it work and if so why not to use it? 2. If it can work I an example of checksum markers 

 http://supp.iar.com/Support/?  because I want to check it from the Boot which doesn't know the size. But in this examplethey use the command line 

''Project > Options > Linker > Extra Options > Use command line options'' where I written --place_holder ielftool_checksum,4,checksum,4 --keep=ielftool_checksum  and 

''Project > Options > Build Actions > Post-build command line''  

where I written ielftool --fill 0xFF;0x08010000-checksum_end+3 --checksum ielftool_checksum:4,crc32,0x0;0x08010000-checksum_end+3 --verbose ''$TARGET_PATH$'' ''$TARGET_PATH$'' (my APP start on 0x08010000 and i want to check all over it include the intvec). SO does this syntax is the soem as ST32Fx CRC machine? I run it over and didn't get the some.      note=62709&from=note+52791  

 http://supp.iar.com/Support/?  because I want to check it from the Boot which doesn't know the size. But in this examplethey use the command line 

''Project > Options > Linker > Extra Options > Use command line options'' where I written --place_holder ielftool_checksum,4,checksum,4 --keep=ielftool_checksum  and 

''Project > Options > Build Actions > Post-build command line''  

where I written ielftool --fill 0xFF;0x08010000-checksum_end+3 --checksum ielftool_checksum:4,crc32,0x0;0x08010000-checksum_end+3 --verbose ''$TARGET_PATH$'' ''$TARGET_PATH$'' (my APP start on 0x08010000 and i want to check all over it include the intvec). SO does this syntax is the soem as ST32Fx CRC machine? I run it over and didn't get the some. 

Posted on October 29, 2014 at 18:32

I'm a Keil guy, I know that IAR has a tool to do some of this, but I build things which are significantly more complex to package my firmware images. If I process ELF or HEX files I can be totally agnostic to the tool chain used, be it Keil, IAR, GNU/GCC

Generic command line tools tend to have tortuous options to try and cover every conceivable use case. This makes them very difficult to use, hard to document and furnish to customers.

Your initial post made no reference to IAR, I've generally approached this by doing the math from first principles, to show how the mechanics work not necessarily how to use others tools, blogs or calculators. If you understand the mechanics you can apply that to whatever problems you have.

The STM32 CRC hardware performs correctly as designed, it's design is a bit awkward and architecturally backward, but I think I've demonstrated how to compute the remainder using hardware and software approaches.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..