Subversion Repositories HomeAutomation

Rev

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

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