Delay Init wifi on nrf5340 and nrf7002

I am using the nrf5340 with the nrf7002 as the companion Wi-Fi IC. The supply voltage to all my peripherals (3V4) is enabled when my device exits sleep (System On + Idle). All the drivers can be initialized after I enable 3V4 to the peripherals, except the Wi-Fi driver (using  zephyr,deferred-init; see flash driver dts below). Is it a config that I need to enable? Alternatively, would I be able to restart the  Wi-Fi driver/stack after I enable the 3V4?

Below Is the dts fragment concerning  Wi-Fi and flash:


flash_spi: &spi4 {
	compatible = "nordic,nrf-spim";
    status = "okay";
	cs-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
	pinctrl-0 = <&spi3_default>;
	pinctrl-1 = <&spi3_sleep>;
	pinctrl-names = "default", "sleep";
    //zephyr,deferred-init; 
    extflash: gd25q128e@0{
        compatible = "jedec,spi-nor";
        reg = <0>;
        //label = "External Flash";
        spi-max-frequency = <80000000>; // Actual Max is 133Mhz
        size = <0x8000000>; // 0x8000000 == 134217728 bits == 16777216 Bytes == 16MB flash
        has-dpd;
        t-enter-dpd = <1000>;
        t-exit-dpd = <1000>;
        zephyr,deferred-init;//Is enabled in code after 3v4 is enabled
    };
};


&qspi {
	status = "okay";
	pinctrl-0 = <&qspi_default>;
	pinctrl-1 = <&qspi_sleep>;
	pinctrl-names = "default", "sleep";
    //WiFi companion IC
	nrf70: nrf7002@1 {
		compatible = "nordic,nrf7002-qspi";
		status = "okay";
		reg = <1>;
		qspi-frequency = <24000000>;
		qspi-quad-mode;
        //Interface Pins Configs
        iovdd-ctrl-gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
        bucken-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
        host-irq-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
        srrf-switch-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
        //2.4G Power configs 
        wifi-max-tx-pwr-2g-dsss = <21>;
        wifi-max-tx-pwr-2g-mcs0 = <16>;
        wifi-max-tx-pwr-2g-mcs7 = <16>;
        //5G Power configs 
        wifi-max-tx-pwr-5g-low-mcs0 = <9>;
        wifi-max-tx-pwr-5g-low-mcs7 = <9>;
        wifi-max-tx-pwr-5g-mid-mcs0 = <11>;
        wifi-max-tx-pwr-5g-mid-mcs7 = <11>;
        wifi-max-tx-pwr-5g-high-mcs0 = <13>;
        wifi-max-tx-pwr-5g-high-mcs7 = <13>;
        wlan0: wlan {
            compatible = "nordic,wlan";
            // zephyr,deferred-init;
        };
        // zephyr,deferred-init;
	};
};

Note that I can connect to  Wi-Fi if I modify my board to have permanent 3V4 for the nRF7002.
Below is the error logs that I get when the board doesn't have permanent 3V4 for the nrf7002:
[00:00:00.287,139] <err> wifi_nrf_bus: Error: RDSR2 failed
[00:00:00.287,170] <err> wifi_nrf: zep_shim_bus_qspi_dev_add: RPU enable failed with error -1
[00:00:00.287,231] <err> wifi_nrf: nrf_wifi_bus_qspi_dev_add: nrf_wifi_osal_bus_qspi_dev_add failed
[00:00:00.287,292] <err> wifi_nrf: nrf_wifi_bal_dev_add: Bus dev_add failed
[00:00:00.287,353] <err> wifi_nrf: nrf_wifi_hal_dev_add: nrf_wifi_bal_dev_add failed
[00:00:00.287,445] <err> wifi_nrf: nrf_wifi_fmac_dev_add: nrf_wifi_hal_dev_add failed
[00:00:00.287,475] <err> wifi_nrf: nrf_wifi_fmac_dev_add_zep: nrf_wifi_fmac_dev_add failed
[00:00:00.287,506] <err> wifi_nrf: nrf_wifi_if_start_zep: nrf_wifi_fmac_dev_add_zep failed

Parents
  • Hi Hakon,

    Q1 Answer: It is a custom design that hasn't been reviewed.

    Q2 Answer: I am using my own custom board dts, so the forwarder is not included (hasn't been enabled or disabled)

    Q3 Answer: 

    I need to answer the question in 2 cases.

    Case 1 (Permanent supply to the nRF7002): 

    Everything works fine and i can connect to a Wi-Fi network.

    Case 2 (Supply to nRF7002 switched on during device initialization):

    Wi-Fi stack fails as it attempts to communicate with the nRF7002 before it has been powered on. As far as i can tell, once this has failed there is no function call to restart the stack / driver.


    For a bit more background info, we are intending to use this for a low power field telemetry device. The sleep current needs to be around 40uA. The nRF7002 sleep current is 1.8mA unless TWT is used (as far as I can tell); however i cant assume that all our customers routers are Wi-Fi 6; therefore TWT is not a complete solution. That is why i want to completely disconnect supply from the nRF7002 when i go to sleep. 

    I am in the process of trying the following to solve both cases:

    1. Initialize the en3v4 (provide power to the nRF7002) before the kernel is initialized:

    //Initialize 3V4 as on by default so wifi stack works
    static int early_gpio_init(void)
    {
        nrf_gpio_cfg_output(DT_GPIO_PIN(DT_NODELABEL(qen3v4), gpios));
        nrf_gpio_pin_set(DT_GPIO_PIN(DT_NODELABEL(qen3v4), gpios));
        //Delay for 500us so 3V4 settles
        for(volatile uint32_t i = 0; i<32000; i++){
            __asm__ volatile("nop");
        }
        return 0;
    }
    //Initialize funtion to be executed before the kernel initializes
    SYS_INIT(early_gpio_init, PRE_KERNEL_1, 0);

    2. Before sleeping, disconnect Wi-Fi, drop Wi-Fi interface with 

        net_if_down(netIF);
    3. Switch off supply to the nRF7002 and then sleep 
    4. Wake from sleep and witch on supply to the nRF7002
    4. Raise wifi interface with:

        net_if_up(netIF);
    Do you think that this approach would work?
Reply
  • Hi Hakon,

    Q1 Answer: It is a custom design that hasn't been reviewed.

    Q2 Answer: I am using my own custom board dts, so the forwarder is not included (hasn't been enabled or disabled)

    Q3 Answer: 

    I need to answer the question in 2 cases.

    Case 1 (Permanent supply to the nRF7002): 

    Everything works fine and i can connect to a Wi-Fi network.

    Case 2 (Supply to nRF7002 switched on during device initialization):

    Wi-Fi stack fails as it attempts to communicate with the nRF7002 before it has been powered on. As far as i can tell, once this has failed there is no function call to restart the stack / driver.


    For a bit more background info, we are intending to use this for a low power field telemetry device. The sleep current needs to be around 40uA. The nRF7002 sleep current is 1.8mA unless TWT is used (as far as I can tell); however i cant assume that all our customers routers are Wi-Fi 6; therefore TWT is not a complete solution. That is why i want to completely disconnect supply from the nRF7002 when i go to sleep. 

    I am in the process of trying the following to solve both cases:

    1. Initialize the en3v4 (provide power to the nRF7002) before the kernel is initialized:

    //Initialize 3V4 as on by default so wifi stack works
    static int early_gpio_init(void)
    {
        nrf_gpio_cfg_output(DT_GPIO_PIN(DT_NODELABEL(qen3v4), gpios));
        nrf_gpio_pin_set(DT_GPIO_PIN(DT_NODELABEL(qen3v4), gpios));
        //Delay for 500us so 3V4 settles
        for(volatile uint32_t i = 0; i<32000; i++){
            __asm__ volatile("nop");
        }
        return 0;
    }
    //Initialize funtion to be executed before the kernel initializes
    SYS_INIT(early_gpio_init, PRE_KERNEL_1, 0);

    2. Before sleeping, disconnect Wi-Fi, drop Wi-Fi interface with 

        net_if_down(netIF);
    3. Switch off supply to the nRF7002 and then sleep 
    4. Wake from sleep and witch on supply to the nRF7002
    4. Raise wifi interface with:

        net_if_up(netIF);
    Do you think that this approach would work?
Children
Related