Skip to content

Instantly share code, notes, and snippets.

@MichaelThessel
Created May 4, 2016 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelThessel/e66dfc3205e854ecf276a3238416f622 to your computer and use it in GitHub Desktop.
Save MichaelThessel/e66dfc3205e854ecf276a3238416f622 to your computer and use it in GitHub Desktop.
AVR Makefile Template
BIN=main
OBJS=main.o
SRCS=main.c
MCU=atmega328p
SPEED=16000000UL
LIBS=-L usbdrv
CC=avr-gcc
OBJCOPY=avr-objcopy
CFLAGS=-Os -DF_CPU=${SPEED} -mmcu=${MCU} ${LIBS} -std=gnu99
default: build flash
build: ${BIN}.hex
${BIN}.elf: ${SRCS}
${CC} ${CFLAGS} -o $@ $^
${BIN}.hex: ${BIN}.elf
${OBJCOPY} -O ihex -R .eeprom $< $@
flash: ${BIN}.hex
avrdude -F -V -c dragon_isp -p atmega328 -U flash:w:$<
clean:
rm -f ${BIN}.elf ${BIN}.hex ${OBJS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment