Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # =====================================================================================
  2. #
  3. # ________ .__ __ ________ ____ ________
  4. # \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
  5. # / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
  6. # / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
  7. # \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
  8. # \__> \/ \/ \/ \/ \/
  9. # ___.
  10. # __ __ _____\_ |__
  11. # | | \/ ___/| __ \
  12. # | | /\___ \ | \_\ \
  13. # |____//____ >|___ /
  14. # \/ \/
  15. #
  16. # www.optixx.org
  17. #
  18. #
  19. # Version: 1.0
  20. # Created: 07/21/2009 03:32:16 PM
  21. # Author: david@optixx.org
  22. # Based on: custom-class, a basic USB example
  23. # Author: Christian Starkjohann
  24. # =====================================================================================
  25. TTY = /dev/tty.PL2303-00002126
  26. DEVICE = atmega644
  27. F_CPU = 20000000 # in Hz
  28. TARGET = main
  29. AVRDUDE = avrdude -c usbasp -p $(DEVICE)
  30. SIZE = avr-size
  31. CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
  32. OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o huffman-decode.o rle.c loader.o
  33. COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
  34. ##############################################################################
  35. # Fuse values for particular devices
  36. ##############################################################################
  37. # http://www.engbedded.com/fusecalc/
  38. FUSE_L = 0xf7
  39. FUSE_H = 0xda
  40. all: hex
  41. help:
  42. @echo "This Makefile has no default rule. Use one of the following:"
  43. @echo "make hex ....... to build main.hex"
  44. @echo "make program ... to flash fuses and firmware"
  45. @echo "make fuse ...... to flash the fuses"
  46. @echo "make flash ..... to flash the firmware (use this on metaboard)"
  47. @echo "make clean ..... to delete objects and hex file"
  48. hex: main.hex
  49. @echo "==============================="
  50. @echo "$(TARGET) compiled for: $(DEVICE)"
  51. @echo -n "size is: "
  52. @$(SIZE) -A $(TARGET).hex | grep "\.sec1" | tr -s " " | cut -d" " -f2
  53. @echo "==============================="
  54. program: flash fuse
  55. # rule for programming fuse bits:
  56. fuse:
  57. @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
  58. { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
  59. $(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
  60. # rule for uploading firmware:
  61. flash: main.hex
  62. $(AVRDUDE) -U flash:w:main.hex:i
  63. # rule for deleting dependent files (those which can be built by Make):
  64. clean:
  65. 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
  66. # Generic rule for compiling C files:
  67. .c.o:
  68. $(COMPILE) -c $< -o $@
  69. # Generic rule for assembling Assembler source files:
  70. .S.o:
  71. $(COMPILE) -x assembler-with-cpp -c $< -o $@
  72. # "-x assembler-with-cpp" should not be necessary since this is the default
  73. # file type for the .S (with capital S) extension. However, upper case
  74. # characters are not always preserved on Windows. To ensure WinAVR
  75. # compatibility define the file type manually.
  76. # Generic rule for compiling C to assembler, used for debugging only.
  77. .c.s:
  78. $(COMPILE) -S $< -o $@
  79. # file targets:
  80. # Since we don't want to ship the driver multipe times, we copy it into this project:
  81. usbdrv:
  82. cp -r ../../../usbdrv .
  83. main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
  84. $(COMPILE) -o main.elf $(OBJECTS) -Wl,-u,vfprintf -lprintf_flt
  85. main.hex: main.elf
  86. rm -f main.hex main.eep.hex
  87. avr-objcopy -j .text -j .data -O ihex main.elf main.hex
  88. avr-size main.hex
  89. # debugging targets:
  90. disasm: main.elf
  91. avr-objdump -d main.elf
  92. cpp:
  93. $(COMPILE) -E main.c