avrdude.mk 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #
  2. # DMBS Build System
  3. # Released into the public domain.
  4. #
  5. # dean [at] fourwalledcubicle [dot] com
  6. # www.fourwalledcubicle.com
  7. #
  8. DMBS_BUILD_MODULES += AVRDUDE
  9. DMBS_BUILD_TARGETS += avrdude avrdude-ee
  10. DMBS_BUILD_MANDATORY_VARS += MCU TARGET
  11. DMBS_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY
  12. DMBS_BUILD_PROVIDED_VARS +=
  13. DMBS_BUILD_PROVIDED_MACROS +=
  14. # Conditionally import the CORE module of DMBS if it is not already imported
  15. DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
  16. ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),)
  17. include $(DMBS_MODULE_PATH)/core.mk
  18. endif
  19. # Default values of optionally user-supplied variables
  20. AVRDUDE_PROGRAMMER ?= jtagicemkii
  21. AVRDUDE_PORT ?= usb
  22. AVRDUDE_FLAGS ?=
  23. AVRDUDE_MEMORY ?= flash
  24. # Sanity check user supplied values
  25. $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
  26. $(call ERROR_IF_EMPTY, MCU)
  27. $(call ERROR_IF_EMPTY, TARGET)
  28. $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
  29. $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
  30. # Output Messages
  31. MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
  32. # Construct base avrdude command flags
  33. BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
  34. # Programs in the target FLASH memory using AVRDUDE
  35. avrdude: $(TARGET).hex $(MAKEFILE_LIST)
  36. @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
  37. avrdude $(BASE_AVRDUDE_FLAGS) -U $(AVRDUDE_MEMORY):w:$< $(AVRDUDE_FLAGS)
  38. # Programs in the target EEPROM memory using AVRDUDE
  39. avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
  40. @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
  41. avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
  42. # Phony build targets for this module
  43. .PHONY: $(DMBS_BUILD_TARGETS)