Split Makefile and configuration, restructure targets

This commit is contained in:
Stefan Kalscheuer 2018-09-08 14:01:17 +02:00
parent 61c131486b
commit e18133d6f4
2 changed files with 61 additions and 10 deletions

View File

@ -1,16 +1,41 @@
CC=avr-gcc
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=attiny2313
OBJ2HEX=avr-objcopy
AVRDUDE=avrdude
TARGET=midifs
# Include environment config
include Makefile.config
# Project specific settings
TARGET = midifs
MCU = t2313
help:
@echo
@echo "Availiable targets:"
@echo " help Displays this help"
@echo
@echo " compile Compiles source code"
@echo " info Outputs device memory information"
@echo " program Programs the device"
@echo " clean Deletes temporary files"
@echo
@echo " all Compile, info, program, clean"
@echo
# Some C flags
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=attiny2313
all: compile info program clean
compile: $(TARGET).hex
info:
avr-size $(TARGET).hex
program: compile
@$(AVRDUDE) -p $(MCU) -c $(PGMDEV) -P $(PGMOPT) -U flash:w:$(TARGET).hex:i
program : $(TARGET).hex
$(AVRDUDE) -p t2313 -c stk500v2 -P /dev/ttyS0 -U $(TARGET).hex
%.obj : %.o
$(CC) $(CFLAGS) $< -o $@
%.hex : %.obj
$(OBJ2HEX) -R .eeprom -O ihex $< $@
@$(OBJ2HEX) -R .eeprom -O ihex $< $@
clean :
rm -f *.hex *.obj *.o
clean:
@$(REMOVE) *.hex *.obj *.o

26
firmware/Makefile.config Normal file
View File

@ -0,0 +1,26 @@
#
# Set toolchain.
# AVR-GCC and AVRDUDE need to be installed
#
CC = avr-gcc
OBJ2HEX = avr-objcopy
AVRDUDE = avrdude
REMOVE = rm -f
#
# You probably want to change this to your own programming device.
# Some commonly used examples shown below.
#
# STK500
PGMDEV = stk500v2
PGMOPT = -P /dev/ttyS0
# AVR ISP mkII
#PGMDEV = avrispmkII
#PGMOPT = -P usb # Try -B 10 in case of programming errors
# Pony-STK200
#PGMDEV = pony-stk200
#PGMOPT = -E noreset