Skip to content

Instantly share code, notes, and snippets.

@TRManderson
Created February 20, 2016 09:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TRManderson/0da3df529f4744fad7d2 to your computer and use it in GitHub Desktop.
Save TRManderson/0da3df529f4744fad7d2 to your computer and use it in GitHub Desktop.
My AVR makefile for a uni course last year
# Name: Makefile
# Author: Tom Manderson
# Based on https://github.com/obdev/CrossPack-AVR/
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
.c.o:
$(COMPILE) -c $< -o $@
.c.s:
$(COMPILE) -S $< -o $@
flash: all
$(AVRDUDE) -U flash:w:project.hex:i
clean:
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
cpp:
$(COMPILE) -E project.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment