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.

Parents
  • Hi Landy,

    I haven't reached a conclusion yet. Sorry for my poor communication!

    I have followed the case you linked to, and the linked private case, and found other related cases - but all cases seem to remain unresolved. Working with the Kscan sample is tricky as it seems to be designed to be used together with a configured driver, and an actual scan matrix keyboard. So both customers and Nordic engineers don't have the setup that this sample assumes. I assume you are also getting this CMake error (in addition to your devicetree issue):

    CMake Warning at /opt/nordic/ncs/v2.2.0/zephyr/CMakeLists.txt:824 (message):
      No SOURCES given to Zephyr library: drivers__kscan

    By the way, could you share your prj.conf with me? Or is it completely unmodified from the kscan sample?

    Also, what kind of hardware are you trying to connect?

    Regarding your suggestion, I don't think there is anything directly wrong with DEVICE_DT_GET(DT_NODELABEL(kscan0)). I tried replacing DT_NODELABEL with for example DT_ALIAS(kscan0) and DT_CHOSEN(kscan), but issue remains. However, I should note that when trying these DT functions, one time I seemed to have some cached value that only changed when I deleted the build folder, and not when doing a pristine build. I'm not sure what was going on there, but just in case, could you try doing a "clean build" like that? An NCS cache issue like that has happened before (but very rarely).

    I have asked internally for suggestions on this issue. I'll let you know if I receive anything useful, and I'll try to keep you updated more regularly.

    Sorry to leave you all stuck with this issue.

    Best regards,

    Raoul

  • 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.

Reply Children
No Data
Related