1
\$\begingroup\$

Every time I want to program my ATtiny85 using AVR Studio 6 it has the MyProject.elf file pre-selected in the "Flash" drop-down box in the Device Programming dialog. Obviously I want it to program the MyProject.hex file, but I manually have to select this every time using the drop-down list. Does anyone know a trick to get my selection to stick?

\$\endgroup\$
  • \$\begingroup\$ Is there a reason you want to use the hex file instead of ELF? My understanding is that the debug info gets stripped during programming so it shouldn't really make a difference. \$\endgroup\$ – PeterJ Nov 1 '13 at 12:37
  • \$\begingroup\$ I thought an ELF file was like a Windows PE file? Surely there's no way my ATtiny can run an ELF file with all the headers and crap that's in there? \$\endgroup\$ – David Högberg Nov 1 '13 at 12:52
  • \$\begingroup\$ I don't have a programmer attached to my PC at the moment to try it but my understanding is the ELF contains the binary code and fuse settings along with debug information but the latter isn't actually programmed into the device. If you've got it all setup maybe give it a try and see how it goes. I've only used V6 for one project so far and that was previously under V5 so maybe I didn't have to change it because of some other default that carried across. \$\endgroup\$ – PeterJ Nov 1 '13 at 13:04
  • \$\begingroup\$ I just tried it and it runs fine with the ELF file. Very strange. Just look at all the headers that are in an ELF file: en.wikipedia.org/wiki/Executable_and_Linkable_Format \$\endgroup\$ – David Högberg Nov 1 '13 at 13:11
  • \$\begingroup\$ As far as I know there is no "AVR Studio 6" - Atmel has renamed AVR Studio to "Atmel Studio 6." If you're using version 6, I'm fairly certain you're using Atmel Studio 6. \$\endgroup\$ – JYelton Nov 1 '13 at 23:44
1
\$\begingroup\$

According to the What is ELF file and how to program it on the AVR devices? support FAQ at Atmel the following is given as a difference:

The difference is when you generate it in AVR Studio you can save the file with data like EEPROM, FLASH, FUSE SETTINGS and LOCK BITS. But the same ELF file, if it is generated through compiler then it contains debugging with source code property along with all we mentioned before. The generated ELF file can be specified as input to the programming dialog so that all contents of the file is programmed in one operation.

Opening up an ELF file I have for an ATtiny85 project it is a total of 386 kB in size and does contain debugging information including the full symbol table and location of all the source code files, but that is skipped during device programming.

There are a number of ELF file viewers available and if you install one and examine the file you'll see that while complex in one way they are broken into a number of sections, so it'd be easy for the programming phase to only use the relevant parts to program the device.

\$\endgroup\$
  • \$\begingroup\$ Oh, so AVR Studio does some magic before writing the file. I thought (perhaps naively) that it just dumped the file contents onto the chip. \$\endgroup\$ – David Högberg Nov 1 '13 at 13:49
1
\$\begingroup\$

The flash and EEPROM in an AVR MCU need to be programmed separately. Using the ELF has the advantage of including both pieces in the same file, whereas 2 HEX files are required for the same operation and both would need to be specified separately. Obviously if you aren't using EEMEM then there isn't an awful lot of difference, but it is convenient when you are.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.