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