1 # $Id: Makefile,v 1.2 2010/03/23 07:55:23 simimeie Exp $
2 # Makefile for the ds1820-to-usb project
10 # target mcu (at90s8515, atmega16, atmega8515...)
12 # Since avrdude is generally crappy software (I liked uisp a lot better, too
13 # bad the project is dead :-/), it cannot use the MCU name everybody else
14 # uses, it has to invent its own name for it. So this defines the same
15 # MCU as above, but with the name avrdude understands.
19 # Clock Frequency of the AVR. Needed for various calculations.
24 # -DKISS enables Keep-It-Simple-Stupid mode, which can only handle one
25 # temperature sensor on the bus.
28 SRCS = usbdrv/usbdrv.c ds1820.c main.c time.c
29 ASMS = usbdrv/usbdrvasm.S
33 CFLAGS = -g -Os -Wall -fno-strict-aliasing -mmcu=$(MCU) $(ADDDEFS)
36 LDFLAGS = -g -mmcu=$(MCU) -Wl,-Map,$(PROG).map
38 CFLAGS += -DCPUFREQ=$(CPUFREQ) -DF_CPU=$(CPUFREQ)
40 OBJS = $(SRCS:.c=.o) $(ASMS:.S=.o)
42 all: compile dump text eeprom
45 $(CC) $(LDFLAGS) -o $(PROG).elf $(OBJS)
48 $(OBJDUMP) -h -S $(PROG).elf > $(PROG).lst
50 hostsoftware: hostsoftware.c
51 gcc -o hostsoftware -O2 -Wall -lusb hostsoftware.c
54 $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
57 $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
59 # Create the flash contents
61 $(OBJCOPY) -j .text -j .data -O ihex $(PROG).elf $(PROG).hex
62 $(OBJCOPY) -j .text -j .data -O srec $(PROG).elf $(PROG).srec
63 $(OBJCOPY) -j .text -j .data -O binary $(PROG).elf $(PROG).bin
65 # Rules for building the .eeprom rom images
67 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $(PROG).elf $(PROG)_eeprom.hex
68 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $(PROG).elf $(PROG)_eeprom.srec
69 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $(PROG).elf $(PROG)_eeprom.bin
72 rm -f $(PROG) *~ *.elf *.rom *.bin *.eep *.o usbdrv/*.o *.lst *.map *.srec *.hex
74 upload: uploadflash uploadeeprom
77 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U flash:w:$(PROG).srec:s
80 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U eeprom:w:$(PROG)_eeprom.srec:s
83 @echo "Sorry, I will not program the fuses for you, since things will"
84 @echo "go horribly wrong if you make a mistake there. It is safest to set"
85 @echo "them with avrstudio."
86 @echo "If you want to use attiny45/85, you will probably want"
87 @echo " lfuse=0xff, hfuse=0xdd, efuse=0xff"
88 @echo "Command line will be something along the lines of"
89 @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U lfuse:w:0xff:m
90 @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U hfuse:w:0xdd:m
91 @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U efuse:w:0xff:m