diff options
author | vg <vgm+dev@devys.org> | 2020-07-07 16:24:01 +0200 |
---|---|---|
committer | vg <vgm+dev@devys.org> | 2020-07-07 16:24:01 +0200 |
commit | 66dcf910bd4744d8ced56cb9586aa937a1a2d4c5 (patch) | |
tree | df4dca1ae4af1e5df0be0d1f4f2cd0d54751f8e8 /avr-test2/Makefile | |
download | hic-66dcf910bd4744d8ced56cb9586aa937a1a2d4c5.tar.gz hic-66dcf910bd4744d8ced56cb9586aa937a1a2d4c5.tar.bz2 hic-66dcf910bd4744d8ced56cb9586aa937a1a2d4c5.zip |
Diffstat (limited to 'avr-test2/Makefile')
-rw-r--r-- | avr-test2/Makefile | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/avr-test2/Makefile b/avr-test2/Makefile new file mode 100644 index 0000000..82fe716 --- /dev/null +++ b/avr-test2/Makefile @@ -0,0 +1,170 @@ +PRG = ledcube +OBJ = launch_effect.o main.o draw.o effect.o font.o gameoflife.o +#MCU_TARGET = at90s2313 +#MCU_TARGET = at90s2333 +#MCU_TARGET = at90s4414 +#MCU_TARGET = at90s4433 +#MCU_TARGET = at90s4434 +#MCU_TARGET = at90s8515 +#MCU_TARGET = at90s8535 +#MCU_TARGET = atmega128 +#MCU_TARGET = atmega1280 +#MCU_TARGET = atmega1281 +#MCU_TARGET = atmega1284p +#MCU_TARGET = atmega16 +#MCU_TARGET = atmega163 +#MCU_TARGET = atmega164p +#MCU_TARGET = atmega165 +#MCU_TARGET = atmega165p +#MCU_TARGET = atmega168 +#MCU_TARGET = atmega169 +#MCU_TARGET = atmega169p +#MCU_TARGET = atmega2560 +#MCU_TARGET = atmega2561 +#MCU_TARGET = atmega32 +#MCU_TARGET = atmega324p +#MCU_TARGET = atmega325 +#MCU_TARGET = atmega3250 +#MCU_TARGET = atmega329 +#MCU_TARGET = atmega3290 +#MCU_TARGET = atmega48 +#MCU_TARGET = atmega64 +#MCU_TARGET = atmega640 +#MCU_TARGET = atmega644 +#MCU_TARGET = atmega644p +#MCU_TARGET = atmega645 +#MCU_TARGET = atmega6450 +#MCU_TARGET = atmega649 +#MCU_TARGET = atmega6490 +MCU_TARGET = atmega8 +#MCU_TARGET = atmega8515 +#MCU_TARGET = atmega8535 +#MCU_TARGET = atmega88 +#MCU_TARGET = attiny2313 +#MCU_TARGET = attiny24 +#MCU_TARGET = attiny25 +#MCU_TARGET = attiny26 +#MCU_TARGET = attiny261 +#MCU_TARGET = attiny44 +#MCU_TARGET = attiny45 +#MCU_TARGET = attiny461 +#MCU_TARGET = attiny84 +#MCU_TARGET = attiny85 +#MCU_TARGET = attiny861 + +#OPTIMIZE = -O2 +OPTIMIZE = -Os + +# One must use -ffunction-sections (compiler switch) AND -Wl,-gc-sections +# (linker switch) to have the linker "garbage collect" (or remove) unused +# sections. The -ffunction-sections switch places all functions within their +# own section. You must use both together to make this work. +DEFS = -ffunction-sections -DF_CPU=16000000UL +LIBS = -Wl,-gc-sections +# You should not have to change anything below here. + +CC = avr-gcc +CXX = avr-g++ + +# Override is only needed by avr-lib build system. + +override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) #-fno-exceptions -fno-rtti +override LDFLAGS = -Wl,-Map,$(PRG).map --relax + +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump + +%.o: src/%.cpp + $(CXX) $(CFLAGS) -c -o $@ $^ + +all: $(PRG).elf lst text eeprom + avr-size --mcu=$(MCU_TARGET) -C $(PRG).elf + +$(PRG).elf: $(OBJ) + $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) + +# dependency: +#demo.o: demo.c iocompat.h +#%.o: %.c + +clean: + rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak + rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) + +lst: $(PRG).lst + +%.lst: %.elf + $(OBJDUMP) -h -S $< > $@ + +# Rules for building the .text rom images + +text: hex bin srec + +hex: $(PRG).hex +bin: $(PRG).bin +srec: $(PRG).srec + +%.hex: %.elf + $(OBJCOPY) -j .text -j .data -O ihex $< $@ + +%.srec: %.elf + $(OBJCOPY) -j .text -j .data -O srec $< $@ + +%.bin: %.elf + $(OBJCOPY) -j .text -j .data -O binary $< $@ + +# Rules for building the .eeprom rom images + +eeprom: ehex ebin esrec + +ehex: $(PRG)_eeprom.hex +ebin: $(PRG)_eeprom.bin +esrec: $(PRG)_eeprom.srec + +%_eeprom.hex: %.elf + $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \ + || { echo empty $@ not generated; exit 0; } + +%_eeprom.srec: %.elf + $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \ + || { echo empty $@ not generated; exit 0; } + +%_eeprom.bin: %.elf + $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \ + || { echo empty $@ not generated; exit 0; } + +# Every thing below here is used by avr-libc's build system and can be ignored +# by the casual user. + +FIG2DEV = fig2dev +EXTRA_CLEAN_FILES = *.hex *.bin *.srec + +dox: eps png pdf + +eps: $(PRG).eps +png: $(PRG).png +pdf: $(PRG).pdf + +%.eps: %.fig + $(FIG2DEV) -L eps $< $@ + +%.pdf: %.fig + $(FIG2DEV) -L pdf $< $@ + +%.png: %.fig + $(FIG2DEV) -L png $< $@ + +flash: + # for atmega8 : + avrdude -p m8 -c stk500v2 -P \ + /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A800dAli-if00-port0 \ + -e -U flash:w:$(PRG).hex + # for attiny25 + #avrdude -p t25 -c stk500v2 -P /dev/ttyUSB0 -e -U flash:w:$(PRG).hex + +a: all flash + +size: + avr-size --mcu=$(MCU_TARGET) -t -A $(PRG).elf + avr-size --mcu=$(MCU_TARGET) -C $(PRG).elf + avr-nm --size-sort $(PRG).elf |