Calculate CRC32 as in STM32 hardware (EWARM v.5.50 and later)

时间:2023-02-14 00:21:24

http://supp.iar.com/Support/?note=64424&from=note+11927

Background
The STM32 devices from ST Micro have a built-in hardware CRC32 calculator. (So using CRC32 in an application does not use up code space for the algorithm.)

Problem
The CRC32 algorithm used in STM32 devices could not be reproduced by the ielftool utility before EWARM version 5.50.

Solution for EWARM version 6.40 and later
Options for 6.40 and later

Options are added to Project > Options > Linker > Checksum to enable ielftool to make CRC32 calculation in the same way as the hardware in the STM32 devices.

The options should be set as follows:

    Size:  bytes
Alignment:
Algorithm: CRC32(0x4C11DB7)
Complement: As is
Bit order: MSB first
[ ]Reverse byte order within word [unchecked]
Initial Value: 0xFFFFFFFF
[ ]Use as input [unchecked]
Checksum unit size: -bit
Example for STM32F10x

This example shows source code, the linker configuration file and the corresponding settings in the linker options dialog.

#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 / ;
uint32_t index = ; RCC_AHBPeriphClockCmd( RCC_AHBPeriph_CRC, ENABLE ); CRC_ResetDR( ); for ( index = ; index < BufferLength; index++ )
{
CRC->DR = pBuffer[ index ];
} return CRC->DR;
} void main( void )
{
... uint32_t valCrc32 =
calcCrc32((uint8_t*)0x08000000, 0x040000 - ); if ( valCrc32 == __checksum )
{
// TBD
}
else
{
// TBD
} ...
}

Linker configuration file (snippet)

define symbol __ICFEDIT_region_ROM_start__   = 0x08000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFB; place at address mem:0x0803FFFC { readonly section .checksum };
Solution for EWARM version 5.50

In version 5.50, ielftool can be configured to calculate CRC32 in the same manner as the calculation of CRC32 using the STM32 hardware. This ability is not documented and it can only be invoked as a command line option.

The details that concern the STM32 CRC32 algorithm are

0xFFFFFFFF as initial value.

Utilize the two new ielftool algorithm flags i and r.

The string to enter in Project > Options > Build Actions > Post-build command line is...

ielftool --fill 0xFF;__checksum_begin-__checksum_end
--checksum __checksum:,crc32:ir,0xFFFFFFFF;__checksum_begin-__checksum_end
--verbose $TARGET_PATH$ $TARGET_PATH$

...where these substrings are placeholders that needs to changed for the project in use:

__checksum

The name of the symbol where the checksum value should be stored.
Note that it must exist in the symbol table in the input ELF file.

__checksum_begin

The first address on which the checksum should be calculated.

__checksum_end

The last address on which the checksum should be calculated.

The preceding command line should be combined with all options reset (unchecked) in Project > Options > Linker > Checksum

ProjectOptionsLinkerChecksum(6.40) (32 KB)

ProjectOptionsLinkerChecksum(6.10-6.30) (31 KB)

Example (6.40)  ZIP, 654 KB)

Example (6.21) (ZIP, 645 KB)

Technical note 11927
Checksum calculation with IELFTOOL after linking with ILINK

Calculate CRC32 as in STM32 hardware (EWARM v.5.50 and later)的更多相关文章

  1. STM32 Hardware Development

    http://www.st.com/web/en/resource/technical/document/application_note/CD00164185.pdf AN2586 http://w ...

  2. 安全刻不容缓「GitHub 热点速览 v&period;21&period;50」

    作者:HelloGitHub-小鱼干 本周最热的事件莫过于 Log4j 漏洞,攻击者仅需向目标输入一段代码,不需要用户执行任何多余操作即可触发该漏洞,使攻击者可以远程控制用户受害者服务器,90% 以上 ...

  3. IAR EWARM Checksum Technical Note

    IELFTOOL Checksum - Basic actions EW targets: ARM, RH850, RX, SH, STM8 EW component: General issues ...

  4. STM32 CRC32与对应的软件CRC32(转)

    源:STM32 CRC32与对应的软件CRC32 简单实现STM32 CRC32使用 使用前记得使能STM32 CRC时钟 //STM32硬件CRC32 byte数据计算,将数据移到最高位,低位补上F ...

  5. 安装IAR ewarm

    一  安装准备 (ST方案) 1 嵌入式集成开发环境IAR ewarm 5.41 2 J-Link4.20 3 emberznet-4.3.0协议栈安装包 option1:tools - stm32软 ...

  6. algorithm&commat; Shortest Path in Directed Acyclic Graph &lpar;O&lpar;&vert;V&vert;&plus;&vert;E&vert;&rpar; time&rpar;

    Given a Weighted Directed Acyclic Graph and a source vertex in the graph, find the shortest paths fr ...

  7. STM32之VCP1&sol;VCAP2引脚的处理

    需要根据仔细根据手册来决定这两个引脚是直接接地还是电容下拉到地 转载:STM32的Vcap的问题及解决---原来经验也害人http://bbs.eeworld.com.cn/thread-499497 ...

  8. 【转载】STM32 ST-LINK Utility介绍、下载、安装、使用方法

    转载地址:https://blog.csdn.net/ybhuangfugui/article/details/52597133 总结的很好!!! Ⅰ.写在前面本文讲述的内容是STM32 ST-LIN ...

  9. 嵌入式单片机STM32应用技术(课本)

    目录SAIU R20 1 6 第1页第1 章. 初识STM32..................................................................... ...

随机推荐

  1. LeetCode - 49&period; Group Anagrams

    49. Group Anagrams Problem's Link ------------------------------------------------------------------ ...

  2. &lbrack;原创&rsqb;使用java批量修改文件编码(ANSI--&gt&semi;UTF-8)

    从网上下载的项目,有时候.java文件的编码是ANSI.导入到自己的MyEclipse后,查看项目源码的时候,总是乱码. 一个个.java去修改的话, 既麻烦又不现实.所以写了下面这个工具类,进行批量 ...

  3. springday04-go2

    练习:计算一个人的bmi指数.算法如下: 身高 单位是米 比如1.70 体重 单位是公斤 比如90 bmi指数 = 体重/身高/身高 如果bmi>24过重,否则正常.视图需要两个,一个是bmi_ ...

  4. 调用webservice查询手机号码归属地信息

    Web Services是由企业发布的完成其特定商务需求的在线应用服务,其他公司或应用软件能够通过Internet来访问并使用这项在线服务.在这里我们使用soap协议往webservice发送信息,然 ...

  5. linux内核学习之保护模式&lpar;一&rpar;

    来源:http://blog.csdn.net/yishuige/article/details/50434746 这一章涉及intel8086系列cpu的保护模式编程,应该是学习内核编程,驱动编程及 ...

  6. 算法技巧讲解》关于对于递推形DP的前缀和优化

    这是在2016在长沙集训的第三天,一位学长讲解了“前缀和优化”这一技巧,并且他这一方法用的很6,个人觉得很有学习的必要. 这一技巧能使线性递推形DP的速度有着飞跃性的提升,从O(N2)优化到O(N)也 ...

  7. CentOS5&period;5下直接安装MySQL5&period;6

    1.安装平台:CentOS5.5 2.由于从MySQL5.0升到MySQL5.6出现重大问题,为了不影响进度,暂时先直接安装MySQL5.6 2.1首先确认yum源,这里使用http://repo.m ...

  8. unix下网络编程之I&sol;O复用(四)

    首先需要了解的是select函数: select函数 #include<sys/select.h> #include<sys/time.h> int select (int m ...

  9. CATIA 各个版本代号详解

    一. 第几代(V-"version")简介 1982—1988年,catia相继发布了第一代—V1版本.第二代—V2版本.第三代—V3版本,并于1993年发布了功能强大的第四代—V ...

  10. 高性能分布式应用开发中间件ICE介绍

    作为一个技术人员,你是否在为不断增长的数据量和日益复杂的业务逻辑而头疼不已,杂乱堆砌在一起的庞大业务让系统越来越脆弱,于是你想到了网格,想到了利用分布式来重组一个健壮的系统架构. 随后,RMI,EJB ...