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.

139 lines
4.7 KiB

  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. # Current options:
  21. #
  22. # AVR:
  23. # halfkay PJRC Teensy
  24. # caterina Pro Micro (Sparkfun/generic)
  25. # atmel-dfu Atmel factory DFU
  26. # lufa-dfu LUFA DFU
  27. # qmk-dfu QMK DFU (LUFA + blinkenlight)
  28. # bootloadHID HIDBootFlash compatible (ATmega32A)
  29. # USBasp USBaspLoader (ATmega328P)
  30. # ARM:
  31. # kiibohd Input:Club Kiibohd bootloader (only used on their boards)
  32. # stm32duino STM32Duino (STM32F103x8)
  33. # stm32-dfu STM32 USB DFU in ROM
  34. # apm32-dfu APM32 USB DFU in ROM
  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)), atmel-dfu)
  39. OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
  40. OPT_DEFS += -DBOOTLOADER_DFU
  41. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  42. BOOTLOADER_SIZE = 4096
  43. endif
  44. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  45. BOOTLOADER_SIZE = 8192
  46. endif
  47. endif
  48. ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
  49. OPT_DEFS += -DBOOTLOADER_LUFA_DFU
  50. OPT_DEFS += -DBOOTLOADER_DFU
  51. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  52. BOOTLOADER_SIZE = 4096
  53. endif
  54. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  55. BOOTLOADER_SIZE = 8192
  56. endif
  57. endif
  58. ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
  59. OPT_DEFS += -DBOOTLOADER_QMK_DFU
  60. OPT_DEFS += -DBOOTLOADER_DFU
  61. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  62. BOOTLOADER_SIZE = 4096
  63. endif
  64. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  65. BOOTLOADER_SIZE = 8192
  66. endif
  67. endif
  68. ifeq ($(strip $(BOOTLOADER)), halfkay)
  69. OPT_DEFS += -DBOOTLOADER_HALFKAY
  70. ifeq ($(strip $(MCU)), atmega32u4)
  71. BOOTLOADER_SIZE = 512
  72. endif
  73. ifeq ($(strip $(MCU)), at90usb1286)
  74. BOOTLOADER_SIZE = 1024
  75. endif
  76. endif
  77. ifeq ($(strip $(BOOTLOADER)), caterina)
  78. OPT_DEFS += -DBOOTLOADER_CATERINA
  79. BOOTLOADER_SIZE = 4096
  80. endif
  81. ifeq ($(strip $(BOOTLOADER)), bootloadHID)
  82. OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
  83. BOOTLOADER_SIZE = 4096
  84. endif
  85. ifeq ($(strip $(BOOTLOADER)), USBasp)
  86. OPT_DEFS += -DBOOTLOADER_USBASP
  87. BOOTLOADER_SIZE = 4096
  88. endif
  89. ifeq ($(strip $(BOOTLOADER)), lufa-ms)
  90. # DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!
  91. # It is extremely prone to bricking, and is only included to support existing boards.
  92. OPT_DEFS += -DBOOTLOADER_MS
  93. BOOTLOADER_SIZE = 6144
  94. FIRMWARE_FORMAT = bin
  95. endif
  96. ifdef BOOTLOADER_SIZE
  97. OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
  98. endif
  99. ifeq ($(strip $(BOOTLOADER)), stm32-dfu)
  100. OPT_DEFS += -DBOOTLOADER_STM32_DFU
  101. # Options to pass to dfu-util when flashing
  102. DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
  103. DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
  104. endif
  105. ifeq ($(strip $(BOOTLOADER)), apm32-dfu)
  106. OPT_DEFS += -DBOOTLOADER_APM32_DFU
  107. # Options to pass to dfu-util when flashing
  108. DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave
  109. DFU_SUFFIX_ARGS ?= -v 314B -p 0106
  110. endif
  111. ifeq ($(strip $(BOOTLOADER)), kiibohd)
  112. OPT_DEFS += -DBOOTLOADER_KIIBOHD
  113. ifeq ($(strip $(MCU_ORIG)), MK20DX128)
  114. MCU_LDSCRIPT = MK20DX128BLDR4
  115. endif
  116. ifeq ($(strip $(MCU_ORIG)), MK20DX256)
  117. MCU_LDSCRIPT = MK20DX256BLDR8
  118. endif
  119. # Options to pass to dfu-util when flashing
  120. DFU_ARGS = -d 1C11:B007
  121. DFU_SUFFIX_ARGS = -v 1C11 -p B007
  122. endif
  123. ifeq ($(strip $(BOOTLOADER)), stm32duino)
  124. OPT_DEFS += -DBOOTLOADER_STM32DUINO
  125. MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader
  126. BOARD = STM32_F103_STM32DUINO
  127. # STM32F103 does NOT have an USB bootloader in ROM (only serial), so setting anything here does not make much sense
  128. STM32_BOOTLOADER_ADDRESS = 0x80000000
  129. # Options to pass to dfu-util when flashing
  130. DFU_ARGS = -d 1EAF:0003 -a 2 -R
  131. DFU_SUFFIX_ARGS = -v 1EAF -p 0003
  132. endif