bootloader.mk 5.3 KB

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