Can't load .hex file

85 views
Skip to first unread message

JMR1972

unread,
Sep 19, 2008, 6:36:42 AM9/19/08
to avrub
Hi,

I've tried using avrubd with a ihex format file as generated by winavr
(the latest version) but it complains about not being able to load
32bit hex format files. I'm not quite sure what I need to do to get
avrubd to load my compiled file to then download it to my target.

Any ideas why that error message appears?

Regards,
JM

管理员

unread,
Sep 19, 2008, 10:55:48 AM9/19/08
to avrub
Hi,

Avrubd cannot handle 32-bits hex format file now, because avr
microcontroller
only has small size flash (max 256K now), so there are not need to use
32bits
hex format. You may try to set parameters to generate normal hex
format file,
or use some software to convert file format.

JMR1972

unread,
Sep 22, 2008, 6:51:27 AM9/22/08
to avrub
Hi,

In my makefile I have the following line to generate a hex file.
avr-objcopy -O ihex -R .eeprom target.elf target.hex

After looking at the error message from avrubd the lines that seems to
cause the error are the two starting with :02 and :03
:0C84340003000000000E225A220000008D
:02000004008278
:03000000EDB9FA5D
:00000001FF

These are the last four lines in the hex file. The target processor is
an ATMega640 with 64kB of flash so obj copy shouldn't be generating a
32bit ihex file.

Do you have an example of command line that generates a valid hex
file? I'd like to use hyperterminal to load my application into Flash
(I've managed to establish communications with the bootloader and
verified that it writes to Flash) however the program doesn't seem to
work for me after a download.
Have you got a command line example that generates a valid raw image
from a standard avr .elf file?

JMR1972

unread,
Sep 22, 2008, 7:46:23 AM9/22/08
to avrub
Hi,
I found what caused the :02 :03 lines I have a fuse section in my code
to avoid forgetting to set these via the programmer. Now the trick is
to write these to the CPU (somehow).

JMR

Johan Roux

unread,
Sep 22, 2008, 10:57:39 AM9/22/08
to av...@googlegroups.com
Hi JMR1972,

This might be the answer you are looking for, if I'm not confused by the question!?!? I havn't really paid any attention to the previous mails...

The following lines demonstrate how to add code, in compile time, to the actual Program/Flash memory:

//This is used to add a number of bytes to the program memory at a specific position (user defined, in this case 0x1300)
unsigned char TestBufffer[4] __attribute__((section(".RelocateSection"))) = {0x11, 0x22, 0x33, 0x44};

The following line must be added to the Makefile i.o.t. add the above Array to program memory:
LDFLAGS +=  -Wl,-Map=AVRBLTS.map -Wl,--section-start=.RelocateSection=0x1300

When you compile and check the *.hex file created by AVR-Studio you should see the TestBuffer[] values, 0x11, 0x22, 0x33 and 0x44 has been added to address 0x1300. This can be used to store a device serial number for instance...

Hope this helps



2008/9/22 JMR1972 <pir...@gmail.com>



--
Regards

Johan Roux

管理员

unread,
Sep 23, 2008, 2:29:55 AM9/23/08
to avrub
Hi,

In next version, I will add ability to analyse fuse bits in hex file.
So you don't need
remove it manually.
Reply all
Reply to author
Forward
0 new messages