Skip to content

Instantly share code, notes, and snippets.



Created Feb 20, 2016
What would you like to do?
My AVR makefile for a uni course last year
# Name: Makefile
# Author: Tom Manderson
# Based on
DEVICE = atmega324a
CLOCK = 8000000
PROGRAMMER = -c avrispmkii
OBJECTS = project.o buttons.o game.o ledmatrix.o score.o scrolling_char_display.o serialio.o spi.o terminalio.o timer0.o
AVRDUDE = avrdude $(PROGRAMMER) -p m324pa -F
COMPILE = avr-gcc -Wall -Os -std=c99 -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: project.hex
$(COMPILE) -c $< -o $@
$(COMPILE) -S $< -o $@
flash: all
$(AVRDUDE) -U flash:w:project.hex:i
rm -f project.hex project.elf $(OBJECTS)
# file targets:
project.elf: $(OBJECTS)
$(COMPILE) -o project.elf $(OBJECTS)
project.hex: project.elf
rm -f project.hex
avr-objcopy -j .text -j .data -O ihex project.elf project.hex
avr-size --format=avr --mcu=$(DEVICE) project.elf
disasm: project.elf
avr-objdump -d project.elf
$(COMPILE) -E project.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment