tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.98k stars 1.7k forks source link

usb_usb stops working when (1) switching on a KVM switch and (2) computer start from sleep #703

Closed lightingghost closed 2 years ago

lightingghost commented 3 years ago

I have a usb2usb converter (pre-assembled, not the pro micro one), I am using it by attaching a unifying receiver to it.

I found the keyboard lost connection when (1) switching to another computer with a KVM switch (2) computer start from sleep. (macbook pro)

I also tried to connect the usb_usb converter directly to my computer using a type-c -> type-a convertor, it still stops working when starts from sleep.

I found this PR to address the similar issue (if not the same), but I built the firmware from the master brach, so it should already been merged.

I would be happy to provide more details or follow your instructions to help debug this issue. Any help will be appreciated.

tmk commented 3 years ago

What is model number of the Unifying redeiver and KVM switch?

Let's forget the KVM and focus (2) sleep problem here. Do you need to replug the converter to recovery the problem, or just repluging the Unifying dongle?

Connect converter directly to macbook. Can you share debug log with hid_listen when you sleep and resume?

tmk commented 3 years ago

Use this debug firmware attached in this post. https://geekhack.org/index.php?topic=69169.msg3075062#msg3075062

lightingghost commented 3 years ago

@tmk

Thank you for helping! I am providing the answers below:

What is model number of the Unifying receiver and KVM switch?

The model number of the unifying receiver is C-U0007 I cannot find the model number of the KVM switch, but the it's UGREEN's usb 2.0 KVM switch

Let's forget the KVM and focus (2) sleep problem here. Do you need to replug the converter to recovery the problem, or just repluging the Unifying dongle?

I need to replug the converter. Replugging the unifying dongle doesn't help -- replugging the unifying dongle makes the connection light on the keyboard blinks, which means it cannot connect the receiver. However, before replugging, although the keyboard has no input, light shows it is able to connect to the receiver.

Connect converter directly to macbook. Can you share debug log with hid_listen when you sleep and resume?

Here is the log after a long sleep.

(After a short time of sleep for example 5 min, the receiver is able to connect back with no problem: pressing the keyboard cannot wake up the computer, and the connection light shows it cannot connect the receiver, but after clicking the mouse to wake up, pressing the keyboard can make it connect the receiver. However, after a long sleep, for example over night, it cannot connect back. The log below is the one after a long sleep over night.)

Waiting for device:
Listening:

//here I replugged the converter 
Device disconnected.
Waiting for new device:...
Listening:

TMK:9154a8/LUFA:d6a7df/UHS2:ee3e6b

USB configured.

Loop start.
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:046D
pid:C52B
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:0054
Ci [xE1][xE++]read:0040
left:0014
read:0014
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:003B
left:0045
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2323
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
tmk commented 3 years ago

I don't own any mac to test, but I just confirm on Windows 10 that the converter works through sleep/resume and wakeup by pressing a key.

With other normal wired keyboard, can the converter wake up mac? and resume normally after long sleep? I want to know whether the problem is specific to Unifying receiver or not.

lightingghost commented 3 years ago

I tested using a normal wired keyboard. The converter cannot wake up mac, and it did not work after waking up.

I tried using my window PC as well: The keyboard connected to the converter cannot wake up from hibernation, but after waking up, it works without replugging.

tmk commented 3 years ago

So the problem seems to be not specific to Unifying receiver but specific to Mac. Can you agree to this?

In general, you can't wake up by key press(or mouse click) from hibernation or deep sleep mode. This is expected behaviour, not problem. Becase those modes shut down power completely for the converter. Meanwhile, you can wake up Windows by key press in suspend or sleep mode. And the converter and keyboard are expected to work without repluging after resuming from any power-saving modes, of course.

On your Windows PC does the covnerter work with both wired keyboard and Unifying as expected above?

lightingghost commented 3 years ago

I agree with you that the problem is more like to be specific to Mac.

My windows pc does not have the option to sleep ( probably due to lack of C3 state), but the converter under hibernation works as expected.

tmk commented 3 years ago

Thanks for the confirmation.

A few more questions to ask: The converter works with short sleep without the problem, right? and the converter can wake Mac with pressing a key during the short sleep?

I read some articles about Mac sleep, interesting TIL :D Mac power state may be changed from normal sleep after some hours(3 and 8?). Can you share your Mac power setting using pmset -g?

https://mackeeper.com/blog/mac-sleep-modes-explained/ https://computers.tutsplus.com/tutorials/how-to-hibernate-a-mac--cms-23235 https://en.wikipedia.org/wiki/Pmset

This attached firmware should display some more debug info on USB suspend and resume. Can you try this on short sleep? Test procedure should be like below.

  1. Run hid_listen on Terminal
  2. Plug the converter only first, and then plug the wired keyboard.
  3. Press a b and c key.
  4. sleep(USB suspend)
  5. wake by pressing Left shift key a few times(USB resume)
  6. Wait for Mac to awake
  7. Press a b and c key.

https://gist.github.com/tmk/0dbd10c69ed4c52d707710a1016845a5

lightingghost commented 3 years ago

Thank you for helping to debug.

The converter works with short sleep without the problem, right?

Yes

and the converter can wake Mac with pressing a key during the short sleep?

Yes

Here is the output of pmset - g

System-wide power settings:
Currently in use:
 standby              1
 standbydelaylow      10800
 womp                 1
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 proximitywake        1
 powernap             1
 gpuswitch            2
 networkoversleep     0
 disksleep            10
 standbydelayhigh     86400
 sleep                30 (sleep prevented by coreaudiod)
 hibernatemode        3
 ttyskeepawake        1
 displaysleep         30
 tcpkeepalive         1
 highstandbythreshold 50
 acwake               0
 lidwake              1

here is the log following the steps you provided

Waiting for device:......
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 12
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2327
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 05 00 00 00 00 00
00 00 05 00 00 00 00 00
binput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 06 00 00 00 00 00
00 00 06 00 00 00 00 00
cinput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
[L0]input 1: 02 00 00 00 00 00 00 00
02 00 00 00 00 00 00 00
input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 05 00 00 00 00 00
00 00 05 00 00 00 00 00
binput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 06 00 00 00 00 00
00 00 06 00 00 00 00 00
cinput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
^C
tmk commented 3 years ago

Seeing the debug log the converter seems to work well after short sleep.

Let's see what the same test procedure displays after resuming from 'standby' mode now. If I understand the power configuration correctly your Mac falls into 'standby' automoatically after 3 hours of normal sleep with less than 50% battery capacity.(24 hours/86400sec with 50% more battery.) I think you can change 'standbydelay[low|high]' setting with pmset so that you don't have to wait for that long time. If the converter doesn't works after resuming from standby, try replugging the keyboard first before replugging the converter.

When plugging the wired keyboard(or Unifying keyboard) directly into Mac it works well after resuming from standby without any issue? Also it can wake Mac by pressing a key when it stays in standby mode?

lightingghost commented 3 years ago

Here is the log under the same procedure after resuming form standby.

Waiting for device:.....
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 12
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 05 00 00 00 00 00
00 00 05 00 00 00 00 00
binput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 06 00 00 00 00 00
00 00 06 00 00 00 00 00
cinput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
[L0]
Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2327
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 06 00 00 00 00 00
00 00 06 00 00 00 00 00
input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 05 00 00 00 00 00
00 00 05 00 00 00 00 00
input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 05 00 00 00 00 00
00 00 05 00 00 00 00 00
binput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 06 00 00 00 00 00
00 00 06 00 00 00 00 00
cinput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
^C

Interestingly, although the converter cannot wake up mac from standby, it has no problem after waking up using mouse.

I tried again with the firmware I built, it does not work after waking up.

I am building at

commit 8c0e245f52182055de1d10397b58373f2bdad46d (HEAD -> master, origin/master, origin/HEAD)
Author: tmk <hasu@tmk-kbd.com>
Date:   Tue Aug 17 23:05:29 2021 +0900

    ibmpc_usb: Update prebuild firmware files

and the avr-gcc version

avr-gcc (Homebrew AVR GCC 8.4.0_1) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Is there anything I am doing wrong? How is your test firmware built?

tmk commented 3 years ago

It is promising result somewhat. Recent changes on 'USB_Host_Shield_2.0-tmk' submodule may cause this problem.

According to the log Mac seems to USB-reset(or power cycle) the converter twice, that is indicated by ' Device disconnected.' lines. It is not what I expected for standby behaviour, but it seems more like deep sleep(hibernation/poweroff).

Without the converter, the wired or Unifying keyboard can wake Mac from standby?

As for firmware build, You can access my current code with this temporary branch https://github.com/tmk/tmk_keyboard/tree/usb_usb_test Note that you need to update submodule too: tmk_core/protocol/usb_hid/USB_Host_Shield_2.0-tmk

lightingghost commented 3 years ago

Without the converter, the wired or Unifying keyboard can wake Mac from standby?

Yes the wired/unifying keyboard can wake Mac from standby.

Thank you for sharing your temporary branch, I'll give it a try later.

lightingghost commented 3 years ago

I don't know what happened, but the converter stopped working again after waking up. I tried replug several times but it still does not work. I changed back to the debug firmware and recorded the following log

Waiting for device:
Listening:
input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 05 00 00 00 00 00
00 00 05 00 00 00 00 00
binput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 06 00 00 00 00 00
00 00 06 00 00 00 00 00
cinput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.....
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 12
[I0]6[L0][L0][L0][L0][L0]usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:046D
pid:C52B
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:0054
Ci [xE1][xE++]read:0040
left:0014
read:0014
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:003B
left:0045
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2325
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
[L0]
Device disconnected.
Waiting for new device:..................................
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_st
Device disconnected.
Waiting for new device:...
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_st
Device disconnected.
Waiting for new device:...
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 12
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:046D
pid:C52B
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
Device disconnected.
Waiting for new device:..
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_st
Device disconnected.
Waiting for new device:...
Listening:
gured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_st
Device disconnected.
Waiting for new device:..
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:046D
pid:C52B
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
nak_limit:7FFF
crSU:0E

getDevDescr 0E
Init:0E
BUSRST
AttemptConfig2:0E
Configuring:0E
host.Task: 408
usb_state: A0
usb_state: 12

here is another log that replugging solves the problem

Waiting for device:
Listening:
input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
[L0]
Device disconnected.
Waiting for new device:...............................
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:046D
pid:C52B
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:0054
Ci [xE1][xE++]read:0040
left:0014
read:0014
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:003B
left:0045
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2324
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
tmk commented 3 years ago

You used Unifying receiver this time while wired keyboard in the last test. With wired keyboard does the converter still work as the last test? Do you think Unifying receiver causes this problem?

In the log the converer failed to initialize Unifying receiver for some reason, crSU:0E in end part means timeout error.

How do you turn your Mac into standby mode? I assume that you have to wait for 3 hours using less 50% battery without AC power adapter unless you change power configuration with pmset or preference pane. Am I right?

It there a way to know current power state of Mac or discriminate between standby and normal sleep? LED indicator, I guess? And according to the manual pmset -g log displays a history of sleeps, wakes, and other power management events. You can check its outputs after resuming test.

lightingghost commented 3 years ago

You used Unifying receiver this time while wired keyboard in the last test. With wired keyboard does the converter still work as the last test? Do you think Unifying receiver causes this problem?

The wired keyboard does not work with the converter as well. Here is the log after sleep over night. I have to replug:

Waiting for device:
Listening:

Device disconnected.
Waiting for new device:...
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
[L0]
Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2327
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:.
Listening:
usb_state: 12
usb_state: 20
usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

Device disconnected.
Waiting for new device:....
Listening:

TMK:39273d/LUFA:d6a7df/UHS2:8dc3c8
[C][S][W][R][W][c]
USB configured.

Loop start.
usb_state: 20
[I0]6[P][L0][L0][L0][L0][L0]usb_state: 40
usb_state: 50
usb_state: 51
Ci read:0012
left:0000
vid:FEED
pid:1964
klass:00
subklass:00
AC1
AC2
A2 driver:00
BM Init
Ci read:0008
left:0000
Addr:01
Ci read:0012
left:0000
NC:01
HID_PROTOCOL_KEYBOARD
[gC]Ci read:0009
left:0000
Cl:006D
Ci [xE1][xE++]read:0040
left:002D
read:002D
left:0000
bNumEP:02
Cnf:01
bIfaceNum:00
bNumIface:00

Interface:00
PROTOCOL SET HID_BOOT rcode:00
SET_IDLE rcode:00
Ci read:0040
left:0040
read:0000
left:0040
RPIPE rcode:00
BM configured
Init:00
AttemptConfig2:00
Configuring:00
host.Task: 2326
usb_state: 90
speed: full
Co input 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 05 00 00 00 00 00
00 00 05 00 00 00 00 00
binput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
input 1: 00 00 06 00 00 00 00 00
00 00 06 00 00 00 00 00
cinput 1: 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

In the log the converer failed to initialize Unifying receiver for some reason, crSU:0E in end part means timeout error.

How do you turn your Mac into standby mode? I assume that you have to wait for 3 hours using less 50% battery without AC power adapter unless you change power configuration with pmset or preference pane. Am I right?

I followed your suggestion by changing the standbyhigh and standbylow to 300

 standbydelaylow      300
 standby              1
 womp                 1
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 proximitywake        1
 powernap             1
 gpuswitch            2
 networkoversleep     0
 disksleep            10
 standbydelayhigh     300
 sleep                30
 hibernatemode        3
 ttyskeepawake        1
 displaysleep         30
 tcpkeepalive         1
 highstandbythreshold 50
 acwake               0
 lidwake              1

It there a way to know current power state of Mac or discriminate between standby and normal sleep? LED indicator, I guess?

I don't think I can see the different without powering on the mac.

And according to the manual pmset -g log displays a history of sleeps, wakes, and other power management events. You can check its outputs after resuming test.

tmk commented 3 years ago

I still can't get good clue out of debug prints so far. I wildly guess that debug print USB interface can cause somehow. You can disable the debug interface by having a line CONSOLE_ENABLE = no in Makefile.

Does MacOS have system logs under directory like /var/log and don't the logs have something informational when the problem occurs? Also trying command $ pmset -g log may display useful infos.

lightingghost commented 3 years ago

Thanks for the suggestion. I tried to disable the debug interface but the problem is still there.

I tried to search system logs using console with the keyword of "usb" and "hid", but I could not find anything. I also tried to search in the log from pmset -g log, there doesn't seem to be anything interesting.

tmk commented 2 years ago

@lightingghost Updated firmware. Try new firmware when you have time. https://geekhack.org/index.php?topic=69169.msg3089895#msg3089895