manueller import aus nem CVS checkout (ist eh nur zum testen)
[ds1820tousb.git] / Makefile
CommitLineData
93ac315e
MPM
1# $Id: Makefile,v 1.2 2010/03/23 07:55:23 simimeie Exp $
2# Makefile for the ds1820-to-usb project
3
4CC = avr-gcc
5OBJDUMP = avr-objdump
6OBJCOPY = avr-objcopy
7AVRDUDE = avrdude
8INCDIR = .
9
10# target mcu (at90s8515, atmega16, atmega8515...)
11MCU = attiny45
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.
16AVRDMCU = t45
17
18# Some more settings
19# Clock Frequency of the AVR. Needed for various calculations.
20CPUFREQ = 15000000UL
21
22# Additional defines
23# Known defines are:
24# -DKISS enables Keep-It-Simple-Stupid mode, which can only handle one
25# temperature sensor on the bus.
26ADDDEFS =
27
28SRCS = usbdrv/usbdrv.c ds1820.c main.c time.c
29ASMS = usbdrv/usbdrvasm.S
30PROG = ds1820tousb
31
32# compiler flags
33CFLAGS = -g -Os -Wall -fno-strict-aliasing -mmcu=$(MCU) $(ADDDEFS)
34
35# linker flags
36LDFLAGS = -g -mmcu=$(MCU) -Wl,-Map,$(PROG).map
37
38CFLAGS += -DCPUFREQ=$(CPUFREQ) -DF_CPU=$(CPUFREQ)
39
40OBJS = $(SRCS:.c=.o) $(ASMS:.S=.o)
41
42all: compile dump text eeprom
43
44compile: $(OBJS)
45 $(CC) $(LDFLAGS) -o $(PROG).elf $(OBJS)
46
47dump: compile
48 $(OBJDUMP) -h -S $(PROG).elf > $(PROG).lst
49
50hostsoftware: hostsoftware.c
51 gcc -o hostsoftware -O2 -Wall -lusb hostsoftware.c
52
53%o : %c
54 $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
55
56%o : %S
57 $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
58
59# Create the flash contents
60text: compile
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
64
65# Rules for building the .eeprom rom images
66eeprom: compile
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
70
71clean:
72 rm -f $(PROG) *~ *.elf *.rom *.bin *.eep *.o usbdrv/*.o *.lst *.map *.srec *.hex
73
74upload: uploadflash uploadeeprom
75
76uploadflash:
77 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U flash:w:$(PROG).srec:s
78
79uploadeeprom:
80 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U eeprom:w:$(PROG)_eeprom.srec:s
81
82uploadfuses:
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
This page took 0.05247 seconds and 4 git commands to generate.