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