Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
181 andfri 1
PRG            = bios
250 andfri 2
OBJ            = vectors.o bios.o flash.o mcp2515/mcp2515.o
284 arune 3
MCU_TARGET     = atmega88
181 andfri 4
OPTIMIZE       = -Os -mcall-prologues
284 arune 5
BIOS_START     = 0xd00
283 andfri 6
BOOT_START     = 0x1e00
181 andfri 7
 
228 andfri 8
DEFS           =
181 andfri 9
LIBS           =
10
 
284 arune 11
TARGET_CLK_SRC = 0xe2
237 arune 12
#TARGET_CLK_SRC for mega88		
13
#0xe7		#CKDIV8=1, external crystal
14
#0xe0		#CKDIV8=1, external clock
15
#0xe2		#CKDIV8=1, internal RC
16
#TARGET_CLK_SRC for mega8
17
#0x24		#BODLEVEL = 4.0V, BODEN=enabled, internal 8MHz
18
#0x20		#BODLEVEL = 4.0V, BODEN=enabled, external clock
234 arune 19
 
284 arune 20
#uncomment this line for programming fuses 
21
#PRGFUSES 	= ok
22
 
237 arune 23
#
181 andfri 24
# You should not have to change anything below here.
237 arune 25
#
181 andfri 26
 
27
CC             = avr-gcc
28
 
29
# Override is only needed by avr-lib build system.
30
 
31
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
228 andfri 32
override LDFLAGS       = -Wl,-Map,$(PRG).map,--defsym,__bios_start=$(BIOS_START),--defsym,__boot_start=$(BOOT_START),-T$(MCU_TARGET)_bios.ld,--cref
33
override ASFLAGS       = -x assembler-with-cpp -Wa,-gstabs -mmcu=$(MCU_TARGET) $(DEFS)
181 andfri 34
 
35
OBJCOPY        = avr-objcopy
36
OBJDUMP        = avr-objdump
37
SIZE           = avr-size
38
SZFLAGS        = 
230 arune 39
UPLOAD         = avrdude
242 arune 40
#avrispv2 avr910
284 arune 41
ULFLAGS        = -p $(MCU_TARGET) -P /dev/ttyUSB0 -c avrispv2 -b 115200 -U flash:w:$(PRG).hex
181 andfri 42
 
237 arune 43
ifeq ($(MCU_TARGET),atmega88)
284 arune 44
#BOOTRST=0, BOOTSZ0=0, BOOTSZ1=1
45
EXTFUSE  = 0x04
237 arune 46
#BODLEVEL = 4.3V
47
HIGHFUSE = 0xdc
48
LOWFUSE  = $(TARGET_CLK_SRC)
49
endif
230 arune 50
 
237 arune 51
ifeq ($(MCU_TARGET),atmega8)
284 arune 52
#BOOTRST=0, BOOTSZ0=0, BOOTSZ1=1
53
HIGHFUSE = 0xd4
237 arune 54
LOWFUSE  = $(TARGET_CLK_SRC)
55
endif
56
 
57
AVRDUDE_WRITE_FUSEBITS = -u
58
ifdef EXTFUSE
59
AVRDUDE_WRITE_FUSEBITS += -U efuse:w:$(EXTFUSE):m
60
endif
61
ifdef HIGHFUSE
62
AVRDUDE_WRITE_FUSEBITS += -U hfuse:w:$(HIGHFUSE):m
63
endif
64
ifdef LOWFUSE
65
AVRDUDE_WRITE_FUSEBITS += -U lfuse:w:$(LOWFUSE):m
66
endif
67
 
68
#comment this line for not programming fusebits
284 arune 69
ifdef PRGFUSES
70
ULFLAGS      += $(AVRDUDE_WRITE_FUSEBITS)
71
endif
237 arune 72
 
181 andfri 73
default: $(PRG).elf lst
74
	@$(SIZE) $(SZFLAGS) $(PRG).elf
75
 
76
all: $(PRG).elf lst text eeprom
77
 
78
$(PRG).elf: $(OBJ)
79
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
80
 
81
clean:
242 arune 82
	rm -f $(OBJ) $(PRG).elf *.eps *.png *.pdf *.bak 
83
	rm -f *.lst *.map $(EXTRA_CLEAN_FILES)
181 andfri 84
 
85
lst:  $(PRG).lst
86
 
87
%.lst: %.elf
88
	$(OBJDUMP) -h -S $< > $@
89
 
90
# Rules for building the .text rom images
91
 
92
text: hex bin srec
93
 
94
hex:  $(PRG).hex
95
bin:  $(PRG).bin
96
srec: $(PRG).srec
97
 
98
%.hex: %.elf
228 andfri 99
	$(OBJCOPY) -j .text -j .data -j .bootloader -O ihex $< $@
181 andfri 100
 
101
%.srec: %.elf
228 andfri 102
	$(OBJCOPY) -j .text -j .data -j .bootloader -O srec $< $@
181 andfri 103
 
104
%.bin: %.elf
228 andfri 105
	$(OBJCOPY) -j .text -j .data -j .bootloader -O binary $< $@
181 andfri 106
 
107
# Rules for uploading rom images to flash
108
 
109
install: hex
110
	$(UPLOAD) $(ULFLAGS)
111
 
112
# Rules for building the .eeprom rom images
113
 
114
eeprom: ehex ebin esrec
115
 
116
ehex:  $(PRG)_eeprom.hex
117
ebin:  $(PRG)_eeprom.bin
118
esrec: $(PRG)_eeprom.srec
119
 
120
%_eeprom.hex: %.elf
121
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
122
 
123
%_eeprom.srec: %.elf
124
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
125
 
126
%_eeprom.bin: %.elf
127
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
128
 
129
# Every thing below here is used by avr-libc's build system and can be ignored
130
# by the casual user.
131
 
132
FIG2DEV                 = fig2dev
133
EXTRA_CLEAN_FILES       = *.hex *.bin *.srec
134
 
135
dox: eps png pdf
136
 
137
eps: $(PRG).eps
138
png: $(PRG).png
139
pdf: $(PRG).pdf
140
 
141
%.eps: %.fig
142
	$(FIG2DEV) -L eps $< $@
143
 
144
%.pdf: %.fig
145
	$(FIG2DEV) -L pdf $< $@
146
 
147
%.png: %.fig
148
	$(FIG2DEV) -L png $< $@
149