Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realforce RGB (AEAX01) startup problem #8

Closed
tmk opened this issue Jul 23, 2021 · 2 comments
Closed

Realforce RGB (AEAX01) startup problem #8

tmk opened this issue Jul 23, 2021 · 2 comments

Comments

@tmk
Copy link
Owner

tmk commented Jul 23, 2021

Problem:
With old firmware Realforce RGB (AEAX01) fails when connecting the keyboard to USB-USB converter first, then plug it into USB port.

https://geekhack.org/index.php?topic=69169.msg2414679#msg2414679

Confirmed the problem with tmk/tmk_keyboard@5132607 (2016-10-18) at least.
NOT confirmed with tmk/tmk_keyboard@cf9f157 (2017-05-11)

Workaround:
https://geekhack.org/index.php?topic=69169.msg2449152#msg2449152

EDIT: for future reference,
at current time workaroudn is plugin converter first, then the keyboard in order.

This doesn't work with tmk/tmk_keyboard@51326077b08.
And tmk/tmk_keyboard@cf9f157a7f6a70 doens't need the workaround at all.

Solution:
This commit doesn't seem to be related regardless of its commit comment.
227f3aa

commit 227f3aab715bf7f04fc616558b80e7fa69d2b914 (origin/upstream_fix_bus_detection, upstream_fix_bus_detection)
Author: Jun Wako <wakojun@gmail.com>
Date:   Sun Jul 14 10:34:05 2019 +0900

    Disable connect detection during settling time
    
    One device has glitch(30us width pulse) on pull-up'd D+ line after
    pulg-in, it can deceive device attach detction of the chip and library.
    This fix ignores the false detection for a while after device attach.
    The deivce with the glitch is a keyboard of Topre REALFORCE RGB AEAX01.

diff --git a/Usb.cpp b/Usb.cpp
index 7843d49..8c3c54c 100644
--- a/Usb.cpp
+++ b/Usb.cpp
@@ -483,6 +483,9 @@ void USB::Task(void) //USB state machine
                         if((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
                                 delay = (uint32_t)millis() + USB_SETTLE_DELAY;
                                 usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE;
+
+                                // disable bus status change interrupt until settled
+                                regWr(rHIEN, (regRd(rHIEN) & ~bmCONDETIE));
                         }
                         break;
         }// switch( tmpdata
@@ -510,6 +513,9 @@ void USB::Task(void) //USB state machine
                                 usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
                         else break; // don't fall through
                 case USB_ATTACHED_SUBSTATE_RESET_DEVICE:
+                        // re-enable bus status change interrupt
+                        regWr(rHIEN, (regRd(rHIEN) | bmCONDETIE));
+
                         regWr(rHCTL, bmBUSRST); //issue bus reset
                         usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE;
                         break;

https://geekhack.org/index.php?topic=69169.msg2635350#msg2635350

Bottom line:
There is/was confusion at workaround and solution for some reason.
In fact tmk/tmk_keyboard@3eae475f8b98 fixed the problem. 2021-07-23

commit 3eae475f8b98152b466f8f3763a74f0ef2330d9d
Author: tmk <hasu@tmk-kbd.com>
Date:   Thu May 11 00:16:21 2017 +0900

    usb_usb: Remove startup wait
    
    Some keyboards boot up quickly and cannot be enumerated
    when powering up converter and keyboard at same time

diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp
index 5b542a75..2d9f5602 100644
--- a/converter/usb_usb/main.cpp
+++ b/converter/usb_usb/main.cpp
@@ -75,11 +75,13 @@ int main(void)
      */
     sei();
 
+/* Some keyboards bootup quickly and cannot be initialized with this startup wait.
     // wait for startup of sendchar routine
     while (USB_DeviceState != DEVICE_STATE_Configured) ;
     if (debug_enable) {
         _delay_ms(1000);
     }
+*/
 
     debug("init: done\n");
@tmk tmk changed the title Bus state change detection Realforce RGB (AEAX01) startup problem Jul 23, 2021
@tmk
Copy link
Owner Author

tmk commented Jul 23, 2021

There is no problem in USB_Host_Shield_2.0 as for this.

The fix 227f3aa and its branch should be removed from repo.

https://github.com/tmk/USB_Host_Shield_2.0/commits/upstream_fix_bus_detection

tmk added a commit that referenced this issue Jul 24, 2021
This reverts commit c20f54f.

#8
This was not required for the problem.
@tmk
Copy link
Owner Author

tmk commented Jul 24, 2021

Closed by f0ae8a1

@tmk tmk closed this as completed Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant