Splitting EEPROM into two sections + AVR Studio 4

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

I am struggling a bit with creating two EEPROM sections.

Firstly, I would like to do this so that there is a set structure at the start of EEPROM on every device I program. This can be reached by the standard program, or the bootloader.

I have created a section eestart which has the address 0x810000 and I have moved eeprom to address 0x810020

I have adjusted my makefile to include the following:


...

COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eestart-0x810000 \
--change-section-address .eeprom-0x810020 

...

# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
	@echo
	@echo $(MSG_FLASH) $@
	$(OBJCOPY) -O $(FORMAT) -R .eeprom -R .eestart $< $@

%.eep: %.elf
	@echo
	@echo $(MSG_EEPROM) $@
	-$(OBJCOPY) -j .eeprom -j .eestart --set-section-flags=.eeprom="alloc,load" \
	--set-section-flags=.eestart="alloc,load" \
	--change-section-lma .eestart=0 \
	--change-section-lma .eeprom=0x000020 -O $(FORMAT) $< $@

...

Now in the code, I have the following setup...

 /* Structure Definitions */
 struct __eep{
	unsigned long serial_no;
	unsigned int  product_code;
	unsigned char software_version;
	unsigned char hardware_version;
	unsigned char product_name[17];
 };
 
struct __eep data __attribute__((section(".eestart"))) =
{
	0x01234567,
	0x0123,
	0x01,
	0x01,
    "AAA BBBBBB CCCCC"
};

struct __eep *prod_inf __attribute__((section(".eestart"))) = &data;
 /* End Structure Definitions */
 
 /* External Global Variables */
extern unsigned char start_of_eeprom __attribute__((section(".eeprom")));

Now, when I read prom.elf into AVR studio, both sections seem to start at 0x810000 still, thus they overwrite each other. I also have a lot of garbage appear in the eeprom dataspace, but I think that's an entirely different problem/bug with AVR Studio.

If I read the output of the linker script, prom.eep, I get virtually what I'm after, the start_of_eeprom variable is initialised and I can see it's character at 0x0020(eeprom memory offset). The rest of the eestart structure seems to start at 0x0002(eeprom memory offset) for some reason, which I have yet to find the answer too. But the main structure is there, and correct....

Any ideas of how I can sort this problem out, or point me to where I need to be looking? Perhaps it's something I cannot mess around with because AVR Studio must import the .eeprom section starting at 0x810000?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have changed the section names to let .eeprom sit at 0x810000 and I have created .eesafe at 0x810020

or at least that's what I thought I had done. But in prom.elf it seems to have given .eesafe an address of 0x80014C (The same as .noinit)

So it looks like all I have to do is find out why the .eesafe section won't reside where I want it too... :(