Software for .hex checksum calc

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

Does anyone know a free software tool for editing/creating intel hex files, that support auto offset calculation at the beginning of line and auto checksum calculation at the end of line.

I want to create a hex for an AVR's EEPROM (and upload by AVR studio) but I don't want calculate anything nor create the base.

Thank you,

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wikipedia says:

Quote:
Checksum, two hex digits - the least significant byte of the two's complement sum of the values of all fields except fields 1 and 6 (Start code ":" byte and two hex digits of the Checksum). It is calculated by adding together the hex-encoded bytes (hex digit pairs), then leaving only the LSB of the result, and making a 2's complement (either by subtracting the byte from 0x100, or inverting it by XOR-ing with 0xFF and adding 0x01). If you are not working with 8-bit variables, you must suppress the overflow by AND-ing the result with 0xFF. The overflow may occur since both 0x100-0 and (0x00 XOR 0xFF)+1 equal 0x100. If the checksum is correctly calculated, adding all the bytes (the Byte count, both bytes in Address, the Record type, each Data byte and the Checksum) together will always result in a value wherein the least significant byte is zero (0x00).

For example, on :0300300002337A1E

03 + 00 + 30 + 00 + 02 + 33 + 7A = E2, 2's complement is 1E

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I want to create a hex for an AVR's EEPROM (and upload by AVR studio) but I don't want calculate anything nor create the base.
And what's so wrong with AVRStudio doing it all for you? :? (C or ASM)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or install WinAVR and use some of the binutils. avr-objcopy will do bin2hex and hex2bin conversions for you if you ask it nicely. Also there isn't much about Intel Hex that Srecord doesn't know how to do.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR studio only accepts intel hex files with correct checksum.

What clawson quoted is exactly what I want to do automatically (plus the offset numbers). I have WinAvr but I don't want to use code (libraries) to make my hex file.

Maybe a spreadsheet could calculate this for me.
But I couldn't found any.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've created the perfect spreadsheet for this purpose.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Google HEX2BIN and BIN2HEX.

--Rich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I have WinAvr but I don't want to use code (libraries) to make my hex file.

If what you are tying to do here is take a .bin file of EEPROM initial values and convert this to Intel .hex (maybe .eep?) for input to your programmer software then either follow RiJoRi's suggestion of BIN2HEX (tons out there if you Google - I think it's Keil who have a good one for download) or just use avr-objcopy in the WinAVR package. It's happily operate a a Hex2Bin for you. Start with "avr-objcopy -?" or "avr-objcopy --info" (hint: you want "binary" and "ihex")

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry I wasn't that clear, I wanted custom HEX data converted to intel format HEX.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So write a small utility to read the "custom hex" and output it as .bin then use standard tool from there on

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have solved my problem with a spreadsheet, check it above.
Intel HEX output is fine for me, I can burn it directly with AVR studio (ISP).
Custom HEX means RAW data e.g: "FF E2 2F.." string.
The xls calcs the necessary checksums.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Custom HEX means RAW data e.g: "FF E2 2F.." string.
Like
.db 0xFF, 0xE2, 0x2F

Surely it must be a lot more complex than that for you to have to write you own program, I must be missing something. :?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly