From 1b6cda50b94df8fdaac6336d80e01c8a9bac5e79 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 10 Nov 2026 06:53:19 +0000 Subject: [PATCH] Add workaround for `A9` on STM32F4x1 (#26494) --- .../xelus/valor_frl_tkl/rev2_0/readme.md | 65 ------------------- .../configs/hal_usb_lld.h | 14 ++++ .../configs/hal_usb_lld.h | 14 ++++ .../configs/hal_usb_lld.h | 14 ++++ .../configs/hal_usb_lld.h | 14 ++++ 5 files changed, 56 insertions(+), 65 deletions(-) create mode 100644 platforms/chibios/boards/BLACKPILL_STM32_F401/configs/hal_usb_lld.h create mode 100644 platforms/chibios/boards/BLACKPILL_STM32_F411/configs/hal_usb_lld.h create mode 100644 platforms/chibios/boards/GENERIC_STM32_F401XC/configs/hal_usb_lld.h create mode 100644 platforms/chibios/boards/GENERIC_STM32_F411XE/configs/hal_usb_lld.h diff --git a/keyboards/xelus/valor_frl_tkl/rev2_0/readme.md b/keyboards/xelus/valor_frl_tkl/rev2_0/readme.md index 3a1b4d53b54..f344bfb5e76 100644 --- a/keyboards/xelus/valor_frl_tkl/rev2_0/readme.md +++ b/keyboards/xelus/valor_frl_tkl/rev2_0/readme.md @@ -6,71 +6,6 @@ An Alice-esque FRL TKL keyboard PCB. * Hardware Supported: Valor FRL TKL * Hardware Availability: Custom keyboard group buys -### Important Note -This version uses the pin PA9 which is un-usable with the current ChibiOS. The first column will be disabled if this firmware is compiled normally. -A patch is required locally to use this version. -Please use this patch: -```diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c -index 0f48d1fd0..38aff8554 100644 ---- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c -+++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c -@@ -40,18 +40,18 @@ - - #if STM32_OTG_STEPPING == 1 - #if defined(BOARD_OTG_NOVBUSSENS) --#define GCCFG_INIT_VALUE (GCCFG_NOVBUSSENS | GCCFG_VBUSASEN | \ -- GCCFG_VBUSBSEN | GCCFG_PWRDWN) -+#define GCCFG_INIT_VALUE (GCCFG_NOVBUSSENS | \ -+ GCCFG_PWRDWN) - #else --#define GCCFG_INIT_VALUE (GCCFG_VBUSASEN | GCCFG_VBUSBSEN | \ -+#define GCCFG_INIT_VALUE (GCCFG_NOVBUSSENS | \ - GCCFG_PWRDWN) - #endif - - #elif STM32_OTG_STEPPING == 2 - #if defined(BOARD_OTG_NOVBUSSENS) --#define GCCFG_INIT_VALUE GCCFG_PWRDWN -+#define GCCFG_INIT_VALUE (GCCFG_NOVBUSSENS | GCCFG_PWRDWN) - #else --#define GCCFG_INIT_VALUE (GCCFG_VBDEN | GCCFG_PWRDWN) -+#define GCCFG_INIT_VALUE (GCCFG_NOVBUSSENS | GCCFG_VBDEN | GCCFG_PWRDWN) - #endif - - #endif -@@ -815,7 +815,7 @@ void usb_lld_start(USBDriver *usbp) { - otgp->PCGCCTL = 0; - - /* VBUS sensing and transceiver enabled.*/ -- otgp->GOTGCTL = GOTGCTL_BVALOEN | GOTGCTL_BVALOVAL; -+ // otgp->GOTGCTL = GOTGCTL_BVALOEN | GOTGCTL_BVALOVAL; - - #if defined(BOARD_OTG2_USES_ULPI) - #if STM32_USB_USE_OTG1 -diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h -index 69a5ab603..200b4b91a 100644 ---- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h -+++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h -@@ -534,7 +534,7 @@ struct USBDriver { - * @notapi - */ - #if (STM32_OTG_STEPPING == 1) || defined(__DOXYGEN__) --#define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_VBUSBSEN) -+#define usb_lld_connect_bus(usbp) - #else - #define usb_lld_connect_bus(usbp) ((usbp)->otg->DCTL &= ~DCTL_SDIS) - #endif -@@ -545,7 +545,7 @@ struct USBDriver { - * @notapi - */ - #if (STM32_OTG_STEPPING == 1) || defined(__DOXYGEN__) --#define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_VBUSBSEN) -+#define usb_lld_disconnect_bus(usbp) - #else - #define usb_lld_disconnect_bus(usbp) ((usbp)->otg->DCTL |= DCTL_SDIS) - #endif -``` - Make example for this keyboard (after setting up your build environment): make xelus/valor_frl_tkl/rev2_0:default diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/hal_usb_lld.h b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/hal_usb_lld.h new file mode 100644 index 00000000000..6c54d165c71 --- /dev/null +++ b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/hal_usb_lld.h @@ -0,0 +1,14 @@ +// Copyright 2026 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include_next + +// Workaround for A9 on STM32F4 not working. This is a temporary workaround until upstream is fixed. +#if defined(BOARD_OTG_NOVBUSSENS) +# undef usb_lld_connect_bus +# define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_NOVBUSSENS) + +# undef usb_lld_disconnect_bus +# define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_NOVBUSSENS) +#endif diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/hal_usb_lld.h b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/hal_usb_lld.h new file mode 100644 index 00000000000..6c54d165c71 --- /dev/null +++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/hal_usb_lld.h @@ -0,0 +1,14 @@ +// Copyright 2026 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include_next + +// Workaround for A9 on STM32F4 not working. This is a temporary workaround until upstream is fixed. +#if defined(BOARD_OTG_NOVBUSSENS) +# undef usb_lld_connect_bus +# define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_NOVBUSSENS) + +# undef usb_lld_disconnect_bus +# define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_NOVBUSSENS) +#endif diff --git a/platforms/chibios/boards/GENERIC_STM32_F401XC/configs/hal_usb_lld.h b/platforms/chibios/boards/GENERIC_STM32_F401XC/configs/hal_usb_lld.h new file mode 100644 index 00000000000..6c54d165c71 --- /dev/null +++ b/platforms/chibios/boards/GENERIC_STM32_F401XC/configs/hal_usb_lld.h @@ -0,0 +1,14 @@ +// Copyright 2026 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include_next + +// Workaround for A9 on STM32F4 not working. This is a temporary workaround until upstream is fixed. +#if defined(BOARD_OTG_NOVBUSSENS) +# undef usb_lld_connect_bus +# define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_NOVBUSSENS) + +# undef usb_lld_disconnect_bus +# define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_NOVBUSSENS) +#endif diff --git a/platforms/chibios/boards/GENERIC_STM32_F411XE/configs/hal_usb_lld.h b/platforms/chibios/boards/GENERIC_STM32_F411XE/configs/hal_usb_lld.h new file mode 100644 index 00000000000..6c54d165c71 --- /dev/null +++ b/platforms/chibios/boards/GENERIC_STM32_F411XE/configs/hal_usb_lld.h @@ -0,0 +1,14 @@ +// Copyright 2026 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include_next + +// Workaround for A9 on STM32F4 not working. This is a temporary workaround until upstream is fixed. +#if defined(BOARD_OTG_NOVBUSSENS) +# undef usb_lld_connect_bus +# define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_NOVBUSSENS) + +# undef usb_lld_disconnect_bus +# define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_NOVBUSSENS) +#endif