KSCAN sample build fail

Hello,

I am using nrf5340dk board to test KSCAN sample.I add overlay file in my kscan application and modify code below:

//const struct device *const kscan_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_keyboard_scan));
const struct device *const kscan_dev = DEVICE_DT_GET(DT_NODELABEL(kscan0));

Here is my overlay file "nrf5340dk_nrf5340_cpuapp.overlay":

/ {
    chosen {
        kscan = &kscan0;
    };

    kscan0: kscan_0 {
        compatible = "kscan-gpio-matrix";
        label = "KSCAN";
        diode-direction = "col2row";
        col-gpios
            = <&gpio1 4 GPIO_ACTIVE_HIGH>
            , <&gpio1 5 GPIO_ACTIVE_HIGH>
            , <&gpio1 6 GPIO_ACTIVE_HIGH>
            ;

        row-gpios
            = <&gpio0 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            , <&gpio0 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            , <&gpio0 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
            ;
    };
    aliases {
        kscan0 = &kscan0;
    };
};

When building,it occurs error:

c:/nordic/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj): in function `block_matrix_callback':
C:\NORDIC\nrf5340_test_1212\kscan\src\main.c:153: undefined reference to `__device_dts_ord_10'
c:/nordic/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj): in function `main':
C:\NORDIC\nrf5340_test_1212\kscan\src\main.c:169: undefined reference to `__device_dts_ord_10'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\NORDIC\toolchains\v2.2.0\opt\bin\cmake.EXE' --build 'c:\NORDIC\nrf5340_test_1212\kscan\build'

It seems that there is something wrong with "DEVICE_DT_GET(DT_NODELABEL(kscan0))".

I checked my zephyr.dts,kscan0 is declared in it.

Is there anything else that needs to be modified?

The nRF connect SDK version I used is v2.2.0.

  • Hi Raoul,

    Thank you for your assistance.

    Here is my prj.conf. I added RTT CONFIG to the sample for debugging, but I don't think this will lead to the build fail of the kscan sample.

    CONFIG_STDOUT_CONSOLE=y
    CONFIG_PRINTK=y
    CONFIG_KSCAN=y
    
    #RTT
    CONFIG_CONSOLE=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    

    I try to connect nrf5340dk with a homemade 3x3 keypad. The keypad only have 6 gpios and doesn't need i2c or other parts. 
    Does the Keyboard matrix connected to the Kscan sample need other hardware other than gpio? Or if there are other matrix keyboards that are compatible with kscan, please let me know.

    Thank you for your suggestion, I will use a clean build when building kscan to prevent possible NCS cache issues.

    I want to implement a simple matrix keyboard. I think kcan is the closest sample, so I use it.  If there are other samples that can implement a matrix keyboard, please let me know.
    I will try to continue to modify the kscan sample and try to get more information from the test modification.
    Thank you again for your assistance.

  • Hi Landy,

    Thanks for sharing your details! No, I don't think RTT will interfere with the sample.

    And as far as I know, only gpio is needed.

    I haven't received any suggestions from my team so far. I'll try to reach a developer on this, and keep you updated.

    Any progress on your side?

    By the way, maybe you are already aware, but there is a Zephyr based open source keyboard firmware called ZMK that you might want to look at. If we don't get further with the NCS sample soon, maybe that could be a better starting point in the interim.

    Best regards,

    Raoul.

  • Hi Raoul,

    There is no new progress on my side.I'm still stuck on the devicetree error.

    Thank you for your suggestion.I'll look at ZMK for more information.

  • Hello,

    I have solved the kscan build fail problem by using device_get_binding instead of DEVICE_DT_GET.

    But device_is_ready(kscan_dev) return false when initializing, and the subsequent steps will not be performed.

    I think this problem is still related to the setting of the devicetree.

    Is there any suggestion for using kscan sample?

  • Hi Landy, thanks for the info! I'll try to replicate what you did, and see if I can find out more.

    Best regards,

    Raoul

Related