From f542aeaaf8b4236be35dff4e3d27e9e6bf3d0b89 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 1 Aug 2025 10:11:37 +0200 Subject: [PATCH 1/2] Ethernet: fix interface discovery on portenta c33 iface 1 and 2 are wifi interfaces, iface 3 is the ethernet one. --- libraries/SocketWrapper/Ethernet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SocketWrapper/Ethernet.h b/libraries/SocketWrapper/Ethernet.h index 989420ab..27599352 100644 --- a/libraries/SocketWrapper/Ethernet.h +++ b/libraries/SocketWrapper/Ethernet.h @@ -46,7 +46,7 @@ class EthernetClass: public NetworkInterface EthernetHardwareStatus hardwareStatus() { const struct device *const dev = DEVICE_DT_GET(DT_COMPAT_GET_ANY_STATUS_OKAY(ethernet_phy)); if (device_is_ready(dev)) { - for (int i = 1; i < 3; i++) { + for (int i = 1; i < 4; i++) { auto _if = net_if_get_by_index(i); if (!net_eth_type_is_wifi(_if)) { netif = _if; From c4c204c9d89ebaac1a692f82b7df5ae21ddb702b Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 1 Aug 2025 10:13:18 +0200 Subject: [PATCH 2/2] Ethernet: add nullptr check on returned network interface --- libraries/SocketWrapper/Ethernet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SocketWrapper/Ethernet.h b/libraries/SocketWrapper/Ethernet.h index 27599352..a3cbcd84 100644 --- a/libraries/SocketWrapper/Ethernet.h +++ b/libraries/SocketWrapper/Ethernet.h @@ -48,7 +48,7 @@ class EthernetClass: public NetworkInterface if (device_is_ready(dev)) { for (int i = 1; i < 4; i++) { auto _if = net_if_get_by_index(i); - if (!net_eth_type_is_wifi(_if)) { + if (_if && !net_eth_type_is_wifi(_if)) { netif = _if; break; }