Makefile 3.7 KB

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