Microchip
直播中

车进

7年用户 207经验值
私信 关注
[问答]

英特尔HEX格式问题

大家好。对不起,如果有一个更好的地方,输出是从XC16,所以我想我粘在这里。我在寻找选项和方法,创建一个引导装载和分发固件更新的一个项目的矿山,我一直在建一个工具,“压缩”产生的“生产十六进制文件”在生成项目时提供AT。基本上只是去除(貌似?)多余的记录,将重置的“扩展线性地址”重置为相同的值,并将更多的指令聚合到单个记录中。这些都是很好的BWT.在HEX文件的末尾是什么看起来是配置位。但我有一个问题,希望有人能回答。以下是我感兴趣的内容:现在我将理解它,我可以删除很多:02行,因为它们只是重复设置目的地址的同一个上面的单词,我们可以把它转换成:我可以将这些进一步聚合到一个记录中,但是我会离开。更接近这一点,第一行(0200 000 0400 02F8)似乎把上面的地址字设置为0x002,这意味着第二行,例如,放在地址0x000 02AFE0(除非IVE得到了我的子孙混合在这里,但我认为我还好……),而值似乎M。我在MPLABX中的配置位窗口中看到了什么(例如,FICD有一个FFCF值,它看起来与上面的第二条记录匹配,只有在小字节中),我不能很好地理解地址如何翻译。在MPLABX,FICD在地址0x157f0……当然,它似乎对我选择的PIC(PIC24EP128)似乎没有意义,但是它非常接近于下一个大小的正确的-PIC24EP256,配置字节开始在0x02AFEC附近。但是,实际上,0x000 02AFE0实际上是在用户程序空间内,最后一页,我相信是正确的(再看数据表)。谁能解释一下这一点,或者指出我在这里的想法出了什么问题?这可能是HEX文件输出中的一个bug吗?0x000 02XXXX似乎不是这个PIC家族的有效地址……但是,看起来我不应该把这些作为软件更新的一部分来写,因为它最终能够实现代码保护,所以也许我只是在我重新工作的输出文件中排除了这些行?谢谢!汤姆

以上来自于百度翻译


      以下为原文

    Hi all. Sorry if there is a better place for this, the output is from XC16 so I figured I'l stick it here.

Im looking in to options and methods for creating a bootloader and distributing firmware updates for a project of mine, and Ive been building a tool to "compress" the resulting "production hex file" that is provided when you build the project. Basically just removing (seemingly?) superfluous records that keep resetting the "extended linear address" to the same value, and aggregating more instructions in to a single record. Thats all working great btw.

At the end of the hex file are what look to be the configuration bits. But I have a question about what is going on that hopefully someone can answer. Here are the contents that I am interested in:

:020000040000fa
:020000040002f8
:04afe000cfff00009f
:020000040000fa
:020000040002f8
:04afe400efff00007b
:020000040000fa
:020000040002f8
:04afe8006aff0000fc
:020000040000fa
:020000040002f8
:04afec001bff000047
:020000040000fa
:020000040002f8
:04aff00078ff0000e6
:020000040000fa
:020000040002f8
:04aff400ffff00005b
:00000001FF

Now as I would understand it, I can remove a lot of the :02 lines, since they are just repeatedly setting the same upper word of the destination address, and we can turn that in to:

:020000040002f8
:04afe000cfff00009f
:04afe400efff00007b
:04afe8006aff0000fc
:04afec001bff000047
:04aff00078ff0000e6
:04aff400ffff00005b
:00000001FF

I could aggregate those further in to a single record, but I'll leave that alone in this post.

Getting closer to the point, the first line (:020000040002f8) seems to set the upper address word to 0x0002, meaning that the second line, for example, gets placed at address 0x0002AFE0 (unless Ive got my endianess mixed up here, but I think Im ok...)

While the values seem to match what I see in the Configuration Bits window in MPLABX (e.g. FICD has a value of FFCF which seems to match the second record above, only in little endian), I cant quite work out how the address translates. In MPLABX, FICD is at address 0x157F0....?

Certainly it doesnt seem to make sense for my chosen PIC (PIC24EP128), but its very close to being correct for the next size up - PIC24EP256, whos configuration bytes start at around 0x02AFEC. But 0x0002AFE0 then actually ends up within user program space, last page actually, which I believe is correct (looking at the datasheets some more).

Can anyone shed any light on this or point out where Ive gone wrong in my thinking here? Is this a bug in the hex file output perhaps? 0x0002XXXX dont appear to be valid addresses for this family of PIC...

It would seem, however, that I shouldnt be writing these as part of a software update anyway as it would end up enabling code protection, so perhaps I just exclude these lines in my re-worked output file?

Thanks!
Tom

回帖(11)

李天竹

2018-11-27 15:31:15
在十六进制文件中,所有的地址都是加倍的。这是因为24位指令只占用2字节的地址空间。要将十六进制文件地址转换为物理地址,需要将其除以2。

以上来自于百度翻译


      以下为原文

    In the HEX file, all the addresses are doubled. This is because 24-bit instructions only occupy 2 bytes of the address space. To translate the HEX file address to the physical address you need to divide by 2.
举报

宋艳艳

2018-11-27 15:46:27
啊哈!太简单了。我甚至从来没有想过尝试除以二,所以这意味着HEX文件中的寻址是字节式的,而数据表是字面的呢?我甚至从未考虑过这一点。

以上来自于百度翻译


      以下为原文

    Ahhhhh!! So simple. I never even thought to try and divide by two.
 
So this means that the addressing in the hex file is byte wise, whereas the datasheets are word wise? Ive never even considered this.
举报

吴键洪

2018-11-27 15:54:31
是的,十六进制文件总是使用字节寻址。

以上来自于百度翻译


      以下为原文

   
Yes, hex files always use byte addressing.
 
举报

陈磊

2018-11-27 16:10:22
HEX文件也是“臃肿”的事实,XC16将第四个幻像字节添加到00个24位指令中,使每个指令32位,因此HEX文件地址可分为两个。如果文件大小非常重要,可以考虑创建将HEX文件转换为SUITAB的ATOOL。LE自定义格式。

以上来自于百度翻译


      以下为原文

   
The Hex file is also "bloated" by the fact that XC16 adds the fourth Phantom Byte as 00 for all 24 bit instructions, making it 32 bits per instruction so that HEX file addresses are dividable by two. If the file size is very important you may consider creating a tool that converts the HEX file to a suitable custom format.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分