Hex文件校验生成和验证
时间:2021-08-18 10:19:16
手机看文章
扫描二维码
随时随地手机看文章
[导读]关注星标公众号,不错过精彩内容编排 |strongerHuang微信公众号| 嵌入式专栏手机升级系统,下载完系统都会存在一个校验过程:其实,在MCU升级过程中,也是需要校验hex文件,如果要想升级更可靠,还可以在hex或bin升级文件后再增加校验信息。我们之前公司做的一个远程升级...
关注 星标公众号,不错过精彩内容编排 | strongerHuang微信公众号 | 嵌入式专栏
手机升级系统,下载完系统都会存在一个校验过程:
其实,在MCU升级过程中,也是需要校验hex文件,如果要想升级更可靠,还可以在hex或bin升级文件后再增加校验信息。
我们之前公司做的一个远程升级的产品,就是在升级文件之后增加了CRC16校验信息,在接收完整个升级文件之后,进行校验,这样做的目的就是使升级更可靠。
今天来讲讲hex文件的校验和验证校验的内容。
关于Hexhex 格式文件由 Intel 制定的一种十六进制标准文件格式,是由编译器转换而成的一种用于下载到处理器里面的ASCII文本文件。
1.解释维基百科解释https://en.wikipedia.org/wiki/Intel_HEXIntel HEX is a file format that conveys binary information in ASCII text form. It is commonly used for programming microcontrollers, EPROMs, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program's source code (such as in C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to "burn" the machine code into a ROM, or is transferred to the target system for loading and execution.
Keil官网解释https://www.keil.com/support/docs/1584/The Intel HEX file is an ASCII text file with lines of text that follow the Intel HEX file format. Each line in an Intel HEX file contains one HEX record. These records are made up of hexadecimal numbers that represent machine language code and/or constant data. Intel HEX files are often used to transfer the program and data that would be stored in a ROM or EPROM. Most EPROM programmers or emulators can use Intel HEX files.
2.格式hex行格式::BBAAAATT 【D···D】CC
其中:: 代表行开始,固定为冒号:
BB代表Bytes,数据长度AAAA代表Address,地址TT代表Type,数据类型(标识)D···D代表Date,数据
CC代表CheckSum,校验和
说明:BB数据长度,也就是D···D这个字段的数据长度;
AAAA地址,起始地址、偏移地址,根据数据类型(TT)有关;
TT数据类型(标识):
CC校验和计算公式:
手机升级系统,下载完系统都会存在一个校验过程:
其实,在MCU升级过程中,也是需要校验hex文件,如果要想升级更可靠,还可以在hex或bin升级文件后再增加校验信息。
我们之前公司做的一个远程升级的产品,就是在升级文件之后增加了CRC16校验信息,在接收完整个升级文件之后,进行校验,这样做的目的就是使升级更可靠。
今天来讲讲hex文件的校验和验证校验的内容。
关于Hexhex 格式文件由 Intel 制定的一种十六进制标准文件格式,是由编译器转换而成的一种用于下载到处理器里面的ASCII文本文件。
1.解释维基百科解释https://en.wikipedia.org/wiki/Intel_HEXIntel HEX is a file format that conveys binary information in ASCII text form. It is commonly used for programming microcontrollers, EPROMs, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program's source code (such as in C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to "burn" the machine code into a ROM, or is transferred to the target system for loading and execution.
Keil官网解释https://www.keil.com/support/docs/1584/The Intel HEX file is an ASCII text file with lines of text that follow the Intel HEX file format. Each line in an Intel HEX file contains one HEX record. These records are made up of hexadecimal numbers that represent machine language code and/or constant data. Intel HEX files are often used to transfer the program and data that would be stored in a ROM or EPROM. Most EPROM programmers or emulators can use Intel HEX files.
2.格式hex行格式::BBAAAATT 【D···D】CC
其中:: 代表行开始,固定为冒号:
BB代表Bytes,数据长度AAAA代表Address,地址TT代表Type,数据类型(标识)D···D代表Date,数据
CC代表CheckSum,校验和
说明:BB数据长度,也就是D···D这个字段的数据长度;
AAAA地址,起始地址、偏移地址,根据数据类型(TT)有关;
TT数据类型(标识):
- 00:数据标识
- 01:文件结束标识
- 02:扩展段地址
- 04:线性地址
- 05:线性开始地址
CC校验和计算公式:
CheckSum = 0x100 - (Sum