avr architecture of input file ... is incompatible with avr:51 output

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

I'm trying to build a program that includes a raw binary image.

From the link step, I get the titular message with the three dots representing a long absolute path to a file made with this command:

avr-objcopy -I binary -O elf32-avr big big.o

"Twas mostly copied from here: https://www.microchip.com/webdoc...

elf32-avr:51 does not help.

 

Edit: My guess is that the cure is the correct -O argument,

but I do not know what it would be.

Presumably it is in the source for avr-objcopy,

but I do not know where to look.

In general ,when I've done a search for the source for pretty much anything,

I've come up dry.

 

This topic has a solution.

"Demons after money.
Whatever happened to the still beating heart of a virgin?
No one has any standards anymore." -- Giles

Last Edited: Fri. Jun 22, 2018 - 08:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

skeeve,

 

have you tried to run this command separately?

from your link to the microchip page there are 2 possible invocations of the command.

 

from what I understand is that you need the second if you use the command in a linker script as the first conversion is not a full conversion that is usable.

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What's really annoying is that within the last year there was a thread comparing how you specify architecture in the compiler tools (-mmcu=) with how you do it for binutils. I found the place in the source and how binutils (objcopy) use a completely different set of symbol names for the same thing - but I simply cannot find the post again.

 

So anyway I checked a fairly recent avr-gcc I have and found the binutils to be version 2.26:

D:\atmel_avr\avr8-gnu-toolchain\bin>avr-objcopy -V
GNU objcopy (AVR_8_bit_GNU_Toolchain_3.5.4_1709) 2.26.20160125
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

so I went here:

 

https://sourceware.org/git/gitwe...

 

and found the tag for the 2_26 release:

 

https://sourceware.org/git/gitwe...

 

from which the "tree" option takes me to the code tree:

 

https://sourceware.org/git/gitwe...

 

That has a "binutils" subdirectory and in it objcopy.c. Within that at line 4809 is:

 

https://sourceware.org/git/gitwe...


4709         case 'B':
4710           input_arch = bfd_scan_arch (optarg);
4711           if (input_arch == NULL)
4712             fatal (_("architecture %s unknown"), optarg);
4713           break;

so if nothing else this tells us the option to set architecture when creating ELF from binary is -B so now it's just a case of knowing what the -B option that means "avr51" is. The function is bfd_scan_arch which tells us this is likely done in libbfd. The source of bfd is in a separate directory alongside binutils:

 

https://sourceware.org/git/gitwe...

 

and on the whole to find the "AVR specific" bts I find it's just a case of looking at likely looking files with "AVR" in the name. Actually the first "hit" is:

 

https://sourceware.org/git/gitwe...

 

which gets us to:

 

https://sourceware.org/git/gitwe...

 

That is:

 


 100 static const bfd_arch_info_type arch_info_struct[] =
 101 {
 102   /* Assembler only.  */
 103   N (16, bfd_mach_avr1, "avr:1", FALSE, & arch_info_struct[1]),
 104
 105   /* Classic, <= 8K.  */
 106   N (16, bfd_mach_avr2, "avr:2", FALSE, & arch_info_struct[2]),
 107
 108   /* Classic + MOVW, <= 8K.  */
 109   N (16, bfd_mach_avr25, "avr:25", FALSE, & arch_info_struct[3]),
 110
 111   /* Classic, > 8K, <= 64K.  */
 112   /* TODO:  addr_bits should be 16, but set to 22 for some following
 113      version of GCC (from 4.3) for backward compatibility.  */
 114   N (22, bfd_mach_avr3, "avr:3", FALSE, & arch_info_struct[4]),
 115
 116   /* Classic, == 128K.  */
 117   N (22, bfd_mach_avr31, "avr:31", FALSE, & arch_info_struct[5]),
 118
 119   /* Classic + MOVW + JMP/CALL, > 8K, <= 64K. */
 120   N (16, bfd_mach_avr35, "avr:35", FALSE, & arch_info_struct[6]),
 121
 122   /* Enhanced, <= 8K.  */
 123   N (16, bfd_mach_avr4, "avr:4", FALSE, & arch_info_struct[7]),
 124
 125   /* Enhanced, > 8K, <= 64K.  */
 126   /* TODO:  addr_bits should be 16, but set to 22 for some following
 127      version of GCC (from 4.3) for backward compatibility.  */
 128   N (22, bfd_mach_avr5, "avr:5", FALSE, & arch_info_struct[8]),
 129
 130   /* Enhanced, == 128K.  */
 131   N (22, bfd_mach_avr51, "avr:51", FALSE, & arch_info_struct[9]),
 132
 133   /* 3-Byte PC.  */
 134   N (22, bfd_mach_avr6, "avr:6", FALSE, & arch_info_struct[10]),
 135
 136   /* Tiny core (AVR Tiny).  */
 137   N (16, bfd_mach_avrtiny, "avr:100", FALSE, & arch_info_struct[11]),
 138
 139   /* Xmega 1.  */
 140   N (24, bfd_mach_avrxmega1, "avr:101", FALSE, & arch_info_struct[12]),
 141
 142   /* Xmega 2.  */
 143   N (24, bfd_mach_avrxmega2, "avr:102", FALSE, & arch_info_struct[13]),
 144
 145   /* Xmega 3.  */
 146   N (24, bfd_mach_avrxmega3, "avr:103", FALSE, & arch_info_struct[14]),
 147
 148   /* Xmega 4.  */
 149   N (24, bfd_mach_avrxmega4, "avr:104", FALSE, & arch_info_struct[15]),
 150
 151   /* Xmega 5.  */
 152   N (24, bfd_mach_avrxmega5, "avr:105", FALSE, & arch_info_struct[16]),
 153
 154   /* Xmega 6.  */
 155   N (24, bfd_mach_avrxmega6, "avr:106", FALSE, & arch_info_struct[17]),
 156
 157   /* Xmega 7.  */
 158   N (24, bfd_mach_avrxmega7, "avr:107", FALSE, NULL)
 159
 160 };

I've highlighted the avr51 entry in that. So the command to avr-objcopy is "-B avr:51" if you try to link data generated using that to code built with -mmcu=avr51 (or any of the models in "avr51") then I think it might just work ;-)

 

EDIT: actually to save me doing this again I'll just add #objcopy #architecture which should make it easy to search for this post in future.

 

PS and now I remember that the previous thread was about "Xtiny". I don't think anyone would have guessed that the way to specify that to objcopy is "-B avr:100" !!

 

EDIT2: and of course, now knowing the search terms does indeed get me back to:

 

https://www.avrfreaks.net/forum/...

 

(in that case it was objdump not objcopy in fact)

Last Edited: Fri. Jun 22, 2018 - 08:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
I'll just add #objcopy #architecture which should make it easy to search for this post in future.

If only the 'Tags' feature of the forum actually worked ...

 

frown

 

or the Bookmarks.

 

frown

 

Speaking of which - what's happening on the forum fixes front ?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

 

Speaking of which - what's happening on the forum fixes front ?

 

 

I think that is again moved to the realm "ssssht, don't mention the war"

it has been quiet for a while again. or like you missed a couple of threads there ;)

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

awneil wrote:
If only the 'Tags' feature of the forum actually worked ...
In what way does it not work?

 

I suppose the drawback is that tags are only available on #1 so OP can add searchable tags but when someone later posts an answer that might be "re-usable" they can't then add the tags that would make it easy to find?

 

Haven't heard a lot from Martin recently - of course that could just mean a vacation! ;-)

 

Oh wait a minute I just noticed that this reply editor has "Add tags". Let me try

 

EDIT: OK I see what you are saying I typed "objcopy, architecture" into the add tags box then posted but no tags showed up - I guess that is the fault you mean?

Last Edited: Fri. Jun 22, 2018 - 11:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
In what way does it not work?

To be honest, I've forgotten!

 

I do remember that I tried it at the beginning, and it was discussed.

 

Now, I just ignore it entirely.

 

Haven't heard a lot from Martin recently

I seem to remember that "Regular Updates" was one of the things specifically requested when Johan did his list ...

 

frown

 

I guess that is the fault you mean?

Sounds familiar ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@meslomp
I typed in the command exactly as given.
From the FAQ, it should have done excatly what I wanted.
The second format is for getting the binary only into flash.
Not what I wanted.

 

@clawson:
Thanks.  I'll try it when I get back to the office.
Assuming it works,, methinks the FAQ needs fixing.
From this discussion, the examples given never work.

"Demons after money.
Whatever happened to the still beating heart of a virgin?
No one has any standards anymore." -- Giles

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

I bet it would work for "default" (the same architecture you get if you invoke the compiler without -mmcu set)

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

awneil wrote:
clawson wrote: I'll just add #objcopy #architecture which should make it easy to search for this post in future. If only the 'Tags' feature of the forum actually worked ...
However it happened, I see objcopy and architecture in my tag list.

"Demons after money.
Whatever happened to the still beating heart of a virgin?
No one has any standards anymore." -- Giles

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

clawson wrote:
I bet it would work for "default" (the same architecture you get if you invoke the compiler without -mmcu set)

Even if we assume that it would work for that rare case,

that is still no excuse for such misleading (at best) "information".

"Demons after money.
Whatever happened to the still beating heart of a virgin?
No one has any standards anymore." -- Giles

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

Even if we assume that it would work for that rare case,

 

that is still no excuse for such misleading (at best) "information".

FOSS.  Contribute!  ;-)

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Fri. Jun 22, 2018 - 08:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

skeeve wrote:
that is still no excuse for such misleading (at best) "information".
Perhaps also not an excuse, but AFAIK the information is simply outdated. This strict architecture checking during linking wasn't there from the beginning.

Stefan Ernst