eep file format: - how to create a custom eep file ?

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

Hello,

I'm progressing nicely. Now I'm looking for a way to create manually an .eep file for the ATMEga128 EEPROM. The EEPROM will store many config values, and so on. Right now, I have an excel sheet like this:

ADDR (hex)	DATA (hex)
00000	00
00001	00
00002	00
00003	00
00004	00
00005	00
00006	00
00007	00
00008	00
00009	00
0000A	1A
0000B	00
0000C	18
0000D	00

I'm now looking for a macro to produce .eep file based on this. I looked at the eep I downloaded from my AVR and I got the following:

:1001F0000000656504040400000000000000000029

I guess there is the adress somewhere (1F00), some padding cars before (100) and after(00), but also a kind of checksum at the end (29). Could you tell me if I'm right ? How the checksum is generated ?

Thanks.
Vincent

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

Intel Hex:

http://en.wikipedia.org/wiki/.hex

Maybe also try googling "bin2hex" - there's load of converters that will change a file of binary values to Intel Hex. One of the first Google hits is:

http://www.keil.com/download/doc...

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

Thanks. I wasn't too far but I didn't think of wikipedia....
I'll start googling.

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

By the way, you language compiler/assembler can probably generate this for you anyway. Something like:

.eseg
ee_data: .db 0,0,0,0,0,0,0,0,0,0,0x1A,0,0x18,0
unsigned char ee_data[] EEMEM = { 0,0,0,0,0,0,0,0,0,0,0x1A,0,0x18,0 };

or similar.

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

There's a bin2hex that comes bundled with WinAVR: it's called avr-objcopy.

avr-objcopy -I binary -O ihex binfile hexfile

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

Thanks for all your comments. I tried many of the bin2hex tools you mentiones, but none seems to take my binary file, which in fact is an ascii file containing the hex data I want in the bin file.
My file contains for example 00FF and the result shows:30304646
I'll see how I can create a real binary file from my excel file so bin2hex can work properly.
Vincent.

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

Then write a small C program to pre-process your ASCII file into binary.

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

Quote:
Then write a small C program to pre-process your ASCII file into binary.

Or in Excel change all the addresses to ".db", prepend your hex values with "0x", export it as an ascii file, load it into a new AVR Studio assembler project, add a ".eseg" in front of it, and assemble it. You'll get your .eep file.

(this is one of the options Cliff showed initially)

.eseg
.db 0x00
.db 0x1a
 (etc.)

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

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

If I'm not mistaken, this one should do it:

perl -e 'while(<>){next unless /^([0-9a-fA-F]+)\s+([0-9a-fA-F]+)/;$a[hex($1)]=hex($2);} printf ":%02X000000", $#a+1; $s = $#a+1; for($i=0; $i<=$#a; $i++) {printf "%02X",$a[$i]; $s += $a[$i]} printf "%02X\r\n:00000001FF\r\n", (-$s & 0xFF)'

;-)

Hint: feed your input data into stdin, e.g. by redirecting it from a file,
and redirect stdout into the hex file.

OK, I could also format it a little nicer...

#! /usr/bin/perl -w
use strict;

my @a; # array to collect data within

while (<>) {
	# discard anything but the lines with XXXX XX
	next unless /^([0-9a-fA-F]+)\s+([0-9a-fA-F]+)/;
	$a[hex($1)] = hex($2);
}

# preamble: length field, start at address 0, record type 0
printf ":%02X000000", $#a + 1;

# initialize checksum with length field
my $s = $#a+1;

# now, print each byte, and update checksum
for(my $i = 0; $i <= $#a; $i++) {
	# fill in zeros for any gaps
	my $val = defined($a[$i])? $a[$i]: 0;
	printf "%02X", $val;
	$s += $val;
}

# print checksum and termination record
printf "%02X\r\n:00000001FF\r\n", (-$s & 0xFF);

Store that in a file, say "makehexfile.pl", and run that on your data
file. The output will be the intel hex file, again, on stdout.
Redirect to your desired hex file.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

Thanks for the pl code. I like the short version.
I also made an excel macro that creates the binary file, then calls avr-objcopy . And that's it !

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

this generates an eep file by pushing 1 button

//file eepromtst.c
//July 28 08 Bob G

#include 

#pragma data:eeprom
char stuffineeprom[]={"I think you can put anything you want in here"};
int morestuff=0x1234;
#pragma data:data

void main(void){
}
//-----eof---------

Imagecraft compiler user

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

Yes. But I was looking for a way to turn external data (excel file) into eeprom by clicking one button (and not pushing....)
V.

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

You mean change the variable declarations above into "#include stuff.h" that you saved from excel?

Imagecraft compiler user