Subversion Repositories HomeAutomation

Rev

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

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