最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

Hex文件格式说明文档

来源:动视网 责编:小OO 时间:2025-09-28 12:33:27
文档

Hex文件格式说明文档

HexFileReferenceThepostlocatorisresponsibleforgeneratingthehexfileneededfortheROMflow.Itcanalsobeusedbyemulatorandsimulatorfortestingpurposes.DuetothedatastructureofIntelhexfiles,itisnotpossibletohandlevirtualandphysicaladdressesasdatastructureswith
推荐度:
导读HexFileReferenceThepostlocatorisresponsibleforgeneratingthehexfileneededfortheROMflow.Itcanalsobeusedbyemulatorandsimulatorfortestingpurposes.DuetothedatastructureofIntelhexfiles,itisnotpossibletohandlevirtualandphysicaladdressesasdatastructureswith
Hex File Reference

The postlocator is responsible for generating the hex file needed for the ROM flow. It can also be used by emulator and simulator for testing purposes. Due to the data structure of Intel hex files, it is not possible to handle virtual and physical addresses as data structures within the same file nor virtual addresses for multiple levels. Therefore, SLE 79 specific information is provided within comment lines. Such information are comments to be is played in the ROM generator GUI, date and time of creation, segment descriptors, virtual addresses and so on.

Note: The Intel hex file is an ASCII text file with lines of text that follow the Intel hex file format. Each data 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 program and data to be stored in ROM or NVM.

1.1 Hex File Structure 

The SLE 70 hex file is divided into three parts which have to occur in the described order:

• Comment part containing the following information:

– As first line “; TYPE=SLE70_MASK_IHEX” as identifier for the SLE 70 hex file format.

– Five sections in arbitrary order

- COMMENT (optional)

- INFO

- MEMORY_ADDRESSES

- CONFIG

- DESCRIPTOR

– The keywords inside these sections may contain

- Letters “a – z” and ”A – Z” (not case sensitive)

- Digits “0 – 9” but not as first character

- “-” or “_” but not as the first character

-Leading and trailing spaces are ignored

• Data part which data lines (records) start always with a colon “:”. The only comments allowed in this part are the definitions of the virtual addresses “V_ADDR = 0x...”. These comments are allowed at the beginning of a line and define the virtual address for the following data lines until another definition of the virtual address. The virtual address must contain the level information in the upper byte. The offset in an extended linear address record affects both the physical and the virtual address. Gaps in the data record section also affect the virtual address.

• Optional comment part which is situated after the “end-record” line.

General Rules

• The indicator for a comment line is the semicolon “;”.

• The indicator for a data line is the colon “:”.

• Every character to the right of the equal sign will be assigned to the value of the keyword, except leading and trailing spaces. Quoting of strings containing spaces is not required.

• Empty lines may occur anywhere in the file.

1.1.1Body of a SLE 70 HEX File

The basic structure of a SLE 70 hex file is given below. Optional parts are shown in green.

Please note that only within the green marked parts user comments are allowed and may be freely edited. All other parts (red, blue and magenta) must not be changed by the user.

Please keep also in mind that within the INFO_SECTION some tool components may appear more than once and in different versions. That is not a fault (is a feature?) because large projects developed over a long time may include modules formerly developed with older tool component versions.

1.1.2 Syntax of INFO_SECTION

1.1.3 Syntax of MEMORY_ADDRESSES_SECTION

1.1.4 Syntax of CONFIG_SECTION

1.1.5 Syntax of FILL_MEMORY_SECTION

1.1.6 Syntax of SYMBOL_SECTION

1.1.7 Syntax of DESCRIPTOR_SECTION

1.2 Record Format

An Intel HEX file is composed of any number of HEX records. Each record is made up of five fields that are arranged in the following format:

Each group of letters corresponds to a different field, and each letter represents a single hexadecimal digit. Each field is composed of at least two hexadecimal digits, which make up a byte, as described below:

1.2.1 Data Record

The Intel HEX file is made up of any number of data records that are terminated with a carriage return and a linefeed. Data records appear as follows:

1.2.2 End-of-File Record

An Intel HEX file must end with an end-of-file (EOF) record. This record must have the value 01 in the record type field. Any HEX records following this record will be ignored. An EOF record always appears as follows: 

1.2.3 Extended Linear Address Record

The Intel HEX contains extended linear address records when the H386 directive is used. This record is used to specify the two most significant bytes (bits 16 - 31) of the absolute address. This address offset is used for all following data records. Extended linear address records appear as follows:

1.3 Example

Hex文件是可以烧录到MCU中,被MCU执行的一种文件格式。如果用记事本打开可发现,整个文件以行为单位,每行以冒号开头,内容全部为16进制码(以ASCII码形式显示)。

Hex文件可以按照如下的方式进行拆分来分析其中的内容:

例如 “:1000080080318B1E0828092820280B1D0C280D2854”可以被看作“0x10 0x00 0x08 0x00 0x80 0x31 0x8B 0x1E 0x08 0x28 0x09 0x28 0x20 0x28 0x0B 0x1D 0x0C 0x28 0x0D 0x28 0x54”

第一个字节 0x10表示本行数据的长度;

第二、三字节 0x00 0x08表示本行数据的起始地址;

第四字节 0x00表示数据类型,数据类型有:0x00、0x01、0x02、0x03、0x04、0x05。

'00' Data Rrecord:用来记录数据,HEX文件的大部分记录都是数据记录

'01' End of File Record: 用来标识文件结束,放在文件的最后,标识HEX文件的结尾

'02' Extended Segment Address Record: 用来标识扩展段地址的记录

'03' Start Segment Address Record:开始段地址记录

'04' Extended Linear Address Record: 用来标识扩展线性地址的记录

'05' Start Linear Address Record:开始线性地址记录

然后是数据,最后一个字节 0x54为校验和。

校验和的算法为:计算0x54前所有16进制码的累加和(不计进位),检验和 = 0x100 - 累加和。

'04' Extended Linear Address Record和'05' Start Linear Address Record都是用来提供地址信息的。每次碰到这两个记录都可以根据记录计算出一个“基”地址,其后的数据记录都是以这个“基”地址为基础的。

例如:

:0200000400F802

:1080000077554D33023403FFFFFFFFFFFFFFFFFFF4

第1条记录的长度为02,LOAD OFFSET为0000,RECTYPE为04,说明该记录为扩展段地址记录。数据为00F8,校验和为02。从这个记录的长度和数据,我们可以计算出一个“基”地址,这个地址为0x00F80000(0x00F8 << 16)。后面的数据记录都以这个地址为基地址。

第2条记录的长度为0x10(16),LOAD OFFSET为0000,RECTYPE为00,说明该记录为数据记录。数据为77554D33023403FFFFFFFFFFFFFFFFFF,共16个BYTE。这个记录的校验和为F4。此时的基地址为0X80000,加上OFFSET,这个记录里的16BYTE的数据的起始地址就是0x80000 + 0x0000 = 0x80000.

文档

Hex文件格式说明文档

HexFileReferenceThepostlocatorisresponsibleforgeneratingthehexfileneededfortheROMflow.Itcanalsobeusedbyemulatorandsimulatorfortestingpurposes.DuetothedatastructureofIntelhexfiles,itisnotpossibletohandlevirtualandphysicaladdressesasdatastructureswith
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top