Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # The number of microsteps
  2. STEPS := 18
  3. ASM := avra
  4. ASMFLAGS := -I /usr/share/avra
  5. AVRDUDE := avrdude
  6. AVRDUDE_ARCH := m8
  7. AVRDUDE_SPEED := 1
  8. PROGRAMMER := avrisp2
  9. PROGPORT := usb
  10. CC := gcc
  11. CFLAGS := -O2 --std=c99 -Wall -Wextra
  12. DEBUG := 0
  13. # Fuses: Ext clock; 4ms SUT; BOD 4V; WDT always-on
  14. LFUSE := 0x10
  15. HFUSE := 0x99
  16. NAME := m8driver
  17. HEX := $(NAME).S.hex
  18. ifneq ($(DEBUG),0)
  19. ASMFLAGS += --define DEBUG
  20. endif
  21. all: $(HEX)
  22. tabgen: tabgen.o
  23. $(CC) $(CFLAGS) -o tabgen tabgen.o $(LDFLAGS) -lm
  24. tables.S: tabgen
  25. ./tabgen $(STEPS) > tables.S
  26. $(HEX): m8driver.S tables.S
  27. $(ASM) $(ASMFLAGS) --listfile $(NAME).S.lst --listmac $(NAME).S
  28. -srec_cat $(HEX) -Intel -Output $(NAME).S.bin -Binary
  29. @echo
  30. @echo "Successfully built the firmware"
  31. install: all
  32. $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
  33. -c $(PROGRAMMER) -P $(PROGPORT) -U flash:w:$(HEX)
  34. dumphex:
  35. $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
  36. -c $(PROGRAMMER) -P $(PROGPORT) -U flash:r:$(HEX).dump:i
  37. dumpbin:
  38. $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
  39. -c $(PROGRAMMER) -P $(PROGPORT) -U flash:r:$(NAME).S.bin.dump:r
  40. avrdude:
  41. $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
  42. -c $(PROGRAMMER) -P $(PROGPORT) -t
  43. reset:
  44. $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \
  45. -c $(PROGRAMMER) -P $(PROGPORT) \
  46. -U signature:r:/dev/null:i -q -q
  47. writefuse:
  48. $(AVRDUDE) -B 10 -p $(AVRDUDE_ARCH) \
  49. -c $(PROGRAMMER) -P $(PROGPORT) -q -q \
  50. -U lfuse:w:$(LFUSE):m \
  51. -U hfuse:w:$(HFUSE):m
  52. clean:
  53. -rm -f *~ *.cof *.hex *.obj *.bin *.lst *.bak *.o tabgen tables.S