Pages: [1]   Go Down
Author Topic: Want to change the length of HEX record lines - possible?  (Read 546 times)
0 Members and 1 Guest are viewing this topic.
Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 799
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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):

:100000000C9462000C948A000C948A000C948A0070

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

:207E0000112484B714BE81FFF0D085E08093810082E08093C00088E18093C10086E08093FC

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
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged


Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 799
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Pages: [1]   Go Up
Jump to: