Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # =====================================================================================
  2. #
  3. # ________ .__ __ ________ ____ ________
  4. # \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
  5. # / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
  6. # / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
  7. # \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
  8. # \__> \/ \/ \/ \/ \/
  9. # www.optixx.org
  10. #
  11. #
  12. # Version: 1.0
  13. # Created: 07/21/2009 03:32:16 PM
  14. # Author: david@optixx.org
  15. # Based on: custom-class, a basic USB example
  16. # Author: Christian Starkjohann
  17. # =====================================================================================
  18. DEBUG = 1
  19. TTY = /dev/tty.PL2303-00002126
  20. DEVICE = atmega644
  21. F_CPU = 20000000 # in Hz
  22. TARGET = main
  23. AVRDUDE = avrdude -c usbasp -p $(DEVICE)
  24. SIZE = avr-size
  25. ifeq ($(DEBUG),1)
  26. LDFLAGS =-Wl,-u,vfprintf -lprintf_flt
  27. CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0
  28. OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
  29. main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
  30. dump.o timer.o watchdog.o rle.c loader.o info.o shared_memory.o \
  31. system.o pwm.o util.o shell.o irq.o command.o testing.o
  32. else
  33. LDFLAGS =-Wl,-u
  34. CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
  35. OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o \
  36. uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o rle.c loader.o \
  37. system.o pwm.o util.o shell.o info.o shared_memory.o command.o irq.o
  38. endif
  39. COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
  40. ##############################################################################
  41. # Fuse values for particular devices
  42. ##############################################################################
  43. # http://www.engbedded.com/fusecalc/
  44. FUSE_L = 0xf7
  45. FUSE_H = 0xda
  46. all: hex
  47. help:
  48. @echo "This Makefile has no default rule. Use one of the following:"
  49. @echo "make hex ....... to build main.hex"
  50. @echo "make program ... to flash fuses and firmware"
  51. @echo "make fuse ...... to flash the fuses"
  52. @echo "make flash ..... to flash the firmware (use this on metaboard)"
  53. @echo "make clean ..... to delete objects and hex file"
  54. hex: main.hex
  55. @echo "$(TARGET) compiled for: $(DEVICE)"
  56. @./checksize $(TARGET).elf
  57. program: flash fuse
  58. # rule for programming fuse bits:
  59. fuse:
  60. @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
  61. { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
  62. $(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
  63. flash: main.hex
  64. $(AVRDUDE) -U flash:w:main.hex:i
  65. loader:
  66. python ../../scripts/conv_rle.py ../../snes/qd16/qd16boot.smc
  67. .c.o:
  68. $(COMPILE) -c $< -o $@
  69. .S.o:
  70. $(COMPILE) -x assembler-with-cpp -c $< -o $@
  71. .c.s:
  72. $(COMPILE) -S $< -o $@
  73. usbdrv:
  74. cp -r ../../../usbdrv .
  75. main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
  76. $(COMPILE) -o main.elf $(OBJECTS) $(LDFLAGS)
  77. main.hex: main.elf
  78. rm -f main.hex main.eep.hex
  79. avr-objcopy -j .text -j .data -O ihex main.elf main.hex
  80. avr-size main.hex
  81. disasm: main.elf
  82. avr-objdump -d main.elf
  83. cpp:
  84. $(COMPILE) -E main.c
  85. clean:
  86. rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s