AVR EEPROM

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From Russian to

Threaded View
All,



#include <avr/pgmspace.h>
#include <avr/eeprom.h>

...

unsigned char       eeVar EEMEM = 0x34;   //byte
unsigned int       eeWord EEMEM = 0x5678; //word

const char __attribute__ ((section (".TestSec"))) str1[4] = "9753";

const UCHAR __attribute__ ((section (".platz1"))) val1 = 0x31;
const char __attribute__ ((section (".platz2"))) val2 = 0x52;




# Makefile for the project wms

## General Flags
PROJECT = wms
MCU = atmega128
TARGET = wms.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_CPU11%059200UL -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,-Map=wms.map

## 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

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

## Objects explicitly added by the user
LINKONLYOBJECTS =

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

## Compile
wms.o: ../wms.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: $
 @echo
 @avr-size -C --mcu=$ $

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


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

=====


=== Begin of wms_hex.txt ===
:10025000FC01E199FECF06C0FFBBEEBBE09A3196F0
:100260000DB20D9241505040B8F70895F894FFCF69
:0402700039373533B2
:010274003158
:010275005236
:00000001FF
=== End of wms_hex.txt =====



=== Begin of wms_eep.txt ===
:03000000347856FB
:00000001FF
=== End of wms_eep.txt =====



    Memory Settings

Eeprom .platz2   0x123
Flash  .testSec  0x3456
Eeprom .platz1   0x357



## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS +=  -Wl,-Map=wms.map
LDFLAGS += -Wl,-section-start=.platz2=0x810123
LDFLAGS += -Wl,-section-start=.TestSec=0x68ac
LDFLAGS += -Wl,-section-start=.platz1=0x810357

## 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 .platz2=0x123
HEX_EEPROM_FLAGS += --change-section-lma .platz1=0x357



=== Begin of wmshex1.txt ===
:10025000FC01E199FECF06C0FFBBEEBBE09A3196F0
:100260000DB20D9241505040B8F70895F894FFCF69
:0468AC003937353310
:02000004008179
:010123005289
:010357003174
:00000001FF
=== End of wmshex1.txt =====









Andrey


AVR EEPROM
All,

You wrote to All:

 AA> Flash  .testSec  0x3456





Flash   .TestSec   0x3456





Andrey


AVR EEPROM
Hi Andrey, hope you are having a nice day!


06 Feb 14, Andrey Arnold wrote to All:





 AA> Flash   .TestSec   0x3456











WBR,
    AVB


AVR EEPROM
Hi Andrey, hope you are having a nice day!


05 Feb 14, Andrey Arnold wrote to All:

 AA> HEX_EEPROM_FLAGS = -j .eeprom




 AA>     Memory Settings

 AA> Eeprom .platz2   0x123
 AA> Flash  .testSec  0x3456
 AA> Eeprom .platz1   0x357



[skip]

 AA> HEX_EEPROM_FLAGS = -j .eeprom
 AA> HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
 AA> HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
 AA> HEX_EEPROM_FLAGS += --change-section-lma .platz2=0x123
 AA> HEX_EEPROM_FLAGS += --change-section-lma .platz1=0x357

 -j sectionname
       --only-section=sectionname
           Copy only the named section from the input file to the output file.  
This option may be given
           more than once.  Note that using this option inappropriately may
make the output file unusable.









WBR,
    AVB


AVR EEPROM
Alexey,

You wrote to Andrey Arnold:

 AB> 05 Feb 14, Andrey Arnold wrote to All:
 AA>> HEX_EEPROM_FLAGS = -j .eeprom


 AA>>     Memory Settings

 AA>> Eeprom .platz2   0x123
 AA>> Flash  .testSec  0x3456
 AA>> Eeprom .platz1   0x357
 AB>

 AB> [skip]
 AA>> HEX_EEPROM_FLAGS = -j .eeprom
 AA>> HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
 AA>> HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0
 AA>> --no-change-warnings HEX_EEPROM_FLAGS += --change-section-lma
 AA>> .platz2=0x123 HEX_EEPROM_FLAGS += --change-section-lma
 AA>> .platz1=0x357
 AB>  -j sectionname
 AB>        --only-section=sectionname
 AB>            Copy only the named section from the input file to the
 AB> output file.  This option may be given
 AB>            more than once.  Note that using this option
 AB> inappropriately may make the output file unusable.
 AB>
















Andrey


AVR EEPROM
Hi Andrey, hope you are having a nice day!


06 Feb 14, Andrey Arnold wrote to Alexey V Bugrov:























WBR,
    AVB


AVR EEPROM


07 Feb 14 02:50, you wrote to Andrey Arnold:

















AVR EEPROM
Eugene,

You wrote to Alexey V Bugrov:





































Andrey


AVR EEPROM


07 Feb 14 20:31, you wrote to me:





















AVR EEPROM
Eugene,

You wrote to Andrey Arnold:





































Andrey


AVR EEPROM


08 Feb 14 11:41, you wrote to me:





















"make release".






FUSES = {
  (LFUSE_DEFAULT
#if !UseCkDiv8
    | uint8_t (~FUSE_CKDIV8)
#endif
  ),
  (HFUSE_DEFAULT
  )
};



MCU = attiny13
DUDE_MCU = -pt13
DUDE_PROG = -cusbtiny
#DUDE_PROG = -cstk500 -Pcom23

TARGET = main

FUSE_MEMORY_SIZE = 2

ifdef FUSE_MEMORY_SIZE

CMD_FUSE = -U fuse:w:lfuse.hex:a
CMD_LFUSE = -U lfuse:w:lfuse.hex:a
CMD_HFUSE = -U hfuse:w:hfuse.hex:a
CMD_EFUSE = -U efuse:w:efuse.hex:a

ifeq "$(FUSE_MEMORY_SIZE)" "1"

CMD_FUSES = -u $(CMD_FUSE)
FUSE_FILES = lfuse.hex

endif

ifeq "$(FUSE_MEMORY_SIZE)" "2"

CMD_FUSES = -u $(CMD_LFUSE) $(CMD_HFUSE)
FUSE_FILES = lfuse.hex hfuse.hex

endif

ifeq "$(FUSE_MEMORY_SIZE)" "3"

CMD_FUSES = -u $(CMD_LFUSE) $(CMD_HFUSE) $(CMD_EFUSE)
FUSE_FILES = lfuse.hex hfuse.hex efuse.hex

endif

endif



lfuse.hex: fuses.hex
    srec_cat fuses.hex -Intel -crop 0x820000 0x820001 -offset -0x820000 -O
lfuse.hex -Intel

hfuse.hex: fuses.hex
    srec_cat fuses.hex -Intel -crop 0x820001 0x820002 -offset -0x820001 -O
hfuse.hex -Intel

efuse.hex: fuses.hex
    srec_cat fuses.hex -Intel -crop 0x820002 0x820003 -offset -0x820002 -O
efuse.hex -Intel


DEF_GCC_FLAGS = -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct
-fshort-enums -Wall -mmcu=$(MCU) -std=gnu++0x

.cpp.o:
    avr-gcc $(DEF_GCC_FLAGS) -c -Wa,-adhlns=main.lst $< -o $@

$(TARGET).elf: main.o
    avr-gcc $(DEF_GCC_FLAGS) -Wa,-adhlns=main.o main.o --output $(TARGET).elf
-Wl,-Map=$(TARGET).map,--cref

$(TARGET).hex: $(TARGET).elf
    avr-objcopy -j .fuse -O ihex $(TARGET).elf fuses.hex
    avr-objcopy -R .fuse -O ihex $(TARGET).elf
    avr-objcopy -O ihex -R .eeprom $(TARGET).elf $(TARGET).hex

all: $(TARGET).hex $(FUSE_FILES)

program: all
    avrdude $(DUDE_PROG) $(DUDE_MCU) -U flash:w:$(TARGET).hex:a $(CMD_FUSES)

clean:
    rm -f $(TARGET). .hex












AVR EEPROM





EM> .cpp.o:
EM>     avr-gcc $(DEF_GCC_FLAGS) -c -Wa,-adhlns=main.lst $< -o $@

EM> $(TARGET).elf: main.o

[...]








icq:240059686, lj-user:nicka_startcev


AVR EEPROM
Eugene,

You wrote to Andrey Arnold:






















=== Begin of wr_L2M2.bat ===
@echo off

cd Prog
call Progr.bat ../../src_Output L2M2.hex
=== End of wr_L2M2.bat =====










=== Begin of progr.bat ===
@echo off

SET HEXFILE=%1/%2

@echo -----------------------------------------------------------
@echo Start Programming AVR with file: %2
@echo -----------------------------------------------------------
@echo .
@echo Deleting flash...
@avreal32 +MEGA128 -p1 -as -o800 -%% -e > output.txt
@if errorlevel 1 goto ERROR
@echo done.
@echo .
@echo Writing Fuses...
@avreal32 +MEGA128 -p1 -as -o800 -%%
-fBLEV=1,BODEN=1,SUT=0,CKSEL=0,BLB1=3,BLB0=3,OCDEN=0,JTAGEN=0,CKOPT=1,EESV=1,BS
IZ=0,BRST=1,M103C=1,WDTON=1, -w > output.txt
@if errorlevel 1 goto ERROR
@echo done.







@echo .
@echo Programming...
@avreal32 +MEGA128 -p1 -as -o6800 -%% -w -c %HEXFILE% > output.txt
@if errorlevel 1 goto ERROR
@echo done.
@echo .
@echo Verifing...
@avreal32 +MEGA128 -p1 -as -o6800 -%% -v -c %HEXFILE% > output.txt
@if errorlevel 1 goto ERROR
@echo done.
@echo .


REM SET EPPFILE=%1/%3

REM cd Prog
REM call Programme.bat ../CC_CPU_V4_Output CC_CPU_V4.hex CC_CPU_V4.eep


@echo -----------------------------------------------------------
@echo Device successfully programmed!
@echo -----------------------------------------------------------
@GOTO END

:ERROR

@echo .
@echo -----------------------------------------------------------
@echo AN ERROR OCCURED DURING PROGRAMMING !!!!!
@echo .
@type output.txt
@GOTO END2

:END
@del output.txt

:END2
pause

=== End of progr.bat =====


 EM>











 EM>


 EM>














Andrey


AVR EEPROM























icq:240059686, lj-user:nicka_startcev


AVR EEPROM
Hello Nickita!

08 Feb 14 00:09, Nickita A Startcev wrote to Eugene Muzychenko:


















Sergei


AVR EEPROM


08 Feb 14 12:20, you wrote to Nickita A Startcev:











AVR EEPROM
Hello Eugene!

08 Feb 14 11:17, Eugene Muzychenko wrote to Sergei Podstrigailo:

















Sergei


AVR EEPROM
Hi Eugene, hope you are having a nice day!


07 Feb 14, Eugene Muzychenko wrote to Alexey V Bugrov:





















WBR,
    AVB


AVR EEPROM


08 Feb 14 01:28, you wrote to me:


























AVR EEPROM
Hi Eugene, hope you are having a nice day!


08 Feb 14, Eugene Muzychenko wrote to Alexey V Bugrov:













































WBR,
    AVB


Site Timeline