Subversion Repositories HomeAutomation

Rev

Rev 237 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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