summaryrefslogtreecommitdiffstats
path: root/sw-avr/rom-loader/makefile
blob: 85222c825d1ab9c20158d4417b9f1df278b98c62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
SOURCES := main.c usart.c
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))

CFLAGS  := -Wall -mmcu=atmega328p -Os -I. \
            -D__AVR_ATmega328p__ -DF_CPU=1000000UL -DBAUD=9600
LDFLAGS := 

.PHONY: all flash clean
all: rom-loader.hex

flash: rom-loader.hex
	avrdude -c usbasp -p atmega328p -U flash:w:$<

clean:
	rm -f *.bin *.hex *.o

rom-loader.hex: rom-loader.bin
	avr-objcopy -R .eeprom -O ihex $< $@

rom-loader.bin: $(OBJECTS)
	avr-gcc $(CFLAGS) $(OBJECTS) -o $@ $(LDFLAGS)

%.o: %.c
	avr-gcc $(CFLAGS) $< -c -o $@ $(LDFLAGS)