Troubleshooting Wi-Fi Connectivity Issues with nRF7002+nRF52840 and net_mgmt

Hello, 

I'm facing an issue with Wi-Fi connectivity on my custom board equipped with nRF7002 and nRF52840. When I attempt to connect using net_mgmt(NET_REQUEST_WIFI_CONNECT), I consistently receive an error code of -134. The error appears almost instantaneously, seems like net_mgmt might not even initiate the Wi-Fi scanning process before returning the error.

But everything functions flawlessly when using the shell example for Wi-Fi connection and pinging 100 times.

I have tried searching the error of net_mgmt but it is closed source 

I would greatly appreciate any insights or suggestions from the forum.

I've already tried the following:

Questions:

1. What does net_mgnt error code mean?

2. What is the difference between shell example "wifi connect <ssid> <password>" and 

net_mgmt(NET_REQUEST_WIFI_CONNECT, iface, &cnx_params, sizeof(struct wifi_connect_req_params));

Here is the error message

*** Booting nRF Connect SDK v2.5.1 ***
[00:00:01.520,538] <err> Lesson4_Exercise1: Connecting to Wi-Fi failed, err: -134

If I further decrease CONFIG_HEAP_MEM_POOL_SIZE=103600, the code produced same error code but more error message were shown.

*** Booting nRF Connect SDK v2.5.1 ***
[00:00:00.528,594] <err> wifi_nrf: hal_rpu_event_get: Unable to alloc HAL msg for event

[00:00:01.520,538] <err> Lesson4_Exercise1: Connecting to Wi-Fi failed, err: -134
[00:00:10.524,688] <err> wifi_nrf: hal_rpu_cmd_queue: Unable to alloc buff for frag HAL cmd

[00:00:10.524,749] <err> wifi_nrf: nrf_wifi_hal_ctrl_cmd_send: Queueing of command failed

[00:00:10.524,780] <err> wifi_nrf: nrf_wifi_wpa_set_supp_port: nrf_wifi_fmac_chg_sta failed

Here is the log for shell example + ping:

SEGGER J-Link V7.90a - Real time terminal output
SEGGER J-Link (unknown) V1.0, SN=683375020
Process: JLink.exe


rtt:~$ [00:00:00.358,673] <inf> wifi_nrf: SPIM spi@4002f000: freq = 8 MHz

rtt:~$ [00:00:00.358,703] <inf> wifi_nrf: SPIM spi@4002f000: latency = 0

rtt:~$ rtt:~$ [00:00:00.592,864] <inf> fs_nvs: 6 Sectors of 4096 bytes
rtt:~$ [00:00:00.592,864] <inf> fs_nvs: alloc wra: 0, fd0
rtt:~$ [00:00:00.592,895] <inf> fs_nvs: data wra: 0, 1c
rtt:~$ *** Booting nRF Connect SDK v2.5.1 ***
rtt:~$ Starting tracker_nrf52840 with CPU frequency: 64 MHz
rtt:~$ [00:00:00.593,444] <inf> wpa_supp: Successfully initialized wpa_supplicant
net ping 8.8.8.8 -c 100
PING 8.8.8.8
Disconnected
Connected
[00:06:37.000,671] <inf> wpa_supp: wlan0: CTRL-EVENT-DISCONNECTED bssid=0e:bd:4f:23:7a:0c reason=7
rtt:~$ net[00:06:37.008,117] <inf> wpa_supp: wlan0: SME: Trying to authenticate with 0e:bd:4f:23:7a:0c (SSID='Wireless_FC' freq=2412 MHz)
rtt:~$ net[00:06:37.029,785] <inf> wpa_supp: wlan0: Trying to associate with 0e:bd:4f:23:7a:0c (SSID='Wireless_FC' freq=2412 MHz)
rtt:~$ net[00:06:37.095,733] <inf> wpa_supp: wlan0: Associated with 0e:bd:4f:23:7a:0c
rtt:~$ net[00:06:37.096,313] <inf> wpa_supp: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
rtt:~$ net[00:06:37.124,847] <inf> wpa_supp: wlan0: WPA: Key negotiation completed with 0e:bd:4f:23:7a:0c [PTK=CCMP GTK=CCMP]
rtt:~$ net[00:06:37.125,213] <inf> wpa_supp: wlan0: CTRL-EVENT-CONNECTED - Connection to 0e:bd:4f:23:7a:0c completed [id=0 id_str=]
rtt:~$ netrtt:~$ netrtt:~$ net[00:06:38.042,755] <inf> net_dhcpv4: Received: 192.168.227.62
rtt:~$ netrtt:~$ net28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=3 ttl=57 time=57 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=4 ttl=57 time=41 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=5 ttl=57 time=53 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=6 ttl=57 time=41 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=7 ttl=57 time=61 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=8 ttl=57 time=26 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=9 ttl=57 time=50 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=10 ttl=57 time=32 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=11 ttl=57 time=35 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=12 ttl=57 time=48 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=13 ttl=57 time=36 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=14 ttl=57 time=44 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=15 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=16 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=17 ttl=57 time=26 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=18 ttl=57 time=35 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=19 ttl=57 time=52 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=20 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=21 ttl=57 time=32 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=22 ttl=57 time=51 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=23 ttl=57 time=45 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=24 ttl=57 time=37 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=25 ttl=57 time=37 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=26 ttl=57 time=38 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=27 ttl=57 time=45 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=28 ttl=57 time=38 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=29 ttl=57 time=41 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=30 ttl=57 time=37 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=31 ttl=57 time=30 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=32 ttl=57 time=33 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=33 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=34 ttl=57 time=70 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=35 ttl=57 time=31 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=36 ttl=57 time=33 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=37 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=38 ttl=57 time=42 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=39 ttl=57 time=34 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=40 ttl=57 time=41 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=41 ttl=57 time=45 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=42 ttl=57 time=42 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=43 ttl=57 time=37 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=44 ttl=57 time=33 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=46 ttl=57 time=1019 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=47 ttl=57 time=46 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=48 ttl=57 time=34 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=49 ttl=57 time=49 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=51 ttl=57 time=1020 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=52 ttl=57 time=48 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=53 ttl=57 time=44 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=54 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=55 ttl=57 time=43 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=56 ttl=57 time=45 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=57 ttl=57 time=42 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=58 ttl=57 time=45 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=59 ttl=57 time=36 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=60 ttl=57 time=32 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=61 ttl=57 time=31 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=62 ttl=57 time=39 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=63 ttl=57 time=41 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=64 ttl=57 time=36 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=65 ttl=57 time=45 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=66 ttl=57 time=36 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=67 ttl=57 time=43 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=68 ttl=57 time=44 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=69 ttl=57 time=42 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=70 ttl=57 time=38 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=71 ttl=57 time=46 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=72 ttl=57 time=37 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=73 ttl=57 time=38 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=74 ttl=57 time=32 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=75 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=76 ttl=57 time=44 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=77 ttl=57 time=30 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=78 ttl=57 time=30 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=79 ttl=57 time=44 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=80 ttl=57 time=43 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=81 ttl=57 time=38 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=82 ttl=57 time=43 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=83 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=84 ttl=57 time=39 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=85 ttl=57 time=41 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=86 ttl=57 time=34 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=87 ttl=57 time=31 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=88 ttl=57 time=33 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=89 ttl=57 time=33 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=90 ttl=57 time=44 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=91 ttl=57 time=34 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=92 ttl=57 time=37 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=93 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=95 ttl=57 time=1021 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=96 ttl=57 time=45 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=97 ttl=57 time=50 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=98 ttl=57 time=48 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=99 ttl=57 time=40 ms
28 bytes from 8.8.8.8 to 192.168.227.62: icmp_seq=100 ttl=57 time=36 ms

wifi status

rtt:~$ wifi status
Status: successful
==================
State: COMPLETED
Interface Mode: STATION
Link Mode: WIFI 4 (802.11n/HT)
SSID: HUAWEI_E5576_4E56               
BSSID: E2:C5:FE:56:4E:75
Band: 2.4GHz
Channel: 6
Security: WPA2-PSK
MFP: Optional
RSSI: -29
Beacon Interval: 100
DTIM: 1
TWT: Not supported
rtt:~$ net stats

Interface 0x20001840 (Ethernet) [1]
===================================
IPv6 recv      121      sent    9       drop    115     forwarded       0
IPv6 ND recv   6        sent    7       drop    0
IPv6 MLD recv  0        sent    2       drop    0
IPv4 recv      154      sent    13      drop    142     forwarded       0
IP vhlerr      2        hblener 0       lblener 0
IP fragerr     0        chkerr  0       protoer 2
ICMP recv      16       sent    19      drop    0
ICMP typeer    0        chkerr  0
UDP recv       2        sent    3       drop    142
UDP chkerr     0
TCP bytes recv 0        sent    0       resent  0
TCP seg recv   0        sent    0       drop    0
TCP seg resent 0        chkerr  0       ackerr  0
TCP seg rsterr 0        rst     0
TCP conn drop  0        connrst 0
TCP pkt drop   0
Bytes received 24779
Bytes sent     2172
Processing err 0
Statistics for Ethernet interface 0x20001840 [1]
Bytes received   : 24779
Bytes sent       : 2172
Packets received : 280
Packets sent     : 24
Bcast received   : 9
Bcast sent       : 3
Mcast received   : 23
Mcast sent       : 3
Send errors      : 4
Receive errors   : 0
Collisions       : 0
Send Drops       : 0
Send timeouts    : 0
Send restarts    : 0
Unknown protocol : 0

Platform:

-nRF7002+nRF52840 custom board

-ncs 2.5.1

-Windows 10, VS code

  • Hi,

    1. What does net_mgnt error code mean?

    Error 134 is not supported (ENOTSUP).

    2. What is the difference between shell example "wifi connect <ssid> <password>" and 

    net_mgmt(NET_REQUEST_WIFI_CONNECT, iface, &cnx_params, sizeof(struct wifi_connect_req_params));

    Wi-Fi shell also uses net_mgmt(NET_REQUEST_WIFI_CONNECT) for connecting, as you can see in wifi_shell.c#L609.

    Which sample are you using, and have you made any changes to it?

    The Wi-Fi driver needs some time to get initialized, so you can try to add a 1-second sleep at the beginning of main() if you do not have it in your code already:

    k_sleep(K_SECONDS(1));

    I also recommend updating to nRF Connect SDK v2.6, as this release includes some updates and fixes to Wi-Fi.

    Best regards,
    Marte

  • Thank you for your reply.

    My code is based on the Wi-Fi Fundamentals course lesson 2 exercise 2. The only modification I made was reducing CONFIG_HEAP_MEM_POOL_SIZE to 146600 to avoid a buffer overflow error during compilation with the default settings. The code from Wi-Fi Fundamentals course includes a 1-second delay for Wi-Fi driver initialization. I've tried increasing the delay to 3 seconds, but the error persists. 

    I've also updated to nRF Connect SDK v2.6.1, which provides more detailed error messages.

    [00:00:00.355,804] <inf> wifi_nrf_bus: SPIM spi@4002f000: freq = 8 MHz
    [00:00:00.355,834] <inf> wifi_nrf_bus: SPIM spi@4002f000: latency = 0
    [00:00:00.367,187] <err> wifi_nrf_bus: RPU wakeup write ACK failed even after 10ms
    [00:00:00.367,187] <err> wifi_nrf_bus: Error: RDSR2 failed
    [00:00:00.367,218] <err> wifi_nrf: zep_shim_bus_qspi_dev_add: RPU enable failed with error -1
    [00:00:00.367,279] <err> wifi_nrf: nrf_wifi_bus_qspi_dev_add: nrf_wifi_osal_bus_qspi_dev_add failed
    [00:00:00.367,340] <err> wifi_nrf: nrf_wifi_bal_dev_add: Bus dev_add failed
    [00:00:00.367,401] <err> wifi_nrf: nrf_wifi_hal_dev_add: nrf_wifi_bal_dev_add failed
    [00:00:00.367,462] <err> wifi_nrf: nrf_wifi_fmac_dev_add: nrf_wifi_hal_dev_add failed
    [00:00:00.367,492] <err> wifi_nrf: nrf_wifi_fmac_dev_add_zep: nrf_wifi_fmac_dev_add failed
    [00:00:00.367,523] <err> wifi_nrf: nrf_wifi_if_start_zep: nrf_wifi_fmac_dd
    [00:00:03.367,767] <inf> Lesson2_Exercise2: Connecting to Wi-Fi
    [00:00:03.367,797] <err> Lesson2_Exercise2: Connecting to Wi-Fi failed, err: -134

    Any further assistance or insights would be greatly appreciated!

  • Hi,

    Did you create a board-specific configuration for the nRF52840DK in the boards directory? You can copy the configurations in the nrf5340dk_nrf5340_cpuapp.conf file:

    CONFIG_WIFI_CREDENTIALS_BACKEND_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_NVS=y

    Best regards,
    Marte

Related