Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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
  22. TARGET = main
  23. AVRDUDE = avrdude -c usbasp -p $(DEVICE)
  24. SIZE = avr-size
  25. BOOT_ROM01 = ../../roms/qd16boot01.smc
  26. BOOT_ROM02 = ../../roms/qd16boot02.smc
  27. CONVERT_RLE = ../../scripts/conv_rle.py
  28. CONVERT_ZIP = ../../scripts/conv_zip.py
  29. ifeq ($(DEBUG),1)
  30. LDFLAGS =-Wl,-u,vfprintf
  31. CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0
  32. OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
  33. main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
  34. dump.o timer.o watchdog.o rle.c loader.o info.o shared_memory.o \
  35. system.o pwm.o util.o shell.o irq.o command.o testing.o
  36. else
  37. LDFLAGS =-Wl,-u
  38. CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
  39. OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o \
  40. sram.o crc.o debug.o dump.o rle.c loader.o \
  41. system.o util.o info.o shared_memory.o command.o irq.o \
  42. pwm.o
  43. endif
  44. COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
  45. ##############################################################################
  46. # Fuse values for particular devices
  47. ##############################################################################
  48. # http://www.engbedded.com/fusecalc/
  49. FUSE_L = 0xf7
  50. FUSE_H = 0xda
  51. all: hex
  52. help:
  53. @echo "This Makefile has no default rule. Use one of the following:"
  54. @echo "make hex ....... to build main.hex"
  55. @echo "make program ... to flash fuses and firmware"
  56. @echo "make fuse ...... to flash the fuses"
  57. @echo "make flash ..... to flash the firmware (use this on metaboard)"
  58. @echo "make clean ..... to delete objects and hex file"
  59. hex: main.hex
  60. @echo "$(TARGET) compiled for: $(DEVICE)"
  61. @./checksize $(TARGET).elf
  62. program: flash fuse
  63. # rule for programming fuse bits:
  64. fuse:
  65. @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
  66. { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
  67. $(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
  68. flash: main.hex
  69. $(AVRDUDE) -U flash:w:main.hex:i
  70. loader01:
  71. python $(CONVERT_RLE) $(BOOT_ROM01)
  72. loader02:
  73. python $(CONVERT_ZIP) $(BOOT_ROM02)
  74. .c.o:
  75. $(COMPILE) -c $< -o $@
  76. .S.o:
  77. $(COMPILE) -x assembler-with-cpp -c $< -o $@
  78. .c.s:
  79. $(COMPILE) -S $< -o $@
  80. usbdrv:
  81. cp -r ../../../usbdrv .
  82. main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
  83. $(COMPILE) -o main.elf $(OBJECTS) $(LDFLAGS)
  84. main.hex: main.elf
  85. rm -f main.hex main.eep.hex
  86. avr-objcopy -j .text -j .data -O ihex main.elf main.hex
  87. avr-size main.hex
  88. disasm: main.elf
  89. avr-objdump -d main.elf
  90. cpp:
  91. $(COMPILE) -E main.c
  92. clean:
  93. 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