Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. # Name: Makefile
  2. # Project: hid-custom-rq example
  3. # Author: Christian Starkjohann
  4. # Creation Date: 2008-04-07
  5. # Tabsize: 4
  6. # Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
  7. # License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
  8. # This Revision: $Id: Makefile 692 2008-11-07 15:07:40Z cs $
  9. DEVICE = atmega168
  10. F_CPU = 16000000 # in Hz
  11. FUSE_L = # see below for fuse values for particular devices
  12. FUSE_H =
  13. AVRDUDE = avrdude -c usbasp -p $(DEVICE) # edit this line for your programmer
  14. CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
  15. OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
  16. COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
  17. ##############################################################################
  18. # Fuse values for particular devices
  19. ##############################################################################
  20. # If your device is not listed here, go to
  21. # http://palmavr.sourceforge.net/cgi-bin/fc.cgi
  22. # and choose options for external crystal clock and no clock divider
  23. #
  24. ################################## ATMega8 ##################################
  25. # ATMega8 FUSE_L (Fuse low byte):
  26. # 0x9f = 1 0 0 1 1 1 1 1
  27. # ^ ^ \ / \--+--/
  28. # | | | +------- CKSEL 3..0 (external >8M crystal)
  29. # | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
  30. # | +------------------ BODEN (BrownOut Detector enabled)
  31. # +-------------------- BODLEVEL (2.7V)
  32. # ATMega8 FUSE_H (Fuse high byte):
  33. # 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
  34. # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
  35. # | | | | | +-------- BOOTSZ1
  36. # | | | | + --------- EESAVE (don't preserve EEPROM over chip erase)
  37. # | | | +-------------- CKOPT (full output swing)
  38. # | | +---------------- SPIEN (allow serial programming)
  39. # | +------------------ WDTON (WDT not always on)
  40. # +-------------------- RSTDISBL (reset pin is enabled)
  41. #
  42. ############################## ATMega48/88/168 ##############################
  43. # ATMega*8 FUSE_L (Fuse low byte):
  44. # 0xdf = 1 1 0 1 1 1 1 1
  45. # ^ ^ \ / \--+--/
  46. # | | | +------- CKSEL 3..0 (external >8M crystal)
  47. # | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
  48. # | +------------------ CKOUT (if 0: Clock output enabled)
  49. # +-------------------- CKDIV8 (if 0: divide by 8)
  50. # ATMega*8 FUSE_H (Fuse high byte):
  51. # 0xde = 1 1 0 1 1 1 1 0
  52. # ^ ^ ^ ^ ^ \-+-/
  53. # | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V)
  54. # | | | | + --------- EESAVE (preserve EEPROM over chip erase)
  55. # | | | +-------------- WDTON (if 0: watchdog always on)
  56. # | | +---------------- SPIEN (allow serial programming)
  57. # | +------------------ DWEN (debug wire enable)
  58. # +-------------------- RSTDISBL (reset pin is enabled)
  59. #
  60. ############################## ATTiny25/45/85 ###############################
  61. # ATMega*5 FUSE_L (Fuse low byte):
  62. # 0xef = 1 1 1 0 1 1 1 1
  63. # ^ ^ \+/ \--+--/
  64. # | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
  65. # | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
  66. # | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
  67. # +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
  68. # ATMega*5 FUSE_H (Fuse high byte):
  69. # 0xdd = 1 1 0 1 1 1 0 1
  70. # ^ ^ ^ ^ ^ \-+-/
  71. # | | | | | +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V)
  72. # | | | | +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved)
  73. # | | | +-------------- WDTON (watchdog timer always on -> disable)
  74. # | | +---------------- SPIEN (enable serial programming -> enabled)
  75. # | +------------------ DWEN (debug wire enable)
  76. # +-------------------- RSTDISBL (disable external reset -> enabled)
  77. #
  78. ################################ ATTiny2313 #################################
  79. # ATTiny2313 FUSE_L (Fuse low byte):
  80. # 0xef = 1 1 1 0 1 1 1 1
  81. # ^ ^ \+/ \--+--/
  82. # | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
  83. # | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
  84. # | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
  85. # +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
  86. # ATTiny2313 FUSE_H (Fuse high byte):
  87. # 0xdb = 1 1 0 1 1 0 1 1
  88. # ^ ^ ^ ^ \-+-/ ^
  89. # | | | | | +---- RSTDISBL (disable external reset -> enabled)
  90. # | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V)
  91. # | | | +-------------- WDTON (watchdog timer always on -> disable)
  92. # | | +---------------- SPIEN (enable serial programming -> enabled)
  93. # | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved)
  94. # +-------------------- DWEN (debug wire enable)
  95. # symbolic targets:
  96. help:
  97. @echo "This Makefile has no default rule. Use one of the following:"
  98. @echo "make hex ....... to build main.hex"
  99. @echo "make program ... to flash fuses and firmware"
  100. @echo "make fuse ...... to flash the fuses"
  101. @echo "make flash ..... to flash the firmware (use this on metaboard)"
  102. @echo "make clean ..... to delete objects and hex file"
  103. hex: main.hex
  104. program: flash fuse
  105. # rule for programming fuse bits:
  106. fuse:
  107. @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
  108. { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
  109. $(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
  110. # rule for uploading firmware:
  111. flash: main.hex
  112. $(AVRDUDE) -U flash:w:main.hex:i
  113. # rule for deleting dependent files (those which can be built by Make):
  114. clean:
  115. 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
  116. # Generic rule for compiling C files:
  117. .c.o:
  118. $(COMPILE) -c $< -o $@
  119. # Generic rule for assembling Assembler source files:
  120. .S.o:
  121. $(COMPILE) -x assembler-with-cpp -c $< -o $@
  122. # "-x assembler-with-cpp" should not be necessary since this is the default
  123. # file type for the .S (with capital S) extension. However, upper case
  124. # characters are not always preserved on Windows. To ensure WinAVR
  125. # compatibility define the file type manually.
  126. # Generic rule for compiling C to assembler, used for debugging only.
  127. .c.s:
  128. $(COMPILE) -S $< -o $@
  129. # file targets:
  130. # Since we don't want to ship the driver multipe times, we copy it into this project:
  131. usbdrv:
  132. cp -r ../../../usbdrv .
  133. main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
  134. $(COMPILE) -o main.elf $(OBJECTS)
  135. main.hex: main.elf
  136. rm -f main.hex main.eep.hex
  137. avr-objcopy -j .text -j .data -O ihex main.elf main.hex
  138. avr-size main.hex
  139. # debugging targets:
  140. disasm: main.elf
  141. avr-objdump -d main.elf
  142. cpp:
  143. $(COMPILE) -E main.c