简体   繁体   English

修复Intel HEX文件上的校验和问题

[英]Fixing checksum issues on intel HEX files

I have made the following intel hex file snippet to test with a couple 8051 processor simulators: 我制作了以下intel十六进制文件片段,以使用几个8051处理器模拟器进行测试:

:1000F5007002501F500CED2562FDEE3561FEEF35A7
:1001050060FFE56233F562E56133F561E56033F57E

One I used is located here: http://www.jroweb.de/8051/ 我使用过的一个位于这里: http : //www.jroweb.de/8051/

From my research, it is to my understanding that a checksum of the intel hex file is calculated by summing all the pairs of hex digits (except last), then ANDing the result with 255 to get the 8-bit value, inversing the value, adding 1, and doing mod 256. 根据我的研究,据我所知,intel十六进制文件的校验和是通过对所有十六进制数字对(最后一个除外)求和,然后将结果与255进行“与”运算来获得8位值,然后求反加1,并做mod 256。

I basically followed the math from a respondent from these forums: 我基本上遵循了来自这些论坛的受访者的数学意见:

https://social.msdn.microsoft.com/Forums/en-US/a1736ae8-2db6-4657-a98c-e3e447ebfda3/calculate-intel-hex-file-format-checksum https://social.msdn.microsoft.com/Forums/en-US/a1736ae8-2db6-4657-a98c-e3e447ebfda3/calculate-intel-hex-file-format-checksum

When I performed the calculations, the checksum values for each line in the above snippet are correct, however in the 8051 processor simulator program I mentioned above, it shows me a checksum error on the last line. 当我执行计算时,以上代码段中每一行的校验和值都是正确的,但是在上面提到的8051处理器模拟器程序中,它在最后一行显示了校验和错误。 It thinks the value should be 7F and not 7E. 它认为该值应为7F而不是7E。

Is it a possibility that a false positive exists in the last hex file line (which confuses certain software to believe that 7F is the correct value)? 最后一个十六进制文件行中是否存在误报(这会使某些软件认为7F是正确的值)? If so, how should I arrange the last line in my hex file to fix it? 如果是这样,我应该如何在hex文件中排列最后一行以进行修复?

AFAICT your checksums are correct. AFAICT您的校验和是正确的。 Based on this and some other records I've fed to it, the simulator seems to have an off-by-one bug on some inputs. 基于此以及我提供给它的一些其他记录,模拟器似乎在某些输入上存在一个错误的错误。

You have several options, including: 您有几种选择,包括:

  • edit the simulator's t8051m.ini file and set IgnoreChecksum to 1 编辑模拟器的t8051m.ini文件,并将IgnoreChecksum设置为1

  • humour the simulator by editing your hex records to carry the checksums it expects instead of the correct checksums 通过编辑十六进制记录来携带模拟器期望的校验和而不是正确的校验和,从而使模拟器幽默

  • disassemble the simulator's .exe file, find the bug, and fix it. 分解模拟器的.exe文件,找到错误,然后修复。 (Before you go to those lengths, you could try reporting the problem to the author. It might be a known issue with a fix that the author just never got around to publishing on his website.) (在进行这些讨论之前,您可以尝试将问题报告给作者。这可能是一个已知的问题,具有一个修复程序,使作者永远无法在自己的网站上发布。)

  • use some other simulator 使用其他模拟器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM