2012-10-01 04:32:13 +02:00
|
|
|
PROJECT=pentabug
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
OPTIMIZATION = -Os
|
2012-10-01 21:04:12 +02:00
|
|
|
MCU = atmega88pa
|
2012-09-02 23:17:59 +02:00
|
|
|
F_CPU = 8000000
|
2012-07-17 01:05:27 +02:00
|
|
|
QUARZ = 8MHZ
|
2012-10-01 04:32:13 +02:00
|
|
|
FUSES = lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0x01:m
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
#########################################################################
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
SRC=$(wildcard lib/*.c *.c)
|
|
|
|
OBJECTS= $(SRC:.c=.o)
|
|
|
|
LSTFILES= $(SRC:.c=.lst)
|
|
|
|
HEADERS=$(wildcard lib/*.h *.h)
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
# Compiler Options
|
|
|
|
GCFLAGS = -ffreestanding -std=gnu99 -mmcu=$(MCU) $(OPTIMIZATION) -Wl,-gc-sections -nostdlib -I.
|
|
|
|
# Warnings
|
|
|
|
GCFLAGS += -Wstrict-prototypes -Wundef -Wall -Wextra -Wunreachable-code
|
|
|
|
# Optimizazions
|
|
|
|
GCFLAGS += -fsingle-precision-constant -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -fno-builtin -ffunction-sections -fno-common -fdata-sections
|
|
|
|
# Debug stuff
|
|
|
|
GCFLAGS += -Wa,-adhlns=$(<:.c=.lst),-gstabs -g
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
GCFLAGS += -DF_CPU=$(F_CPU) -DQUARZ=$(QUARZ)
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 21:04:12 +02:00
|
|
|
LDFLAGS = -mmcu=$(MCU) $(OPTIMIZATION) -gc-sections
|
2012-07-17 01:05:27 +02:00
|
|
|
|
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
# Paths
|
|
|
|
GCC = avr-gcc
|
2012-07-17 01:05:27 +02:00
|
|
|
OBJCOPY = avr-objcopy
|
2012-10-01 04:32:13 +02:00
|
|
|
REMOVE = rm -f
|
2012-07-17 01:05:27 +02:00
|
|
|
SIZE = avr-size
|
|
|
|
AVRDUDE = avrdude
|
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
#########################################################################
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
all: $(PROJECT).hex Makefile
|
|
|
|
@$(SIZE) --mcu=$(MCU) --format=avr $(PROJECT).elf
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
$(PROJECT).hex: $(PROJECT).elf Makefile
|
2012-10-01 04:36:13 +02:00
|
|
|
@echo " \033[1;34mOBJCOPY\033[0m $(PROJECT).elf -> $(PROJECT).hex"
|
2012-10-01 04:32:13 +02:00
|
|
|
@$(OBJCOPY) -O ihex -R .eeprom $(PROJECT).elf $(PROJECT).hex
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
$(PROJECT).elf: $(OBJECTS) Makefile
|
2012-10-01 04:36:13 +02:00
|
|
|
@echo " \033[1;34mLink \033[0m (\033[1;33m $(OBJECTS)\033[0m) -> $(PROJECT).elf"
|
2012-10-01 04:32:13 +02:00
|
|
|
@$(GCC) $(OBJECTS) $(LDFLAGS) -o $(PROJECT).elf
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
clean:
|
|
|
|
$(REMOVE) $(OBJECTS)
|
|
|
|
$(REMOVE) $(LSTFILES)
|
|
|
|
$(REMOVE) $(PROJECT).hex
|
|
|
|
$(REMOVE) $(PROJECT).elf
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
#########################################################################
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
%.o: %.c Makefile $(HEADERS)
|
2012-10-01 04:36:13 +02:00
|
|
|
@echo " \033[1;34mCompile\033[0m $<"
|
|
|
|
@$(GCC) $(GCFLAGS) -o $@ -c $<
|
2012-07-17 01:05:27 +02:00
|
|
|
|
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
#########################################################################
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
fuse:
|
2012-10-01 21:04:12 +02:00
|
|
|
$(AVRDUDE) -p m88 -F -c usbtiny -v -v -U $(FUSES)
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
flash: $(PROJECT).hex Makefile
|
2012-10-01 21:04:12 +02:00
|
|
|
$(AVRDUDE) -p m88 -F -c usbtiny -v -v -U flash:w:$(PROJECT).hex
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
fljohn: $(PROJECT).hex Makefile
|
2012-10-01 21:04:12 +02:00
|
|
|
$(AVRDUDE) -p m88 -F -P /dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0 -c stk500v2 -v -v -U flash:w:$(PROJECT).hex
|
2012-07-17 01:05:27 +02:00
|
|
|
|
2012-10-03 18:47:12 +02:00
|
|
|
flsmart: $(PROJECT).hex Makefile
|
|
|
|
$(AVRDUDE) -p m88 -F -P /dev/ttyUSB0 -c stk500v2 -v -v -U flash:w:$(PROJECT).hex
|
|
|
|
|
|
|
|
|
2012-10-01 04:32:13 +02:00
|
|
|
.PHONY : clean all fuse flash fljohn
|
2012-10-01 21:04:12 +02:00
|
|
|
|