Error while blending two Nordic samples – the WiFi Provisioning sample and the Memfault sample

Hello Nordic,

I hope this message finds you well. I wanted to reach out to you all for some guidance regarding a challenge I'm facing with my nRF7002DK board. I'm relatively new to Zephyr, and I think that's where I'm hitting a snag.

I've been working on merging two Nordic samples - the WiFi Provisioning sample and the Memfault sample. Each works fine on its own, but I'm encountering issues when I try to combine them into a single project. Specifically, I'm attempting to replace the WiFi static credentials with Bluetooth for provisioning, but this leads to the provisioning service failing to connect to the WiFi network.

You can find my project here: Provisioning-memfault on GitHub.
I would appreciate it if you could try to run it and provide any insights, advice, or pointers you can share.


What I found was that I was able to retrieve the SSID of the Wi-Fi and the passkey.
I ended up in this file: \ncs\v2.5.99-dev1\nrf\subsys\bluetooth\services\wifi_prov\wifi_prov_handler.c.

The error happens inside this function: static void prov_set_config_handler(Request *req, Response *rsp).
This particular code blob is where the error occurs. In our case, we end up in error path number 4.
I don't understand why the network management layer suddenly fails to connect when we integrate memfault.
I can't pinpoint what has changed in the configuration.

	rc = net_mgmt(NET_REQUEST_WIFI_CONNECT, iface, &cnx_params,
		      sizeof(struct wifi_connect_req_params));
	/* Invalid argument error. */
	if (rc == -EINVAL) {
		rsp->has_status = true;
		rsp->status = Status_INVALID_ARGUMENT;
		LOG_ERR("		3                  ");
		return;
	}
	/* Other error. */
	if (rc != 0) {
		rsp->has_status = true;
		rsp->status = Status_INTERNAL_ERROR;
		LOG_ERR("		4                  ");
		return;
	}

  • Hi,

     

    I am having some local setup issues at this moment, so I am not able to fully test your sample, but there is atleast one thing that I see. Since you will now setup memfault, it will have an impact on the overall socket usage in your firmware, so I would recommend that you explicitly add these configurations:

    CONFIG_POSIX_MAX_FDS=16
    CONFIG_NET_SOCKETS_POLL_MAX=10
    CONFIG_NET_CONFIG_INIT_TIMEOUT=0 # to avoid waiting 30 secs on boot up

     

    Could you also share a log output of what happens on your end? Ie. how far you come in the process on the firmware side of things. You'll need to set CONFIG_CONSOLE=y + CONFIG_LOG=y for debug output, as these are n-selected in your current default configuration.

     

    Kind regards,

    Håkon

  • Dear Håkon,

    I hope you are doing well. Firstly, I would like to express my gratitude for your support. I am writing to you today to provide some information regarding the project. 

    The project has a CMakePresets.json file that indicates some overlays need to be added to the following configurations: overlay-debug.conf, overlay-memfault.conf, and overlay_wifi_provisioning.conf. 

    The debug overlays have CONFIG_CONSOLE=y and CONFIG_LOG=y enabled for debug output. We only need them for debugging purposes on our side.

    Regarding your suggestion, I am willing to try it out I have tried it out and it doesn't fix the problem.
    However, it would be helpful if you could provide some explanation as to why the modification was made.

    CONFIG_POSIX_MAX_FDS is currently set to 9. However, we only have two concurrent open file descriptors - one for the connection to memfault (https) and one for the Bluetooth connection. Would increasing it to 16 be beneficial?

    The default value for CONFIG_NET_SOCKETS_POLL_MAX is 3, but I want to try setting it to 10. Can you tell me if there are any other file descriptors (FDs) that could be monitored by a poll() or select() function and potentially exceed the limit of 3?

    Is there any other impact for CONFIG_NET_CONFIG_INIT_TIMEOUT=0, other than the waiting time? In my code sample, I enabled the network stack using CONFIG_NET_CONFIG_AUTO_INIT=y, but disabled connection attempts using CONFIG_L2_WIFI_CONNECTIVITY_AUTO_CONNECT=n.

    Regards,
    Vincent

  • I have another update regarding my investigation. It appears that the error is occurring within the wifi_mgmt.c file at line 254 ( wifi_connect function ) in ncs\v2.5.99-dev1\zephyr\subsys\net\l2\wifi\wifi_mgmt.c . The issue seems to be with the wifi_mgmt_api->connect which is NULL, leading to an error - ENOTSUP. I have attached a picture for context.


  • Hi,

     

    Thank you for your patience in this matter.

    There seems to be a conflict with using net connection manager (CONFIG_NET_CONNECTION_MANAGER), where provisioning lib uses net_mgmt directly and net connection manager is built on-top of the net mgmt subsys. This seems to cause a conflict in the app + memfault integration. I'll report this internally.

    Could you try to comment lines memfault.c::152-157 ?

    And also set this in boards/nrf7002dk_nrf5340_cpuapp.conf ?

    CONFIG_NET_CONNECTION_MANAGER=n

     

    Kind regards,

    Håkon

  • Hi Håkon,

    Thank you for your response. I have attempted the solution you suggested, but unfortunately, it did not work. At this time, I don't have any additional information to provide.

    Have you been able to reproduce the issue on your end? 

    Could you please provide details about the steps your team has taken to resolve the issue?
    Also, there were several questions in my previous message that went unanswered. It is important for our team to understand your thought process in order to gain a better understanding of the situation and the platform.

    Thank you,
    Vincent

Related