avr.mk 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Programmer used for In System Programming
  2. ISP_PROG = usbasp
  3. # device the ISP programmer is connected to
  4. ISP_DEV =
  5. # Programmer used for serial programming (using the bootloader)
  6. SERIAL_PROG = avr109
  7. # device the serial programmer is connected to
  8. SERIAL_DEV = /dev/ttyS0
  9. # programs
  10. CC = avr-gcc
  11. OBJCOPY = avr-objcopy
  12. OBJDUMP = avr-objdump
  13. AS = avr-as
  14. CP = cp
  15. RM = rm -f
  16. AVRDUDE = avrdude
  17. SIZE = avr-size
  18. -include $(CURDIR)/config.mk
  19. # flags for avrdude
  20. ifeq ($(MCU),atmega8)
  21. AVRDUDE_MCU=m8
  22. endif
  23. ifeq ($(MCU),atmega48)
  24. AVRDUDE_MCU=m48
  25. endif
  26. ifeq ($(MCU),atmega88)
  27. AVRDUDE_MCU=m88
  28. endif
  29. ifeq ($(MCU),atmega168)
  30. AVRDUDE_MCU=m168
  31. endif
  32. ifeq ($(MCU),atmega644)
  33. AVRDUDE_MCU=m644
  34. endif
  35. AVRDUDE_FLAGS += -p $(AVRDUDE_MCU)
  36. # flags for the compiler
  37. CFLAGS += -g -Os -finline-limit=800 -mmcu=$(MCU) -DF_CPU=$(F_CPU) -std=gnu99
  38. ASFLAGS += -g -mmcu=$(MCU) -DF_CPU=$(F_CPU)
  39. # flags for the linker
  40. LDFLAGS += -mmcu=$(MCU)
  41. ifneq ($(DEBUG),)
  42. CFLAGS += -Wall -W -Wchar-subscripts -Wmissing-prototypes
  43. CFLAGS += -Wmissing-declarations -Wredundant-decls
  44. CFLAGS += -Wstrict-prototypes -Wshadow -Wbad-function-cast
  45. CFLAGS += -Winline -Wpointer-arith -Wsign-compare
  46. #CFLAGS += -Wunreachable-code -Wdisabled-optimization -Werror
  47. CFLAGS += -Wunreachable-code -Wdisabled-optimization
  48. CFLAGS += -Wcast-align -Wwrite-strings -Wnested-externs -Wundef
  49. CFLAGS += -Wa,-adhlns=$(basename $@).lst
  50. CFLAGS += -DDEBUG
  51. endif
  52. all:
  53. $(OBJECTS):
  54. clean:
  55. $(RM) *.hex *.eep.hex *.o *.lst *.lss
  56. .PHONY: all clean interactive-isp interactive-serial launch-bootloader
  57. flash:
  58. $(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -U flash:w:$<
  59. flash-eeprom-%: %.eep.hex
  60. $(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -U eeprom:w:$<
  61. %.hex: %
  62. $(OBJCOPY) -O ihex -R .eeprom $< $@
  63. %.eep.hex: %
  64. $(OBJCOPY) --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex -j .eeprom $< $@
  65. %.lss: %
  66. $(OBJDUMP) -h -S $< > $@
  67. %-size: %.hex
  68. $(SIZE) $<