Open VineetaNarkhede-eaton opened 3 weeks ago
I was hoping a proper issue instead of pressing the "convert to issue" button as this just copies the first question to an issue. Lot of relevant information missing now. Anyway, lets start by first figuring out what wifi driver are you using, mentioning chip does not really help here.
Hi @jukkar,
Apologies, if "convert to issue" is not a right approach in this scenario. We are using customized Infineon WiFi driver. During migration to zephyr 3.6.0, We found that airoc_wifi driver is tightly coupled for PSOC6 controller and it can't be easily integrated with our current code for STM32U575zi, hence currently we are using our customized wifi driver code which we were running with zephyr 3.2.0 also.
Regarding the comment given by rajolegajendra-eaton on this discussion, I would like to understand the significance of NET_IF_LOWER_UP and NET_IF_UP. Can we replace NET_IF_LOWER_UP with NET_IF_UP in net_if_tx() function to solve this issue?
Can we replace NET_IF_LOWER_UP with NET_IF_UP in net_if_tx() function to solve this issue?
No, you should not do that. NET_IF_UP
presents admin state of the interface i.e., it is set when the application or user turns on the interface. The NET_IF_LOWER_UP
is set when the carrier is turned on. For wifi this means that when the wifi connection is "ready". So it looks like the wifi interface carrier status is turned "ON" too early by the driver when the interface in fact is not yet ready for the connection.
Can we replace NET_IF_LOWER_UP with NET_IF_UP in net_if_tx() function to solve this issue?
No, you should not do that.
NET_IF_UP
presents admin state of the interface i.e., it is set when the application or user turns on the interface. TheNET_IF_LOWER_UP
is set when the carrier is turned on. For wifi this means that when the wifi connection is "ready". So it looks like the wifi interface carrier status is turned "ON" too early by the driver when the interface in fact is not yet ready for the connection.
Hello @jukkar,
We have noticed one change in NET_IF_INIT() macro which is getting called by NET_DEVICE_DT_INST_DEFINE() macro. It is setting flag bit for NET_IF_LOWER_UP as highlighted in following image:
This sets the flag as carrier ON. As mentioned earlier we are initializing WiFi in application and not before main. So carrier must be turned on only after Network Link is Up and Valid IP is assigned. Since carrier flag is set before wireless network is setup, so iface will not have Valid IP address. When mDNS is initialized from init_listener() using SYS_INIT() so it finds iface src address as null and gives bus fault.
What is the significance of setting flag to NET_IF_LOWER_UP in NET_IF_INIT()? Found one commit where this change was done. Link is here.
cc: @VineetaNarkhede-eaton
@jukkar , We are waiting for your response.
Above issue can be resolved if we change NET_IF_LOWER_UP
flag to NET_IF_NO_AUTO_START
.
You have out of tree driver and application, it very difficult to understand what your code is doing.
cc: @rlubos if you have any extra ideas
This sets the flag as carrier ON. As mentioned earlier we are initializing WiFi in application and not before main. So carrier must be turned on only after Network Link is Up and Valid IP is assigned.
The carrier is set to ON by default, for legacy reasons (and we don't push to change it as Linux does the same). If the particular interface is not ready to use after system initialization, it should be changed to off.
Every network interface has possibility to run boot-time initialization by registering init()
function from struct net_if_api
(the API struct is statically provided when registering interface with NET_DEVICE_DT_INST_DEFINE()
or similar). You should set carrier to OFF there.
You can take ESP driver as a reference here, it seems to be a similar case: https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/wifi/esp32/src/esp_wifi_drv.c#L681
You can take ESP driver as a reference here, it seems to be a similar case: https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/wifi/esp32/src/esp_wifi_drv.c#L681
Hello @rlubos, Thanks for the reference, we have tried it and it seems Bus Fault issue is resolved. Will add an update here once testing is completed. cc: @VineetaNarkhede-eaton
Discussed in https://github.com/zephyrproject-rtos/zephyr/discussions/71540