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