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,

    It's OK.I will wait for you.

    I'll keep trying to modify my code for this problem, and if there are new test results, I will post them here.

    Thank you for your assistance.

  • I'm trying to build lvgl sample in \ncs\v2.2.0\zephyr\samples\subsys\display\lvgl on nrf52840dk. Also, we have similar building error with kscan and "const struct device *kscan_dev = DEVICE_DT_GET(KSCAN_NODE);". We'd like to follow up this discussion to see if it is solved. 

  • Hi, thanks for letting us know. I had to prioritize other cases the past few days but I'm now investigating this. I'll get back to you when I know more!

    Best regards,

    Raoul

  • Excuse me,
    Is there any suggestions on this issue? I'm still waiting for a reply.

  • 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

Related