Keyboard firmwares for Atmel AVR and Cortex-M
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.

lufa_dfu.mk 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #
  2. # LUFA Library
  3. # Copyright (C) Dean Camera, 2012.
  4. #
  5. # dean [at] fourwalledcubicle [dot] com
  6. # www.lufa-lib.org
  7. #
  8. LUFA_BUILD_MODULES += DFU
  9. LUFA_BUILD_TARGETS += flip flip-ee dfu dfu-ee
  10. LUFA_BUILD_MANDATORY_VARS += MCU TARGET
  11. LUFA_BUILD_OPTIONAL_VARS +=
  12. LUFA_BUILD_PROVIDED_VARS +=
  13. LUFA_BUILD_PROVIDED_MACROS +=
  14. # -----------------------------------------------------------------------------
  15. # LUFA DFU Bootloader Buildsystem Makefile Module.
  16. # -----------------------------------------------------------------------------
  17. # DESCRIPTION:
  18. # Provides a set of targets to re-program a device currently running a DFU
  19. # class bootloader with a project's FLASH and EEPROM files.
  20. # -----------------------------------------------------------------------------
  21. # TARGETS:
  22. #
  23. # flip - Program FLASH into target via Atmel FLIP
  24. # flip-ee - Program EEPROM into target via Atmel FLIP
  25. # dfu - Program FLASH into target via dfu-programmer
  26. # dfu-ee - Program EEPROM into target via dfu-programmer
  27. #
  28. # MANDATORY PARAMETERS:
  29. #
  30. # MCU - Microcontroller device model name
  31. # TARGET - Application name
  32. #
  33. # OPTIONAL PARAMETERS:
  34. #
  35. # (None)
  36. #
  37. # PROVIDED VARIABLES:
  38. #
  39. # (None)
  40. #
  41. # PROVIDED MACROS:
  42. #
  43. # (None)
  44. #
  45. # -----------------------------------------------------------------------------
  46. SHELL = /bin/sh
  47. ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
  48. ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
  49. ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
  50. # Sanity-check values of mandatory user-supplied variables
  51. $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
  52. $(call ERROR_IF_EMPTY, MCU)
  53. $(call ERROR_IF_EMPTY, TARGET)
  54. # Output Messages
  55. MSG_COPY_CMD := ' [CP] :'
  56. MSG_REMOVE_CMD := ' [RM] :'
  57. MSG_DFU_CMD := ' [DFU] :'
  58. flip: $(TARGET).hex $(MAKEFILE_LIST)
  59. @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
  60. batchisp -hardware usb -device $(MCU) -operation erase f
  61. batchisp -hardware usb -device $(MCU) -operation loadbuffer $< program
  62. batchisp -hardware usb -device $(MCU) -operation start reset 0
  63. flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
  64. @echo $(MSG_DFU_CMD) Copying EEP file to temporary file \"$<.hex\"
  65. cp $< $<.hex
  66. @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
  67. batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
  68. batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program
  69. batchisp -hardware usb -device $(MCU) -operation start reset 0
  70. @echo $(MSG_DFU_CMD) Removing temporary file \"$<.hex\"
  71. rm $<.hex
  72. dfu: $(TARGET).hex $(MAKEFILE_LIST)
  73. @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
  74. dfu-programmer $(MCU) erase
  75. dfu-programmer $(MCU) flash $<
  76. dfu-programmer $(MCU) reset
  77. dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
  78. @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
  79. dfu-programmer $(MCU) eeprom-flash $<
  80. dfu-programmer $(MCU) reset
  81. # Phony build targets for this module
  82. .PHONY: flip flip-ee dfu dfu-ee