From bc8a81b0edd193f0bb06037b7e1b1a6c602a985f Mon Sep 17 00:00:00 2001 From: Joakim Tufvegren Date: Tue, 11 May 2021 20:02:36 +0200 Subject: [PATCH 1/3] Remove the #10088 hotfix for K20x MCU:s. It seems to _cause_ the issue it intended to solve there. --- tmk_core/protocol/chibios/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index e2ec01118638..5c70b8dd8afb 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c @@ -226,7 +226,9 @@ int main(void) { /* Remote wakeup */ if (suspend_wakeup_condition()) { usbWakeupHost(&USB_DRIVER); +# ifndef K20x restart_usb_driver(&USB_DRIVER); +# endif } } /* Woken up */ From f869d34dfd8a58704acb36de2fc7d6c8d43f35bd Mon Sep 17 00:00:00 2001 From: Joakim Tufvegren Date: Tue, 11 May 2021 20:02:36 +0200 Subject: [PATCH 2/3] Cleaner way of removing #10088 hotfix. Now only affects Ergodox Infinity, Whitefox and K-type, though. Switches over Ergodox Infinity to the `IC_TEENSY_3_1` board, since that was a nice place to implement the `restart_usb_driver` override. However, I would guess this issue is present for other K20x/Teensy 3.1 boards as well... --- keyboards/ergodox_infinity/rules.mk | 9 +++++++++ platforms/chibios/IC_TEENSY_3_1/board/board.c | 5 +++++ tmk_core/protocol/chibios/main.c | 2 -- tmk_core/protocol/chibios/usb_main.c | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/keyboards/ergodox_infinity/rules.mk b/keyboards/ergodox_infinity/rules.mk index b9ead9e87c8d..2ab144815310 100644 --- a/keyboards/ergodox_infinity/rules.mk +++ b/keyboards/ergodox_infinity/rules.mk @@ -4,6 +4,15 @@ MCU = MK20DX256 # Bootloader selection BOOTLOADER = kiibohd +# Board: it should exist either in /os/hal/boards/ +# or /boards +# - BOARD = +# - PJRC_TEENSY_LC for Teensy LC +# - PJRC_TEENSY_3 for Teensy 3.0 +# - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2 +# - MCHCK_K20 for Infinity KB +BOARD = IC_TEENSY_3_1 + # Build Options # comment out to disable the options. # diff --git a/platforms/chibios/IC_TEENSY_3_1/board/board.c b/platforms/chibios/IC_TEENSY_3_1/board/board.c index 36ae8051eee4..424e0c975b40 100644 --- a/platforms/chibios/IC_TEENSY_3_1/board/board.c +++ b/platforms/chibios/IC_TEENSY_3_1/board/board.c @@ -144,3 +144,8 @@ void __early_init(void) { * @todo Add your board-specific code, if any. */ void boardInit(void) {} + + +void restart_usb_driver(USBDriver *usbp) { + // Do nothing. Restarting the USB driver on these boards breaks it. +} diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index 5c70b8dd8afb..e2ec01118638 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c @@ -226,9 +226,7 @@ int main(void) { /* Remote wakeup */ if (suspend_wakeup_condition()) { usbWakeupHost(&USB_DRIVER); -# ifndef K20x restart_usb_driver(&USB_DRIVER); -# endif } } /* Woken up */ diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index d04302acae09..f9ef16c53ca5 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -705,7 +705,7 @@ void init_usb_driver(USBDriver *usbp) { chVTObjectInit(&keyboard_idle_timer); } -void restart_usb_driver(USBDriver *usbp) { +__attribute__((weak)) void restart_usb_driver(USBDriver *usbp) { usbStop(usbp); usbDisconnectBus(usbp); From 6b5686565c8eda45655a042c602a8c5436963dff Mon Sep 17 00:00:00 2001 From: Joakim Tufvegren Date: Sat, 3 Jul 2021 12:47:35 +0200 Subject: [PATCH 3/3] Fix comment regarding `IC_TEENSY_3_1` for all keyboards using it. --- keyboards/ergodox_infinity/rules.mk | 8 +++----- keyboards/k_type/rules.mk | 3 ++- keyboards/whitefox/rules.mk | 8 +++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/keyboards/ergodox_infinity/rules.mk b/keyboards/ergodox_infinity/rules.mk index 2ab144815310..40417c3e303b 100644 --- a/keyboards/ergodox_infinity/rules.mk +++ b/keyboards/ergodox_infinity/rules.mk @@ -6,11 +6,9 @@ BOOTLOADER = kiibohd # Board: it should exist either in /os/hal/boards/ # or /boards -# - BOARD = -# - PJRC_TEENSY_LC for Teensy LC -# - PJRC_TEENSY_3 for Teensy 3.0 -# - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2 -# - MCHCK_K20 for Infinity KB +# This board was copied from PJRC_TEENSY_3_1. The only difference should be a +# hack to ensure the watchdog has started before trying to disable it, and an +# override to disable restart of USB driver after returning from suspend. BOARD = IC_TEENSY_3_1 # Build Options diff --git a/keyboards/k_type/rules.mk b/keyboards/k_type/rules.mk index 369cab4f09e3..ffd350ef8a04 100644 --- a/keyboards/k_type/rules.mk +++ b/keyboards/k_type/rules.mk @@ -7,7 +7,8 @@ BOOTLOADER = kiibohd # Board: it should exist either in /os/hal/boards/ # or /boards # This board was copied from PJRC_TEENSY_3_1. The only difference should be a -# hack to ensure the watchdog has started before trying to disable it. +# hack to ensure the watchdog has started before trying to disable it, and an +# override to disable restart of USB driver after returning from suspend. BOARD = IC_TEENSY_3_1 # Build Options diff --git a/keyboards/whitefox/rules.mk b/keyboards/whitefox/rules.mk index 771804369c33..048722b31fa8 100644 --- a/keyboards/whitefox/rules.mk +++ b/keyboards/whitefox/rules.mk @@ -6,11 +6,9 @@ BOOTLOADER = kiibohd # Board: it should exist either in /os/hal/boards/ # or /boards -# - BOARD = -# - PJRC_TEENSY_LC for Teensy LC -# - PJRC_TEENSY_3 for Teensy 3.0 -# - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2 -# - MCHCK_K20 for Infinity KB +# This board was copied from PJRC_TEENSY_3_1. The only difference should be a +# hack to ensure the watchdog has started before trying to disable it, and an +# override to disable restart of USB driver after returning from suspend. BOARD = IC_TEENSY_3_1 # Build Options