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_dfu.mk 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 += 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. # Programs in the target FLASH memory using BATCHISP, the command line tool used by FLIP
  59. flip: $(TARGET).hex $(MAKEFILE_LIST)
  60. @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
  61. batchisp -hardware usb -device $(MCU) -operation erase f loadbuffer $< program
  62. batchisp -hardware usb -device $(MCU) -operation start reset 0
  63. # Programs in the target EEPROM memory using BATCHISP, the command line tool used by FLIP
  64. flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
  65. @echo $(MSG_COPY_CMD) Copying EEP file to temporary file \"$<.hex\"
  66. cp $< $<.hex
  67. @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
  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_REMOVE_CMD) Removing temporary file \"$<.hex\"
  71. rm $<.hex
  72. # Programs in the target FLASH memory using DFU-PROGRAMMER
  73. dfu: $(TARGET).hex $(MAKEFILE_LIST)
  74. @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
  75. dfu-programmer $(MCU) erase
  76. dfu-programmer $(MCU) flash $<
  77. dfu-programmer $(MCU) reset
  78. # Programs in the target EEPROM memory using DFU-PROGRAMMER
  79. dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
  80. @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
  81. dfu-programmer $(MCU) eeprom-flash $<
  82. dfu-programmer $(MCU) reset
  83. # Phony build targets for this module
  84. .PHONY: flip flip-ee dfu dfu-ee