Subversion Repositories HomeAutomation

Rev

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

Rev 229 Rev 231
1
PRG            = main
1
PRG            = main
2
OBJ            = main.o
2
OBJ            = main.o
3
MCU_TARGET     = atmega88
3
MCU_TARGET     = atmega8
4
OPTIMIZE       = -Os -mcall-prologues
4
OPTIMIZE       = -Os -mcall-prologues
5
# grep bios.map for __bios_ram_end to retreive this value
5
# grep bios.map for __bios_ram_end to retreive this value
6
BIOS_RAM_END   = 0x008000bd
6
BIOS_RAM_END   = 0x008000bd
7
# In the future, this should be automatically inserted into *_app.ld at every bios compilation
7
# In the future, this should be automatically inserted into *_app.ld at every bios compilation
8
 
8
 
9
DEFS           = -I../AVR-Bios
9
DEFS           = -I../AVR-Bios
10
LIBS           =
10
LIBS           =
11
 
11
 
12
# You should not have to change anything below here.
12
# You should not have to change anything below here.
13
 
13
 
14
CC             = avr-gcc
14
CC             = avr-gcc
15
 
15
 
16
# Override is only needed by avr-lib build system.
16
# Override is only needed by avr-lib build system.
17
 
17
 
18
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
18
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
19
override LDFLAGS       = -v -Wl,-Map,$(PRG).map,-L../AVR-Bios,--defsym,__bios_ram_end=$(BIOS_RAM_END),-T$(MCU_TARGET)_app.ld
19
override LDFLAGS       = -v -Wl,-Map,$(PRG).map,-L../AVR-Bios,--defsym,__bios_ram_end=$(BIOS_RAM_END),-T$(MCU_TARGET)_app.ld
20
override ASFLAGS       = -x assembler-with-cpp -Wa,-gstabs -mmcu=$(MCU_TARGET) $(DEFS)
20
override ASFLAGS       = -x assembler-with-cpp -Wa,-gstabs -mmcu=$(MCU_TARGET) $(DEFS)
21
 
21
 
22
OBJCOPY        = avr-objcopy
22
OBJCOPY        = avr-objcopy
23
OBJDUMP        = avr-objdump
23
OBJDUMP        = avr-objdump
24
SIZE           = avr-size
24
SIZE           = avr-size
25
SZFLAGS        = 
25
SZFLAGS        = 
26
UPLOAD         = uisp
26
UPLOAD         = avrdude
27
ULFLAGS        = -dpart=$(MCU_TARGET) -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 --upload --verify if=$(PRG).hex
27
ULFLAGS        = -p $(MCU_TARGET) -D -P /dev/ttyUSB0 -c avrispv2 -b 115200 -U flash:w:$(PRG).hex
-
 
28
# -D disables erase!
28
 
29
 
29
default: $(PRG).elf lst
30
default: $(PRG).elf lst
30
	@$(SIZE) $(SZFLAGS) $(PRG).elf
31
	@$(SIZE) $(SZFLAGS) $(PRG).elf
31
 
32
 
32
all: $(PRG).elf lst text eeprom
33
all: $(PRG).elf lst text eeprom
33
 
34
 
34
$(PRG).elf: $(OBJ)
35
$(PRG).elf: $(OBJ)
35
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
36
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
36
 
37
 
37
clean:
38
clean:
38
	rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak 
39
	rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak 
39
	rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
40
	rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
40
 
41
 
41
lst:  $(PRG).lst
42
lst:  $(PRG).lst
42
 
43
 
43
%.lst: %.elf
44
%.lst: %.elf
44
	$(OBJDUMP) -h -S $< > $@
45
	$(OBJDUMP) -h -S $< > $@
45
 
46
 
46
# Rules for building the .text rom images
47
# Rules for building the .text rom images
47
 
48
 
48
text: hex bin srec
49
text: hex bin srec
49
 
50
 
50
hex:  $(PRG).hex
51
hex:  $(PRG).hex
51
bin:  $(PRG).bin
52
bin:  $(PRG).bin
52
srec: $(PRG).srec
53
srec: $(PRG).srec
53
 
54
 
54
%.hex: %.elf
55
%.hex: %.elf
55
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
56
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
56
 
57
 
57
%.srec: %.elf
58
%.srec: %.elf
58
	$(OBJCOPY) -j .text -j .data -O srec $< $@
59
	$(OBJCOPY) -j .text -j .data -O srec $< $@
59
 
60
 
60
%.bin: %.elf
61
%.bin: %.elf
61
	$(OBJCOPY) -j .text -j .data -O binary $< $@
62
	$(OBJCOPY) -j .text -j .data -O binary $< $@
62
 
63
 
63
# Rules for uploading rom images to flash
64
# Rules for uploading rom images to flash
64
 
65
 
65
install: hex
66
install: hex
66
	$(UPLOAD) $(ULFLAGS)
67
	$(UPLOAD) $(ULFLAGS)
67
 
68
 
68
# Rules for building the .eeprom rom images
69
# Rules for building the .eeprom rom images
69
 
70
 
70
eeprom: ehex ebin esrec
71
eeprom: ehex ebin esrec
71
 
72
 
72
ehex:  $(PRG)_eeprom.hex
73
ehex:  $(PRG)_eeprom.hex
73
ebin:  $(PRG)_eeprom.bin
74
ebin:  $(PRG)_eeprom.bin
74
esrec: $(PRG)_eeprom.srec
75
esrec: $(PRG)_eeprom.srec
75
 
76
 
76
%_eeprom.hex: %.elf
77
%_eeprom.hex: %.elf
77
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
78
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
78
 
79
 
79
%_eeprom.srec: %.elf
80
%_eeprom.srec: %.elf
80
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
81
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
81
 
82
 
82
%_eeprom.bin: %.elf
83
%_eeprom.bin: %.elf
83
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
84
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
84
 
85
 
85
# Every thing below here is used by avr-libc's build system and can be ignored
86
# Every thing below here is used by avr-libc's build system and can be ignored
86
# by the casual user.
87
# by the casual user.
87
 
88
 
88
FIG2DEV                 = fig2dev
89
FIG2DEV                 = fig2dev
89
EXTRA_CLEAN_FILES       = *.hex *.bin *.srec
90
EXTRA_CLEAN_FILES       = *.hex *.bin *.srec
90
 
91
 
91
dox: eps png pdf
92
dox: eps png pdf
92
 
93
 
93
eps: $(PRG).eps
94
eps: $(PRG).eps
94
png: $(PRG).png
95
png: $(PRG).png
95
pdf: $(PRG).pdf
96
pdf: $(PRG).pdf
96
 
97
 
97
%.eps: %.fig
98
%.eps: %.fig
98
	$(FIG2DEV) -L eps $< $@
99
	$(FIG2DEV) -L eps $< $@
99
 
100
 
100
%.pdf: %.fig
101
%.pdf: %.fig
101
	$(FIG2DEV) -L pdf $< $@
102
	$(FIG2DEV) -L pdf $< $@
102
 
103
 
103
%.png: %.fig
104
%.png: %.fig
104
	$(FIG2DEV) -L png $< $@
105
	$(FIG2DEV) -L png $< $@
105
 
106