Skip to content

Instantly share code, notes, and snippets.

@genelocated genelocated/Makefile
Created Jun 19, 2019

Embed
What would you like to do?
Programming AVR on Linux

Programming AVR on Linux

Install avr-gcc, avr-libc, avr-binutils, avrdude:

$ sudo pacman -S avr-gcc avr-libc avr-binutils avrdude

Build the hex file:

$ make hex

Flash to the chip:

$ sudo make flash
MCU = atmega32
F_CPU = 16000000
PROGRAMMER = -c usbasp
AVRDUDE = avrdude $(PROGRAMMER) -p $(MCU)
CC = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU)
.PHONY: hex flash clean
hex: blink.hex
%.hex: %.elf
rm -f $@
avr-objcopy -j .text -j .data -O ihex $< $@
%.elf: %.o
$(CC) $< -o $@
%.o: %.c
$(CC) -c $< -o $@
flash: hex
$(AVRDUDE) -U flash:w:blink.hex:i
clean:
rm -f blink.hex blink.elf blink.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.