allocating variable to --- specific address of EEPROM

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

My code is :---
uint8_t data1 __attribute__((section(".eepromp2"))) = 0x01;

Compilation gives ;--

Code:
avr-gcc -mmcu=atmega32 -Wl,--defsym=__stack=0x800 -Wl,-Map=stepper_motor.map -Wl,-section-start=.eepromp2=0x810010 main.o aaa.o -o stepper_motor.elf

But when i view the momory for EEPROM while debugging it shows 0x01 in the first memory location not at location 0x10..

How can i place it to 0x10 of eeprom ?

const uint8_t sinewave[] __attribute__((section(".mysection1")))= {0x80,0x83,0x86,0x89,0x8c};
Also i want to place this table to specific section of Flash at end of the memmory, suppose address 0x01FF

I am trying for partial writing of EEPROM & FLASH by bootloader.

Please suggest for this.

Please suggest.

Attachment(s): 

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

Ok. The above gobbledygook is specific to the avr-gcc compiler.

The important question is "Why do you want to complicate life?"

C will find your variables wherever they are placed in memory. The only time when you actually need to force an address is for an SPM function to live in the bootloader section.

A bootloader will typically load your application and run it. The application knows where its own Sinewave tables live.

If you put the Compiler and Linker into a straitjacket you just end up with inefficient and possibly fatal code. Yes. It can be done. I advise against it.

David.

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

but i want to work with embedded c, which alow for segmented i/o spaces. please suggest I just want to try.

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

As I said to you in PM - WHY do you think you need to position an EEPROM variable at a specific address? Why not just put it in EEMEM and let the linker position it.

Quote:

But when i view the momory for EEPROM while debugging it shows 0x01 in the first memory location not at location 0x10..

How could it even have 0x01? Your private section, unlike .eeprom from EEMEM, will not have rules to generate a .eep that could have been pre-programmed to initialise it.

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

Quote:
How could it even have 0x01? Your private section, unlike .eeprom from EEMEM, will not have rules to generate a .eep that could have been pre-programmed to initialise it.

It is having 0x01 because i am initialising eeprom variable with value 0x01 & also in the above .png file you can see that i have created an segment with name .eeprom2 of type EEPROM at address 0x10 which will be passed to the linker at command line.

avr-gcc -mmcu=atmega32 -Wl,--defsym=__stack=0x800 -Wl,-Map=stepper_motor.map -Wl,-section-start=.eepromp2=0x810010 main.o aaa.o -o stepper_motor.elf 

My code is :---
uint8_t data1 __attribute__((section(".eepromp2"))) = 0x01;

Quote:
A bootloader will typically load your application and run it. The application knows where its own Sinewave tables live.

As I said to you in PM - WHY do you think you need to position an EEPROM variable at a specific address? Why not just put it in EEMEM and let the linker position it.


Actually one of my friend is in Automotive industry, they use to make ECU body control unit. It use to contain the CAR-CONFIGURATION PARAMETERS which is an constant values like car is fitted with AC or not, Is it two door car or 4 door , is it right hand drive or left hand, is it automatic or manual AC , what is the model of car ....... like this there are about 252 parameters or simply we can say block of 252 bytes are there which use to decide which part of the software is active under which configuartion value. This array of 252 byte is at an constant fixed location in the PROM.

So suppose if the value of carconfiguration parameter stored at 200 location of array is.
AC_IN_CAR = 0x01(with manual AC) or (0x02 with automatic AC)

so software is like ;---

if( AC_IN_CAR == 0x01)
{
/* Do this*/
}
else if ( AC_IN_CAR == 0x02)
{
/* Do this*/
}

So under this condition to test the software for diffrent value of car configuration they are doing the partial flashing of the carconfiguration. While other s/w they are not flashing.

Change the car-config & flash it to test the s/w. This is done by bootloader which is capable of flashing at particular address when that request comes. Mostly they change one or two parameter at there requirement & then flash whole 252 bytes.

This partial flashing is very helpful at end-of-line-testing just saves time.

So i just want to try the partial flashing of the memory to make same condition for both EEPROM & PROM as above & check if it works or not. For this i need to place my array at some predefined location in flash & EEPROM. Then i can make my bootloader as per my request.

Please suggest how to put variable at predefined address in PROM & EEPROM ?

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

Rather than hard coding the addresses, why not put pointers to the data in the first few locations of eeprom? The bootloader can read these locations and find the required data with no need to force the hand of the compiler or linker.

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

Quote:
Rather than hard coding the addresses, why not put pointers to the data in the first few locations of eeprom?
This will waste 1 byte in EEPROM & also these kind of request to keep the array of 252 byte at some fixed address use to come from the OEM. And his case it is FORD & they use to ask for some fixed memmory for this ARRAY but they are using HC12 controller in there case.

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

I'm still not getting it - nothing outside of the AVR can know/see it's EEPROM layout?

Anyway this works (see photo):

#include 
#include 

uint8_t my_ee_var __attribute__((section(".myee")));

int main(void) 
{ 
	eeprom_write_byte(&my_ee_var, 0x55);
	while(1);
}// end main 
avr-gcc  -mmcu=atmega328p -Wall -std=gnu99 --save-temps -fverbose-asm -gdwarf-2 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT test.o -MF dep/test.o.d  -c  ../test.c

avr-gcc -mmcu=atmega328p -Wl,-Map=test.map -Wl,-section-start=.myee=0x810010 test.o    -lm  -o test.elf

Attachment(s): 

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

uint8_t my_ee_var __attribute__((section(".myee"))) = 0x95; 

int main(void) 
{ 
   
   DDRD = eeprom_read_byte(&my_ee_var);
  DDRB = DDRA;
   while(1); 
}// end main 

But why if i initialise the variable at starting does not reflect the value.

I am using the avr simulator :--
Winavr 2009, Avrstudio-4

Attachment(s): 

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

It appears that if I build the code with AVR Studio (to which I've added the .myee section) it uses:

avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings --change-section-lma .myee=0x810010 -O ihex test.elf test.eep || exit 0

Although it's smart enough to have added a --change-section-lma for .myee it (a) appears to have forgotten that its 0x810000 relative addressing so the LMA should be 0x10 not 0x810010 and (b) it doesn't have a -j for .myee anyway.

This is why your initialisers are not in the .eep file.

For an easy life just do run time initialisation.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Build started 29.11.2010 at 17:53:35
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT EEPROM.o -MF dep/EEPROM.o.d  -c  ../EEPROM.c


avr-gcc -mmcu=atmega32 -Wl,--defsym=__stack=0x800  -Wl,-Map=EEPROM.map -Wl,-section-start=.myee=0x810010 EEPROM.o     -o EEPROM.elf


avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  EEPROM.elf EEPROM.hex


avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings --change-section-lma .myee=0x10 -O ihex EEPROM.elf EEPROM.eep || exit 0
avr-objdump -h -S EEPROM.elf > EEPROM.lss

This is compilation result for me. What is lacking please suggest :?:

Quote:
For an easy life just do run time initialisation.
But this is not the solution

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

I leave you to work it out. The clues are there.

(hint: you aren't going to be able to do this using Studio's Makefile so you'll need to export it and modify it)

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

I have created an section at location 0x10 in EEPROM & placed an variable my_ee_var at that location. Compilation is giving right output
1> -j option added
2> .myeprom located at section 0x10

Quote:
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings --change-section-lma .myeprom=0x10 -O ihex stepper_motor.elf stepper_motor.eep || exit 0

When i write to this memory location it works. Value 0x55 is written to location 0x10 in EEPROM

#include  
#include  

volatile uint8_t my_ee_var __attribute__((section(".myee"))) ; 

int main(void) 
{ 
   eeprom_write_byte(&my_ee_var, 0x55); 

   DDRD = eeprom_read_byte(&my_ee_var);
  DDRB = DDRA;
   while(1); 
}// end main 

But when i initialise this variable to an value 0x95 it is not intialised when the programe runs & gives the value 0xFF.

#include  
#include  

volatile uint8_t my_ee_var __attribute__((section(".myee"))) = 0x95; 

int main(void) 
{ 

   DDRD = eeprom_read_byte(&my_ee_var);
  DDRB = DDRA;
   while(1); 
}// end main 

My makefile is :--

###############################################################################
# Makefile for the project EEPROM
###############################################################################

## General Flags
PROJECT = EEPROM
MCU = atmega32
TARGET = EEPROM.elf
CC = avr-gcc

CPP = avr-g++

## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)

## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -std=gnu99  -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 

## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -Wl,--defsym=__stack=0x800 -Wl,-Map=EEPROM.map
LDFLAGS += -Wl,-section-start=.myee=0x810010


## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
HEX_EEPROM_FLAGS += --change-section-lma .myee=0x10


## Objects that must be built in order to link
OBJECTS = EEPROM.o 

## Objects explicitly added by the user
LINKONLYOBJECTS = 

## Build
all: $(TARGET) EEPROM.hex EEPROM.eep EEPROM.lss size

## Compile
EEPROM.o: ../EEPROM.c
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<

##Link
$(TARGET): $(OBJECTS)
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

%.hex: $(TARGET)
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@

%.eep: $(TARGET)
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

%.lss: $(TARGET)
	avr-objdump -h -S $< > $@

size: ${TARGET}
	@echo
	@avr-size -C --mcu=${MCU} ${TARGET}

## Clean target
.PHONY: clean
clean:
	-rm -rf $(OBJECTS) EEPROM.elf dep/* EEPROM.hex EEPROM.eep EEPROM.lss EEPROM.map


## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)

I have experimented & tried changing makefile manually but was not sucessfull. I am not getting what is missing. Please suggest how to initialise the this eeprom variable in segment .myee :?:

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

Assuming you do program (burn) the .eep file into the chip, you need to extract the .myee sections' content from the .elf. For now, you are extracting only the .eeprom section (see -j switch).

JW

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

wek wrote:
Assuming you do program (burn) the .eep file into the chip, you need to extract the .myee sections' content from the .elf. For now, you are extracting only the .eeprom section (see -j switch).

JW

Quote:
HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
HEX_EEPROM_FLAGS += -j --change-section-lma .myee=0x10

I have even tried -j option it did not worked. Even i was not able to get much out of GNU make document. Can you tell which line i have to make changes :?:
http://www.gnu.org/software/make/manual/make.html#Special-Targets

GNU make knows how to execute several recipes at once. Normally, make will execute only one recipe at a time, waiting for it to finish before executing the next. However, the ‘-j’ or ‘--jobs’ option tells make to execute many recipes simultaneously
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings

HEX_FLASH_FLAGS += -R .myee
HEX_EEPROM_FLAGS = -j .myee
HEX_EEPROM_FLAGS += --change-section-lma .myee=0x10

The resulting EEPROM.eep then should be:

:01001000955A
:00000001FF

JW

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

wek wrote:

## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings

HEX_FLASH_FLAGS += -R .myee
HEX_EEPROM_FLAGS = -j .myee
HEX_EEPROM_FLAGS += --change-section-lma .myee=0x10

The resulting EEPROM.eep then should be:

:01001000955A
:00000001FF

JW

I have changed the makefile as per your,s

###############################################################################
# Makefile for the project EEPROM
###############################################################################

## General Flags
PROJECT = EEPROM
MCU = atmega32
TARGET = EEPROM.elf
CC = avr-gcc

CPP = avr-g++

## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)

## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -std=gnu99  -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 

## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -Wl,--defsym=__stack=0x800 -Wl,-Map=EEPROM.map
LDFLAGS += -Wl,-section-start=.myee=0x810010


## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings

HEX_EEPROM_FLAGS += -R .myee
HEX_EEPROM_FLAGS  = -j .myee 
HEX_EEPROM_FLAGS += --change-section-lma .myee=0x10


## Objects that must be built in order to link
OBJECTS = EEPROM.o 

## Objects explicitly added by the user
LINKONLYOBJECTS = 

## Build
all: $(TARGET) EEPROM.hex EEPROM.eep EEPROM.lss size

## Compile
EEPROM.o: ../EEPROM.c
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<

##Link
$(TARGET): $(OBJECTS)
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

%.hex: $(TARGET)
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@

%.eep: $(TARGET)
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

%.lss: $(TARGET)
	avr-objdump -h -S $< > $@

size: ${TARGET}
	@echo
	@avr-size -C --mcu=${MCU} ${TARGET}

## Clean target
.PHONY: clean
clean:
	-rm -rf $(OBJECTS) EEPROM.elf dep/* EEPROM.hex EEPROM.eep EEPROM.lss EEPROM.map


## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)

But i am not getting the variable preloaded into the eeprom my memory map for eeprom is same as yours.

EEPROM.eep file -- how can we decode it.

:01001000955A
:00000001FF

what is lacking in this makefile, so that compiler can load preload variable to EEPROM :?:

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

I can see in .eep file variable at address 0x10 ... value 0x95 ... but why avr studio is not able to load the variable. When using simulator :?:

Attachment(s): 

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

Quote:

but why avr studio is not able to load the variable. When using simulator

But that picture shows exactly what you want - location 0x0010 holds 0x95 ?!?! Where's the problem here?

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

clawson wrote:
Quote:

but why avr studio is not able to load the variable. When using simulator

But that picture shows exactly what you want - location 0x0010 holds 0x95 ?!?! Where's the problem here?
In avr studio programe memory window while simulating i am not able to see it.

But when opening in ponyprog i am able to see it.

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

When you start to debug the project in Studio does it not pop up a window saying "this project contains initialised EEPROM data - should I download it now?". If you aren't seeing that then you can do it manually. The debug menu has a "upload/dowload memory" entry. Use that to read the .eep file and have it downloaded into the EEPROM memory of the simulated/debugged chip.

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

Quote:
When you start to debug the project in Studio does it not pop up a window saying "this project contains initialised EEPROM data - should I download it now?".
No it does not.

Quote:
The debug menu has a "upload/dowload memory" entry. Use that to read the .eep file and have it downloaded into the EEPROM memory of the simulated/debugged chip.
yes it worked. But is it fault with avr-studio :?:

Also when i put one eeprom variable in one segment while i tell compiler to put other variavle in any other location. Then with your methord to load EEPROM file directly only load the value of variable in .myee segment. While value of variable eeprombyte is not there in .eep file when i open it with pony prog.Is it fault with avr-studio :?:

.eep -- eeprom file gives this. How can i decode this info :?:

:01001000955A
:00000001FF
#include  
#include  

volatile uint8_t my_ee_var __attribute__((section(".myee"))) = 0x95; 
//store initial byte to eeprom
uint8_t EEMEM eeprombyte=0x10;

int main(void) 
{ 


   DDRD = eeprom_read_byte((const uint8_t *)&my_ee_var);
   DDRB = eeprom_read_byte((const uint8_t *)&eeprombyte);;
   PORTA = 0x01;


   while(1); 
}// end main

Makefile :

###############################################################################
# Makefile for the project EEPROM
###############################################################################

## General Flags
PROJECT = EEPROM
MCU = atmega32
TARGET = EEPROM.elf
CC = avr-gcc

CPP = avr-g++

## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)

## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -std=gnu99  -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 

## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -Wl,--defsym=__stack=0x800 -Wl,-Map=EEPROM.map
LDFLAGS += -Wl,-section-start=.myee=0x810010


## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings

HEX_EEPROM_FLAGS += -R .myee
HEX_EEPROM_FLAGS  = -j .myee 
HEX_EEPROM_FLAGS += --change-section-lma .myee=0x10


## Objects that must be built in order to link
OBJECTS = EEPROM.o 

## Objects explicitly added by the user
LINKONLYOBJECTS = 

## Build
all: $(TARGET) EEPROM.hex EEPROM.eep EEPROM.lss size

## Compile
EEPROM.o: ../EEPROM.c
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<

##Link
$(TARGET): $(OBJECTS)
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

%.hex: $(TARGET)
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@

%.eep: $(TARGET)
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

%.lss: $(TARGET)
	avr-objdump -h -S $< > $@

size: ${TARGET}
	@echo
	@avr-size -C --mcu=${MCU} ${TARGET}

## Clean target
.PHONY: clean
clean:
	-rm -rf $(OBJECTS) EEPROM.elf dep/* EEPROM.hex EEPROM.eep EEPROM.lss EEPROM.map


## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)

Attachment(s): 

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

din.gulu.er wrote:
Also when i put one eeprom variable in one segment while i tell compiler to put other variavle in any other location. Then with your methord to load EEPROM file directly only load the value of variable in .myee segment. While value of variable eeprombyte is not there in .eep file when i open it with pony prog.Is it fault with avr-studio :?:

HEX_EEPROM_FLAGS  = -j .myee 


The fact that you don't have "+=" but only "=" effectively removes all previous content of the HEX_EEPROM_FLAGS variable - including the line, which would make avr-objcpy output the content of the standard .eeprom section into the .eep file.

You should have a look at how exactly avr-objcpy is invoked in the "bottommost" window in avrstudio.

Quote:

.eep -- eeprom file gives this. How can i decode this info :?:

:01001000955A
:00000001FF

This is an intelhex format - google for this word.

JW

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

Read:

:01001000955A 
:00000001FF 

as

:01 0010 00 95 5A 
:00 0000 01 FF 

The first record has 1 byte of data (01), it's for address 0010, the type of the record is 00 (ie data), the data is 95 and the checksum for the line is 5A.

The second record has no data (00), while the address is irrelevant the field is 0000, the record type is 01 and the checksum is FF

By the way, I STILL don't see your reason for absolute location in EEPROM or why you need to use multiple segments in EEMEM to achieve this. If I wrote:

typdef struct {
  char c;
  char filler1[8];
  char d;
} ee_type;

ee_type my_ee EEMEM = { 'A', {0}, 'B'};

this would set the first byte to 'A' and the tenth byte to 'B' in a single .eep created by the normal mechanism.

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

Quote:
The fact that you don't have "+=" but only "=" effectively removes all previous content of the HEX_EEPROM_FLAGS variable - including the line, which would make avr-objcpy output the content of the standard .eeprom section into the .eep file.
When i changed my makefile as per this it compilation is not at all generating the .eep file. Even now all the eeprom flag are " += " .So this will combine all the EEPROM flags. Have i missed something else :?:

## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings

HEX_EEPROM_FLAGS += -R .myee
HEX_EEPROM_FLAGS  += -j .myee 
HEX_EEPROM_FLAGS += --change-section-lma .myee=0x10

I am getting following compilation result.

avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -R .myee -j .myee  --change-section-lma .myee=0x10 -O ihex EEPROM.elf EEPROM.eep || exit 0
c:\WinAVR-20090313\bin\avr-objcopy.exe: .myee both copied and removed
avr-objdump -h -S EEPROM.elf > EEPROM.lss

AVR Memory Usage
----------------
Device: atmega32

Program:     154 bytes (0.5% Full)
(.text + .data + .bootloader)

Data:          0 bytes (0.0% Full)
(.data + .bss + .noinit)

EEPROM:        1 bytes (0.1% Full)
(.eeprom)


Build succeeded with 0 Warnings...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not exactly core competence for me, but isn't this a clue:

Quote:

c:\WinAVR-20090313\bin\avr-objcopy.exe: .myee both copied and removed 


?

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]