Atmel Studio ELF production Files for AVR

Atmel have added a new feature to Atmel Studio from 6.2 on-wards including 7. You can now create a single file that contains all the data needed to program an AVR or ATxmega microcontroller. This includes flash, EEPROM, fuses, lock bits and ATxmega User Row. This is called an ELF production file and Kanda AVR Handheld Programmers now support this format.

Microchip PIC MPLAB has always been able to create one file that contains all the data needed by a device programmer but AVRStudio has not had this ability until now. It has finally arrived but you have to do all the work to add the data needed.

Adding Data to Your Project
You can do this in code with a C project or use the programmer dialog.

Code Example for ATxmega
Here is a code example that defines the different memory sections for ATxmega.

#include <avr/io.h>

// Example data for ATxmega128A1

const char eeprdata[] __attribute__ ((section (“.eeprom”))) =

“Hello EEPROM”;

const char fusedata[] __attribute__ ((section (“.fuse”))) =

{0xA2, 0x00, 0xFF, 0xFF, 0xFF, 0xF5};

const char lockbits[] __attribute__ ((section (“.lockbits”))) =


const char userdata[] __attribute__ ((section (“.user_signatures”))) =

“Hello User Signatures”;

AVR C Code Example

#include <avr/io.h>
#include <avr/eeprom.h>

int EEMEM test = 12345;
char text[] EEMEM = "Hello World";
	.extended = 0xF8,
	.high = 0xDD,
	.low  = 0xFD
  LOCKBITS = (0xFC);

Make sure your AVR device has all these fuses. For example, ATmega16 does not have extended fuse and you will get a compiler error if you include it. If you don’t want to use Hex values, you can use fuse names to make it clearer like this.

   .low  = FUSE_CKSEL1,

To see all the fuse defines in Atmel Studio, right click on HFUSE_DEFAULT and select Goto Implementation. All the fuse bits are defined in the correct version of io.h, eg “iom16.h” for ATmega16, which Studio selects from project device setting. The EEMEM define will create EEPROM data that will be used to create an EEP file but it will also be added to the ELF file. EEMEM is just a define of a section, __attribute__((section(“.eeprom”))), in eeprom.h.

The linker will automatically create an ELF file with this data in it, except you need to configure the linker to know where to put the User Signatures on an ATxmega. It already knows where to put EEPROM, fuses and lock bits.

Choose Project -> Project Properties and in Properties Dialog select Toolchain.

Linker Set UP for User Row

Select Miscellaneous and add this flag:


When you build the project an ELF file is automatically created in the Debug folder, along with separate Hex files for flash and EEPROM. Studio doesn’t create a separate user signature file though.

Create ELF file from Programmer/Debug Tool

You can also create an ELF file in programming or debug tools like AVRISP-MKII, Simulator or Dragon. Select Device Programmer from Tools menu and select your tool, click apply. Choose Production File from the left pane:

Create ELF production File in Device Programmer

Set the fuses and lock bits first on the Fuse screen and Lock Bits screen. You will need to click Program button after you have changed them before the new values are saved. Select your code hex file and EEPROM file (in Project -> Debug folder). Then save the ELF file.

Using ELF File

The ELF file is a debug file but there is a tool to produce a hex file output from it, avr-objcopy.exe, which is part of AVRStudio install. The resulting hex file looks like this


The code is at the top, followed by extended address markers (04 record type) that define the EEPROM at address 0x810000 (:02000004008179), Fuses at 0x820000 (:02000004008278), Lockbits at 0x830000 (:02000004008377), Device ID (stored backwards!) at 0x840000 (:02000004008476) and user row at 0x850000 (:02000004008575). These addresses are well beyond the size of the biggest AVR microcontroller and won’t clash with flash code.

If you want to know more about Intel Hex file format, see Intel Hex Files Explained Post

Kanda Handheld programmers for ATxmega and AVR can now load ELF files, which makes it easier to send files to production.


Now that Microchip own Atmel, they have been adding AVR support to MPLAB X. This will generate hex files that include the same extra data as Atmel Studio ELF files but in hex file format.

To add Fuse data to your AVR project in MPLAB X,  go to Window -> Target Memory Views -> Configuration Bits and fuse values can be set.

ELF file loaders, like in Kanda handheld programmers, will deal with these new type of AVR hex files as if they were ELF files.

Leave a Reply