Skip to content

Instantly share code, notes, and snippets.

@Gautier
Created September 20, 2012 09:46
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 Gautier/3754972 to your computer and use it in GitHub Desktop.
Save Gautier/3754972 to your computer and use it in GitHub Desktop.
Makefile for arduino avr programs
MCU='atmega328p'
F_CPU=16000000
PORT='/dev/ttyACM0'
UPLOAD_RATE=115200
SOURCES=main.c
all: compile
compile: build/main.hex
upload: build/main.hex
avrdude -p $(MCU) -P $(PORT) -c arduino -b $(UPLOAD_RATE) -U flash:w:build/main.hex:i
build/main.elf: build *.c
avr-gcc -o build/main.elf -mmcu=$(MCU) -DF_CPU=$(F_CPU) $(SOURCES)
build/main.hex: build/main.elf
avr-objcopy -O ihex -R .eeprom build/main.elf build/main.hex
build:
mkdir build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment