qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

bootloader.mk (4710B)


      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 
     40 FIRMWARE_FORMAT?=bin
     41 
     42 ifeq ($(strip $(BOOTLOADER)), custom)
     43     OPT_DEFS += -DBOOTLOADER_CUSTOM
     44     BOOTLOADER_TYPE = custom
     45 endif
     46 
     47 ifeq ($(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
     55 endif
     56 ifeq ($(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
     63 endif
     64 ifeq ($(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
     71 endif
     72 ifeq ($(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
     79 endif
     80 ifeq ($(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
     94 endif
     95 ifeq ($(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
    103 endif
    104 ifeq ($(strip $(BOOTLOADER)), tinyuf2)
    105     OPT_DEFS += -DBOOTLOADER_TINYUF2
    106     BOOTLOADER_TYPE = tinyuf2
    107     FIRMWARE_FORMAT = uf2
    108 endif
    109 ifeq ($(strip $(BOOTLOADER)), uf2boot)
    110     OPT_DEFS += -DBOOTLOADER_UF2BOOT
    111     BOARD = STM32_F103_STM32DUINO
    112     BOOTLOADER_TYPE = uf2boot
    113     FIRMWARE_FORMAT = uf2
    114 endif
    115 ifeq ($(strip $(BOOTLOADER)), rp2040)
    116     OPT_DEFS += -DBOOTLOADER_RP2040
    117     BOOTLOADER_TYPE = rp2040
    118 endif
    119 ifeq ($(strip $(BOOTLOADER)), wb32-dfu)
    120     OPT_DEFS += -DBOOTLOADER_WB32_DFU
    121     BOOTLOADER_TYPE = wb32_dfu
    122 endif
    123 ifeq ($(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
    130 endif
    131 
    132 ifeq ($(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
    138 endif