Configure and Connect nRF7002 to nRF52840 on SDK 2.2.2

I am using nRF52840 as host processor. Now I need to connect to nRF7002 for WiFi usage. I am using ncs 2.2.2 SDK. I have a few questions?
1. Does nRF7002 work on v2.2.2? I created the nRF7002 device on the device tree with "nordic,nrf7002-spi" compatible . However, I cannot link to it. The CONFIG_NRF700X_SPI=y is not supported.

error: undefined reference to `__device_dts_ord_133'

2. Can you provide an example of configure and link nRF7002 to nRF52840 on v2.2.2 SDK?

3. If I have to move to higher version of SDK, what is the steps to do the upgrade?

My device tree:

&spi1 {
compatible = "nordic,nrf-spim";
status = "okay";
cs-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&spi1_default>;
pinctrl-1 = <&spi1_sleep>;
pinctrl-names = "default", "sleep";

nrf7002: nrf7002@0 {
compatible = "nordic,nrf7002-spi";
status = "okay";
reg = <0>; /* SPI chip select index */
spi-max-frequency = <8000000>; /* 8 MHz */
/*duplex = "full";*/ /* required for SPI_CONFIG_DT */
/*frame-format = "motorola";*/ /* required for SPI_CONFIG_DT */
label = "nrf7002";

/* GPIOs for control signals */
iovdd-ctrl-gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
bucken-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
host-irq-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;

/* Optional: COEX interface */
coex {
compatible = "nordic,nrf700x-coex";
grant-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
req-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
/*prio-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;*/


status0-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
/*status1-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;*/
};
};
};

My code:
const struct device *nrf7002_dev = DEVICE_DT_GET(DT_NODELABEL(nrf7002));

if (!device_is_ready(nrf7002_dev))
{
LOG_ERR("SPI device not ready\n");
return -1;
}
else
{
LOG_INF("SPI device READY\n");
}

Thank you.

Parents
  • Hi,

     

    I am using nRF52840 as host processor. Now I need to connect to nRF7002 for WiFi usage. I am using ncs 2.2.2 SDK. I have a few questions?
    1. Does nRF7002 work on v2.2.2? I created the nRF7002 device on the device tree with "nordic,nrf7002-spi" compatible . However, I cannot link to it. The CONFIG_NRF700X_SPI=y is not supported.

    I assume you mean ncs v3.2.2?

    nRF7002 shall be supported in this version.

    In your device tree, try to add these sections (taken from the nrf7002eb device tree files):

    /*
     * Copyright (c) 2024 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <freq.h>
    
    / {
    	chosen {
    		zephyr,wifi = &wlan0;
    	};
    };
    
    &spi1 {
    	status = "okay";
    
    	nrf70: nrf7002@0 {
    		compatible = "nordic,nrf7002-spi";
    		status = "okay";
    
    		wlan0: wlan0 {
    			compatible = "nordic,wlan";
    		};
    
    		wlan1: wlan1 {
    			compatible = "nordic,wlan";
    		};
    
    		wifi-max-tx-pwr-2g-dsss = <21>;
    		wifi-max-tx-pwr-2g-mcs0 = <16>;
    		wifi-max-tx-pwr-2g-mcs7 = <16>;
    		wifi-max-tx-pwr-5g-low-mcs0 = <13>;
    		wifi-max-tx-pwr-5g-low-mcs7 = <13>;
    		wifi-max-tx-pwr-5g-mid-mcs0 = <13>;
    		wifi-max-tx-pwr-5g-mid-mcs7 = <13>;
    		wifi-max-tx-pwr-5g-high-mcs0 = <12>;
    		wifi-max-tx-pwr-5g-high-mcs7 = <12>;
    		...rest of your configuration..
    	};
    };

     

    I suspect that the issue is the chosen "zephyr,wifi = &wlan0" is missing from your overlay.

    Could you check if this works as intended?

     

    Kind regards,

    Håkon

  • Sorry, I am using nRF Connect S?DK v2.2.0. I am still seeing the same issue. Where can I find the complete example of nRF7002 used in nRF52840?

    Thanks!

  • No chance in SDK 2.2.0. I don't see DTS bindings in my 2.6.1 SDK installation either.

    do see bindings in the SDK 2.9.2 version here, so this is probably close to the minimum required SDK version. But you should probably upgrade all the way to a recent 3.x version here while you are at it.

  • Hi,

     

    You should use a newer NCS version.

      

    Yimin Tang said:
    Sorry, I am using nRF Connect S?DK v2.2.0. I am still seeing the same issue. Where can I find the complete example of nRF7002 used in nRF52840?

    We recommend that you look into pairing the nRF7002 with nRF5340 or nRF54L15/nRF54LM20:

    https://nrfconnectdocs.nordicsemi.com/ncs/latest/nrf/releases_and_maturity/software_maturity.html#wi-fi-feature-support

     

    This is due to RAM requirements for running the hostap/wpad.

     

    Kind regards,

    Håkon

  • Thank you Turbo and Hakon for your help.

    Finally, I upgraded my ncs SDK from v2.2.0 to v2.9.3.  Can you point me an example of using nRF7002 on nRF52840 (or nRF5340 if not available on nRF52840)? I basically need to connect the WiFI network and retrieve the location information from the network.

    Appreciate your help!

Reply Children
  • Hi,

     

    You will likely run into issues with overflowing RAM when running nRF52840+nRF7002, especially if you require a secure connection (HTTPS/secure MQTT), but wifi/sta sample can be a starting point:

    https://nrfconnectdocs.nordicsemi.com/ncs/latest/nrf/samples/wifi/sta/README.html

     

    As mentioned; we recommend that you combine nRF7002 with a device that has a bit more RAM.

     

    Kind regards,

    Håkon

  • Thanks Hakon,

    Our current hardware is using nRF52840 with nRF7002. It takes time for a new hardware with different nRF processor with large RAM. For now, I am just using our current hardware to bring up the WiFi. So removed all other components in our application to save resources. 

    I ported over the "sta" sample. However, I could not get valid wifi interface.   

    struct net_if *iface = net_if_get_first_wifi();

    if (!iface)
    {
    LOG_ERR("Failed to get Wi-Fi interface");
    return -1;
    }

    Here is my devicetree configuration.

    chosen {
    ...
    zephyr,wifi = &wlan0;
    };

    &spi1 {
    compatible = "nordic,nrf-spim";
    status = "okay";
    cs-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
    pinctrl-0 = <&spi1_default>;
    pinctrl-1 = <&spi1_sleep>;
    pinctrl-names = "default", "sleep";

    nrf70: nrf7002@0 {
    compatible = "nordic,nrf7002-spi";
    status = "okay";

    reg = <0>;
    spi-max-frequency = <DT_FREQ_M(8)>;

    bucken-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;  => not used. high always
    iovdd-ctrl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;  => same as above
    host-irq-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
    //srrf-switch-gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;


    wifi-max-tx-pwr-2g-dsss = <21>;
    wifi-max-tx-pwr-2g-mcs0 = <16>;
    wifi-max-tx-pwr-2g-mcs7 = <16>;
    wifi-max-tx-pwr-5g-low-mcs0 = <13>;
    wifi-max-tx-pwr-5g-low-mcs7 = <13>;
    wifi-max-tx-pwr-5g-mid-mcs0 = <13>;
    wifi-max-tx-pwr-5g-mid-mcs7 = <13>;
    wifi-max-tx-pwr-5g-high-mcs0 = <12>;
    wifi-max-tx-pwr-5g-high-mcs7 = <12>;

    wlan0: wlan0 {
    compatible = "nordic,wlan";
    };

    wlan1: wlan1 {
    compatible = "nordic,wlan";
    };
    };
    };

    I looked into the Zephyr net_if.c file.

    struct net_if *net_if_get_first_wifi(void)
    {
    printk("\nnet_if_get_first_wifi is called\n");  ===> Reached here

    STRUCT_SECTION_FOREACH(net_if, iface)
    {
    printk("\nnet_if_get_first_wifi inside");   ==> NOT reached here.
    if (net_if_is_wifi(iface)) {
    return iface;
    }
    }
    return NULL;
    }


    I copied over all the kconfig from "sta" example.

    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_LOG=y
    CONFIG_NET_IPV4=y
    CONFIG_NET_UDP=y
    CONFIG_NET_TCP=y
    CONFIG_NET_DHCPV4=y
    CONFIG_NET_PKT_RX_COUNT=8
    CONFIG_NET_PKT_TX_COUNT=8

    # Zephyr Network Management API
    CONFIG_NET_MGMT=y
    CONFIG_NET_MGMT_EVENT=y
    CONFIG_NET_MGMT_EVENT_INFO=y

    # Wi-Fi Core Drivers and Supplicant
    CONFIG_WIFI=y
    CONFIG_WIFI_NRF70=y

    # WPA supplicant
    CONFIG_WIFI_NM_WPA_SUPPLICANT=y
    CONFIG_WIFI_READY_LIB=y
    CONFIG_NRF_WIFI_RPU_RECOVERY=y

    CONFIG_WIFI_MGMT_EXT=y
    CONFIG_WIFI_CREDENTIALS=y
    CONFIG_WIFI_CREDENTIALS_STATIC=y
    CONFIG_WIFI_CREDENTIALS_STATIC_SSID="RMED-AP"
    CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="Rmed24Ghz"

    # Memory Optimizations for Wi-Fi Stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096
    CONFIG_MAIN_STACK_SIZE=4096

    CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.99"
    CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.255.0"
    CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.1.1"

    CONFIG_NET_IF_LOG_LEVEL_DBG=y
    CONFIG_WIFI_LOG_LEVEL_DBG=y
    CONFIG_NET_L2_ETHERNET=y

    #=================================
    # Networking
    CONFIG_NET_BUF_RX_COUNT=8
    CONFIG_NET_BUF_TX_COUNT=16
    CONFIG_NRF70_RX_NUM_BUFS=16
    CONFIG_HEAP_MEM_POOL_IGNORE_MIN=y
    CONFIG_NET_TC_TX_COUNT=1

    CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
    CONFIG_NET_MAX_CONTEXTS=5
    CONFIG_NET_CONTEXT_SYNC_RECV=y

    CONFIG_INIT_STACKS=y

    CONFIG_NET_L2_ETHERNET=y

    CONFIG_NET_CONFIG_SETTINGS=y
    CONFIG_NET_CONFIG_INIT_TIMEOUT=0

    CONFIG_NET_SOCKETS_POLL_MAX=10

    # Memories
    CONFIG_NET_TX_STACK_SIZE=4096
    CONFIG_NET_RX_STACK_SIZE=4096

    # Debugging
    CONFIG_STACK_SENTINEL=y
    CONFIG_DEBUG_COREDUMP=y
    CONFIG_DEBUG_COREDUMP_BACKEND_LOGGING=y
    CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
    CONFIG_SHELL_CMDS_RESIZE=n


    # Kernel options
    CONFIG_ENTROPY_GENERATOR=y

    # Logging
    #CONFIG_POSIX_CLOCK=y

    # printing of scan results puts pressure on queues in new locking
    # design in net_mgmt. So, use a higher timeout for a crowded
    # environment.
    CONFIG_NET_MGMT_EVENT_QUEUE_TIMEOUT=5000

    Anything I missed?
    Do I have to have a flawless hardware to grap the wifi interface?

    Can you give me a clue?

    Thank you.

    Yimin

      

     

  • Hi Yimin,

     

    Yimin Tang said:
    I ported over the "sta" sample. However, I could not get valid wifi interface.   

    you shouldn't have to change the code at all; the only thing you need is to define the pin-out/connection towards the nRF7002.

    The sample intended to work for nRF52840DK + nRF7002EK.

     

    I assume you got a RPU error message on the console?

     

    I do not see any specific issue with your overlay:

    Yimin Tang said:

    &spi1 {
    compatible = "nordic,nrf-spim";
    status = "okay";
    cs-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
    pinctrl-0 = <&spi1_default>;
    pinctrl-1 = <&spi1_sleep>;
    pinctrl-names = "default", "sleep";

    nrf70: nrf7002@0 {
    compatible = "nordic,nrf7002-spi";
    status = "okay";

    reg = <0>;
    spi-max-frequency = <DT_FREQ_M(8)>;

    bucken-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;  => not used. high always
    iovdd-ctrl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;  => same as above
    host-irq-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
    //srrf-switch-gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;

     

    Are you testing on a DK or your own hardware? If using DK, P0.20 is connected to the external flash.

    What is the pins used for spi1_default?

    Yimin Tang said:
    bucken-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;  => not used. high always
    iovdd-ctrl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;  => same as above

    The comments here, what do you mean by "not used, high always"?

     

    Kind regards,

    Håkon

  • Hi Hakon,

    I am testing on my our hardware. I do not have a DK board. Here is the SPI pin configuration:

    /* For new design: Need to add a WIFI SPI
    SCK 0, 6
    MISO 0, 7
    MOSI 0, 4 */
    spi1_default: spi1_default {
    group1 {
    psels = <NRF_PSEL(SPIM_SCK, 0, 6)>,
    <NRF_PSEL(SPIM_MISO, 0, 7)>,
    <NRF_PSEL(SPIM_MOSI, 0, 4)>;
    };
    };

    spi1_sleep: spi1_sleep {
    group1 {
    psels = <NRF_PSEL(SPIM_SCK, 0, 6)>,
    <NRF_PSEL(SPIM_MISO, 0, 7)>,
    <NRF_PSEL(SPIM_MOSI, 0, 4)>;
    low-power-enable;
    };
    };
    };

    The error I got is:

    struct net_if *iface = net_if_get_first_wifi();

    if (!iface)
    {
    LOG_ERR("Failed to get Wi-Fi interface");  ==> Got this....
    return -1;
    }

    We used a GPIO from an IOExpander for bucken-gpios.

    Is iovdd-ctrl-gpios the pin48 of NRF7002-QFAA-R? If so, we pulled it high. 

    Thanks, 

    Yimin

  • I also found that there are some debug/warning messages before the application starts. I believe they are from net intialization during  POST_KERNEL stage.

    Net MGMT initialized: queue of 5 entries, stack size of 4096
    [00:00:01.124,084] <dbg> net_if: net_if_init: (main):
    [00:00:01.124,603] <err> net_if: There is no network interface to work with!
    [00:00:01.125,091] <dbg> net_if: net_if_post_init: (main):
    *** Booting nRF Connect SDK v2.9.3-6961c01f95c2 ***
    *** Using Zephyr OS v3.7.99-aa34a5632971 ***
    [00:00:01.126,037] <wrn> net_config: No auto-started network interface - network-bound app initialization skipped.

    For some reasons, I see  STRUCT_SECTION_FOREACH(net_if, iface) never get run into because:

     the _net_if_list_start = 20001B70, _net_if_list_end 20001B70. They are the same.

Related