I am trying to embed code in my Attiny4 project that will set fuses and lock bits(In AtmelStudio 7). I copy/pasted the code that Atmel suggests here:
#include <avr/io.h>
typedef struct _tagConfig
{
unsigned char f1;
} Config;
typedef struct _tagLock
{
unsigned char f1;
} Lock;
typedef struct _tagSig
{
unsigned char f1;
unsigned char f2;
unsigned char f3;
} Signature;
Config __config __attribute__((section(".config"))) =
{
f1 : 0xfb, // Set CKOUT
};
Lock __lock __attribute__((section(".lock"))) =
{
f1 : 0xfc, // Further programming and verification disabled
};
Signature __sig __attribute__((section(".signature"))) =
{
f1 : 0x03,
f2 : 0x90,
f3 : 0x1e,
};
Then i try to compile and it directly fails with the following errors:
attiny4-fan.elf section `.config' will not fit in region `config'
region `config' overflowed by 1 bytes
ld returned 1 exit status
recipe for target 'attiny4-fan.elf' failed
I can't seem to find any other information on how to do this for an ATTiny4/5/9/10. The Datasheet seems to mention something about the locations but since i have never done this before, especially not for the Attiny4 i'm playing with here, i have no idea on how to proceed.
This is the output of
avr-objdump --section-headers
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000000c8 00000000 00000000 00000074 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00800040 00800040 0000013c 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000003 00800040 00800040 0000013c 2**0
ALLOC
3 .comment 00000030 00000000 00000000 0000013c 2**0
CONTENTS, READONLY
4 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 0000016c 2**2
CONTENTS, READONLY
5 .debug_info 000002ab 00000000 00000000 000001a8 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_abbrev 00000284 00000000 00000000 00000453 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_line 000000d3 00000000 00000000 000006d7 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_str 000000f6 00000000 00000000 000007aa 2**0
CONTENTS, READONLY, DEBUGGING
In the mean time, i also found out that in the ATtiny DFP header file for the Attiny4/5/9/10, the following macros are defined(ATtiny9 as example):
/* Fuses */
#define FUSE_MEMORY_SIZE 0
/* Lock Bits */
#define __LOCK_BITS_EXIST
/* Signature */
#define SIGNATURE_0 0x1E
#define SIGNATURE_1 0x90
#define SIGNATURE_2 0x08
Why would FUSE_MEMORY_SIZE be defined as 0?
Can anybody help me to get my ELF to contain fuses and lock bits?
objdump --section-headers
to see if you have any other sections that match.config*
in there? Looking through the linker script, any such sections would be concatenated into the space, which obviously isn't going to work... \$\endgroup\$