pentabug/firmware/Makefile

80 lines
2.3 KiB
Makefile
Raw Normal View History

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
MCU = atmega88pa
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-11 23:22:33 +02:00
SRC=$(wildcard lib/*.c apps/*.c *.c)
2012-10-01 04:32:13 +02:00
OBJECTS= $(SRC:.c=.o)
LSTFILES= $(SRC:.c=.lst)
2013-08-26 01:08:00 +02:00
HEADERS=$(wildcard */*/*.h */*.h *.h)
2012-07-17 01:05:27 +02:00
2012-10-01 04:32:13 +02:00
# Compiler Options
2013-08-26 01:08:00 +02:00
GCFLAGS = -ffreestanding -std=gnu99 -mmcu=$(MCU) $(OPTIMIZATION) -Wl,-gc-sections -nostdlib -I. -Iinclude
2012-10-01 04:32:13 +02:00
# 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
2013-08-26 01:08:00 +02:00
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
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:
$(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
2013-07-08 12:02:24 +02:00
$(AVRDUDE) -p m88 -F -c usbtiny -B 1 -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
$(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
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