zmkfirmware / zmk

ZMK Firmware Repository
https://zmk.dev/
MIT License
2.79k stars 2.82k forks source link

Bug: keypresses not working after commit 0438cb0 #2388

Closed Scalee closed 3 months ago

Scalee commented 3 months ago

After updating to this commit my keyboard stops working. (or just the latest commit, Just narrowed it down to this commit)

The keyboard will still connect and output logs but no keystrokes.

If I change chosen to &kscan1, the gpio-matrix will start working. If I switch to &kscan2 the charlieplex will start working. Back to kscan_composite, nothing. Rolling back one commit and recompiling everything works as expected.

Was asked to create a new issue and link to #2376 since they might be related.

#include <dt-bindings/zmk/matrix_transform.h>

/ {
    chosen {
        zmk,kscan = &kscan0;
        zmk,matrix-transform = &comp_transform;
    };

    comp_transform: keymap_transform {
        compatible = "zmk,matrix-transform";

        rows = <12>;
        columns = <7>;

        map = <
            //Left side
            RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6)        
            RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) 
            RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6)       
            RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6)        
            RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) 
            RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4) RC(5,5) RC(5,6)

            //Right side
            RC(6,1) RC(7,0) RC(8,0) RC(9,0) RC(10,0) RC(11,0) RC(12,0)
            RC(6,2) RC(7,2) RC(8,1) RC(9,1) RC(10,1) RC(11,1) RC(12,1)
            RC(6,3) RC(7,3) RC(8,3) RC(9,2) RC(10,2) RC(11,2) RC(12,2)
            RC(6,4) RC(7,4) RC(8,4) RC(9,4) RC(10,3) RC(11,3) RC(12,3)
            RC(6,5) RC(7,5) RC(8,5) RC(9,5) RC(10,5) RC(11,4) RC(12,4)
            RC(6,6) RC(7,6) RC(8,6) RC(9,6) RC(10,6) RC(11,6) RC(12,5)
        >;
    };

    kscan0: kscan_composite {
        compatible = "zmk,kscan-composite";
        rows = <12>;
        columns = <7>;

        matrix {
            kscan = <&kscan1>;
        };

        charlie {
            kscan = <&kscan2>;
            row-offset = <6>;
        };
    };
    kscan1: kscan_matrix  {
        compatible = "zmk,kscan-gpio-matrix";
        wakeup-source;

        diode-direction = "col2row";
        col-gpios
            = <&gpio0 10 GPIO_ACTIVE_HIGH>,
              <&gpio1 11 GPIO_ACTIVE_HIGH>,
              <&gpio1 13 GPIO_ACTIVE_HIGH>,
              <&gpio1 15 GPIO_ACTIVE_HIGH>,
              <&gpio0 2 GPIO_ACTIVE_HIGH>,
              <&gpio0 29 GPIO_ACTIVE_HIGH>,
              <&gpio0 31 GPIO_ACTIVE_HIGH>;

        row-gpios
            = <&gpio1 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            , <&gpio1 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            , <&gpio1 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            , <&gpio1 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            , <&gpio1 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            , <&gpio0 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
    };

   kscan2: kscan_charlie {
        compatible = "zmk,kscan-gpio-charlieplex";
        wakeup-source;

        interrupt-gpios = <&gpio0 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN) >;

        gpios
          = <&gpio0 8 GPIO_ACTIVE_HIGH>
          , <&gpio0 17 GPIO_ACTIVE_HIGH>
          , <&gpio0 20 GPIO_ACTIVE_HIGH>
          , <&gpio0 22 GPIO_ACTIVE_HIGH>
          , <&gpio0 24 GPIO_ACTIVE_HIGH>
          , <&gpio1 0 GPIO_ACTIVE_HIGH>
          , <&gpio0 11 GPIO_ACTIVE_HIGH>;
    };
};
Scalee commented 3 months ago

Did some testing.

When kscan_composite isn't being used kscan_charlieplex_pm_action does get called on boot.

*** Booting Zephyr OS build 87fa801c5b91 ***
[00:00:00.477,935] <inf> fs_nvs: 8 Sectors of 4096 bytes
[00:00:00.477,935] <inf> fs_nvs: alloc wra: 0, e20
[00:00:00.477,966] <inf> fs_nvs: data wra: 0, 2ac
[00:00:00.479,492] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.479,522] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:00.479,553] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 3.5 Build 0
[00:00:00.479,888] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.479,980] <dbg> zmk: kscan_charlieplex_pm_action
[00:00:00.479,980] <dbg> zmk: kscan_charlieplex_setup_pins
[00:00:00.480,163] <dbg> zmk: kscan_charlieplex_init_interrupt
[00:00:00.480,194] <dbg> zmk: kscan_charlieplex_enable
[00:00:00.480,560] <dbg> zmk: kscan_charlieplex_interrupt_enable
[00:00:00.480,560] <dbg> zmk: kscan_charlieplex_interrupt_configure
[00:00:00.480,682] <dbg> zmk: kscan_charlieplex_configure
[00:00:00.480,682] <dbg> zmk: kscan_charlieplex_enable
[00:00:00.481,048] <dbg> zmk: kscan_charlieplex_interrupt_enable
[00:00:00.481,079] <dbg> zmk: kscan_charlieplex_interrupt_configure

When using the composite driver is used, kscan_charlieplex_pm_action isn't called.

[00:00:00.434,173] <dbg> zmk: kscan_charlieplex_init
*** Booting Zephyr OS build 87fa801c5b91 ***
[00:00:00.440,185] <inf> fs_nvs: 8 Sectors of 4096 bytes
[00:00:00.440,185] <inf> fs_nvs: alloc wra: 0, e20
[00:00:00.440,185] <inf> fs_nvs: data wra: 0, 2ac
[00:00:00.441,741] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.441,772] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:00.441,802] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 3.5 Build 0
[00:00:00.442,138] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.442,230] <dbg> zmk: kscan_charlieplex_configure
[00:00:00.442,413] <dbg> zmk: kscan_charlieplex_enable
[00:00:00.442,779] <dbg> zmk: kscan_charlieplex_interrupt_enable
[00:00:00.442,810] <dbg> zmk: kscan_charlieplex_interrupt_configure

Difference being:

[00:00:00.479,980] <dbg> zmk: kscan_charlieplex_pm_action
[00:00:00.479,980] <dbg> zmk: kscan_charlieplex_setup_pins
[00:00:00.480,163] <dbg> zmk: kscan_charlieplex_init_interrupt
petejohanson commented 3 months ago

@Scalee Can you please give #2402 a try for me on this?

Scalee commented 3 months ago

Fixed