Skip to content

Instantly share code, notes, and snippets.

@smcl
Last active November 28, 2015 21:42
Show Gist options
  • Save smcl/6c3e4b9b5c7702eac75b to your computer and use it in GitHub Desktop.
Save smcl/6c3e4b9b5c7702eac75b to your computer and use it in GitHub Desktop.
$ cat Makefile
CC = avr-gcc
PROCESSOR = atmega328p
FREQ = 16000000
AVRDUDE_CONFIG = arduino
AVRDUDE_PART = ATMEGA328P
AVRDUDE_PROGRAMMING_DEVICE = /dev/tty.usbmodem1411
all: build
clean:
rm *.o *.hex blink
compile:
$(CC) -Os -DF_CPU=$(FREQ)UL -mmcu=$(PROCESSOR) -c -o blink.o blink.c
build: compile
$(CC) -mmcu=$(PROCESSOR) blink.o -o blink
flash: build
avrdude -F -V -c $(AVRDUDE_CONFIG) -p $(AVRDUDE_PART) -P $(AVRDUDE_PROGRAMMING_DEVICE) -b 115200 -U flash:w:blink:e
$ make flash
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o blink.o blink.c
avr-gcc -mmcu=atmega328p blink.o -o blink
avr-objcopy -O ihex -R .eeprom blink blink.hex
avrdude -F -V -c arduino -p ATMEGA328P -P /dev/tty.usbmodem1411 -b 115200 -U flash:w:blink.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "blink.hex"
avrdude: input file blink.hex auto detected as Intel Hex
avrdude: writing flash (176 bytes):
Writing | ################################################## | 100% 0.04s
avrdude: 176 bytes of flash written
avrdude: safemode: Fuses OK (H:00, E:00, L:00)
avrdude done. Thank you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment