AVRStudio 4.12.460 WinAVR EEPROM section bug

1 post / 0 new
Author
Message
#1
  • 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.

#include 
#include 

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; 

// 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:

:100000000C942A000C9445000C9445000C94450077
:100010000C9445000C9445000C9445000C9445004C
:100020000C9445000C9445000C9445000C9445003C
:100030000C9445000C9445000C9445000C9445002C
:100040000C9445000C9445000C9445000C9445001C
:100050000C94450011241FBECFE5D8E0DEBFCDBF14
:1000600010E0A0E6B0E0ECEBF0E002C005900D92ED
:10007000A036B107D9F710E0A0E6B0E001C01D92AC
:10008000A036B107E1F70C9447000C940000CFE5CF
:10009000D8E0DEBFCDBF84E090E00E94560081BF73
:1000A0008FEF87BB81B7809588BBFFCFE199FECFEB
:0C00B0009FBB8EBBE09A99278DB308958A
:02000004008179
:0400010000000000FB
:00000001FF