logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

bootloader.mk (4914B)


  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. FIRMWARE_FORMAT?=hex
  39. ifeq ($(strip $(BOOTLOADER)), custom)
  40. OPT_DEFS += -DBOOTLOADER_CUSTOM
  41. BOOTLOADER_TYPE = custom
  42. endif
  43. ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
  44. OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
  45. OPT_DEFS += -DBOOTLOADER_DFU
  46. BOOTLOADER_TYPE = dfu
  47. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  48. BOOTLOADER_SIZE = 4096
  49. endif
  50. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  51. BOOTLOADER_SIZE = 8192
  52. endif
  53. endif
  54. ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
  55. OPT_DEFS += -DBOOTLOADER_LUFA_DFU
  56. OPT_DEFS += -DBOOTLOADER_DFU
  57. BOOTLOADER_TYPE = dfu
  58. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  59. BOOTLOADER_SIZE ?= 4096
  60. endif
  61. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  62. BOOTLOADER_SIZE ?= 8192
  63. endif
  64. endif
  65. ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
  66. OPT_DEFS += -DBOOTLOADER_QMK_DFU
  67. OPT_DEFS += -DBOOTLOADER_DFU
  68. BOOTLOADER_TYPE = dfu
  69. ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
  70. BOOTLOADER_SIZE ?= 4096
  71. endif
  72. ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
  73. BOOTLOADER_SIZE ?= 8192
  74. endif
  75. endif
  76. ifeq ($(strip $(BOOTLOADER)), qmk-hid)
  77. OPT_DEFS += -DBOOTLOADER_QMK_HID
  78. OPT_DEFS += -DBOOTLOADER_HID
  79. BOOTLOADER_TYPE = dfu
  80. BOOTLOADER_SIZE ?= 4096
  81. endif
  82. ifeq ($(strip $(BOOTLOADER)), halfkay)
  83. OPT_DEFS += -DBOOTLOADER_HALFKAY
  84. BOOTLOADER_TYPE = halfkay
  85. # Teensy 2.0
  86. ifeq ($(strip $(MCU)), atmega32u4)
  87. BOOTLOADER_SIZE = 512
  88. endif
  89. # Teensy 2.0++
  90. ifeq ($(strip $(MCU)), at90usb1286)
  91. BOOTLOADER_SIZE = 1024
  92. endif
  93. endif
  94. ifeq ($(strip $(BOOTLOADER)), caterina)
  95. OPT_DEFS += -DBOOTLOADER_CATERINA
  96. BOOTLOADER_TYPE = caterina
  97. BOOTLOADER_SIZE = 4096
  98. endif
  99. ifeq ($(strip $(BOOTLOADER)), bootloadhid)
  100. OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
  101. BOOTLOADER_TYPE = bootloadhid
  102. BOOTLOADER_SIZE = 4096
  103. endif
  104. ifeq ($(strip $(BOOTLOADER)), usbasploader)
  105. OPT_DEFS += -DBOOTLOADER_USBASP
  106. BOOTLOADER_TYPE = usbasploader
  107. BOOTLOADER_SIZE = 4096
  108. endif
  109. ifeq ($(strip $(BOOTLOADER)), lufa-ms)
  110. OPT_DEFS += -DBOOTLOADER_MS
  111. BOOTLOADER_TYPE = dfu
  112. BOOTLOADER_SIZE ?= 8192
  113. FIRMWARE_FORMAT = bin
  114. cpfirmware: lufa_warning
  115. .INTERMEDIATE: lufa_warning
  116. lufa_warning: $(FIRMWARE_FORMAT)
  117. $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
  118. $(info LUFA MASS STORAGE Bootloader selected)
  119. $(info DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!)
  120. $(info It is extremely prone to bricking, and is only included to support existing boards.)
  121. $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
  122. endif
  123. ifdef BOOTLOADER_SIZE
  124. OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
  125. endif
  126. ifeq ($(strip $(BOOTLOADER_TYPE)),)
  127. ifneq ($(strip $(BOOTLOADER)),)
  128. $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
  129. else
  130. $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
  131. endif
  132. endif