3.2.7.7.1 Creating ELF Files for tinyAVR®, megaAVR®, and XMEGA® Devices
This code shows how to add memory sections for tinyAVR, megaAVR, and XMEGA devices (except ATtiny4/5/9/10). This example is for an ATxmega128A1 device. For other devices, it has to be modified accordingly.
#include <avr/io.h> // Example data for ATxmega128A1 const char eeprdata[] __attribute__ ((section (".eeprom"))) = "Hello EEPROM"; // The order of the fuse values is from low to high. 0xA2 is written to Fuse byte 0, 0x00 to byte 1... const uint8_t fusedata[] __attribute__ ((section (".fuse"))) = {0xA2, 0x00, 0xFF, 0xFF, 0xFF, 0xF5}; const uint8_t lockbits[] __attribute__ ((section (".lockbits"))) = {0xFC}; const char userdata[] __attribute__ ((section (".user_signatures"))) = "Hello User Signatures"; // Remember to set the following Toolchain project options, // under AVR/GNU -> Miscellaneous: // // -Wl,--section-start,.user_signatures=0x00850000 int main(void) { while(1) { // TODO:: Please write your application code } }
Linker Setup for the User Signature Section
The User Signatures section must have a specific Linker Setup, as shown below. This Linker Setup is necessary to get the correct address offset for the User Signature section in the elf file. Other memory sections get the correct address automatically.