Rev 250 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 250 | Rev 253 | ||
|---|---|---|---|
| 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 = atmega8 |
3 | MCU_TARGET = atmega8 |
| 4 | OPTIMIZE = -Os -mcall-prologues |
4 | OPTIMIZE = -Os -mcall-prologues |
| 5 | BIOS_START = |
5 | BIOS_START = 0x1562 |
| 6 | BOOT_START = 0x1f00 |
6 | BOOT_START = 0x1f00 |
| 7 | 7 | ||
| 8 | DEFS = |
8 | DEFS = |
| 9 | LIBS = |
9 | LIBS = |
| 10 | 10 | ||
| 11 | TARGET_CLK_SRC = 0x24 |
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 | #avrispv2 avr910 |
37 | #avrispv2 avr910 |
| 38 | ULFLAGS = -p $(MCU_TARGET) -P /dev/ttyS0 -c avr910 -b 115200 -U flash:w:$(PRG).hex |
38 | ULFLAGS = -p $(MCU_TARGET) -P /dev/ttyS0 -c avr910 -b 115200 -U flash:w:$(PRG).hex |
| 39 | 39 | ||
| 40 | ifeq ($(MCU_TARGET),atmega88) |
40 | ifeq ($(MCU_TARGET),atmega88) |
| 41 | #BOOTRST=0, BOOTSZ0=1, BOOTSZ1=1 |
41 | #BOOTRST=0, BOOTSZ0=1, BOOTSZ1=1 |
| 42 | EXTFUSE = 0x06 |
42 | EXTFUSE = 0x06 |
| 43 | #BODLEVEL = 4.3V |
43 | #BODLEVEL = 4.3V |
| 44 | HIGHFUSE = 0xdc |
44 | HIGHFUSE = 0xdc |
| 45 | LOWFUSE = $(TARGET_CLK_SRC) |
45 | LOWFUSE = $(TARGET_CLK_SRC) |
| 46 | endif |
46 | endif |
| 47 | 47 | ||
| 48 | ifeq ($(MCU_TARGET),atmega8) |
48 | ifeq ($(MCU_TARGET),atmega8) |
| 49 | #BOOTRST=0, BOOTSZ0=1, BOOTSZ1=1 |
49 | #BOOTRST=0, BOOTSZ0=1, BOOTSZ1=1 |
| 50 | HIGHFUSE = 0xd6 |
50 | HIGHFUSE = 0xd6 |
| 51 | LOWFUSE = $(TARGET_CLK_SRC) |
51 | LOWFUSE = $(TARGET_CLK_SRC) |
| 52 | endif |
52 | endif |
| 53 | 53 | ||
| 54 | AVRDUDE_WRITE_FUSEBITS = -u |
54 | AVRDUDE_WRITE_FUSEBITS = -u |
| 55 | ifdef EXTFUSE |
55 | ifdef EXTFUSE |
| 56 | AVRDUDE_WRITE_FUSEBITS += -U efuse:w:$(EXTFUSE):m |
56 | AVRDUDE_WRITE_FUSEBITS += -U efuse:w:$(EXTFUSE):m |
| 57 | endif |
57 | endif |
| 58 | ifdef HIGHFUSE |
58 | ifdef HIGHFUSE |
| 59 | AVRDUDE_WRITE_FUSEBITS += -U hfuse:w:$(HIGHFUSE):m |
59 | AVRDUDE_WRITE_FUSEBITS += -U hfuse:w:$(HIGHFUSE):m |
| 60 | endif |
60 | endif |
| 61 | ifdef LOWFUSE |
61 | ifdef LOWFUSE |
| 62 | AVRDUDE_WRITE_FUSEBITS += -U lfuse:w:$(LOWFUSE):m |
62 | AVRDUDE_WRITE_FUSEBITS += -U lfuse:w:$(LOWFUSE):m |
| 63 | endif |
63 | endif |
| 64 | 64 | ||
| 65 | #comment this line for not programming fusebits |
65 | #comment this line for not programming fusebits |
| 66 | #ULFLAGS += $(AVRDUDE_WRITE_FUSEBITS) |
66 | #ULFLAGS += $(AVRDUDE_WRITE_FUSEBITS) |
| 67 | 67 | ||
| 68 | default: $(PRG).elf lst |
68 | default: $(PRG).elf lst |
| 69 | @$(SIZE) $(SZFLAGS) $(PRG).elf |
69 | @$(SIZE) $(SZFLAGS) $(PRG).elf |
| 70 | 70 | ||
| 71 | all: $(PRG).elf lst text eeprom |
71 | all: $(PRG).elf lst text eeprom |
| 72 | 72 | ||
| 73 | $(PRG).elf: $(OBJ) |
73 | $(PRG).elf: $(OBJ) |
| 74 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
74 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 75 | 75 | ||
| 76 | clean: |
76 | clean: |
| 77 | rm -f $(OBJ) $(PRG).elf *.eps *.png *.pdf *.bak |
77 | rm -f $(OBJ) $(PRG).elf *.eps *.png *.pdf *.bak |
| 78 | rm -f *.lst *.map $(EXTRA_CLEAN_FILES) |
78 | rm -f *.lst *.map $(EXTRA_CLEAN_FILES) |
| 79 | 79 | ||
| 80 | lst: $(PRG).lst |
80 | lst: $(PRG).lst |
| 81 | 81 | ||
| 82 | %.lst: %.elf |
82 | %.lst: %.elf |
| 83 | $(OBJDUMP) -h -S $< > $@ |
83 | $(OBJDUMP) -h -S $< > $@ |
| 84 | 84 | ||
| 85 | # Rules for building the .text rom images |
85 | # Rules for building the .text rom images |
| 86 | 86 | ||
| 87 | text: hex bin srec |
87 | text: hex bin srec |
| 88 | 88 | ||
| 89 | hex: $(PRG).hex |
89 | hex: $(PRG).hex |
| 90 | bin: $(PRG).bin |
90 | bin: $(PRG).bin |
| 91 | srec: $(PRG).srec |
91 | srec: $(PRG).srec |
| 92 | 92 | ||
| 93 | %.hex: %.elf |
93 | %.hex: %.elf |
| 94 | $(OBJCOPY) -j .text -j .data -j .bootloader -O ihex $< $@ |
94 | $(OBJCOPY) -j .text -j .data -j .bootloader -O ihex $< $@ |
| 95 | 95 | ||
| 96 | %.srec: %.elf |
96 | %.srec: %.elf |
| 97 | $(OBJCOPY) -j .text -j .data -j .bootloader -O srec $< $@ |
97 | $(OBJCOPY) -j .text -j .data -j .bootloader -O srec $< $@ |
| 98 | 98 | ||
| 99 | %.bin: %.elf |
99 | %.bin: %.elf |
| 100 | $(OBJCOPY) -j .text -j .data -j .bootloader -O binary $< $@ |
100 | $(OBJCOPY) -j .text -j .data -j .bootloader -O binary $< $@ |
| 101 | 101 | ||
| 102 | # Rules for uploading rom images to flash |
102 | # Rules for uploading rom images to flash |
| 103 | 103 | ||
| 104 | install: hex |
104 | install: hex |
| 105 | $(UPLOAD) $(ULFLAGS) |
105 | $(UPLOAD) $(ULFLAGS) |
| 106 | 106 | ||
| 107 | # Rules for building the .eeprom rom images |
107 | # Rules for building the .eeprom rom images |
| 108 | 108 | ||
| 109 | eeprom: ehex ebin esrec |
109 | eeprom: ehex ebin esrec |
| 110 | 110 | ||
| 111 | ehex: $(PRG)_eeprom.hex |
111 | ehex: $(PRG)_eeprom.hex |
| 112 | ebin: $(PRG)_eeprom.bin |
112 | ebin: $(PRG)_eeprom.bin |
| 113 | esrec: $(PRG)_eeprom.srec |
113 | esrec: $(PRG)_eeprom.srec |
| 114 | 114 | ||
| 115 | %_eeprom.hex: %.elf |
115 | %_eeprom.hex: %.elf |
| 116 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ |
116 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ |
| 117 | 117 | ||
| 118 | %_eeprom.srec: %.elf |
118 | %_eeprom.srec: %.elf |
| 119 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ |
119 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ |
| 120 | 120 | ||
| 121 | %_eeprom.bin: %.elf |
121 | %_eeprom.bin: %.elf |
| 122 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ |
122 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ |
| 123 | 123 | ||
| 124 | # Every thing below here is used by avr-libc's build system and can be ignored |
124 | # Every thing below here is used by avr-libc's build system and can be ignored |
| 125 | # by the casual user. |
125 | # by the casual user. |
| 126 | 126 | ||
| 127 | FIG2DEV = fig2dev |
127 | FIG2DEV = fig2dev |
| 128 | EXTRA_CLEAN_FILES = *.hex *.bin *.srec |
128 | EXTRA_CLEAN_FILES = *.hex *.bin *.srec |
| 129 | 129 | ||
| 130 | dox: eps png pdf |
130 | dox: eps png pdf |
| 131 | 131 | ||
| 132 | eps: $(PRG).eps |
132 | eps: $(PRG).eps |
| 133 | png: $(PRG).png |
133 | png: $(PRG).png |
| 134 | pdf: $(PRG).pdf |
134 | pdf: $(PRG).pdf |
| 135 | 135 | ||
| 136 | %.eps: %.fig |
136 | %.eps: %.fig |
| 137 | $(FIG2DEV) -L eps $< $@ |
137 | $(FIG2DEV) -L eps $< $@ |
| 138 | 138 | ||
| 139 | %.pdf: %.fig |
139 | %.pdf: %.fig |
| 140 | $(FIG2DEV) -L pdf $< $@ |
140 | $(FIG2DEV) -L pdf $< $@ |
| 141 | 141 | ||
| 142 | %.png: %.fig |
142 | %.png: %.fig |
| 143 | $(FIG2DEV) -L png $< $@ |
143 | $(FIG2DEV) -L png $< $@ |
| 144 | 144 | ||