Go Down

Topic: Want to change the length of HEX record lines - possible? (Read 563 times) previous topic - next topic

Krupski

Hi all,

AVR-GCC (by itself and called by the Arduino IDE) generates Intel HEX record files containing the code to load into the chip.

A typical line looks like this (16 bytes of code):

[font=monospace]:100000000C9462000C948A000C948A000C948A0070[/font]

I want it to generate 32 byte lines, like this:

[font=monospace]:207E0000112484B714BE81FFF0D085E08093810082E08093C00088E18093C10086E08093FC[/font]

Is there a configuration somewhere that I can change this?

Oh, and to answer the inevitable "Why do you want to do that - it doesn't matter anyway" question: I want to do it because I plan to embed HEX records into a piece of code that programs ISP devices and I need 32 bytes at a time. Yes I know I can read two 16 byte lines and concatenate them, but I want 32 byte lines.... OK?

Thanks!

-- Roger
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Nick Gammon

I had a similar problem with a bootloader programmer. However I wrote a script in Lua to read the hex file and actually convert into C.

Since you say you want to imbed the hex into code, that might suit you.

http://www.gammon.com.au/forum/?id=11635

Converted output looks like this:

Code: [Select]

byte PROGMEM ATmegaBOOT_168_atmega1280_hex [] = {
0x0C, 0x94, 0x72, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8,
0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8,
0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8,
0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8, 0x0C, 0x94, 0x92, 0xF8,


So the code on the device doesn't need to understand how to read .hex files, that's done during the conversion phase.

If you don't want to use that they may be an option to avrdump that reads a hex file and outputs it again in a different format.

Or you could write a small C program to do it. Bear in mind each line has a sumcheck on it.
http://www.gammon.com.au/electronics

Krupski


I had a similar problem with a bootloader programmer. However I wrote a script in Lua to read the hex file and actually convert into C.


I actually have small C programs that I wrote a long time ago that convert HEX to BIN and BIN to HEX (with variable record length), but I was hoping to change a config somewhere so the compiler (actually the linker probably) output the proper record length natively.

For lots of quick and dirty file format conversions, I use (believe it or not) BASIC! Yes plain old BASIC.

I've got a wonderful "clone" of GWBASIC called "BAS" written by Michael Haardt (compiled and runs in Linux). It's 100% GWBASIC syntax compatible and it actually works better in many respects (for example, I can "PRINT HEX$(262144)" and not get an overflow like GWBASIC does.

I used to run GWBASIC in a virtual DOS machine before I found BAS... that's how much I use BASIC.

Well... enough rambling! Thanks for the info!

-- Roger
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Go Up