makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # LUFA Library
  3. # Copyright (C) Dean Camera, 2018.
  4. #
  5. # dean [at] fourwalledcubicle [dot] com
  6. # www.lufa-lib.org
  7. #
  8. # --------------------------------------
  9. # LUFA Project Makefile.
  10. # --------------------------------------
  11. # Run "make help" for target help.
  12. MCU = at90usb1287
  13. ARCH = AVR8
  14. BOARD = USBKEY
  15. F_CPU = 8000000
  16. F_USB = $(F_CPU)
  17. OPTIMIZATION = s
  18. TARGET = BootloaderMassStorage
  19. SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S Lib/SCSI.c Lib/VirtualFAT.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
  20. LUFA_PATH = ../../LUFA
  21. CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
  22. LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
  23. # Flash size and bootloader section sizes of the target, in KB. These must
  24. # match the target's total FLASH size and the bootloader size set in the
  25. # device's fuses.
  26. FLASH_SIZE_KB = 128
  27. BOOT_SECTION_SIZE_KB = 8
  28. # Bootloader address calculation formulas
  29. # Do not modify these macros, but rather modify the dependent values above.
  30. CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
  31. BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
  32. BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
  33. # Bootloader linker section flags for relocating the API table sections to
  34. # known FLASH addresses - these should not normally be user-edited.
  35. BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
  36. BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
  37. BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
  38. BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
  39. # Check if the bootloader needs an AUX section, located before the real bootloader section to store some of the
  40. # bootloader code. This is required for 32KB and smaller devices, where the actual bootloader is 6KB but the maximum
  41. # bootloader section size is 4KB. The actual usable application space will be reduced by 6KB for these devices.
  42. ifeq ($(BOOT_SECTION_SIZE_KB),8)
  43. CC_FLAGS += -DAUX_BOOT_SECTION_SIZE=0
  44. else
  45. AUX_BOOT_SECTION_SIZE_KB = (6 - $(BOOT_SECTION_SIZE_KB))
  46. CC_FLAGS += -DAUX_BOOT_SECTION_SIZE='($(AUX_BOOT_SECTION_SIZE_KB) * 1024)'
  47. LD_FLAGS += -Wl,--section-start=.boot_aux=$(call BOOT_SEC_OFFSET, (($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024 - 16))
  48. LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .boot_aux_trampoline, Boot_AUX_Trampoline, ($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024)
  49. endif
  50. # Default target
  51. all:
  52. # Include LUFA-specific DMBS extension modules
  53. DMBS_LUFA_PATH ?= $(LUFA_PATH)/Build/LUFA
  54. include $(DMBS_LUFA_PATH)/lufa-sources.mk
  55. include $(DMBS_LUFA_PATH)/lufa-gcc.mk
  56. # Include common DMBS build system modules
  57. DMBS_PATH ?= $(LUFA_PATH)/Build/DMBS/DMBS
  58. include $(DMBS_PATH)/core.mk
  59. include $(DMBS_PATH)/cppcheck.mk
  60. include $(DMBS_PATH)/doxygen.mk
  61. include $(DMBS_PATH)/dfu.mk
  62. include $(DMBS_PATH)/gcc.mk
  63. include $(DMBS_PATH)/hid.mk
  64. include $(DMBS_PATH)/avrdude.mk
  65. include $(DMBS_PATH)/atprogram.mk