Calculating CRC32 with IAR ELF Tool the same way as STM32 hardware

Technical Note 64424



10/11/2017 2:28 PM


This technical note describes how to configure IAR ELF Tool to calculate CRC32 the same way as the built-in hardware CRC32 calculator of STM32 devices from STMicroelectronics.


The settings might depend on which version of IAR Embedded Workbench for ARM you are using.

This technical note will describe the IAR ELF Tool settings for version 6.40 (and later).

IAR ELF Tool settings

To configure the CRC32 calculation in the IDE, choose Project>Options>Linker>Checksum and make there settings:


  • Checksum size: 4 bytes
  • Alignment: 4
  • Algorithm: CRC32 (0x4C11DB7)
  • Complement: As is
  • Bit order: MSB first
  • [deselected] Reverse byte order within word
  • Initial Value: 0xFFFFFFFF
  • [deselected] Use as input
  • Checksum unit size: 32-bit


Example project for STM32F10x

Click to download:


Source code extract from the example project

This source code shows how the built-in hardware CRC32 calculator of STM32 devices is invoked to calculate the CRC32 value. The CRC32 value calculated by the device is then compared to the CRC32 value calculated by IAR ELF Tool.

#include "stm32f10x_crc.h"

extern uint32_t __checksum;

uint32_t calcCrc32(uint8_t* data, uint32_t len)
uint32_t* pBuffer = (uint32_t*) data;
uint32_t BufferLength = len/4;
uint32_t index = 0;



for(index = 0; index < BufferLength; index++)
CRC->DR = pBuffer[index];

return CRC->DR;

void main(void)

uint32_t valCrc32 =
calcCrc32((uint8_t*)0x08000000, 0x040000 - 4);

if (valCrc32 == __checksum)
// TBD
// TBD



This technical note describes CRC32 calculation (IAR ELF Tool and STM32 hardware), using version 6.40 (or newer) of IAR Embedded Workbench for ARM.
If your version of IAR Embedded Workbench for ARM is not covered by this technical note, contact IAR Systems support for assistance.

All Product names are trademarks or registered trademarks of their respective owners.

Related Tech Notes

© IAR Systems 1995-2021 - All rights reserved.

We use cookies on this website to provide you with a better experience. You need to accept cookies to continue using this site. Cookies