bootloader.mk 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 ARM:
  22. # halfkay PJRC Teensy
  23. # kiibohd Input:Club Kiibohd bootloader (only used on their boards)
  24. # stm32duino STM32Duino (STM32F103x8)
  25. # stm32-dfu STM32 USB DFU in ROM
  26. # apm32-dfu APM32 USB DFU in ROM
  27. # wb32-dfu WB32 USB DFU in ROM
  28. # tinyuf2 TinyUF2
  29. # rp2040 Raspberry Pi RP2040
  30. # Current options for RISC-V:
  31. # gd32v-dfu GD32V USB DFU in ROM
  32. #
  33. # If you need to provide your own implementation, you can set inside `rules.mk`
  34. # `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
  35. # the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
  36. # which functions may be overridden.
  37. ifeq ($(strip $(BOOTLOADER)), custom)
  38. OPT_DEFS += -DBOOTLOADER_CUSTOM
  39. BOOTLOADER_TYPE = custom
  40. endif
  41. ifeq ($(strip $(BOOTLOADER)), halfkay)
  42. OPT_DEFS += -DBOOTLOADER_HALFKAY
  43. BOOTLOADER_TYPE = halfkay
  44. # Teensy LC, 3.0, 3.1/2, 3.5, 3.6
  45. ifneq (,$(filter $(MCU_ORIG), MKL26Z64 MK20DX128 MK20DX256 MK64FX512 MK66FX1M0))
  46. FIRMWARE_FORMAT = hex
  47. endif
  48. endif
  49. ifeq ($(strip $(BOOTLOADER)), stm32-dfu)
  50. OPT_DEFS += -DBOOTLOADER_STM32_DFU
  51. BOOTLOADER_TYPE = stm32_dfu
  52. # Options to pass to dfu-util when flashing
  53. DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
  54. DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
  55. endif
  56. ifeq ($(strip $(BOOTLOADER)), apm32-dfu)
  57. OPT_DEFS += -DBOOTLOADER_APM32_DFU
  58. BOOTLOADER_TYPE = stm32_dfu
  59. # Options to pass to dfu-util when flashing
  60. DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave
  61. DFU_SUFFIX_ARGS ?= -v 314B -p 0106
  62. endif
  63. ifeq ($(strip $(BOOTLOADER)), gd32v-dfu)
  64. OPT_DEFS += -DBOOTLOADER_GD32V_DFU
  65. BOOTLOADER_TYPE = gd32v_dfu
  66. # Options to pass to dfu-util when flashing
  67. DFU_ARGS ?= -d 28E9:0189 -a 0 -s 0x08000000:leave
  68. DFU_SUFFIX_ARGS ?= -v 28E9 -p 0189
  69. endif
  70. ifeq ($(strip $(BOOTLOADER)), kiibohd)
  71. OPT_DEFS += -DBOOTLOADER_KIIBOHD
  72. BOOTLOADER_TYPE = kiibohd
  73. ifeq ($(strip $(MCU_ORIG)), MK20DX128)
  74. MCU_LDSCRIPT = MK20DX128BLDR4
  75. endif
  76. ifeq ($(strip $(MCU_ORIG)), MK20DX256)
  77. MCU_LDSCRIPT = MK20DX256BLDR8
  78. endif
  79. # Options to pass to dfu-util when flashing
  80. DFU_ARGS = -d 1C11:B007
  81. DFU_SUFFIX_ARGS = -v 1C11 -p B007
  82. endif
  83. ifeq ($(strip $(BOOTLOADER)), stm32duino)
  84. OPT_DEFS += -DBOOTLOADER_STM32DUINO
  85. MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader
  86. BOARD = STM32_F103_STM32DUINO
  87. BOOTLOADER_TYPE = stm32duino
  88. # Options to pass to dfu-util when flashing
  89. DFU_ARGS = -d 1EAF:0003 -a 2 -R
  90. DFU_SUFFIX_ARGS = -v 1EAF -p 0003
  91. endif
  92. ifeq ($(strip $(BOOTLOADER)), tinyuf2)
  93. OPT_DEFS += -DBOOTLOADER_TINYUF2
  94. BOOTLOADER_TYPE = tinyuf2
  95. FIRMWARE_FORMAT = uf2
  96. endif
  97. ifeq ($(strip $(BOOTLOADER)), rp2040)
  98. OPT_DEFS += -DBOOTLOADER_RP2040
  99. BOOTLOADER_TYPE = rp2040
  100. endif
  101. ifeq ($(strip $(BOOTLOADER)), wb32-dfu)
  102. OPT_DEFS += -DBOOTLOADER_WB32_DFU
  103. BOOTLOADER_TYPE = wb32_dfu
  104. endif
  105. ifeq ($(strip $(BOOTLOADER_TYPE)),)
  106. ifneq ($(strip $(BOOTLOADER)),)
  107. $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
  108. else
  109. $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
  110. endif
  111. endif