Skip to content

Instantly share code, notes, and snippets.

@MatthaeusHarris
Created February 18, 2019 02:48
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 MatthaeusHarris/067103e0678e561a55f893e5c8534179 to your computer and use it in GitHub Desktop.
Save MatthaeusHarris/067103e0678e561a55f893e5c8534179 to your computer and use it in GitHub Desktop.
Non-working makefile (compiles, but code does not run on microcontroller)
PRG = binaryclock
MCU_TARGET = atmega328p
PROGRAMMER = usbtiny
PFLAGS = #-P /dev/ttyUSB0
OPTIMIZE = -Os
DEFS = -DF_CPU=1000000UL
LIBS =
HEADERS =
CC = avr-gcc
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -W1,-Map,$(PRG).map
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
FLASH = avrdude
all: $(PRG).hex
$(PRG).hex: $(PRG).elf
$(OBJCOPY) -O ihex -R .eeprom $(PRG).elf $(PRG).hex
$(PRG).elf: $(PRG).o twimaster.o
$(CC) $(PRG).o twimaster.o -o $(PRG).elf
$(PRG).o: $(PRG).c $(HEADERS)
$(CC) $(CFLAGS) -c $(PRG).c -o $(PRG).o
twimaster.o: twimaster.c
$(CC) $(CFLAGS) -c twimaster.c -o twimaster.o
flash:
$(FLASH) -c $(PROGRAMMER) $(PFLAGS) -p $(MCU_TARGET) -U flash:w:$(PRG).hex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment