Beta test for GNU binutils ELF->COFF converter

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

After threatening about it in some Internet forums for a while, it's
now finally ready, and we can start beta tests for the new method to
convert the ELF files produced by avr-gcc into AVR COFF or AVR
»extended« COFF files as they are understood by certain commercial
software for the AVR controller series, notably AVR Studio 3 and 4 by
Atmel, and VMLAB by Advanced Micro Tools.

The new method implements what should (IMO) have been done from the
beginning: it teaches GNU binutils to handle the AVR COFF file format.
GNU binutils are already a part of the opensource toolchain for the
AVR controllers (commonly known alltogether as just "avr-gcc"), they
provide the assembler (avr-as), the linker (avr-ld), and various tools
to convert and analyze AVR object files (like avr-nm, avr-size,
avr-objdump, avr-objcopy). GNU binutils is based on a backend called
BFD (binary filedescriptor library) that handles all the object file
IO that is common to these utilities, and COFF historically being the
standard UNIX object file format of past days (10+ years ago), it's
not a surprise that GNU binutils could already handle more than two
dozen different flavours of COFF file implementations. So it seemed
to be only logical to base the new ELF->AVR COFF converter on GNU
binutils. Actually, the converter isn't that new at all, it's the
well-known avr-objcopy tool.

The conversion is currently done as a patch against the latest
official GNU binutils release (2.13.2.1), with the ultimate goal to
eventually have it incorporated into the official GNU binutils source
tree after the beta tests.

Currently, the patch is available in either source form (patch against
vanilla binutils-2.13.2.1, this is intented for Unix users who want to
test it, and can build binutils from source without much trouble), and
as a WinAVR add-on package. There's also a more verbose README that
explains what to do in order to use these tools.

The URLs for the various parts are:

README:
http://www.sax.de/~joerg/README....

Source code patch:
http://www.sax.de/~joerg/coff-av...

WinAVR add-on package, kindly provided by Eric Weddington:
http://sourceforge.net/projects/...

Chose »AVR COFF Beta« here. Note that some mirrors do not seem to
have mirrored these bits yet. Watch out for the new template
Makefile, it contains a hook for the new conversion method; you might
want to merge that into your existing project's Makefile. Note that
this template Makefile contains two targets, so you can say »make
coff« in order to get the older AVR COFF file format, and »make
extcoff« for the newer AVR »extended« COFF format. Please refer to
the README for details.

As a reminder, i do not have Windows (that's why i needed Eric's
help to provide the binaries), so do not assume i could reproduce any
problem you've got myself on Windows.

For bug reports, please make sure you're following the guidelines
outlined in the README. In particular, please see to investigate
yourself first. The more detailed and exact the report is, the faster
i'll be able to handle it. This is all my hobby work, i've been
spending about three months of spare-time (maybe hundred hours or so)
in writing this stuff, so frankly, i expect you to spend an hour in
analyzing your problem as well. Evidence that you didn't even read
the README file will be a good chance to become ignored, sorry. For
general questions, the usual Internet forums (the avr-gcc mailinglist,
the AVRfreaks avr-gcc forum, and for German users, the forum on
avr-gcc on http://www.mikrocontroller.net/ ) will still be a good
place, as more people than just me will be able to reply.

Finally, my thanks go to the following people who helped me in this
project:

Eric Weddington
for testing, and providing the WinAVR integration
of all this

Wallace White
Markus Assfalg
Volkmar Dierkes
Marc Wetzel
Andrew Ghali
Ömer Sinan KAYA

for alpha testing these bits and providing
feedback to me (which required them to build
all this from sources!)

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

Hi Betatesters,

i have test the new extcoff, but it end in a memory error. One pointer inside
of avr-objcopy points to NULL.

Here is the output :

C:\WinAVR\Projekte\TAMROS>make extcoff avr-objcopy --debugging --change-section-address .data-0x800000 --change-section -address .bss-0x800000 --change-section-address .noinit-0x800000 --change-section-address .eeprom-0x810000 -O coff-ext-avr tamros.elf tamros.cof
Discarding local symbol outside any compilation unit: .__do_copy_data_start
Discarding local symbol outside any compilation unit: .__do_copy_data_loop
make: *** [extcoff] Error -1073741819

Have somebody an idea ?

Best regards

Torsten Albrecht
AttNet

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

The warnings are OK.

Can you provide me with a stack trace (from GDB)? If
not, please write a bug report (see the README for the
email address), and attach the ELF file that produces
it (preferably the minimal ELF file that could reproduce
the bug).

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

Hi Joerg,

thank you for this elf2coff converter. I have already tried it. Until now it works well.
The tool came for me just at the right time.

regards
Konrad

admin's test signature
 

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

Hi Joerg,

I have a projetc with some assembler and some "C" files. When I tr to load the produced coff file into AvrStudio version:

- 4.07 - The file loads well, but I am unable to see assembler sources, or better I can open the source files, but the code doesn't jump into them when calling a function defined in a assebler file. (even if I use -gstabs). Also I am unabe to ses memebers of a pointer to a structure.

-3.56 - I am unable to load the coff file and I get "Unable to open source file. Error in Coff file !"

Thanks in advance !

m@rko

admin's test signature
 

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

--gstabs alone is not sufficient to produce enough debugging information
for COFF. That's partially the fault of COFF, since it cannot handle
include files, but the way gcc handles preprocessed assembler sources,
the actual file name is only available as an include filename.

There has been a discussion in the avr-gcc list about it, and i've been
posting a workaround there. Please subscribe to that list (ask
avr-gcc-list-request@avr1.org for help), then you'll be able to read
the mailing list archives.

If AVR Studio 3.x cannot read the COFF file, i guess you're using the
wrong COFF format. AS3 can only handle coff-avr, not coff-ext-avr.

AS4 is supposed to handle structs, but only with a recent version
of AS4.07. I've got positive confirmation that it works from one of
the alpha testers, so my guess is that your version might be too old.
(This time, it'll only work with coff-ext-avr.)

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

Hi Joerg (and all others),
thanks for your elf->coff converter, now I can see may variables in AVR 4.07. I am using the extended coff format.

The only thing I am still missing is with the initialisation, you may remember the lines:

#define DISPLAY_INIT_LEN 8
unsigned char DisplayInit[DISPLAY_INIT_LEN] = {0x38, 0x38, 0x38, 0x38, 0x06, 0x0e, 0x01, 0x80);

I know this is a known issue, but what kind of workaround would you suggest?
Is there an other possibility to code this?

The ugly thing is not that I cannot see these values in debugging, but the µC is really calculating with a lot of 0xff. (I put them on a port)

Best regards
Ralph

admin's test signature
 

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

There is no workaround other than using Atmel's fixed COFF parser DLL.
Unfortunately, they didn't officially distribute that so far.

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

Hi Joerg!

Thank you for the elf2coff converter. I have the problem, described by Marko Panger - when i try to open .cof file AVRStudio 3.56 writes 2 messages
"unable to open source file" and "Error in Coff file" one after another.

I'm using the following command string for convert .elf to .cof file:

d:\WinAVR/bin/avr-objcopy --debugging --change-section-address .data-0x800000 --change-section-address .bss-0x800000 --change-section-address .noinit-0x800000 --change-section-address .eeprom-0x810000 -O coff-avr agent-t.elf agent-t.cof
Discarding local symbol outside any compilation unit: .__do_copy_data_start
Discarding local symbol outside any compilation unit: .__do_copy_data_loop

Thank you.

Best regards,
Boris.

admin's test signature
 

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

Thank you for the elf2coff converter.

I have the problem described by Marko Panger and Boris Rozentsvaig : when i try to open .cof file AVRStudio 3.53 (and 3.56) writes 2 messages
"unable to open source file" and "Error in Coff file" one after another.

I can open The cof file done with objtool.
I look at the 2 cof files with a hex viewer to see if there was a wrong file name; in both the cof files I saw a structure like 'file', some bytes, then the ascii file name of the source file.
In the cof file done with the new converter, near the end of the cof file after all the file names of the project, I found the structure like 'file', then some bytes, then ''.
I suppose that this produce the error message, since AS3 try to find the file name ''.

Thank you for your excellent work.

Best regards,
Patrizio.

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

Thank you for the elf2coff converter.

I have the problem described by Marko Panger and Boris Rozentsvaig : when i try to open .cof file AVRStudio 3.53 (and 3.56) writes 2 messages
"unable to open source file" and "Error in Coff file" one after another.

I can open The cof file done with objtool.
I look at the 2 cof files with a hex viewer to see if there was a wrong file name; in both the cof files I saw a structure like "file", some bytes, then the ascii file name of the source file.
In the cof file done with the new converter, near the end of the cof file after all the file names of the project, I found the structure like "file", then some bytes, then ''".
I suppose that this produce the error message, since AS3 try to find the file name ''".

I sent again because in the previous mail the word was missing.

Thank you for your excellent work.

Best regards,
Patrizio.

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

I'm afraid only Atmel can answer that question then.
AVR Studio 3 is no longer being developed, and is known
to be quite picky about the COFF files it is willing
to understand.

Try analyzing the COFF file (see the README), and see
whether the source file names in it are OK.

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

The source file name in the cof file are ok; what i tryed to write (but I was not able) was that at the end of the file appear the following data:

00 00 00 00 00 00 00 00 2E 66 69 6C 65 00 00 00 .........file...
A0 00 00 00 FE FF 00 00 67 01 6D 61 69 6E 2E 63 ........g.main.c
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

...

00 00 03 00 2E 66 69 6C 65 00 00 00 7C 01 00 00 .....file...|...
FE FF 00 00 67 01 6B 65 79 62 2E 63 00 00 00 00 ....g.keyb.c....
00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 ............G...

and near the end of the cof file

2E 66 69 6C 65 00 00 00 00 00 00 00 FE FF 00 00 .file...........
67 01 3C 62 75 69 6C 74 2D 69 6E 3E 00 00 00 00 g.....
00 00 00 00 00 00 00 00 EF 07 00 00 86 EC 00 00 ................
02 00 00 00 03 00 00 00 00 00 FF 07 00 00 78 EC ..............x.

The cof file done with objtool do not have this part near the end.

Loading the same cof file with AvrStudio4 is ok, but in the project source files, the name appears.

Thank you

Patrizio.

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

Hmm, that name comes from the input file,
somehow.

Better not use hexdump, but avr-objdump -t or -g, as
described in the README.

AS3 is picky about files it cannot find. Try to find
out which input file that might actually come from
(NB: you can use the same avr-objdump -t, -g, or -G
on the input ELF file), maybe you can somehow run
avr-strip -g on that input object file (not on
the entire input file, but on a single .o before
linking!).

You can try changing that filename to something
AS3 will be able to find, use

--change-pathname '' 'someknownfile.c'

The best advise is probably to no longer use AS3, and
switch to AS4. Atmel doesn't support AS3 anymore, so
even if this might be a bug in AS3, they won't fix it.

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

Hello,

I have attached a simple test program and the avr-objdump -t files.
The string appears both in elf dump and in cof file.
In AS3 is not possible to load the file, while in AS4 is possible to load the file, even if in the Project tab, the 2 source files appear ( main.c and ).

I agree with you that Atmel will not do anything more on AS3 (even if would be a good things to fix problems),

Thanks,

Patrizio.

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

I have an idea why that happens... It comes from one
of the library modules. While Eric already strips the
debugging symbols from most of them, it looks like he
forgot to strip them from libgcc.a. Please try to
find all copies of libgcc.a on your machine. There
should be four of them total, one in a certain directory
i do not know, and then there'll be subdirs named
avr3 through avr5 which each have a copy of libgcc.a
as well.

Run avr-strip -g libgcc.a on each of them. Then
re-link your application, and see whether this helps.

If we know that this helps, it should not be too
difficult for Eric to also strip -g them in the default
WinAVR installation.

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

GREAT !!

Thanks, you were right!
I followed your instructions and stripped down the debugging symbols from all the copy of libgcc.a, recompile the project and I was able to load the cof file with AS3.

Thank you again.

Patrizio.

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

Hi,

Regarding my previous post about assembler files.

I use studio version 4.07, the latest downloaded yesterday from thi site and I am unable to debug assembler source files. I can open them in AVRStudio, but when I call a function which is defined as a assembler function (ex. MyAsmFunc(), defined in file.S) the code doesn't jump into the assebler function, but on the next "C" statement, just after the function call.

Can anybody (Joerg) give me a suggestion ?

Second I tried to "watch" a pointer, which is in fact a pointer to a structure:

typedef struct {
uint8 a;
uint8 b;
uint8 c;
} my_struct_t;

Later in a function:

my_struct_t *pStruct = (my_struct_t*) 0x100;

And I am unable to see memebers of pStruct ?

Any hint ?

Thanks in advance and thanks for the new ELF->COFF converter Joerg !

marko

admin's test signature
 

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

Regarding debugging of assembler sources, please read here:

http://www.avr1.org/pipermail/av...

Regarding the pointer to struct, please follow the descriptoin in
the README, and try analyzing the COFF file using avr-objdump -g.
Look there whether that looks OK or not. Needless to say, you must
use an coff-ext-avr file for this, coff-avr (the AVR Studio 3.x
compatible format) doesn't support struct debugging.

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

The tip mentioned at http://www.avr1.org/pipermail/av...
works for me, but only if I use a capital .S as suffix for the assembler file (check the makefile!).

- Michael

admin's test signature
 

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

Yes, sure. That makes it to run through the C
preprocessor. However, that's usually what you want
anyway, so you can #include and such.

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

Hi Betatesters,

I used the avr coff beta 2003-5-19 from sourceforge.net.
It comes with a sample makefile "makefile.cof" but there is
nor target "extcoff" inside this file.

Does anybody know where I can find the correct target "extcoff"?

Thanks
Thomas

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

You need to make sure that the avr-objcopy is called
using -O coff-ext-avr.

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

Hi Joerg

> There is no workaround other than using Atmel's fixed COFF parser DLL.
> Unfortunately, they didn't officially distribute that so far.

is there any posibility for get this file ?

admin's test signature