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 |
| 237 | arune | 3 | MCU_TARGET = atmega8 |
| 181 | andfri | 4 | OPTIMIZE = -Os -mcall-prologues |
| 234 | arune | 5 | BIOS_START = 0x1000 |
| 228 | andfri | 6 | BOOT_START = 0x1f00 |
| 181 | andfri | 7 | |
| 228 | andfri | 8 | DEFS = |
| 181 | andfri | 9 | LIBS = |
| 10 | |||
| 237 | arune | 11 | TARGET_CLK_SRC = 0xe2 |
| 12 | #TARGET_CLK_SRC for mega88 |
||
| 13 | #0xe7 #CKDIV8=1, external crystal |
||
| 14 | #0xe0 #CKDIV8=1, external clock |
||
| 15 | #0xe2 #CKDIV8=1, internal RC |
||
| 16 | #TARGET_CLK_SRC for mega8 |
||
| 17 | #0x24 #BODLEVEL = 4.0V, BODEN=enabled, internal 8MHz |
||
| 18 | #0x20 #BODLEVEL = 4.0V, BODEN=enabled, external clock |
||
| 234 | arune | 19 | |
| 237 | arune | 20 | # |
| 181 | andfri | 21 | # You should not have to change anything below here. |
| 237 | arune | 22 | # |
| 181 | andfri | 23 | |
| 24 | CC = avr-gcc |
||
| 25 | |||
| 26 | # Override is only needed by avr-lib build system. |
||
| 27 | |||
| 28 | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
||
| 228 | andfri | 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) |
||
| 181 | andfri | 31 | |
| 32 | OBJCOPY = avr-objcopy |
||
| 33 | OBJDUMP = avr-objdump |
||
| 34 | SIZE = avr-size |
||
| 35 | SZFLAGS = |
||
| 230 | arune | 36 | UPLOAD = avrdude |
| 37 | ULFLAGS = -p $(MCU_TARGET) -P /dev/ttyUSB0 -c avrispv2 -b 115200 -U flash:w:$(PRG).hex |
||
| 181 | andfri | 38 | |
| 237 | arune | 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 |
||
| 230 | arune | 46 | |
| 237 | arune | 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) |
||
| 66 | |||
| 181 | andfri | 67 | default: $(PRG).elf lst |
| 68 | @$(SIZE) $(SZFLAGS) $(PRG).elf |
||
| 69 | |||
| 70 | all: $(PRG).elf lst text eeprom |
||
| 71 | |||
| 72 | $(PRG).elf: $(OBJ) |
||
| 73 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
||
| 74 | |||
| 75 | clean: |
||
| 76 | rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak |
||
| 77 | rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) |
||
| 78 | |||
| 79 | lst: $(PRG).lst |
||
| 80 | |||
| 81 | %.lst: %.elf |
||
| 82 | $(OBJDUMP) -h -S $< > $@ |
||
| 83 | |||
| 84 | # Rules for building the .text rom images |
||
| 85 | |||
| 86 | text: hex bin srec |
||
| 87 | |||
| 88 | hex: $(PRG).hex |
||
| 89 | bin: $(PRG).bin |
||
| 90 | srec: $(PRG).srec |
||
| 91 | |||
| 92 | %.hex: %.elf |
||
| 228 | andfri | 93 | $(OBJCOPY) -j .text -j .data -j .bootloader -O ihex $< $@ |
| 181 | andfri | 94 | |
| 95 | %.srec: %.elf |
||
| 228 | andfri | 96 | $(OBJCOPY) -j .text -j .data -j .bootloader -O srec $< $@ |
| 181 | andfri | 97 | |
| 98 | %.bin: %.elf |
||
| 228 | andfri | 99 | $(OBJCOPY) -j .text -j .data -j .bootloader -O binary $< $@ |
| 181 | andfri | 100 | |
| 101 | # Rules for uploading rom images to flash |
||
| 102 | |||
| 103 | install: hex |
||
| 104 | $(UPLOAD) $(ULFLAGS) |
||
| 105 | |||
| 106 | # Rules for building the .eeprom rom images |
||
| 107 | |||
| 108 | eeprom: ehex ebin esrec |
||
| 109 | |||
| 110 | ehex: $(PRG)_eeprom.hex |
||
| 111 | ebin: $(PRG)_eeprom.bin |
||
| 112 | esrec: $(PRG)_eeprom.srec |
||
| 113 | |||
| 114 | %_eeprom.hex: %.elf |
||
| 115 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ |
||
| 116 | |||
| 117 | %_eeprom.srec: %.elf |
||
| 118 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ |
||
| 119 | |||
| 120 | %_eeprom.bin: %.elf |
||
| 121 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ |
||
| 122 | |||
| 123 | # Every thing below here is used by avr-libc's build system and can be ignored |
||
| 124 | # by the casual user. |
||
| 125 | |||
| 126 | FIG2DEV = fig2dev |
||
| 127 | EXTRA_CLEAN_FILES = *.hex *.bin *.srec |
||
| 128 | |||
| 129 | dox: eps png pdf |
||
| 130 | |||
| 131 | eps: $(PRG).eps |
||
| 132 | png: $(PRG).png |
||
| 133 | pdf: $(PRG).pdf |
||
| 134 | |||
| 135 | %.eps: %.fig |
||
| 136 | $(FIG2DEV) -L eps $< $@ |
||
| 137 | |||
| 138 | %.pdf: %.fig |
||
| 139 | $(FIG2DEV) -L pdf $< $@ |
||
| 140 | |||
| 141 | %.png: %.fig |
||
| 142 | $(FIG2DEV) -L png $< $@ |
||
| 143 |