Hello,
I'm working with a custom board using an nRF5340 as its primary MCU and NCS 2.7.0. The application I'm developing requires internet connection and can ideally support both WiFi and ethernet (favoring ethernet if available, otherwise falling back to WiFi). The board utilizes an nRF7002 for WiFi support and a W5500 for ethernet.
I was able to bring up both interfaces individually and they work perfectly on their own. But attempting to enable both simultaneously hasn't been working as expected. I've written my application so that if the ethernet connection is detected on bootup, it will use that as its network interface for all operations. If that connection is not present at bootup, or if it gets lost (detecting this with the NET_EVENT_ETHERNET_CARRIER_ON/OFF events), then the network interface gets switched to the wifi network interface, brought up, and then connection is requested and verified with the NET_EVENT_L4_CONNECTED event. Additionally, I have explicitly set CONFIG_NRF_WIFI_IF_AUTO_START=n in order for this custom board to be able to meet the nRF7002's power supply sequence requirements.
The behavior I'm seeing is as follows:
Regardless of which interface is set as default in prj.conf, either interface can successfully be brought up as well as assigned an IP address. However, attempting to use that connection with the non-default interface consistently fails. I'm trying to perform a simple SNTP sync and it always fails at zsock_send() with "Failed to send over UDP socket -1", and errno is 115 (ENETDOWN).
I have a strong suspicion that the root of the issue is that the default interface set in prj.conf is what is only getting used internally, in Zephyr's library. I'm pretty sure I enabled some debug logs at some point and saw a pointer to the default interface being used, despite being passed the other interface. Unfortunately I'm at a point where things are getting a little mixed up and disorganized and I lost track of when or how I saw those logs. But I also came across this albeit tangentially related post that leads me to believe my suspicion is not outside the realm of possibility. Contrarily, after spending 12+ hours stepping through the library with the debugger, watching the iface variable closely, it actually looks like it's using the correct interface the whole time! I haven't been able to find where the 115 error's coming from, cause I either keep setting the wrong breakpoint or some fatal error occurs and I get kicked off. So I'm seeking some guidance as to whether I'm on the right track with my suspicion or if there's something I'm missing.
If this is indeed the issue, is there a workaround? Dynamically supporting both ethernet and WiFi are critical to the completion of this project, so I'm trying to exhaust my options before pivoting.
Also I know this is more related to Zephyr, so I'm assuming answers might be limited on this forum, but since I'm using NCS I'm not getting any help from them unless I can recreate the issue with only upstream Zephyr.
Apologies for the long-winded post, just trying to include as much info as could be helpful! Any assistance is appreciated!
Random info of whose relevance I'm not sure:
- I remember reading something about how Nordic's WiFi driver shares the same L2 implementation (or something like that) in some documentation, but I'm not really sure how to use that information.
- Looking in zephyr_final.map, I see that there exist static lists with prefix _net_if_list, _net_if_dev_list, and _net_l2_list, where the first two lists have two entries, one for each network device (further evidence of both interfaces coexisting), but the L2 list has just one ETHERNET entry. This makes sense with the documentation I mentioned above, but I'm assuming all of this is expected, so I'm not really sure what to do with this either.