1 # $Id: Makefile,v 1.4 2010/07/24 20:56:28 simimeie Exp $
2 # Makefile for HaWo Moodlight
8 AVRDUDE = /opt/avrdude-5.10/bin/avrdude
10 # There are a few additional defines that en- or disable certain features,
11 # mainly to save space in case you are running out of flash.
12 # You can add them here.
13 # -DJOKECMDS Just some joke commands
16 # target mcu (atmega328p or atmega168p)
18 # Since avrdude is generally crappy software (I liked uisp a lot better, too
19 # bad the project is dead :-/), it cannot use the MCU name everybody else
20 # uses, it has to invent its own name for it. So this defines the same
21 # MCU as above, but with the name avrdude understands.
25 # Clock Frequency of the AVR. Needed for various calculations.
27 # desired baudrate of serial debug console
30 SRCS = console.c ledframing.c ledpwm.c ircontrol.c timers.c main.c rfm12.c
34 CFLAGS = -g -Os -Wall -Wno-pointer-sign -mmcu=$(MCU) $(ADDDEFS)
37 LDFLAGS = -g -mmcu=$(MCU) -Wl,-Map,$(PROG).map
39 CFLAGS += -DCPUFREQ=$(CPUFREQ) -DF_CPU=$(CPUFREQ) -DBAUDRATE=$(BAUDRATE)
43 all: compile dump text eeprom
44 @echo -n "Compiled size: " && ls -l ${PROG}.bin
47 $(CC) $(LDFLAGS) -o $(PROG).elf $(OBJS)
50 $(OBJDUMP) -h -S $(PROG).elf > $(PROG).lst
53 $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
55 # Create the flash contents
57 $(OBJCOPY) -j .text -j .data -O ihex $(PROG).elf $(PROG).hex
58 $(OBJCOPY) -j .text -j .data -O srec $(PROG).elf $(PROG).srec
59 $(OBJCOPY) -j .text -j .data -O binary $(PROG).elf $(PROG).bin
61 # Rules for building the .eeprom rom images
63 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $(PROG).elf $(PROG)_eeprom.hex
64 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $(PROG).elf $(PROG)_eeprom.srec
65 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $(PROG).elf $(PROG)_eeprom.bin
68 rm -f $(PROG) *~ *.elf *.rom *.bin *.eep *.o *.lst *.map *.srec *.hex
70 upload: uploadflash uploadeeprom
73 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U flash:w:$(PROG).srec:s
76 $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U eeprom:w:$(PROG)_eeprom.srec:s