Modify zephyr's Driver with out of tree procedure

Hi

I have been using my out of tree driver for my BG95 module, which I have copy pasted from the zephyr's quectel_bg9x driver (drivers/modem/quectel-bg9x) and its required files into respective folders and renamed as quectel-bg95cd and made a few additions to the code. Following is my folder structure

boards
└── ...

drivers
└── modem
    ├── CMakeLists
    ├── Kconfig
    ├── Kconfig.quectel-bg95cd
    ├── modem_context.c
    ├── modem_cmd_handler.c
    ├── modem_iface_uart_async.c
    ├── modem_iface_uart_interrupt.c
    ├── modem_socket.c
    └──quectel_bg95cd.c
└── zephyr
    └── module.yml

dts
└── bindings
    └── modem
        └── quectel,bg95cd.yaml

include
└── app
    └── drivers
        └── modem
            ├── quectel-bg95cd.h
            ├── modem_socket.h
            ├── modem_context.h
            ├── modem_cmd_handler.h
            └── modem_iface_uartt.h

I set the following in my main CMakeLists

  list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/drivers)
  zephyr_include_directories(include/app/drivers)

I need the "quectel-bg95cd.h" to be included in my main.c file, that's why I have placed them in include/app/drivers/modem folder, so I can have access to my added functions and also to strcut's like sockaddr, modem_cmd from my main.c file

I have changed my #include "quectel-bg9x.h" into <quectel-bg95cd.h> in quectel-bg95cd.c file, and also able to include it in main.c as #include <modem/quectel-bg95cd.h>

It builds and works fine till ncs v2.5.2, when I upgraded to ncs v2.6.0, I face the following error

/include/app/drivers/modem/modem_socket.h:20:10: fatal error: sockets_internal.h: No such file or directory

I could able to see a change in the CMakeLists in zephyr's drivers/modem/CMakeLists , is that the reason I'm unable to build?? or am I doing it wrong??

For reference ,I attach my drivers/modem/CMakeLists.txt (I have tried many cmds trying to resolve but didn't help)

# SPDX-License-Identifier: Apache-2.0

zephyr_library()

#zephyr_library_sources_ifdef(CONFIG_MODEM_RECEIVER modem_receiver.c)
#zephyr_library_sources_ifdef(CONFIG_MODEM_SHELL modem_shell.c)

#zephyr_library_sources_ifdef(CONFIG_MODEM_CONTEXT modem_context.c)

#zephyr_library_sources_ifdef(CONFIG_MODEM_IFACE_UART_INTERRUPT modem_iface_uart_interrupt.c)
#zephyr_library_sources_ifdef(CONFIG_MODEM_IFACE_UART_ASYNC modem_iface_uart_async.c)
#zephyr_library_sources_ifdef(CONFIG_MODEM_CMD_HANDLER modem_cmd_handler.c)
#zephyr_library_sources_ifdef(CONFIG_MODEM_SOCKET modem_socket.c)

zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/ip)
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/lib/sockets)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers/modem)
zephyr_library_include_directories(${APPLICATION_BASE}/include/app/drivers/modem)

zephyr_library_include_directories(.)
# zephyr_syscall_header(${APPLICATION_BASE}/include/app/drivers/modem/modem_test.h)
zephyr_syscall_header(${ZEPHYR_BASE}/drivers/modem/modem_context.h)
zephyr_syscall_header(${ZEPHYR_BASE}/drivers/modem/modem_socket.h)
zephyr_syscall_header(${ZEPHYR_BASE}/drivers/modem/modem_cmd_handler.h)
zephyr_syscall_header(${ZEPHYR_BASE}/drivers/modem/modem_iface_uart.h)

if(CONFIG_MODEM_QUECTEL_BG95CD)
	zephyr_library_sources(quectel-bg95cd.c)
endif()

Kindly guide me with this. Thanks.

Parents
  • Hi Vignesh,

    It seems that from NCS v2.6.0, Zephyr was changed in a way that internal headers are not readily available to external modules, which I think is a good thing.

    Can you try adding this to the driver's CMakeLists.txt?

    zephyr_library_include_directories_ifdef(CONFIG_NET_SOCKETS ${ZEPHYR_BASE}/subsys/net/lib/sockets)

    Hieu

  • Hello Hieu,

    I tried putting this line in my drivers/modem/CMakeLists.txt file (available in line no.16 of the cmakelists I gave above)

    Now as u suggested I tried putting it in my drivers/CMakeLists.txt too, but ended up with same error

    attaching my drivers/CMakeLists.txt

    # Copyright (c) 2021 Nordic Semiconductor ASA
    # SPDX-License-Identifier: Apache-2.0
    
    message("*** drivers folder file ***")
    zephyr_library_include_directories_ifdef(CONFIG_NET_SOCKETS ${ZEPHYR_BASE}/subsys/net/lib/sockets)
    add_subdirectory_ifdef(CONFIG_MODEM modem)

Reply
  • Hello Hieu,

    I tried putting this line in my drivers/modem/CMakeLists.txt file (available in line no.16 of the cmakelists I gave above)

    Now as u suggested I tried putting it in my drivers/CMakeLists.txt too, but ended up with same error

    attaching my drivers/CMakeLists.txt

    # Copyright (c) 2021 Nordic Semiconductor ASA
    # SPDX-License-Identifier: Apache-2.0
    
    message("*** drivers folder file ***")
    zephyr_library_include_directories_ifdef(CONFIG_NET_SOCKETS ${ZEPHYR_BASE}/subsys/net/lib/sockets)
    add_subdirectory_ifdef(CONFIG_MODEM modem)

Children
Related