Hex文件
hex 格式文件由 Intel 制定的一种十六进制标准文件格式,是由编译器转换而成的一种用于下载到处理器里面的ASCII文本文件。
1.解释
维基百科解释
https://en.wikipedia.org/wiki/Intel_HEX
Intel 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:线性开始地址
(地址代表高16位地址,也就是要向左移16bit)
CC校验和计算公式:
CheckSum = 0x100 - (Sum & 0xFF)
|