diff options
Diffstat (limited to 'builddefs')
-rw-r--r-- | builddefs/bootloader.mk | 49 | ||||
-rw-r--r-- | builddefs/mcu_selection.mk | 77 | ||||
-rw-r--r-- | builddefs/message.mk | 5 |
3 files changed, 127 insertions, 4 deletions
diff --git a/builddefs/bootloader.mk b/builddefs/bootloader.mk index ccb92392d9..56ef7ff5d8 100644 --- a/builddefs/bootloader.mk +++ b/builddefs/bootloader.mk @@ -30,6 +30,7 @@ # bootloadhid HIDBootFlash compatible (ATmega32A) # usbasploader USBaspLoader (ATmega328P) # ARM: +# halfkay PJRC Teensy # kiibohd Input:Club Kiibohd bootloader (only used on their boards) # stm32duino STM32Duino (STM32F103x8) # stm32-dfu STM32 USB DFU in ROM @@ -37,12 +38,23 @@ # RISC-V: # gd32v-dfu GD32V USB DFU in ROM # +# If you need to provide your own implementation, you can set inside `rules.mk` +# `BOOTLOADER = custom` -- you'll need to provide your own implementations. See +# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see +# which functions may be overridden. +# # BOOTLOADER_SIZE can still be defined manually, but it's recommended # you add any possible configuration to this list +ifeq ($(strip $(BOOTLOADER)), custom) + OPT_DEFS += -DBOOTLOADER_CUSTOM + BOOTLOADER_TYPE = custom +endif ifeq ($(strip $(BOOTLOADER)), atmel-dfu) OPT_DEFS += -DBOOTLOADER_ATMEL_DFU OPT_DEFS += -DBOOTLOADER_DFU + BOOTLOADER_TYPE = dfu + ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) BOOTLOADER_SIZE = 4096 endif @@ -53,6 +65,8 @@ endif ifeq ($(strip $(BOOTLOADER)), lufa-dfu) OPT_DEFS += -DBOOTLOADER_LUFA_DFU OPT_DEFS += -DBOOTLOADER_DFU + BOOTLOADER_TYPE = dfu + ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) BOOTLOADER_SIZE ?= 4096 endif @@ -63,6 +77,8 @@ endif ifeq ($(strip $(BOOTLOADER)), qmk-dfu) OPT_DEFS += -DBOOTLOADER_QMK_DFU OPT_DEFS += -DBOOTLOADER_DFU + BOOTLOADER_TYPE = dfu + ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) BOOTLOADER_SIZE ?= 4096 endif @@ -73,10 +89,14 @@ endif ifeq ($(strip $(BOOTLOADER)), qmk-hid) OPT_DEFS += -DBOOTLOADER_QMK_HID OPT_DEFS += -DBOOTLOADER_HID + BOOTLOADER_TYPE = dfu + BOOTLOADER_SIZE ?= 4096 endif ifeq ($(strip $(BOOTLOADER)), halfkay) OPT_DEFS += -DBOOTLOADER_HALFKAY + BOOTLOADER_TYPE = halfkay + ifeq ($(strip $(MCU)), atmega32u4) BOOTLOADER_SIZE = 512 endif @@ -86,18 +106,26 @@ ifeq ($(strip $(BOOTLOADER)), halfkay) endif ifeq ($(strip $(BOOTLOADER)), caterina) OPT_DEFS += -DBOOTLOADER_CATERINA + BOOTLOADER_TYPE = caterina + BOOTLOADER_SIZE = 4096 endif ifneq (,$(filter $(BOOTLOADER), bootloadhid bootloadHID)) OPT_DEFS += -DBOOTLOADER_BOOTLOADHID + BOOTLOADER_TYPE = bootloadhid + BOOTLOADER_SIZE = 4096 endif ifneq (,$(filter $(BOOTLOADER), usbasploader USBasp)) OPT_DEFS += -DBOOTLOADER_USBASP + BOOTLOADER_TYPE = usbasploader + BOOTLOADER_SIZE = 4096 endif ifeq ($(strip $(BOOTLOADER)), lufa-ms) OPT_DEFS += -DBOOTLOADER_MS + BOOTLOADER_TYPE = dfu + BOOTLOADER_SIZE ?= 8192 FIRMWARE_FORMAT = bin cpfirmware: lufa_warning @@ -115,6 +143,7 @@ endif ifeq ($(strip $(BOOTLOADER)), stm32-dfu) OPT_DEFS += -DBOOTLOADER_STM32_DFU + BOOTLOADER_TYPE = stm32_dfu # Options to pass to dfu-util when flashing DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave @@ -122,6 +151,7 @@ ifeq ($(strip $(BOOTLOADER)), stm32-dfu) endif ifeq ($(strip $(BOOTLOADER)), apm32-dfu) OPT_DEFS += -DBOOTLOADER_APM32_DFU + BOOTLOADER_TYPE = stm32_dfu # Options to pass to dfu-util when flashing DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave @@ -129,6 +159,7 @@ ifeq ($(strip $(BOOTLOADER)), apm32-dfu) endif ifeq ($(strip $(BOOTLOADER)), gd32v-dfu) OPT_DEFS += -DBOOTLOADER_GD32V_DFU + BOOTLOADER_TYPE = gd32v_dfu # Options to pass to dfu-util when flashing DFU_ARGS ?= -d 28E9:0189 -a 0 -s 0x08000000:leave @@ -136,6 +167,8 @@ ifeq ($(strip $(BOOTLOADER)), gd32v-dfu) endif ifeq ($(strip $(BOOTLOADER)), kiibohd) OPT_DEFS += -DBOOTLOADER_KIIBOHD + BOOTLOADER_TYPE = kiibohd + ifeq ($(strip $(MCU_ORIG)), MK20DX128) MCU_LDSCRIPT = MK20DX128BLDR4 endif @@ -151,8 +184,7 @@ ifeq ($(strip $(BOOTLOADER)), stm32duino) OPT_DEFS += -DBOOTLOADER_STM32DUINO MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO - # STM32F103 does NOT have an USB bootloader in ROM (only serial), so setting anything here does not make much sense - STM32_BOOTLOADER_ADDRESS = 0x80000000 + BOOTLOADER_TYPE = stm32duino # Options to pass to dfu-util when flashing DFU_ARGS = -d 1EAF:0003 -a 2 -R @@ -160,4 +192,17 @@ ifeq ($(strip $(BOOTLOADER)), stm32duino) endif ifeq ($(strip $(BOOTLOADER)), tinyuf2) OPT_DEFS += -DBOOTLOADER_TINYUF2 + BOOTLOADER_TYPE = tinyuf2 +endif +ifeq ($(strip $(BOOTLOADER)), halfkay) + OPT_DEFS += -DBOOTLOADER_HALFKAY + BOOTLOADER_TYPE = halfkay +endif +ifeq ($(strip $(BOOTLOADER)), md-boot) + OPT_DEFS += -DBOOTLOADER_MD_BOOT + BOOTLOADER_TYPE = md_boot +endif + +ifeq ($(strip $(BOOTLOADER_TYPE)),) + $(error No bootloader specified. Please set an appropriate 'BOOTLOADER' in your keyboard's 'rules.mk' file) endif diff --git a/builddefs/mcu_selection.mk b/builddefs/mcu_selection.mk index 46d34aabe4..9fdd22c3b6 100644 --- a/builddefs/mcu_selection.mk +++ b/builddefs/mcu_selection.mk @@ -143,6 +143,9 @@ ifneq ($(findstring STM32F042, $(MCU)),) # This ensures that the EEPROM page buffer fits into RAM USE_PROCESS_STACKSIZE = 0x600 USE_EXCEPTIONS_STACKSIZE = 0x300 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFFC400 endif ifneq ($(findstring STM32F072, $(MCU)),) @@ -175,6 +178,9 @@ ifneq ($(findstring STM32F072, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32F0 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFFC800 endif ifneq ($(findstring STM32F103, $(MCU)),) @@ -239,6 +245,9 @@ ifneq ($(findstring STM32F303, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32F3 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFFD800 endif ifneq ($(findstring STM32F401, $(MCU)),) @@ -276,6 +285,9 @@ ifneq ($(findstring STM32F401, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32F4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq ($(findstring STM32F405, $(MCU)),) @@ -308,6 +320,9 @@ ifneq ($(findstring STM32F405, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32F4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq ($(findstring STM32F407, $(MCU)),) @@ -340,6 +355,9 @@ ifneq ($(findstring STM32F407, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32F4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq ($(findstring STM32F411, $(MCU)),) @@ -377,6 +395,9 @@ ifneq ($(findstring STM32F411, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32F4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq ($(findstring STM32F446, $(MCU)),) @@ -406,6 +427,9 @@ ifneq ($(findstring STM32F446, $(MCU)),) BOARD ?= GENERIC_STM32_F446XE USE_FPU ?= yes + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq ($(findstring STM32G431, $(MCU)),) @@ -438,6 +462,9 @@ ifneq ($(findstring STM32G431, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32G4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq ($(findstring STM32G474, $(MCU)),) @@ -470,6 +497,46 @@ ifneq ($(findstring STM32G474, $(MCU)),) # UF2 settings UF2_FAMILY ?= STM32G4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 +endif + +ifneq (,$(filter $(MCU),STM32L432 STM32L442)) + # Cortex version + MCU = cortex-m4 + + # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 + ARMV = 7 + + ## chip/board settings + # - the next two should match the directories in + # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) + MCU_FAMILY = STM32 + MCU_SERIES = STM32L4xx + + # Linker script to use + # - it should exist either in <chibios>/os/common/startup/ARMCMx/compilers/GCC/ld/ + # or <keyboard_dir>/ld/ + MCU_LDSCRIPT ?= STM32L432xC + + # Startup code to use + # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/ + MCU_STARTUP ?= stm32l4xx + + # Board: it should exist either in <chibios>/os/hal/boards/, + # <keyboard_dir>/boards/, or drivers/boards/ + BOARD ?= GENERIC_STM32_L432XC + + PLATFORM_NAME ?= platform_l432 + + USE_FPU ?= yes + + # UF2 settings + UF2_FAMILY ?= STM32L4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq (,$(filter $(MCU),STM32L433 STM32L443)) @@ -504,6 +571,9 @@ ifneq (,$(filter $(MCU),STM32L433 STM32L443)) # UF2 settings UF2_FAMILY ?= STM32L4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq (,$(filter $(MCU),STM32L412 STM32L422)) @@ -538,6 +608,9 @@ ifneq (,$(filter $(MCU),STM32L412 STM32L422)) # UF2 settings UF2_FAMILY ?= STM32L4 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 endif ifneq ($(findstring WB32F3G71, $(MCU)),) @@ -567,6 +640,10 @@ ifneq ($(findstring WB32F3G71, $(MCU)),) BOARD ?= GENERIC_WB32_F3G71XX USE_FPU ?= no + + # Bootloader address for WB32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFFE000 + WB32_BOOTLOADER_ADDRESS ?= 0x1FFFE000 endif ifneq ($(findstring GD32VF103, $(MCU)),) diff --git a/builddefs/message.mk b/builddefs/message.mk index cb4ef43719..1187491452 100644 --- a/builddefs/message.mk +++ b/builddefs/message.mk @@ -87,6 +87,7 @@ define GENERATE_MSG_AVAILABLE_KEYMAPS endef MSG_AVAILABLE_KEYMAPS = $(eval $(call GENERATE_MSG_AVAILABLE_KEYMAPS))$(MSG_AVAILABLE_KEYMAPS_ACTUAL) +MSG_BOOTLOADER_NOT_FOUND_BASE = Bootloader not found. Make sure the board is in bootloader mode. See https://docs.qmk.fm/\#/newbs_flashing\n MSG_CHECK_FILESIZE = Checking file size of $(TARGET).$(FIRMWARE_FORMAT) MSG_CHECK_FILESIZE_SKIPPED = (Firmware size check does not yet support $(MCU_ORIG); skipping) MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n @@ -97,6 +98,6 @@ MSG_PYTHON_MISSING = $(ERROR_COLOR)ERROR:$(NO_COLOR) Cannot run \"qmk hello\"!\n Please run $(BOLD)qmk setup$(NO_COLOR) to install all the dependencies QMK requires.\n\n MSG_FLASH_BOOTLOADER = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's bootloader is not specified or is not supported by the \":flash\" target at this time.\n\n MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n -MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) Bootloader not found. Trying again in 5s (Ctrl+C to cancel)\n +MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) $(MSG_BOOTLOADER_NOT_FOUND_BASE) Trying again in 5s (Ctrl+C to cancel)\n BOOTLOADER_RETRY_TIME ?= 0.5 -MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY = Bootloader not found. Trying again every $(BOOTLOADER_RETRY_TIME)s (Ctrl+C to cancel) +MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY = $(MSG_BOOTLOADER_NOT_FOUND_BASE) Trying again every $(BOOTLOADER_RETRY_TIME)s (Ctrl+C to cancel) |