Make elf file from hex and fuse bits in command line?

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

Hi. I have an hex file(combined of Bootloader and main program), and fuse bits. I want to make ELF file,for fast production. Is there any way to make ELF from HEX and FUSE bits in command line? I know there is a GUI tool in atmel studio(Device Programming-> Production file) but i need command line. Is there any way?

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

The command line too you want is called "objcopy", and for AVRs often specifically "avr-objcopy".

 

It can take an ELF file as input and extract parts of it to Intel hex format.

 

The exact options to feed it to have id do what you want depends to a large extent to exactly what you want to do and what your ELF file contains. No one-stop cook-book advice is possible.

 

The general look of an objcopy command line is

avr-obcopy -O output-format [-j section-to include]... [-R section-to-remove]... input-file output-file

but there are more options availiable that thjese basic ones shown above.

 

If you are familiar with GNU Make and makefiles then you could look at some makefiles targeting the avr-gcc toolchain to see how it is done there.

 

Here are rough examples adapted from a makefile I often use. First, create a hex file for flash (by simply removing the EEPROM section (assuming that the ELF only contains flash- and EEPROM-destined content):

 

avr-objcopy -O ihex -R .eeprom filename.elf filename.hex

And then an example creating a file with EEPROM contents (by explicitly including the .eeprom section of the ELF, and also demonstrating more options - here "rebasing" the .eeprom addresses to start at zero):

 

avr-objcopy -j .eeprom --set-section-flags .eeprom=alloc,load --change-section-lma .eeprom=0 -O ihex filename.elf filename.eep

 

You could also have a look at the build output from Studio - it engages objcopy as one of it's last steps in a build.

 

Documentation for GNU objcopy is here.

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]

Last Edited: Sat. Jan 20, 2018 - 12:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
It can take an ELF file as input and extract parts of it to Intel hex format.  

But OP is asking to do the opposite:

 

sabuniver5 wrote:
I have an hex file ...  I want to make ELF file,for fast production.

But that makes no sense - how would having an ELF file help production??

 

It is usually the HEX file that made for production!

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: Sat. Jan 20, 2018 - 01:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
But OP is asking to do the opposite

Doh! Sorry for the confusion.

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: 1

While you can convert hex back to elf why didn't you just have the original build put it all together in an ELF?

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

awneil wrote:
But that makes no sense - how would having an ELF file help production??  
 

Because the ELF would come to the production point as one monolithic file rather than a set of files for the different memories.

 

There's certainly programming software that uses, or can use, the ELF file as the sole source for programming different memories. Look no further than Atmel Studio..

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

Ah, I think it's my turn to mis-read the OP - I thought it said the Hex file was all "combined" - but perhaps not ...

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

how to merge elf and eep file and generate elf file by using command prompt

Varun

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

Please do NOT cross post - you have a thread about that here: https://www.avrfreaks.net/forum/... already.