]> git.tdb.fi Git - model-railway-devices.git/blob - firmware/Makefile
Add a program for serial port control and associated Arduino firmware
[model-railway-devices.git] / firmware / Makefile
1 # $Id$
2
3 MCU = atmega328p
4 CLOCK = 16000000
5 CFLAGS = -Wall -Os -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(CLOCK)
6 LDFLAGS = -Os -Wl,--gc-sections -mmcu=$(MCU)
7
8 help:
9         @echo "Targets:"
10         @echo "  %.hex:    Build firmware from %.c"
11         @echo "  upload-%: Upload firmware to AVR"
12
13 %.hex: %.elf
14         avr-objcopy -O ihex $< $@
15
16 %.elf: %.o
17         avr-gcc $(LDFLAGS) -o $@ $<
18
19 %.o: %.c
20         avr-gcc -c $(CFLAGS) -o $@ $<
21
22 upload-%: %.hex
23         avrdude -p$(MCU) -cstk500v1 -P/dev/ttyUSB0 -b57600 -D -Uflash:w:$<:i