Commit 4814c0d4 authored by Sebastian Neuser's avatar Sebastian Neuser
Browse files

Add Makefile to build and program BOB3 firmware

parent 7f7427e4
MCU = atmega88p
F_CPU = 8000000
CC = avr-gcc
OBJCOPY = avr-objcopy
SIZE = avr-size
AVRDUDE = avrdude
PGM_TYPE = avrispmkII
PGM_DEV = usb
FLAGS = -mmcu=$(MCU) -DAVR -DF_CPU=$(F_CPU) -D_BOB3_ -I. -Wall -Os -ffunction-sections
CFLAGS = $(FLAGS) -std=c99
C_FILES := $(wildcard bob3/*.c) $(wildcard bob3/*.cpp)
OBJS := $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(C_FILES)))
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp
$(CC) $(CCFLAGS) -c $< -o $@
%.elf: %.o $(OBJS)
$(CC) -mmcu=$(MCU) $(OBJS) $< -o $@
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.compile: %.hex
$(SIZE) $<
%.program: %.hex
$(AVRDUDE) -p $(MCU) -c $(PGM_TYPE) -P $(PGM_DEV) -U flash:w:$<:i
rm -f $(OBJS) *.o *.elf *.hex
.PRECIOUS: %.hex
.PHONY: clean
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment