bootloader.mk 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. # qmk-hid QMK HID (LUFA + blinkenlight)
  29. # bootloadhid HIDBootFlash compatible (ATmega32A)
  30. # usbasploader USBaspLoader (ATmega328P)
  31. # ARM:
  32. # kiibohd Input:Club Kiibohd bootloader (only used on their boards)
  33. # stm32duino STM32Duino (STM32F103x8)
  34. # stm32-dfu STM32 USB DFU in ROM
  35. # apm32-dfu APM32 USB DFU in ROM
  36. # RISC-V:
  37. # gd32v-dfu GD32V USB DFU in ROM
  38. #
  39. # BOOTLOADER_SIZE can still be defined manually, but it's recommended
  40. # you add any possible configuration to this list
  41. ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
  42. OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
  43. OPT_DEFS += -DBOOTLOADER_DFU
  44. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  45. BOOTLOADER_SIZE = 4096
  46. endif
  47. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  48. BOOTLOADER_SIZE = 8192
  49. endif
  50. endif
  51. ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
  52. OPT_DEFS += -DBOOTLOADER_LUFA_DFU
  53. OPT_DEFS += -DBOOTLOADER_DFU
  54. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  55. BOOTLOADER_SIZE ?= 4096
  56. endif
  57. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  58. BOOTLOADER_SIZE ?= 8192
  59. endif
  60. endif
  61. ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
  62. OPT_DEFS += -DBOOTLOADER_QMK_DFU
  63. OPT_DEFS += -DBOOTLOADER_DFU
  64. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  65. BOOTLOADER_SIZE ?= 4096
  66. endif
  67. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  68. BOOTLOADER_SIZE ?= 8192
  69. endif
  70. endif
  71. ifeq ($(strip $(BOOTLOADER)), qmk-hid)
  72. OPT_DEFS += -DBOOTLOADER_QMK_HID
  73. OPT_DEFS += -DBOOTLOADER_HID
  74. BOOTLOADER_SIZE ?= 4096
  75. endif
  76. ifeq ($(strip $(BOOTLOADER)), halfkay)
  77. OPT_DEFS += -DBOOTLOADER_HALFKAY
  78. ifeq ($(strip $(MCU)), atmega32u4)
  79. BOOTLOADER_SIZE = 512
  80. endif
  81. ifeq ($(strip $(MCU)), at90usb1286)
  82. BOOTLOADER_SIZE = 1024
  83. endif
  84. endif
  85. ifeq ($(strip $(BOOTLOADER)), caterina)
  86. OPT_DEFS += -DBOOTLOADER_CATERINA
  87. BOOTLOADER_SIZE = 4096
  88. endif
  89. ifneq (,$(filter $(BOOTLOADER), bootloadhid bootloadHID))
  90. OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
  91. BOOTLOADER_SIZE = 4096
  92. endif
  93. ifneq (,$(filter $(BOOTLOADER), usbasploader USBasp))
  94. OPT_DEFS += -DBOOTLOADER_USBASP
  95. BOOTLOADER_SIZE = 4096
  96. endif
  97. ifeq ($(strip $(BOOTLOADER)), lufa-ms)
  98. OPT_DEFS += -DBOOTLOADER_MS
  99. BOOTLOADER_SIZE ?= 8192
  100. FIRMWARE_FORMAT = bin
  101. cpfirmware: lufa_warning
  102. .INTERMEDIATE: lufa_warning
  103. lufa_warning: $(FIRMWARE_FORMAT)
  104. $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
  105. $(info LUFA MASS STORAGE Bootloader selected)
  106. $(info DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!)
  107. $(info It is extremely prone to bricking, and is only included to support existing boards.)
  108. $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
  109. endif
  110. ifdef BOOTLOADER_SIZE
  111. OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
  112. endif
  113. ifeq ($(strip $(BOOTLOADER)), stm32-dfu)
  114. OPT_DEFS += -DBOOTLOADER_STM32_DFU
  115. # Options to pass to dfu-util when flashing
  116. DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
  117. DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
  118. endif
  119. ifeq ($(strip $(BOOTLOADER)), apm32-dfu)
  120. OPT_DEFS += -DBOOTLOADER_APM32_DFU
  121. # Options to pass to dfu-util when flashing
  122. DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave
  123. DFU_SUFFIX_ARGS ?= -v 314B -p 0106
  124. endif
  125. ifeq ($(strip $(BOOTLOADER)), gd32v-dfu)
  126. OPT_DEFS += -DBOOTLOADER_GD32V_DFU
  127. # Options to pass to dfu-util when flashing
  128. DFU_ARGS ?= -d 28E9:0189 -a 0 -s 0x08000000:leave
  129. DFU_SUFFIX_ARGS ?= -v 28E9 -p 0189
  130. endif
  131. ifeq ($(strip $(BOOTLOADER)), kiibohd)
  132. OPT_DEFS += -DBOOTLOADER_KIIBOHD
  133. ifeq ($(strip $(MCU_ORIG)), MK20DX128)
  134. MCU_LDSCRIPT = MK20DX128BLDR4
  135. endif
  136. ifeq ($(strip $(MCU_ORIG)), MK20DX256)
  137. MCU_LDSCRIPT = MK20DX256BLDR8
  138. endif
  139. # Options to pass to dfu-util when flashing
  140. DFU_ARGS = -d 1C11:B007
  141. DFU_SUFFIX_ARGS = -v 1C11 -p B007
  142. endif
  143. ifeq ($(strip $(BOOTLOADER)), stm32duino)
  144. OPT_DEFS += -DBOOTLOADER_STM32DUINO
  145. MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader
  146. BOARD = STM32_F103_STM32DUINO
  147. # STM32F103 does NOT have an USB bootloader in ROM (only serial), so setting anything here does not make much sense
  148. STM32_BOOTLOADER_ADDRESS = 0x80000000
  149. # Options to pass to dfu-util when flashing
  150. DFU_ARGS = -d 1EAF:0003 -a 2 -R
  151. DFU_SUFFIX_ARGS = -v 1EAF -p 0003
  152. endif
  153. ifeq ($(strip $(BOOTLOADER)), tinyuf2)
  154. OPT_DEFS += -DBOOTLOADER_TINYUF2
  155. endif