.elf vs .hex

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

I noticed that AS7 default for programming flash is .elf.  AS6.2 was the same, but I was told it was going to change to .hex in AS7.  Do I just go with the default and send the .elf file to flash, or do I need to change it to the .hex file?  Why does Atmel default to .elf?  Is it better for debugging, or what?

 

Confused as usual

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

The .ELF is not programmed to Flash - the tool extracts the code from it, and then programs that to flash.

 

The .HEX is purely the code for programming to Flash.

 

You need the .ELF (or an equivalent) on the Host for debugging information.

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:
You need the .ELF (or an equivalent) on the Host for debugging information.

 

Is the Host the laptop I am running AS7 on, or the ICE?

Last Edited: Sun. Jul 23, 2017 - 09:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Host = the thing hosting the tools; so, yes - that would be your laptop.

 

As opposed to Target = the thing where your code runs.

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

That's what I thought you meant. What I don't understand is why the AS7 default sends the .elf file through the ICE only to have the ICE strip off the .hex and throw the rest away since the .elf file is already on the host. It would make sense if the ICE needed something from the .elf for debugging

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

Why would you think that we send the elf file?

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

meolsen wrote:
Why would you think that we send the elf file?

When I click on the lightening bolt in AS7, and then click Apply, and then click Memories, the file that appears in the little window above the Program button is the .elf file for the project I just built.  I assume when I button on Program, that is the file that gets sent to the ICE and programs my flash.  I can change that file name to the .hex file and the ATmega gets programmed the same.

Last Edited: Sun. Jul 23, 2017 - 10:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Probably not.  The tool will extract the binary information from the .elf file and send it via appropriate protocol to the ICE, which then further processes it into programming commands for the actual device.   (The same is probably true of .hex files, BTW.  Most programmers (STK500, STK500v2, AVR109, etc) don't actually interpret hex code - they want binary.)

 

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

Wes, are you using "tool" to mean the same thing that awneil calls "Host"  When I click on the lightening bolt and then Apply, the "Tool" window says Atmel ICE.  We have a semantics issue here.  But from context I think you are using "Tool" to mean my laptop, or what awneil calls 'Host'  The little "Device" window says ATmega1284P.

 

I was just wondering why when I button on Memories the .elf file appears by default in the little window.  In AS5.2 it was the .hex file

Last Edited: Sun. Jul 23, 2017 - 11:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So everyone agrees that either the Host (my laptop) or the Tool (my ICE) strips off the .hex file and sends it on to eventually reside in my Device (ATmega1284P) flash memory.  But I still have my question of #9.

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

Nope, hex and elf both contains the binary data that should end up in flash on the target. Why studio changed the default? Maybe popular demand?

When studio talks to a tool, it uses a well defined protocol: http://www.atmel.com/webdoc/protocoldocs/index.html

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

Thanks Morton!  I guess I assumed the hex data went to flash because that is what was in the window in AS5, but now I know it is binary.  Thanks to Wes too, for the additional info.  Things are all clear now, and I learned something, so that makes it a good day.  smiley

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

Afterthought: Yes "tool" is a very ambiguous word. Not only can a piece of software be a tool (e.g. a piece of programming software) and a piece of hardware be a tool (like an ICE dongle). It is also true that the compiler-linker-... suite is called a toolchain! 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

The "advantage" of ELF over Hex is that Hex contains only the contents to be programmed into flash while ELF contains .text+.data (flash), .eepom (EEPROM), .lock (Lock bits), .fuse (Fuse bytes). So in one case you have a file with one set of data and in the other case you have a file with four or more.

 

I imagine that is why Atmel have preferred .elf over .hex

 

By the way a .hex file is made simply by extracting the one (well two) sections (.text and .data) from the .elf in the first place using objcopy.

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

The PC is a tool

Atmel Studio is tool

The compiler is a tool

The linker is a tool

The AtmelICE is a tool

 

We could collectively call them a tool-chain (though that usually just means the compiler-assembler-linker-objcopy chain)

 

The point is, it doesn't really matter where, exactly, in the chain the extra "baggage" of the ELF is discarded before it reaches the Flash.

 

The point is that the .HEX contains purely the info that goes into the flash, and the .ELF contains a whole lot more - in particular, the Debug Info required by the Atmel Studio for debugging.

 

So it makes sense to use the .ELF in development - because it has all the info.

 

You'd really only want the .HEX when you are purely blowing chips  - EDIT: or, particularly, getting a 3rd party to blow them for you.

 

 

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...
Last Edited: Mon. Jul 24, 2017 - 08:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
The point is that the .HEX contains purely the info that goes into the flash
Well actually that's not true either. Only a .bin could be said to truly contain only that which goes to the flash. A Hex file contains additional line length, addressing and checking information ;-)

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

The .HEX is a representation of the .bin

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:
The .HEX is a representation of the .bin
So is (part) of the ELF. So how are they really any different?

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

 

So how are they really any different?

 

The elf has stealth

 

https://www.youtube.com/watch?v=yi1oPMZv82k

When in the dark remember-the future looks brighter than ever.

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

 

awneil wrote:

The .HEX is a representation of the .bin

clawson wrote:
So is (part) of the ELF. So how are they really any different?

The difference is that the .HEX represents only the .BIN part - whereas the .ELF contains a whole lot more.

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