bootloader.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # Copyright 2017 Jack Humbert
  2. #
  3. # This program is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. # If it's possible that multiple bootloaders can be used for one project,
  16. # you can leave this unset, and the correct size will be selected
  17. # automatically.
  18. #
  19. # Sets the bootloader defined in the keyboard's/keymap's rules.mk
  20. #
  21. # Current options for AVR:
  22. # halfkay PJRC Teensy
  23. # caterina Pro Micro (Sparkfun/generic)
  24. # atmel-dfu Atmel factory DFU
  25. # lufa-dfu LUFA DFU
  26. # qmk-dfu QMK DFU (LUFA + blinkenlight)
  27. # qmk-hid QMK HID (LUFA + blinkenlight)
  28. # bootloadhid HIDBootFlash compatible (ATmega32A)
  29. # usbasploader USBaspLoader (ATmega328P)
  30. #
  31. # If you need to provide your own implementation, you can set inside `rules.mk`
  32. # `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
  33. # the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
  34. # which functions may be overridden.
  35. #
  36. # BOOTLOADER_SIZE can still be defined manually, but it's recommended
  37. # you add any possible configuration to this list
  38. ifeq ($(strip $(BOOTLOADER)), custom)
  39. OPT_DEFS += -DBOOTLOADER_CUSTOM
  40. BOOTLOADER_TYPE = custom
  41. endif
  42. ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
  43. OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
  44. OPT_DEFS += -DBOOTLOADER_DFU
  45. BOOTLOADER_TYPE = dfu
  46. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  47. BOOTLOADER_SIZE = 4096
  48. endif
  49. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  50. BOOTLOADER_SIZE = 8192
  51. endif
  52. endif
  53. ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
  54. OPT_DEFS += -DBOOTLOADER_LUFA_DFU
  55. OPT_DEFS += -DBOOTLOADER_DFU
  56. BOOTLOADER_TYPE = dfu
  57. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  58. BOOTLOADER_SIZE ?= 4096
  59. endif
  60. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  61. BOOTLOADER_SIZE ?= 8192
  62. endif
  63. endif
  64. ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
  65. OPT_DEFS += -DBOOTLOADER_QMK_DFU
  66. OPT_DEFS += -DBOOTLOADER_DFU
  67. BOOTLOADER_TYPE = dfu
  68. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  69. BOOTLOADER_SIZE ?= 4096
  70. endif
  71. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  72. BOOTLOADER_SIZE ?= 8192
  73. endif
  74. endif
  75. ifeq ($(strip $(BOOTLOADER)), qmk-hid)
  76. OPT_DEFS += -DBOOTLOADER_QMK_HID
  77. OPT_DEFS += -DBOOTLOADER_HID
  78. BOOTLOADER_TYPE = dfu
  79. BOOTLOADER_SIZE ?= 4096
  80. endif
  81. ifeq ($(strip $(BOOTLOADER)), halfkay)
  82. OPT_DEFS += -DBOOTLOADER_HALFKAY
  83. BOOTLOADER_TYPE = halfkay
  84. # Teensy 2.0
  85. ifeq ($(strip $(MCU)), atmega32u4)
  86. BOOTLOADER_SIZE = 512
  87. endif
  88. # Teensy 2.0++
  89. ifeq ($(strip $(MCU)), at90usb1286)
  90. BOOTLOADER_SIZE = 1024
  91. endif
  92. endif
  93. ifeq ($(strip $(BOOTLOADER)), caterina)
  94. OPT_DEFS += -DBOOTLOADER_CATERINA
  95. BOOTLOADER_TYPE = caterina
  96. BOOTLOADER_SIZE = 4096
  97. endif
  98. ifeq ($(strip $(BOOTLOADER)), bootloadhid)
  99. OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
  100. BOOTLOADER_TYPE = bootloadhid
  101. BOOTLOADER_SIZE = 4096
  102. endif
  103. ifeq ($(strip $(BOOTLOADER)), usbasploader)
  104. OPT_DEFS += -DBOOTLOADER_USBASP
  105. BOOTLOADER_TYPE = usbasploader
  106. BOOTLOADER_SIZE = 4096
  107. endif
  108. ifeq ($(strip $(BOOTLOADER)), lufa-ms)
  109. OPT_DEFS += -DBOOTLOADER_MS
  110. BOOTLOADER_TYPE = dfu
  111. BOOTLOADER_SIZE ?= 8192
  112. FIRMWARE_FORMAT = bin
  113. cpfirmware: lufa_warning
  114. .INTERMEDIATE: lufa_warning
  115. lufa_warning: $(FIRMWARE_FORMAT)
  116. $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
  117. $(info LUFA MASS STORAGE Bootloader selected)
  118. $(info DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!)
  119. $(info It is extremely prone to bricking, and is only included to support existing boards.)
  120. $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
  121. endif
  122. ifdef BOOTLOADER_SIZE
  123. OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
  124. endif
  125. ifeq ($(strip $(BOOTLOADER_TYPE)),)
  126. ifneq ($(strip $(BOOTLOADER)),)
  127. $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
  128. else
  129. $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
  130. endif
  131. endif