Hello,
We are doing some Wi-Fi connection tests on our custom board equipped with the nRF5340 and nRF7002 chips, and at some point during our tests, we encountered a strange error that we do not understand nor know how to fix.
The test goes as follows:
- Start up the Wi-Fi with net_if_up()
- Request a connection to the Wi-Fi net_mgmt NET_REQUEST_WIFI_CONNECT
- Once connected, we send a small packet to a server
- Disconnect from the Wi-Fi with net_mgmt NET_REQUEST_WIFI_DISCONNECT
- Shut down the WiFi with net_if_down()
- Wait 5 minutes and then repeat from Step 1
Now, our tests run smoothly at the beginning, always able to connect to the same Wi-Fi, send a packet, shut down, etc. However, after hours of doing it (about 23 hours), the Wi-Fi starts to fail more often. Initially, it sometimes fails the connection by giving the error -116 within the Wi-Fi connection callback. Then it will always fail with the error -116, and ultimately the net_mgmt Wi-Fi connect request will fail, returning -1. The following log is displayed: "<err> net_sock: invalid access on sock 6 by thread 0x20001ce8".
We began analyzing the behavior of threads to see if thread 0x20001ce8 might have been leaking, but we didn't find anything unusual compared to previous instances when the Wi-Fi connection worked.
Here's an overview of our connection request function:
int8_t wifi_connect(void) { struct net_if *interface = net_if_get_default(); static struct wifi_connect_req_params connection_parameters; printk("<Inf> Connection requested\n"); wifi_configuration_reader(&connection_parameters); int status = net_mgmt(NET_REQUEST_WIFI_CONNECT, interface, &connection_parameters, sizeof(struct wifi_connect_req_params)); if (status) { printk("<Err> Connection request failed (%d)\n", status); return -ENOEXEC; } return 0; }
We tried replacing all references to `net_if_get_default()` with `net_if_get_first_wifi()`, but it did not prevent the bug from occurring.
We couldn't find many references to this encountered issue, and we hope the information we provided is sufficient for you to assist us. Please reach out to us if you need more information.
Thank you for your time and have a good day!