Parent directory

bootloader.mk

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