CC = avr-gcc GDB = avr-gdb DDD = ddd DEBUGGER = ddd OBJCOPY = avr-objcopy OBJDUMP = avr-objdump ASFLAGS = -Wa,-ahlms=$(<:.S=.lst),-gstabs CFLAGS = -O$(OPT) -g -funsigned-char -funsigned-bitfields -fpack-struct \ -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst) -mcall-prologues LDFLAGS = -Wl,-Map=$(TARGET).map,--cref UISP = uisp UISPFLAGS = -v UISPPROG = stk500 UISPDEV = /dev/ttyS0 UISPFLAGS = --rd_vtg --rd_aref --rd_osc -v AVARICE = avarice JTAGICEDEV = /dev/ttyS0 JTAGICEPORT = 4242 INCLUDES= LIBS = #Define part here #MCU = attiny12 MCU = atmega32 # Additional libraries # # Minimalistic printf version # LDFLAGS += -Wl,-u,vfprintf -lprintf_min # # Floating point printf version (requires -lm below) #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt # # -lm = math library #LDFLAGS += -lm FORMAT = ihex OPT = s PROGMETHOD = progice TARGET = t CSRC = a.c ASRC = # Configurables end here OBJS = $(CSRC:.c=.o) $(ASRC:.S=.o) LST = $(ASRC:.S=.lst) $(NSRC:.c=.lst) .PHONY:= all debug progice prog progflash progeep size clean .PRECIOUS: $(OBJS) .SECONDARY: all: $(TARGET).elf $(TARGET).hex $(TARGET).eep $(TARGET).lss size debug: $(TARGET).elf $(AVARICE) --file $(TARGET).elf --jtag $(JTAGICEDEV) \ --detach localhost:$(JTAGICEPORT) echo 'set remoteaddresssize 32' > .avaricetmp echo 'set remote Z-packet enable' >> .avaricetmp echo 'set remote step-over-range-packet enable' >> .avaricetmp # These don't work in my version of gdb. # echo 'set remote hardware-breakpoint-limit 3' >> .avaricetmp # echo 'set remote hardware-watchpoint-limit 2' >> .avaricetmp echo 'file $(TARGET).elf' >> .avaricetmp echo 'target extended-remote localhost:$(JTAGICEPORT)' >> .avaricetmp ifeq ($(DEBUGGER),ddd) $(DDD) --debugger '$(GDB) -x .avaricetmp' else $(GDB) -x .avaricetmp endif killall -TERM avarice rm .avaricetmp prog: $(PROGMETHOD) progice: $(TARGET).elf $(AVARICE) --file $(TARGET).elf --jtag $(JTAGICEDEV) --program --verify progflash: $(TARGET).hex $(UISP) -dprog=$(UISPPROG) -dserial=$(UISPDEV) -dpart=$(MCU) $(UISPFLAGS) --segment=flash --erase --upload --verify if=$< progeep: $(TARGET).eep $(UISP) -dprog=$(UISPPROG) -dserial=$(UISPDEV) -dpart=$(MCU) $(UISPFLAGS) --segment=eeprom --erase --upload --verify if=$< progboth: $(TARGET).hex $(TARGET).eep $(UISP) -dprog=$(UISPPROG) -dserial=$(UISPDEV) -dpart=$(MCU) $(UISPFLAGS) --segment=flash --erase --upload --verify if=$(TARGET).hex # EEPROM writing doesn't seem to work for Tiny12 $(UISP) -dprog=$(UISPPROG) -dserial=$(UISPDEV) -dpart=$(MCU) $(UISPFLAGS) --segment=eeprom --upload --verify if=$(TARGET).eep %.hex: %.elf $(OBJCOPY) -O$(FORMAT) -R .eeprom $< $@ %.eep: %.elf $(OBJCOPY) -O$(FORMAT) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 $< $@ %.srec: %.elf $(OBJCOPY) $< $@ -R .eeprom -Osrec %.ihex: %.elf $(OBJCOPY) $< $@ -R .eeprom -Oihex %.bin: %.elf $(OBJCOPY) -Obinary -R .eeprom $< $@ %.elf: $(OBJS) $(CC) -mmcu=$(MCU) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ %.o: %.c $(CC) -mmcu=$(MCU) $(CFLAGS) $(INCLUDES) -c $< -o $@ %.o: %.S $(CC) -mmcu=$(MCU) $(ASFLAGS) $(INCLUDES) -c $< -o $@ %.s: %.c $(CC) -mmcu=$(MCU) $(CFLAGS) $(INCLUDES) -S $< -o $@ %.s: %.S $(CC) -mmcu=$(MCU) $(ASFLAGS) $(INCLUDES) -S $< > $@ %.lss: %.elf $(OBJDUMP) -h -S $< > $@ size: @if [ -f $(TARGET).elf ]; then echo Size:; avr-size -A $(TARGET).elf; fi clean: rm -f $(TARGET).hex rm -f $(TARGET).srec rm -f $(TARGET).eep rm -f $(TARGET).bin rm -f $(TARGET).elf rm -f $(TARGET).map rm -f $(TARGET).lss rm -f $(OBJS) rm -f $(LST) rm -f $(CSRC:.c=.s) rm -f $(CSRC:.c=.d)