From 46c85c93f05003ecc9d5b9266bc78e98cc7a843b Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 11 Jan 2023 19:58:27 +0000 Subject: [PATCH] Revert "De-duplicate platform detection (#19545)" (#19564) This reverts commit e11235ee14f9cd3fc45b836eec99ed312cb137dd. --- builddefs/build_keyboard.mk | 25 ++++++++++++++++++------- data/mappings/info_rules.hjson | 2 -- lib/python/qmk/info.py | 3 --- platforms/arm_atsam/bootloader.mk | 2 -- platforms/avr/bootloader.mk | 2 -- platforms/chibios/bootloader.mk | 2 -- platforms/chibios/platform.mk | 3 --- 7 files changed, 18 insertions(+), 21 deletions(-) diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk index 37466cbbe5..8999ac80ad 100644 --- a/builddefs/build_keyboard.mk +++ b/builddefs/build_keyboard.mk @@ -180,13 +180,6 @@ generated-files: $(KEYMAP_OUTPUT)/src/config.h $(KEYMAP_OUTPUT)/src/keymap.c endif -# PLATFORM_KEY should be detected in info.json via key 'processor' (or rules.mk 'MCU') -ifeq ($(PLATFORM_KEY),) - $(call CATASTROPHIC_ERROR,Platform not defined) -endif -PLATFORM=$(shell echo $(PLATFORM_KEY) | tr '[:lower:]' '[:upper:]') - - include $(BUILDDEFS_PATH)/converters.mk include $(BUILDDEFS_PATH)/mcu_selection.mk @@ -264,6 +257,24 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).h)","") FOUND_KEYBOARD_H = $(KEYBOARD_FOLDER_5).h endif +# Determine and set parameters based on the keyboard's processor family. +# We can assume a ChibiOS target When MCU_FAMILY is defined since it's +# not used for LUFA +ifdef MCU_FAMILY + PLATFORM=CHIBIOS + PLATFORM_KEY=chibios + FIRMWARE_FORMAT?=bin + OPT_DEFS += -DMCU_$(MCU_FAMILY) +else ifdef ARM_ATSAM + PLATFORM=ARM_ATSAM + PLATFORM_KEY=arm_atsam + FIRMWARE_FORMAT=bin +else + PLATFORM=AVR + PLATFORM_KEY=avr + FIRMWARE_FORMAT?=hex +endif + # Find all of the config.h files and add them to our CONFIG_H define. CONFIG_H := ifneq ("$(wildcard $(KEYBOARD_PATH_5)/config.h)","") diff --git a/data/mappings/info_rules.hjson b/data/mappings/info_rules.hjson index c409da04c6..b020d0c813 100644 --- a/data/mappings/info_rules.hjson +++ b/data/mappings/info_rules.hjson @@ -38,8 +38,6 @@ "PS2_MOUSE_ENABLE": {"info_key": "ps2.mouse_enabled", "value_type": "bool"}, "PS2_DRIVER": {"info_key": "ps2.driver"}, - "PLATFORM_KEY": {"info_key": "platform_key", "to_json": false}, - // Items we want flagged in lint "CTPC": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"}, "CONVERT_TO_PROTON_C": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"}, diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 789d05850c..af3b0f3091 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -751,7 +751,6 @@ def arm_processor_rules(info_data, rules): """ info_data['processor_type'] = 'arm' info_data['protocol'] = 'ChibiOS' - info_data['platform_key'] = 'chibios' if 'STM32' in info_data['processor']: info_data['platform'] = 'STM32' @@ -759,7 +758,6 @@ def arm_processor_rules(info_data, rules): info_data['platform'] = rules['MCU_SERIES'] elif 'ARM_ATSAM' in rules: info_data['platform'] = 'ARM_ATSAM' - info_data['platform_key'] = 'arm_atsam' return info_data @@ -769,7 +767,6 @@ def avr_processor_rules(info_data, rules): """ info_data['processor_type'] = 'avr' info_data['platform'] = rules['ARCH'] if 'ARCH' in rules else 'unknown' - info_data['platform_key'] = 'avr' info_data['protocol'] = 'V-USB' if info_data['processor'] in VUSB_PROCESSORS else 'LUFA' # FIXME(fauxpark/anyone): Eventually we should detect the protocol by looking at PROTOCOL inherited from mcu_selection.mk: diff --git a/platforms/arm_atsam/bootloader.mk b/platforms/arm_atsam/bootloader.mk index 7e503bdca9..1ec42edeb6 100644 --- a/platforms/arm_atsam/bootloader.mk +++ b/platforms/arm_atsam/bootloader.mk @@ -27,8 +27,6 @@ # the respective file under `platforms//bootloaders/custom.c` to see # which functions may be overridden. -FIRMWARE_FORMAT?=bin - ifeq ($(strip $(BOOTLOADER)), custom) OPT_DEFS += -DBOOTLOADER_CUSTOM BOOTLOADER_TYPE = custom diff --git a/platforms/avr/bootloader.mk b/platforms/avr/bootloader.mk index 36e3fd83db..63fe635d96 100644 --- a/platforms/avr/bootloader.mk +++ b/platforms/avr/bootloader.mk @@ -37,8 +37,6 @@ # BOOTLOADER_SIZE can still be defined manually, but it's recommended # you add any possible configuration to this list -FIRMWARE_FORMAT?=hex - ifeq ($(strip $(BOOTLOADER)), custom) OPT_DEFS += -DBOOTLOADER_CUSTOM BOOTLOADER_TYPE = custom diff --git a/platforms/chibios/bootloader.mk b/platforms/chibios/bootloader.mk index 546faf2d27..0568d35321 100644 --- a/platforms/chibios/bootloader.mk +++ b/platforms/chibios/bootloader.mk @@ -36,8 +36,6 @@ # the respective file under `platforms//bootloaders/custom.c` to see # which functions may be overridden. -FIRMWARE_FORMAT?=bin - ifeq ($(strip $(BOOTLOADER)), custom) OPT_DEFS += -DBOOTLOADER_CUSTOM BOOTLOADER_TYPE = custom diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk index fd4c6bd2e5..b2a8ec89e1 100644 --- a/platforms/chibios/platform.mk +++ b/platforms/chibios/platform.mk @@ -442,9 +442,6 @@ LDFLAGS += $(SHARED_LDFLAGS) $(SHARED_LDSYMBOLS) $(TOOLCHAIN_LDFLAGS) $(TOOLCHA # Tell QMK that we are hosting it on ChibiOS. OPT_DEFS += -DPROTOCOL_CHIBIOS -# And what flavor of MCU -OPT_DEFS += -DMCU_$(MCU_FAMILY) - # ChibiOS supports synchronization primitives like a Mutex OPT_DEFS += -DPLATFORM_SUPPORTS_SYNCHRONIZATION