AVRStudio 4.12.460 WinAVR EEPROM section bug

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to understand EEPROM handling in WinAVR so I built a simple project using suggestion by lfmorrision in another thread.

I set the project settings for ATmega32 with 8 MHz oscillator and a memory section in EEPROM starting at address 0x001 named Osccal_Vars. I debugged it using JTAGICE mkII and everything worked.

When I went to program the .HEX file, I got a won't fit into device error message. Looked at the .HEX file and it had an extended linear address record type in it. This was for Osccal_Vars section.

I exported the makefile and had to add

HEX_FLASH_FLAGS += -R Osccal_Vars

to it so avr-objcopy will also exclude Osccal_Vars when building the .HEX file.

FYI, if I add

HEX_EEPROM_FLAGS += -j Osccal_Vars

it will add Osccal_Vars to the .EEP file. This isn't what I want to do but I thought I would mention it.

Below is my code if it matters.


int main (void);

// Allocate all your EEPROM variables
// as members of one single structure. 
// This way, the linker won't make 
// silly decisions about re-arranging
// the locations of the variables. 
typedef struct Osccal_Vars_t
	uint8_t uc1MHzOsccal; 
	uint8_t uc2MHzOsccal; 
	uint8_t uc4MHzOsccal; 
	uint8_t uc8MHzOsccal; 

// Osccal_Vars is in EEPROM starting at
// address 0x001.  This was defined in
// the Memory Settings section of
// Configuration Options.  The first
// four bytes are programmed by STK500
// tool.
OSCCAL_VARS OscalVars __attribute__((section("Osccal_Vars")));

int main (void)
	OSCCAL = eeprom_read_byte (&OscalVars.uc8MHzOsccal);

	DDRB = 0xFF;		// set to all outputs
	PORTB = ~OSCCAL;	// LED on indicate bit set

	while (1)

	return (0);

Here is the .HEX file with the extended linear address record (third line from the bottom) in it: