STAR32 하드웨어와 동일한 방법으로 IAR ELF Tool을 사용한 CRC32 계산

기술노트 64424

아키텍처:

Arm

컴포넌트:

general

업데이트:

2018-02-28 오전 2:33

Introduction

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.

Discussion

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:

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;

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);

CRC_ResetDR();

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
}
else
{
// TBD
}

...
}

Conclusion

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.

죄송하지만, 당사 사이트에서는 Internet Explorer를 지원하지 않습니다.보다 편안한 사이트를 위해 Chrome, Edge, Firefox 등과 같은 최신 브라우저를 사용해 주시길 부탁드립니다.