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

Wake from suspend stopped working #756

Closed
mek-apelsin opened this issue Mar 11, 2023 · 6 comments
Closed

Wake from suspend stopped working #756

mek-apelsin opened this issue Mar 11, 2023 · 6 comments

Comments

@mek-apelsin
Copy link
Contributor

I suspect commit 781e2df introduced a bug which inhibits the ability to wake from sleep. I can't get my computer (running Ubuntu) to wake from sleep when using a m0118, a teensy2 and the "vanilla" keymap.

I can reliably trigger the "buggy" behavior by doing the following:
git checkout 781e2dfc && ( git submodule update && cd converter/adb_usb/ && make --silent clean && MCU=atmega32u4 make --silent teensy ) && sleep 5 && systemctl suspend

I re-enable the ability to wake from suspend by doing the following:
git checkout 781e2dfc~ && ( git submodule update && cd converter/adb_usb/ && make --silent clean && MCU=atmega32u4 make --silent teensy ) && sleep 5 && systemctl suspend

Haven't had the time to do much debugging, so far I got this:

  • GOOD
    ** PWR then SPACE during ordinary usage:
    7F7F FFFF 31FF B1FF
    ** PWR then SPACE during suspend:
    F7F FFFF 1FF

  • BAD
    ** PWR then SPACE during ordinary usage:
    $E:7F7F $E:FFFF $E:31FF $E:B1FF
    ** PWR then SPACE during suspend:
    $E:7F7F $E:FFFF $E:31B1

@tmk
Copy link
Owner

tmk commented Mar 11, 2023

Can you try adb_usb_rev1_unimap.hex and show full debug log?
https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb/binary

@tmk
Copy link
Owner

tmk commented Mar 11, 2023

Confirmed the bug. You are right, the commit introduced it.

This change should fix the bug. I'll update code in repo soon. Thanks.

diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c
index 73c47649..74470743 100644
--- a/converter/adb_usb/matrix.c
+++ b/converter/adb_usb/matrix.c
@@ -811,11 +811,6 @@ void matrix_init(void)
 {
 }
  
-uint8_t matrix_scan(void)
-{
-    return 0;
-}
-
 inline
 matrix_row_t matrix_get_row(uint8_t row)
 {
@@ -832,7 +827,7 @@ void led_set(uint8_t usb_led)
     adb_host_kbd_led(ADB_ADDR_KEYBOARD, ~usb_led);
 }
  
-void hook_main_loop(void)
+uint8_t matrix_scan(void)
 {
     static uint16_t poll_ms;
     static uint16_t detect_ms;

@tmk
Copy link
Owner

tmk commented Mar 11, 2023

@mek-apelsin Can you share M0118 debug log at startup like below?
It would be helpful to improve ISO-layout keyboard support.

TMK:e9c74f/LUFA:d6a7df

USB configured.

Scan:
$2 R3:6C01


Loop start.
R:$2:Found. R3:6D01
R:$2:Move to $F. R3:6A01
K:$F:Setup. R3:6101
K:$F:Layout: ANSI

Table:
A:H  a:h
---------
F:01 2:01

@mek-apelsin
Copy link
Contributor Author

mek-apelsin commented Mar 11, 2023

Waiting for device:
Listening:
# Running teensy_loader_cli  --mcu=atmega32u4  -w converter/adb_usb/binary/adb_usb_rev1_unimap.hex in other window


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

TMK:c46d7b/LUFA:d6a7df

USB configured.

Scan:
$2 R3:6804


Loop start.
R:$2:Found. R3:6A04
R:$2:Move to $F. R3:6504
K:$F:Setup. R3:6D04
K:$F:Layout: ISO

Table:
A:H  a:h
---------
F:04 2:04

# Testing a few keys... a  g  l  PWR and lshift+a
K:$F:04:00FF K:$F:04:80FF K:$F:04:05FF K:$F:04:85FF K:$F:04:25FF K:$F:04:A5FF K:$F:04:7F7F K:$F:04:FFFF 
Scan:
$F R3:6104


Table:
A:H  a:h
---------
F:04 2:04

K:$F:04:38FF K:$F:04:00FF K:$F:04:80FF K:$F:04:B8FF 

# Enabling debug:
K:$F:04:7F7F K:$F:04:02FF 
debug: off
K:$F:04:82FF K:$F:04:FFFF 
Scan:
$F R3:6004


Table:
A:H  a:h
---------
F:04 2:04

# oh, it is on by default, reenabling

K:$F:04:7F7F K:$F:04:02FF 
debug: on
K:$F:04:82FF K:$F:04:FFFF 
Scan:
$F R3:6304


Table:
A:H  a:h
---------
F:04 2:04

K:$F:04:33FF K:$F:04:B3FF K:$F:04:33FF K:$F:04:B3FF K:$F:04:33FF K:$F:04:B3FF K:$F:04:33FF K:$F:04:B3FF 
# A few Backspaces

# And lets run suspend...

K:$F:04:31B1 K:$F:04:31B1 K:$F:04:31B1 K:$F:04:31B1 

# Pressed quite a few times on space and PWR, and once on 'j'. Did not wake from suspend. 



@mek-apelsin
Copy link
Contributor Author

The fix in ecf5298 works as expected.

@tmk
Copy link
Owner

tmk commented Mar 11, 2023

Thanks for the log.

I confirmed that M0118 has hanlder ID:0x04 and ISO Layout of the keyboard should be supported by current firmware.

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

2 participants