picadae/control/ctrl/Makefile

49 lines
1.1 KiB
Makefile
Raw Normal View History

2019-07-07 01:59:39 +00:00
ifndef TTY
TTY=/dev/ttyACM0
endif
MMCU=atmega328
#MMCU=atmega2560
ifeq ($(MMCU),atmega328)
PROG_MMCU=atmega328p
PROG_DEV=arduino
AVRD_CONF=
DISABLE_AUTO_ERASE=
SKIP_CHECKS=-FV
endif
ifeq ($(MMCU),atmega2560)
PROG_MMCU=$(MMCU)
PROG_DEV=wiring
AVRD_CONF=-C/etc/avrdude/avrdude.conf
DISABLE_AUTO_ERASE=-D
SKIP_CHECKS=-FV
endif
2019-07-07 01:59:39 +00:00
# compiler flags:
# -Os : optimize size
# -DF_CPU=16000000UL : define F_CPU as 16Mghz
# -mmcu=atmega328p : target MCU
# -F : skip device signature read
# -V : disable automatic verify step
# -v : enable verbose output
# -D : disable auto erase flash
2019-07-07 01:59:39 +00:00
main.hex : main.c
# compile to object file (optimize for size)
avr-gcc -Os -DF_CPU=16000000UL -mmcu=$(MMCU) -o main.elf main.c twi.c
2019-07-07 01:59:39 +00:00
# link as ELF binary
#avr-gcc -mmcu=atmega328p main.o -o main.elf
# convert ELF format to an IHEX format as used by avrdude
avr-objcopy -O ihex -R .eeprom main.elf main.hex
burn:
avrdude $(SKIP_CHECKS) -v $(AVRD_CONF) -c$(PROG_DEV) -p$(PROG_MMCU) -P$(TTY) -b 115200 $(DISABLE_AUTO_ERASE) -U flash:w:main.hex:i
2019-07-07 01:59:39 +00:00
clean :
rm main.o twi.o main.elf main.hex