Calculating the check sum for the microcontroller ROM

Simple, but yet, I wanted to quickly generate the check sum in my hex file to be loaded into a PIC microcontroller. The file format is Intel Hex and I will not spend any time explaining the details. Read the Wiki page and you will understand.

Essentially, we have a string from the hex file in which we should change a number.

:0400000080312D28F6
:1000080080318331F0238031200054080A3A0319E3
:10001800571C11288631772680312100931D09004D
...
:0C0E2000640080010131890B112F0034A7
:020000040001F9
:04000E00A4C9FFDEA4
:00000001FF

into e.g.

:0400000080312D28F6
:1000080080318331F0238031200054080A3A0319E3
:10001800571C11288631772680312100931DX900??
...
:0C0E2000640080010131890B112F0034A7
:020000040001F9
:04000E00A4C9FFDEA4
:00000001FF

How do we quickly get the check sum out of that. Of course, we can just do the summation on a piece of paper and get the result. There are plenty of C hacks, there are plenty of Python hacks, but in general too much is hidden in the noise floor on the internet. Of course, we can also use the internal hex editor of the compiler tool, and there are some more options available out there.

However, this is my contribution to the noise floor. Here I did a spread sheet (and I have to admit I saved it in XLSX – gasp!) for a potentially wider audience. So download the spread sheet. Copy the string from the emacs buffer (or vi, ththth – read more about the editor war… nerdy, nerdy. ),

Allright, now I will at least find it next time I’m searching for it…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s