upload
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

lufa_avrdude.mk 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #
  2. # LUFA Library
  3. # Copyright (C) Dean Camera, 2014.
  4. #
  5. # dean [at] fourwalledcubicle [dot] com
  6. # www.lufa-lib.org
  7. #
  8. LUFA_BUILD_MODULES += AVRDUDE
  9. LUFA_BUILD_TARGETS += avrdude avrdude-ee
  10. LUFA_BUILD_MANDATORY_VARS += MCU TARGET
  11. LUFA_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
  12. LUFA_BUILD_PROVIDED_VARS +=
  13. LUFA_BUILD_PROVIDED_MACROS +=
  14. # -----------------------------------------------------------------------------
  15. # LUFA AVRDUDE Programmer Buildsystem Makefile Module.
  16. # -----------------------------------------------------------------------------
  17. # DESCRIPTION:
  18. # Provides a set of targets to re-program a device using the open source
  19. # avr-dude utility.
  20. # -----------------------------------------------------------------------------
  21. # TARGETS:
  22. #
  23. # avrdude - Program target FLASH with application using
  24. # avrdude
  25. # avrdude-ee - Program target EEPROM with application data
  26. # using avrdude
  27. #
  28. # MANDATORY PARAMETERS:
  29. #
  30. # MCU - Microcontroller device model name
  31. # TARGET - Application name
  32. #
  33. # OPTIONAL PARAMETERS:
  34. #
  35. # AVRDUDE_PROGRAMMER - Name of programming hardware to use
  36. # AVRDUDE_PORT - Name of communication port to use
  37. # AVRDUDE_FLAGS - Flags to pass to avr-dude
  38. #
  39. # PROVIDED VARIABLES:
  40. #
  41. # (None)
  42. #
  43. # PROVIDED MACROS:
  44. #
  45. # (None)
  46. #
  47. # -----------------------------------------------------------------------------
  48. SHELL = /bin/sh
  49. ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
  50. ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
  51. ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
  52. # Default values of optionally user-supplied variables
  53. AVRDUDE_PROGRAMMER ?= jtagicemkii
  54. AVRDUDE_PORT ?= usb
  55. AVRDUDE_FLAGS ?=
  56. # Sanity check user supplied values
  57. $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
  58. $(call ERROR_IF_EMPTY, MCU)
  59. $(call ERROR_IF_EMPTY, TARGET)
  60. $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
  61. $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
  62. # Output Messages
  63. MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
  64. # Construct base avrdude command flags
  65. BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
  66. # Programs in the target FLASH memory using AVRDUDE
  67. avrdude: $(TARGET).hex $(MAKEFILE_LIST)
  68. @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
  69. avrdude $(BASE_AVRDUDE_FLAGS) -U flash:w:$< $(AVRDUDE_FLAGS)
  70. # Programs in the target EEPROM memory using AVRDUDE
  71. avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
  72. @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
  73. avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
  74. # Phony build targets for this module
  75. .PHONY: avrdude avrdude-ee