Skip to content

Instantly share code, notes, and snippets.

@glnds
Last active October 24, 2020 19:34
Show Gist options
  • Save glnds/ce62919ec564dc4eec70 to your computer and use it in GitHub Desktop.
Save glnds/ce62919ec564dc4eec70 to your computer and use it in GitHub Desktop.
AVR assembler makefile
#
# Simple Makefile for programming Atmel AVR MCUs using avra and avrdude
#
# Assemble with 'make', flash hexfile to microcontroller with 'make flash'.
#
# Configuration:
#
# MCU -> name of microcontroller to program (see 'avrdude -p ?' for a list)
# TARGET -> target board/programmer to use (see 'avrdude -c ?' for a list)
# DEVICE -> linux device file refering to the interface your programmer is plugged in to
# INCPATH -> path to the AVR include files
# SRCFILE -> single assembler file that contains the source
#
MCU = m16
TARGET = stk500
DEVICE = /dev/tty.usbserial
INCPATH = /usr/share/avra/includes
SRCFILE = filename.S
$(SRCFILE).hex: $(SRCFILE)
avra -l $(SRCFILE).lst -I $(INCPATH) $(SRCFILE)
flash:
avrdude -c $(TARGET) -p $(MCU) -P $(DEVICE) -U flash:w:$(SRCFILE).hex:i
showfuses:
avrdude -c $(TARGET) -p $(MCU) -P $(DEVICE) -v 2>&1 | grep "fuse reads" | tail -n2
clean:
rm -f $(SRCFILE).hex $(SRCFILE).obj $(SRCFILE).cof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment