Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1014375
  • 博文数量: 327
  • 博客积分: 9995
  • 博客等级: 中将
  • 技术积分: 4319
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-25 11:21
文章存档

2011年(31)

2010年(139)

2009年(157)

我的朋友

分类:

2010-06-27 09:18:12

IntelHEX 文件比较常见,下面是这个文件格式简单的介绍。如果你经常想弄懂那些要烧写进芯片的冬冬是啥意思你可以参考一下。

Intel HEX-record Format

INTRODUCTION
Intel's Hex-record format allows program or data files to be encoded in a printable (ASCII) format. This allows viewing of the object file with standard tools and easy file transfer from one computer to another, or between a host and target. An individual Hex-record is a single line in a file composed of many Hex-records.
 
HEX-RECORD CONTENT
Hex-Records are character strings made of several fields which specify the record type, record length, memory address, data, and checksum. Each byte of binary data is encoded as a 2-character hexadecimal number: the first ASCII character representing the high-order 4 bits, and the second the low-order 4 bits of the byte.
The 6 fields which comprise a Hex-record are defined as follows: Field Characters Description
1 Start code 1 An ASCII colon, ":".
2 Byte count 2 The count of the character pairs in the data field.
3 Address 4 The 2-byte address at which the data field is to be loaded into memory.
4 Type 2 00, 01, or 02.
5 Data 0-2n From 0 to n bytes of executable code, or memory loadable data.
n is normally 20 hex (32 decimal) or less.
6 Checksum 2 The least significant byte of the two's complement sum of the values represented by all the pairs of characters in the record except the start code and checksum.

Each record may be terminated with a CR/LF/NULL. Accuracy of transmission is ensured by the byte count and checksum fields.
HEX-RECORD TYPES
There are three possible types of Hex-records. 00 A record containing data and the 2-byte address at which the data is to reside.
01 A termination record for a file of Hex-records. Only one termination record is allowed per file and it must be the last line of the file. There is no data field.
02 A segment base address record. This type of record is ignored by Lucid programmers.

HEX-RECORD EXAMPLE
Following is a typical Hex-record module consisting of four data records and a termination record.
:10010000214601360121470136007EFE09D2190140
:100110002146017EB7C20001FF5F16002148011988
:10012000194E79234623965778239EDA3F01B2CAA7
:100130003F0156702B5E712B722B732146013421C7
:00000001FF
The first data record is explained as follows:
: Start code.
10 Hex 10 (decimal 16), indicating 16 data character
pairs, 16 bytes of binary data, in this record.
01 Four-character 2-byte address field: hex address 0100,
00 indicates location where the following data is to be loaded.
00 Record type indicating a data record.
The next 16 character pairs are the ASCII bytes of the actual program data.
40 Checksum of the first Hex-record.

The termination record is explained as follows:
: Start code.
00 Byte count is zero, no data in termination record.
00 Four-character 2-byte address field, zeros.
00
01 Record type 01 is termination.
FF Checksum of termination record.
阅读(3791) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~