From 42c2e8d1f7cb5845a583f26e03acde2cdf883f48 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Fri, 30 Aug 2024 21:29:08 +0200 Subject: [PATCH] platforms: rp: split into common and rp2040 part Signed-off-by: Stefan Kerkmann --- platforms/chibios/platform.mk | 7 ++- platforms/chibios/vendors/RP/RP2040/RP2040.mk | 52 ++++++++++++++++++ .../vendors/RP/{ => RP2040}/_pin_defs.h | 0 .../RP/{ => RP2040}/stage2_bootloaders.c | 0 .../vendors/RP/{RP2040.mk => rp_common.mk} | 53 +++---------------- 5 files changed, 63 insertions(+), 49 deletions(-) create mode 100644 platforms/chibios/vendors/RP/RP2040/RP2040.mk rename platforms/chibios/vendors/RP/{ => RP2040}/_pin_defs.h (100%) rename platforms/chibios/vendors/RP/{ => RP2040}/stage2_bootloaders.c (100%) rename platforms/chibios/vendors/RP/{RP2040.mk => rp_common.mk} (65%) diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk index 169707966ff..88ed5384ccb 100644 --- a/platforms/chibios/platform.mk +++ b/platforms/chibios/platform.mk @@ -298,11 +298,14 @@ EXTRAINCDIRS += $(CHIBIOS)/os/license \ # QMK specific MCU family support selection. ############################################################################## ifneq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_SERIES).mk)","") - # Either by MCU series e.g. STM32/STM32F1xx.mk or... + # MCU series e.g. STM32/STM32F1xx.mk include $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_SERIES).mk else ifneq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_FAMILY).mk)","") - # By MCU family e.g. STM32/STM32.mk + # MCU family e.g. STM32/STM32.mk include $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_FAMILY).mk +else ifneq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_SERIES)/$(MCU_SERIES).mk)","") + # MCU series in subfolders e.g. RP/RP2040/RP2040.mk + include $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY)/$(MCU_SERIES)/$(MCU_SERIES).mk endif # diff --git a/platforms/chibios/vendors/RP/RP2040/RP2040.mk b/platforms/chibios/vendors/RP/RP2040/RP2040.mk new file mode 100644 index 00000000000..e332d1551c9 --- /dev/null +++ b/platforms/chibios/vendors/RP/RP2040/RP2040.mk @@ -0,0 +1,52 @@ +PLATFORM_RP_PATH := $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY) +PLATFORM_RP2040_PATH := $(PLATFORM_RP_PATH)/$(MCU_SERIES) + +include $(PLATFORM_RP_PATH)/rp_common.mk + +# +# RP2040 specific source and header files needed by QMK and ChibiOS +############################################################################## +RP2040_INC = $(PICOSDKROOT)/src/rp2040/hardware_regs/include \ + $(PICOSDKROOT)/src/rp2040/hardware_structs/include \ + $(PICOSDKROOT)/src/rp2040/pico_platform/include \ + $(PLATFORM_RP2040_PATH) + +RP2040_SRC = $(PLATFORM_RP2040_PATH)/stage2_bootloaders.c + +CFLAGS += -DPICO_RP2040=1 + +# +# RP2040 optimized compiler intrinsics +############################################################################## + +# The RP2040 sdk provides optimized compiler intrinsics which override the GCC +# built-ins. Some of these functions are located in the bootrom of the RP2040. +# Execution of these functions is realized via a vtable that is populated on +# bootup. This mechanism needs startup code and linker script support from +# ChibiOS, which is currently not implemented thus these functions are disabled +# ATM. +RP2040_SRC += $(PICOSDKROOT)/src/rp2_common/hardware_divider/divider.S \ + $(PICOSDKROOT)/src/rp2_common/pico_divider/divider_hardware.S \ + $(PICOSDKROOT)/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S + +RP2040_INC += $(PICOSDKROOT)/src/rp2_common/hardware_divider/include \ + $(PICOSDKROOT)/src/common/pico_divider_headers/include + +# integer division intrinsics utilizing the RP2040 hardware divider +OPT_DEFS += -DPICO_DIVIDER_IN_RAM=1 +OPT_DEFS += -DPICO_DIVIDER_DISABLE_INTERRUPTS=1 + +CFLAGS += -Wl,--wrap=__aeabi_idiv +CFLAGS += -Wl,--wrap=__aeabi_idivmod +CFLAGS += -Wl,--wrap=__aeabi_ldivmod +CFLAGS += -Wl,--wrap=__aeabi_uidiv +CFLAGS += -Wl,--wrap=__aeabi_uidivmod +CFLAGS += -Wl,--wrap=__aeabi_uldivmod + +# 64bit integer intrinsics +OPT_DEFS += -DPICO_INT64_OPS_IN_RAM=1 + +CFLAGS += -Wl,--wrap=__aeabi_lmul + +PLATFORM_SRC += $(RP2040_SRC) +EXTRAINCDIRS += $(RP2040_INC) diff --git a/platforms/chibios/vendors/RP/_pin_defs.h b/platforms/chibios/vendors/RP/RP2040/_pin_defs.h similarity index 100% rename from platforms/chibios/vendors/RP/_pin_defs.h rename to platforms/chibios/vendors/RP/RP2040/_pin_defs.h diff --git a/platforms/chibios/vendors/RP/stage2_bootloaders.c b/platforms/chibios/vendors/RP/RP2040/stage2_bootloaders.c similarity index 100% rename from platforms/chibios/vendors/RP/stage2_bootloaders.c rename to platforms/chibios/vendors/RP/RP2040/stage2_bootloaders.c diff --git a/platforms/chibios/vendors/RP/RP2040.mk b/platforms/chibios/vendors/RP/rp_common.mk similarity index 65% rename from platforms/chibios/vendors/RP/RP2040.mk rename to platforms/chibios/vendors/RP/rp_common.mk index de26ecc9007..1d71411578b 100644 --- a/platforms/chibios/vendors/RP/RP2040.mk +++ b/platforms/chibios/vendors/RP/rp_common.mk @@ -1,7 +1,7 @@ # -# Raspberry Pi RP2040 specific drivers +# Raspberry Pi specific drivers, same for all RP2xxx based boards ############################################################################## -COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/vendor/$(MCU_FAMILY)/$(MCU_SERIES) +COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/vendor/$(MCU_FAMILY)/rp2040 ifeq ($(strip $(WS2812_DRIVER)), vendor) OPT_DEFS += -DRP_DMA_REQUIRED=TRUE @@ -14,8 +14,7 @@ ADEFS += -DCRT0_VTOR_INIT=1 \ -DCRT0_EXTRA_CORES_NUMBER=0 \ -DCRT0_INIT_VECTORS=1 -CFLAGS += -DNDEBUG \ - -DPICO_RP2040=1 +CFLAGS += -DNDEBUG # # Pico SDK source and header files needed by QMK and ChibiOS @@ -64,50 +63,10 @@ PICOSDKINC = $(CHIBIOS)/os/various/pico_bindings/dumb/include \ $(PICOSDKROOT)/src/rp2_common/pico_platform_panic/include \ $(PICOSDKROOT)/src/rp2_common/pico_platform_sections/include \ $(PICOSDKROOT)/src/rp2_common/pico_runtime_init/include \ - $(PICOSDKROOT)/src/rp2_common/pico_runtime/include \ - $(PICOSDKROOT)/src/rp2040/hardware_regs/include \ - $(PICOSDKROOT)/src/rp2040/hardware_structs/include \ - $(PICOSDKROOT)/src/rp2040/pico_platform/include + $(PICOSDKROOT)/src/rp2_common/pico_runtime/include -PLATFORM_RP2040_PATH := $(PLATFORM_PATH)/$(PLATFORM_KEY)/vendors/$(MCU_FAMILY) - -PICOSDKSRC += $(PLATFORM_RP2040_PATH)/stage2_bootloaders.c \ - $(PLATFORM_RP2040_PATH)/pico_sdk_shims.c - -PICOSDKINC += $(PLATFORM_RP2040_PATH) - -# -# RP2040 optimized compiler intrinsics -############################################################################## - -# The RP2040 sdk provides optimized compiler intrinsics which override the GCC -# built-ins. Some of these functions are located in the bootrom of the RP2040. -# Execution of these functions is realized via a vtable that is populated on -# bootup. This mechanism needs startup code and linker script support from -# ChibiOS, which is currently not implemented thus these functions are disabled -# ATM. -PICOSDKSRC += $(PICOSDKROOT)/src/rp2_common/hardware_divider/divider.S \ - $(PICOSDKROOT)/src/rp2_common/pico_divider/divider_hardware.S \ - $(PICOSDKROOT)/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S - -PICOSDKINC += $(PICOSDKROOT)/src/rp2_common/hardware_divider/include \ - $(PICOSDKROOT)/src/common/pico_divider_headers/include - -# integer division intrinsics utilizing the RP2040 hardware divider -OPT_DEFS += -DPICO_DIVIDER_IN_RAM=1 -OPT_DEFS += -DPICO_DIVIDER_DISABLE_INTERRUPTS=1 - -CFLAGS += -Wl,--wrap=__aeabi_idiv -CFLAGS += -Wl,--wrap=__aeabi_idivmod -CFLAGS += -Wl,--wrap=__aeabi_ldivmod -CFLAGS += -Wl,--wrap=__aeabi_uidiv -CFLAGS += -Wl,--wrap=__aeabi_uidivmod -CFLAGS += -Wl,--wrap=__aeabi_uldivmod - -# 64bit integer intrinsics -OPT_DEFS += -DPICO_INT64_OPS_IN_RAM=1 - -CFLAGS += -Wl,--wrap=__aeabi_lmul +PICOSDKSRC += $(PLATFORM_RP_PATH)/pico_sdk_shims.c +PICOSDKINC += $(PLATFORM_RP_PATH) PLATFORM_SRC += $(PICOSDKSRC) EXTRAINCDIRS += $(PICOSDKINC)