Skip to content

Instantly share code, notes, and snippets.

@naotaco
Created October 1, 2016 14:21
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 naotaco/1ce1f274504b5bf5cf28b8fb4db65fe5 to your computer and use it in GitHub Desktop.
Save naotaco/1ce1f274504b5bf5cf28b8fb4db65fe5 to your computer and use it in GitHub Desktop.
Makefile sample for AVR program with USBasp
TARGET = atmega88
COMPILE = avr-gcc -Wall -O2 -I. -mmcu=$(TARGET) # -DDEBUG_LEVEL=2
OBJECTS = main.o
all: main.hex
.c.o:
$(COMPILE) -c $< -o $@
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $@
.c.s:
$(COMPILE) -S $< -o $@
clean:
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o main.s
main.bin: $(OBJECTS)
$(COMPILE) -o main.bin $(OBJECTS) -Wl,-Map,main.map
main.hex: main.bin
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
cpp:
$(COMPILE) -E main.c
flash:
avrdude -c usbasp -p $(TARGET) -U flash:w:main.hex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment