DHCPv4 client + Ethernet (W5500) Fails to work in SDK 2.4

Hello everyone,

I am working on an application based on dhcpv4_client from the zephyr SDK samples https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.99-dev2/zephyr/samples/net/dhcpv4_client/README.html#dhcpv4-client-sample.

I am using wiz550io v3 ethernet controller which uses W5500 driver.
I made the same implementation on nrf 2.3 SDK and it works, however the same implementation dose not work with 2.4 SDK. I can build the app and flash it. however no data is received, I am not sure it seems that the callback function dose not receive any interpret signal.

The serial monitor print initializing the dhcp_client and then remains stuck.

Note: I am using nrf 2.4 SDK with the nrf52833dk 

# Networking General
CONFIG_NETWORKING=y
CONFIG_NET_IPV4=y
CONFIG_NET_ARP=y
CONFIG_NET_UDP=y
CONFIG_NET_DHCPV4=y
CONFIG_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_LOG=y
CONFIG_LOG=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_L2_ETHERNET=y

# Networking Protocols and Extensions
CONFIG_NET_IPV6=n
CONFIG_NET_TCP=y
CONFIG_DNS_RESOLVER=y
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"
CONFIG_NET_SOCKETS=y

# Testing and Debugging
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_SHELL=y

# System and Library Configurations
CONFIG_NEWLIB_LIBC=y
CONFIG_MAIN_STACK_SIZE=1200
CONFIG_GPIO=y
CONFIG_ENTROPY_GENERATOR=y
CONFIG_INIT_STACKS=y



Networking Hardware Suppor
CONFIG_NETWORKING = y
CONFIG_ETH_DRIVER=y
CONFIG_ETH_W5500=y
CONFIG_ETH_W5500_TIMEOUT=1000
 

Prj.conf file

 

&spi1 {
        compatible = "nordic,nrf-spi";
        status = "okay";
        cs-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
        w5500: w5500@0 {
                compatible = "wiznet,w5500";
                label = "w5500";
                reg = <0>;
                spi-max-frequency = <1000000>;
                int-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
                reset-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
        };
};

nrf52833dk overlay file 

Parents
  • Hi Abdullah,

    Just to be clear, are you using the exact same application with NCS v2.3.0 and v2.4.0? Or have you recreated it for each of them? Note that with our VS Code extension, it's quite easy to change the NCS version you are building with (let me know if you need help with that).

    Unfortunately I don't have any ethernet modules available for testing, and also don't know how closely your application is to the sample. Would you be able to recreate a minimal example of this issue using the dhcpv4_client sample you mentioned, with as few modifications as possible?

    I also see that there have been some changes to the sample since NCS v2.3.0 launched in March:

    https://github.com/zephyrproject-rtos/zephyr/commits/main/samples/net/dhcpv4_client

    It's possible that the changes there are necessary for compatibility with NCS v2.4.0.

    So, if you have issues with the v2.3.0 sample on v2.4.0, could you try using the v2.4.0 sample as a starting point to see if the changes there fix your issue?

    If you happen to find a bug in the sample, feel free to create an issue on Github to reach the developers directly. But of course, let me know if you need further help.

    Best regards,

    Raoul

  • Hello Raoul,

    First thank you very much for your response and effort.
    Regarding the application, I have recreated the app for each SDK, I didn't really change a lot, I only included the project configuration and the ethernet controller overlay. I am including my app for 2.4 SDK.


    Regards,
    Abdullah 

    Ethernet.rar

  • Thanks! I'm a bit busy at the moment, but I'll take a closer look at this as soon as I can.

    Best regards,

    Raoul

Reply Children
  • Abdullah,

    I'm sorry to say I still haven't had time to look into this. I'll try to get you an answer no later than Tuesday. Thanks for your patience, and let me know if you happened to have made any progress.

    Best regards,
    Raoul

  • Hi Raoul,

    I used a logic analyzer to confirm if the w5500 driver for the wiz550io is working, as far as I have seen all operations within the driver are working. It seems to me that what ever is not working happens within the zephyr network stack.

    I am attaching the datasheet for the ethernet shield if its needed https://docs.wiznet.io/Product/ioModule/wiz550io

    regards,
    Abdullah

  • Hello again Raoul,

    I have another update.
    1st test: I have compared the two of versions on DHCPv4 sample 2.3SDK and 2.4 SDK.
    The internet interface is the same, the DHCP initiation is also the same. The difference is within the net management initiation callback, some naming convention and managements of threads within the library. 

    2nd test: was only establishing connection and ping test from my pc to the ethernet controller wiz550i0 .I have commented everything except the network interface function and disabled the DHCP configuration, as well as setup a static IP address.

    /* Networking DHCPv4 client */
    
    /*
     * Copyright (c) 2017 ARM Ltd.
     * Copyright (c) 2016 Intel Corporation.
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr/logging/log.h>
    LOG_MODULE_REGISTER(net_dhcpv4_client_sample, LOG_LEVEL_DBG);
    
    #include <zephyr/kernel.h>
    #include <zephyr/linker/sections.h>
    #include <errno.h>
    #include <stdio.h>
    
    #include <zephyr/net/net_if.h>
    #include <zephyr/net/net_core.h>
    #include <zephyr/net/net_context.h>
    #include <zephyr/net/net_mgmt.h>
    
    static struct net_mgmt_event_callback mgmt_cb;
    
    // static void handler(struct net_mgmt_event_callback *cb,
    // 		    uint32_t mgmt_event,
    // 		    struct net_if *iface)
    // {
    // 	int i = 0;
    
    // 	if (mgmt_event != NET_EVENT_IPV4_ADDR_ADD) {
    // 		return;
    // 	}
    
    // 	for (i = 0; i < NET_IF_MAX_IPV4_ADDR; i++) {
    // 		char buf[NET_IPV4_ADDR_LEN];
    
    // 		if (iface->config.ip.ipv4->unicast[i].addr_type !=
    // 							NET_ADDR_DHCP) {
    // 			continue;
    // 		}
    
    // 		LOG_INF("Your address: %s",
    // 			net_addr_ntop(AF_INET,
    // 			    &iface->config.ip.ipv4->unicast[i].address.in_addr,
    // 						  buf, sizeof(buf)));
    // 		LOG_INF("Lease time: %u seconds",
    // 			 iface->config.dhcpv4.lease_time);
    // 		LOG_INF("Subnet: %s",
    // 			net_addr_ntop(AF_INET,
    // 				       &iface->config.ip.ipv4->netmask,
    // 				       buf, sizeof(buf)));
    // 		LOG_INF("Router: %s",
    // 			net_addr_ntop(AF_INET,
    // 						 &iface->config.ip.ipv4->gw,
    // 						 buf, sizeof(buf)));
    // 	}
    // }
    
    int main(void)
    {
    	struct net_if *iface;
    
    	LOG_INF("Run dhcpv4 client");
    
    	// net_mgmt_init_event_callback(&mgmt_cb, handler,
    	// 			     NET_EVENT_IPV4_ADDR_ADD);
    	// net_mgmt_add_event_callback(&mgmt_cb);
    
    	iface = net_if_get_default();
    
    	// net_dhcpv4_start(iface);
    	return 0;
    }
    
     

    Sample code SDK 2.4

    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_MAIN_STACK_SIZE=1200
    
    # nothing here
    CONFIG_SPI=y
    CONFIG_NET_L2_ETHERNET=y
    CONFIG_ETH_W5500=y
    CONFIG_ETH_W5500_TIMEOUT=1000
    CONFIG_NET_DHCPV4=n
    
    # CONFIG_CONSOLE=y
    CONFIG_GPIO=y
    CONFIG_NETWORKING=y
    # CONFIG_NET_IPV6=y
    CONFIG_NET_IPV4=y
    CONFIG_NET_ARP=y
    CONFIG_NET_TCP=y
    CONFIG_NET_UDP=y
    
    
    #CONFIG_APP_EVENT_MANAGER=y
    
    CONFIG_ENTROPY_GENERATOR=y
    CONFIG_TEST_RANDOM_GENERATOR=y
    CONFIG_INIT_STACKS=y
    
    CONFIG_INIT_STACKS=y
    
    CONFIG_NET_STATISTICS=y
    
    
    # CONFIG_NET_PKT_RX_COUNT=32
    # CONFIG_NET_PKT_TX_COUNT=32
    # CONFIG_NET_BUF_RX_COUNT=32
    # CONFIG_NET_BUF_TX_COUNT=32
    
    # CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
    # CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
    #CONFIG_NET_MAX_CONTEXTS=10
    
    CONFIG_NET_MGMT=y
    CONFIG_NET_MGMT_EVENT=y
    
    CONFIG_NET_LOG=y
    CONFIG_LOG=y
    
    # # Network address config
    # CONFIG_NET_CONFIG_SETTINGS=y
    # # CONFIG_NET_CONFIG_NEED_IPV6=y
    # CONFIG_NET_CONFIG_NEED_IPV4=y
    
    # CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8:200::1"
    # CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8:200::2"
    # CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.160"
    # CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.168.1.161"
    # CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.1.1"
    #  CONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=n
    # #CONFIG_ETH_NATIVE_POSIX_MAC_ADDR="00:00:5e:00:53:c8"
    # CONFIG_ETH_NATIVE_POSIX_SETUP_SCRIPT="echo"
    # CONFIG_ETH_NATIVE_POSIX_DRV_NAME="w5500"
    
    
    CONFIG_DNS_RESOLVER=y
    CONFIG_DNS_SERVER_IP_ADDRESSES=y
    CONFIG_DNS_SERVER1="8.8.8.8"
    
    # CONFIG_ETH_NATIVE_POSIX=y
    # CONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=y
    
    # CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
    # CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
    # CONFIG_NET_MAX_CONTEXTS=10
    
    CONFIG_NET_SHELL=y
    # CONFIG_NET_DEFAULT_IF_ETHERNET=y
    CONFIG_NET_SOCKETS=y
    # CONFIG_NET_SOCKETS_POSIX_NAMES=y
    
    # CONFIG_UART_CONSOLE=n
    # CONFIG_RTT_CONSOLE=y
    
    
    
    CONFIG_NET_CONFIG_SETTINGS=y
    CONFIG_NET_CONFIG_NEED_IPV6=n
    CONFIG_NET_CONFIG_NEED_IPV4=y
    CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.3"
    CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
    CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.255.0"
    CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.1.1"

    prj configuration file

    Pinging 192.168.1.3 with 32 bytes of data:
    Reply from 192.168.1.3: bytes=32 time=61ms TTL=64
    Reply from 192.168.1.3: bytes=32 time=3ms TTL=64
    Reply from 192.168.1.3: bytes=32 time=3ms TTL=64
    Reply from 192.168.1.3: bytes=32 time=3ms TTL=64

    terminal output pinging the device from my pc

    uart:~$ net ping 192.168.1.2
    PING 192.168.1.2
    Ping timeout
    

    terminal output pinging my pc from the device

    I did the same thing also for SDK 2.3 sample and I got the same output for both.
    Note: I made all required configuration for the ethernet from my pc side

    3rd Test: I Connected the ethernet to a router and pinged my pc and 8.8.8.8 (Google) server IP address . In both SDK 2.3 and 2.4 pinging my pc which is connected to same network didn't work for some reason. However pinging google did work in SDK 2.3 but not 2.4. 

    Please note that My goal is to establish connection using ethernet socket (wiz550io) which uses w5500 driver in SDK 2.4. 

    Regards,
    Abdullah Al Abri

Related