Skip to content

eth_nxp_enet_mac failed with -120 #92281

@Stanislas-MARTIN

Description

@Stanislas-MARTIN

Describe the bug

I am using an overlay to set a set mac on the rt1170. It was working before commit 3d8196f

Regression

  • This is a regression.

Steps to reproduce

  1. Use the sample hello_world and replace the main by
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(Main, LOG_LEVEL_INF);

#include <zephyr/kernel.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>

#define DHCP_POLLING_MS (500)

static volatile bool ip_is_assigned = false;
static struct net_mgmt_event_callback mgmt_cb;
static struct net_dhcpv4_option_callback dhcp_cb;

static void start_dhcpv4_client(struct net_if *iface, void *user_data) {
        (void)(user_data);
        LOG_INF("Start interface %s: index=%d", net_if_get_device(iface)->name, net_if_get_by_iface(iface));
        net_dhcpv4_start(iface);
}

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].ipv4.addr_type != NET_ADDR_DHCP) {
                        continue;
                }

                LOG_INF("   Address[%d]: %s", net_if_get_by_iface(iface), net_addr_ntop(AF_INET, &iface->config.ip.ipv4->unicast[i].ipv4.address.in_addr, buf, sizeof(buf)));
                LOG_INF("    Subnet[%d]: %s", net_if_get_by_iface(iface), net_addr_ntop(AF_INET, &iface->config.ip.ipv4->unicast[i].netmask, buf, sizeof(buf)));
                LOG_INF("    Router[%d]: %s", net_if_get_by_iface(iface), net_addr_ntop(AF_INET, &iface->config.ip.ipv4->gw, buf, sizeof(buf)));
                LOG_INF("Lease time[%d]: %u seconds", net_if_get_by_iface(iface), iface->config.dhcpv4.lease_time);

                ip_is_assigned = true;
        }
}


int main(void)
{
        LOG_INF("NET initialization");

        // Initialize callbacks.
        net_mgmt_init_event_callback(&mgmt_cb, handler, NET_EVENT_IPV4_ADDR_ADD);
        net_mgmt_add_event_callback(&mgmt_cb);
        net_dhcpv4_add_option_callback(&dhcp_cb);
        // Start DHCP on all interfaces.
        net_if_foreach(start_dhcpv4_client, NULL);

        // Wait for IP assignment.
        while (!ip_is_assigned) {
                LOG_INF("Waiting for IP");
                k_sleep(K_MSEC(DHCP_POLLING_MS));
        }

        return 0;
}
  1. Add the following to the prj.conf
CONFIG_NETWORKING=y
CONFIG_NET_LOG=y
CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
CONFIG_NET_IPV6=n
CONFIG_NET_IPV4=y
CONFIG_POSIX_API=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POLL_MAX=4
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_NET_DHCPV4=y
CONFIG_NET_DHCPV4_OPTION_CALLBACKS=y
CONFIG_NET_INTERFACE_NAME=y
CONFIG_NET_DEFAULT_IF_ETHERNET=y
CONFIG_NET_SOCKETS_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_DRIVERS=y
CONFIG_NET_LOOPBACK=y
CONFIG_POSIX_TIMERS=y
CONFIG_XOPEN_STREAMS=y
  1. Create an overlay with the following content
&enet_mac {
         /delete-property/ zephyr,random-mac-address;
        local-mac-address = [your-mac];
};
  1. Build with the following command west build -p -b mimxrt1170_evk/mimxrt1176/cm7 -- -DDTC_OVERLAY_FILE=app.overlay
  2. Flash the rt1170

Relevant log output

Error log:
[00:00:00.051,000] <inf> phy_mii: PHY (0) ID 1CC816
[00:00:00.053,000] <err> eth_nxp_enet_mac: phy_configure_link failed with error: -120
[00:00:00.054,000] <inf> eth_nxp_enet_mac: Link is down
[00:00:00.054,000] <err> eth_nxp_enet_mac: phy_configure_link failed with error: -120
*** Booting Zephyr OS build v4.1.0-7032-g3198db1b1229 ***
[00:00:00.055,000] <inf> Main: NET initialization
[00:00:00.055,000] <inf> Main: Start interface ethernet: index=1
[00:00:00.055,000] <inf> Main: Start interface lo: index=2
[00:00:00.055,000] <inf> Main: Waiting for IP
[00:00:00.555,000] <inf> Main: Waiting for IP
[00:00:01.055,000] <inf> Main: Waiting for IP
[00:00:01.555,000] <inf> Main: Waiting for IP
[00:00:02.055,000] <inf> Main: Waiting for IP
[00:00:02.555,000] <inf> Main: Waiting for IP
[00:00:03.056,000] <inf> Main: Waiting for IP
[00:00:03.155,000] <inf> phy_mii: PHY (0) Link speed 100 Mb, full duplex
[00:00:03.155,000] <inf> eth_nxp_enet_mac: Link is up
[00:00:03.556,000] <inf> Main: Waiting for IP
[00:00:04.056,000] <inf> Main: Waiting for IP
[00:00:04.556,000] <inf> Main: Waiting for IP
[00:00:05.056,000] <inf> Main: Waiting for IP
[00:00:05.556,000] <inf> Main: Waiting for IP
[00:00:06.056,000] <inf> Main: Waiting for IP
[00:00:06.556,000] <inf> Main: Waiting for IP
[00:00:07.056,000] <inf> Main: Waiting for IP
[00:00:07.557,000] <inf> Main: Waiting for IP
[00:00:08.057,000] <inf> Main: Waiting for IP
--------------------------------------------------------------
Working log

[00:00:00.051,000] <inf> phy_mii: PHY (0) ID 1CC816
[00:00:00.054,000] <inf> eth_nxp_enet_mac: Link is down
*** Booting Zephyr OS build v4.1.0-5129-g05f71f3874d4 ***
[00:00:00.056,000] <inf> Main: NET initialization
[00:00:00.056,000] <inf> Main: Start interface ethernet: index=1
[00:00:00.056,000] <inf> Main: Start interface lo: index=2
[00:00:00.057,000] <inf> Main: Waiting for IP
[00:00:00.557,000] <inf> Main: Waiting for IP
[00:00:01.057,000] <inf> Main: Waiting for IP
[00:00:01.557,000] <inf> Main: Waiting for IP
[00:00:02.058,000] <inf> Main: Waiting for IP
[00:00:02.558,000] <inf> Main: Waiting for IP
[00:00:03.058,000] <inf> Main: Waiting for IP
[00:00:03.558,000] <inf> Main: Waiting for IP
[00:00:04.058,000] <inf> Main: Waiting for IP
[0Hello World! mimxrt1170_evk@B/mimxrt1176/cm7
0:00:04.558,000] <inf> Main: Waiting for IP
[00:00:05.058,000] <inf> Main: Waiting for IP
[00:00:05.456,000] <inf> phy_mii: PHY (0) Link speed 100 Mb, full duplex
[00:00:05.456,000] <inf> eth_nxp_enet_mac: Link is up
[00:00:05.459,000] <inf> net_dhcpv4: Received: 10.10.150.144
[00:00:05.459,000] <inf> Main:    Address[1]: 10.10.150.144
[00:00:05.459,000] <inf> Main:     Subnet[1]: 255.255.255.192
[00:00:05.459,000] <inf> Main:     Router[1]: 10.10.150.129
[00:00:05.459,000] <inf> Main: Lease time[1]: 36000 seconds

Impact

Major – Severely degrades functionality; workaround is difficult or unavailable.

Environment

  • OS: Windows, Wsl (Ubuntu 24.02)
  • Toolchain: Zephyr SDK 0.17
  • Commit: 3198db1

Additional Context

No response

Metadata

Metadata

Labels

RegressionSomething, which was working, does not anymorearea: EthernetbugThe issue is a bug, or the PR is fixing a bugplatform: NXPNXPpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions