Skip to content

Instantly share code, notes, and snippets.

@krmerchant
Forked from edwardhotchkiss/Makefile
Created February 21, 2017 05:44
Show Gist options
  • Save krmerchant/1dcf9f56dab35c3912c048904a9a8e81 to your computer and use it in GitHub Desktop.
Save krmerchant/1dcf9f56dab35c3912c048904a9a8e81 to your computer and use it in GitHub Desktop.
ATtiny85 avr-gcc / avrdude Makefile
DEVICE = attiny85
CLOCK = 8000000
PROGRAMMER = stk500v1
PORT = /dev/tty.usbmodem1421
BAUD = 19200
FILENAME = main
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
all: usb clean build upload
usb:
ls /dev/cu.*
build:
$(COMPILE) -c $(FILENAME).c -o $(FILENAME).o
$(COMPILE) -o $(FILENAME).elf $(FILENAME).o
avr-objcopy -j .text -j .data -O ihex $(FILENAME).elf $(FILENAME).hex
avr-size --format=avr --mcu=$(DEVICE) $(FILENAME).elf
upload:
avrdude -v -p $(DEVICE) -c $(PROGRAMMER) -P $(PORT) -b $(BAUD) -U flash:w:$(FILENAME).hex:i
clean:
rm main.o
rm main.elf
rm main.hex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment