Skip to content

Instantly share code, notes, and snippets.

@lcosta
Forked from zacharyvoase/Makefile
Created March 7, 2013 22:31
Show Gist options
  • Save lcosta/5112440 to your computer and use it in GitHub Desktop.
Save lcosta/5112440 to your computer and use it in GitHub Desktop.
Makefile for arduino uno R3
# Basic AVR Makefile
# Author: Zachary Voase
# License: Public Domain <http://unlicense.org/>
#
# Configured to work with the Arduino Uno R3, programmed from a Mac, using
# CrossPack (http://www.obdev.at/products/crosspack/index.html).
# This needs to be the TTY device on your Mac at which the Arduino is mounted.
# Mine is normally either 1421 or 1411.
PORT = /dev/tty.usbmodem1421
# Consult Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt for
# values to use for these configuration parameters.
DEVICE = atmega328p
F_CPU = 16000000
AVRDUDE = avrdude -c arduino -P $(PORT) -p $(DEVICE)
# These probably need to be left alone unless you know what you're doing.
AR=avr-ar
AS=avr-as
CC=avr-gcc
CXX=avr-g++
CFLAGS=-Wall -Os -DF_CPU=$(F_CPU) -mmcu=$(DEVICE) \
-I/usr/local/CrossPack-AVR/avr/include/
.PHONY: all flash fuse install load clean
all: main.hex
flash: main.hex
$(AVRDUDE) -U flash:w:main.hex:i
clean:
rm -f main.hex main.elf *.o
# This will be made by an implicit Make rule.
main.o: main.c
main.elf: main.o
$(CC) $(LDFLAGS) -o $@ $^
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
avr-size --format=avr --mcu=$(DEVICE) main.elf
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment