dfu.mk 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 += DFU
  9. DMBS_BUILD_TARGETS += flip flip-ee dfu dfu-ee
  10. DMBS_BUILD_MANDATORY_VARS += MCU TARGET
  11. DMBS_BUILD_OPTIONAL_VARS +=
  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. # Sanity-check values of mandatory user-supplied variables
  20. $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
  21. $(call ERROR_IF_EMPTY, MCU)
  22. $(call ERROR_IF_EMPTY, TARGET)
  23. # Output Messages
  24. MSG_COPY_CMD := ' [CP] :'
  25. MSG_REMOVE_CMD := ' [RM] :'
  26. MSG_DFU_CMD := ' [DFU] :'
  27. # Programs in the target FLASH memory using BATCHISP, the command line tool used by FLIP
  28. flip: $(TARGET).hex $(MAKEFILE_LIST)
  29. @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
  30. batchisp -hardware usb -device $(MCU) -operation erase f loadbuffer $< program
  31. batchisp -hardware usb -device $(MCU) -operation start reset 0
  32. # Programs in the target EEPROM memory using BATCHISP, the command line tool used by FLIP
  33. flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
  34. @echo $(MSG_COPY_CMD) Copying EEP file to temporary file \"$<.hex\"
  35. cp $< $<.hex
  36. @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
  37. batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program
  38. batchisp -hardware usb -device $(MCU) -operation start reset 0
  39. @echo $(MSG_REMOVE_CMD) Removing temporary file \"$<.hex\"
  40. rm $<.hex
  41. # Programs in the target FLASH memory using DFU-PROGRAMMER
  42. dfu: $(TARGET).hex $(MAKEFILE_LIST)
  43. @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
  44. dfu-programmer $(MCU) erase
  45. dfu-programmer $(MCU) flash $<
  46. dfu-programmer $(MCU) reset
  47. # Programs in the target EEPROM memory using DFU-PROGRAMMER
  48. dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
  49. @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
  50. dfu-programmer $(MCU) flash --eeprom $<
  51. dfu-programmer $(MCU) reset
  52. # Phony build targets for this module
  53. .PHONY: $(DMBS_BUILD_TARGETS)