This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Adding in drivers into zephyr

Hey all


trying to understand how to add in drivers from zephyr into my project. an example like adding the w5500 module would that ential something like this ?

-1) copy contents of kconfig file into source kconfig (file: Kconfig.w5500 into -> prj.conf
-2) from cmakelists.txt in the ethernet directory 
    -- add zephyr_include_directories(${ZEPHYR_BASE}/subsys/net/l2)
    -- add zephyr_sources_ifdef(CONFIG_ETH_W5500 eth_w5500.c)
    -- add 

 if(CONFIG_ETH_NATIVE_POSIX)
zephyr_library()
zephyr_library_compile_definitions(
NO_POSIX_CHEATS
_BSD_SOURCE
_DEFAULT_SOURCE
)
zephyr_library_sources(
eth_native_posix.c
eth_native_posix_adapt.c
)
endif()


and then reload and enable it in menuconfig ?

Just want some confirmation before i start tinkering.
tried searching on the forum for a similiar question but i didnt see any results with "zephyr & drivers"
if these a page on https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/index.html that i've missed please pop that through as i've missed it

Thankyou !!

Parents
  • Hi,

     

    This driver is a zephyr component, but I'll try to help you along the way.

    You need to first add the dependencies of the device itself, which is the transport layer (SPI) and the net stack in zephyr:

    CONFIG_SPI=y
    CONFIG_NETWORKING=y
    CONFIG_NET_L2_ETHERNET=y
    CONFIG_ETH_W5500=y
    

     

    And you need to define the device in device tree as well. This can be done by creating the my-application/boards folder, and $(BOARD).overlay (for example: boards/nrf5340dk_nrf5340_cpuapp.overlay), which should hold the peripheral and device specific declaration:

    &spi3 {
            sck-pin = <47>;
            miso-pin = <46>;
            mosi-pin = <45>;
            cs-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
            status = "okay";
            w5500: w5500@0 {
                    compatible = "wiznet,w5500";
                    label = "w5500";
                    reg = <0>;
                    spi-max-frequency = <1000000>;
                    int-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
    // optional:             reset-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
            };
    };

     

    Note that the above is provided as an example, please change the GPIOs to match your wanted pins.

     

    Kind regards,

    Håkon

  • Sorry for the delay. oh ok, so just to reitterate 
    CONFIG_NETWORKING=y
    CONFIG_NET_L2_ETHERNET=y
    CONFIG_ETH_W5500=y
    alone link the drivers to the project.

    so in the case that the driver isnt a zephyr component does that make it alot harder to add in ?  is there a template/ tutorial / page on the matter ?

  • Hi,

     

    lolcatsnin said:
    so in the case that the driver isnt a zephyr component does that make it alot harder to add in ?  is there a template/ tutorial / page on the matter ?

    If the component/driver isn't already present in zephyr, and you want to add it in the "zephyr way", I'd recommend reading the zephyr documentation, and its driver model:

    https://docs.zephyrproject.org/latest/reference/drivers/index.html

    And the device tree:

    https://docs.zephyrproject.org/latest/reference/devicetree/index.html#

     

    Kind regards,

    Håkon

Reply Children
Related