Enabling Wifi on nRF7002

Hello everyone,

I'm trying to set up the Wifi stack on the nRF7002 and use it with MicroPython, but encountering a lot of difficulty with it. I cropped up a network_wlan.c file and added it to the build. I configured the CMakeLists.txt, prj.conf and nrf7002dk_nrf5340_cpuapp_ns.conf to the best of my knowledge (based on the given wifi samples) but I've hit a roadblock.

Since I've got no prior experience with this board or Zephyr, I decided to start by just enabling the Wifi_scan functionality.

Right now I can "choose" which error I'd like to see:
1). Given this "main_scan()" function which I'm calling via REPL to use in microPy:

STATIC mp_obj_t main_scan(void)
 {
	scan_result = 0U;
 
	 net_mgmt_init_event_callback(&wifi_shell_mgmt_cb,
					  wifi_mgmt_event_handler,
					  WIFI_SHELL_MGMT_EVENTS);
 
	 net_mgmt_add_event_callback(&wifi_shell_mgmt_cb);
 
	 k_sleep(K_SECONDS(1));
	 printk("Starting %s with CPU frequency: %d MHz\n", CONFIG_BOARD, SystemCoreClock / MHZ(1));

	 if (net_if_get_default() == NULL) {
		printk("Bad!!! \n");
		return 0;
	}

	 if (!is_mac_addr_set(net_if_get_default())) {
		printk("0000\n");
		 struct net_if *iface = net_if_get_default();
		 int ret;
		 struct ethernet_req_params params;
 
		 /* Set a local MAC address with Nordic OUI */
		 if (net_if_is_admin_up(iface)) {
			 ret = net_if_down(iface);
			 if (ret < 0 && ret != -EALREADY) {
				 LOG_ERR("Cannot bring down iface (%d)", ret);
				 printk("11111\n");
				 return ret;
			 }
		 }
 
		 ret = net_bytes_from_str(params.mac_address.addr, sizeof(CONFIG_WIFI_MAC_ADDRESS),
					  CONFIG_WIFI_MAC_ADDRESS);
		 if (ret) {
			 LOG_ERR("Failed to parse MAC address: %s (%d)",
				 CONFIG_WIFI_MAC_ADDRESS, ret);
				 printk("2222\n");
			 return ret;
		 }
 
		 net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface,
			  &params, sizeof(params));
 
		 ret = net_if_up(iface);
		 if (ret < 0 && ret != -EALREADY) {
			 LOG_ERR("Cannot bring up iface (%d)", ret);
			 return ret;
		 }
 
		 LOG_INF("OTP not programmed, proceeding with local MAC: %s", net_sprint_ll_addr(
							 net_if_get_link_addr(iface)->addr,
							 net_if_get_link_addr(iface)->len));
	 }
 
	 while (1) {
		 wifi_scan();
		 printk("Scanning\n");
		 k_sleep(K_SECONDS(CONFIG_WIFI_SCAN_INTERVAL_S));
	 }
 
	 return 0;
 }
 static MP_DEFINE_CONST_FUN_OBJ_1(scan_obj, main_scan);


When I try to invoke it via these commands, I get a Secure Fault:
>>> [00:00:00.000,000] <dbg> counteMicroPython c44a93be3-dirty on 2025-04-18; zephyr-nrf7002dk with nrf5340
Type "help()" for more information.
>>> 
>>> 
>>> 
>>> 
>>> import network
>>> 
>>> w = network.WLAN(network.AP_IF)
>>> 
>>> w.scanwifi()
r_rtc.0: init_rtc: Initialized
--- 99 messages dropped ---
[00:00:00.473,236] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030d64, count: 1, orig prio: 0
[00:00:00.473,266] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030d64 lock_count: 1
[00:00:00.473,297] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030d64: (nil) (prio: -1000)
[00:00:00.473,480] <inf> wifi_supplicant: wpa_supplicant initialized
[00:00:00.474,151] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030d64, count: 1, orig prio: 0
[00:00:00.474,182] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030d64 lock_count: 1
[00:00:00.474,212] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030d64: (nil) (prio: -1000)
[00:00:00.474,914] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030d64, count: 1, orig prio: 0
[00:00:00.474,945] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030d64 lock_count: 1
[00:00:00.474,975] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030d64: (nil) (prio: -1000)
[00:00:00.475,280] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:00.475,341] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:00.475,372] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:00.475,402] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:00.475,433] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:00.475,463] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:10.473,632] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:10.473,663] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:10.473,693] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:10.473,724] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:10.473,785] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:10.473,815] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:10.473,907] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:10.473,937] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:10.473,968] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:10.473,999] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:10.474,060] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:10.474,090] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:20.473,999] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:20.474,029] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:20.474,060] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:20.474,090] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:20.474,151] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:20.474,182] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:20.474,273] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:20.474,304] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:20.474,334] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:20.474,365] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:20.474,426] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:20.474,456] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:30.474,365] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:30.474,426] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:30.474,456] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:30.474,487] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:30.474,517] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:30.474,548] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:30.474,670] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:30.474,700] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:30.474,731] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:30.474,761] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:30.474,792] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:30.474,822] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:40.474,792] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:40.474,822] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:40.474,853] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:40.474,884] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:40.474,914] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:40.474,945] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:40.475,067] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:40.475,097] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:40.475,128] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:40.475,158] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:40.475,189] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:40.475,219] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:50.475,128] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:50.475,189] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:50.475,219] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:50.475,250] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:50.475,280] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:50.475,311] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:00:50.475,402] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:00:50.475,463] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:00:50.475,494] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:00:50.475,524] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:00:50.475,555] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:00:50.475,585] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:01:00.475,524] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:01:00.475,555] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:01:00.475,585] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:01:00.475,616] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:01:00.475,646] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:01:00.475,677] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:01:00.475,799] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x200300e8, count: 1, orig prio: 0
[00:01:00.475,830] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200300e8 lock_count: 1
[00:01:00.475,860] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200300e8: (nil) (prio: -1000)
[00:01:00.475,891] <dbg> os: z_impl_k_mutex_lock: 0x20032370 took mutex 0x20030178, count: 1, orig prio: 0
[00:01:00.475,921] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030178 lock_count: 1
[00:01:00.475,952] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030178: (nil) (prio: -1000)
[00:01:06.882,568] <dbg> os: z_impl_k_mutex_lock: 0x200336f8 took mutex 0x20030e04, count: 1, orig prio: 0
[00:01:06.882,598] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030e04 lock_count: 1
[00:01:06.882,629] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030e04: (nil) (prio: -1000)
[00:01:06.882,659] <dbg> os: z_tick_sleep: thread 0x200336f8 for 32768 ticks
[00:01:06.882,720] <dbg> os: z_impl_k_mutex_lock: 0x20032228 took mutex 0x20030e04, count: 1, orig prio: 7
[00:01:06.882,751] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030e04 lock_count: 1
[00:01:06.882,781] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030e04: (nil) (prio: -1000)
[00:01:07.770,935] <dbg> os: z_impl_k_mutex_lock: 0x20032b88 took mutex 0x20030d64, count: 1, orig prio: 14
[00:01:07.770,965] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030d64 lock_count: 1
[00:01:07.770,996] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030d64: (nil) (prio: -1000)
[00:01:07.771,026] <dbg> os: z_impl_k_mutex_lock: 0x20032b88 took mutex 0x20030d78, count: 1, orig prio: 14
[00:01:07.771,057] <dbg> os: z_impl_k_mutex_unlock: mutex 0x20030d78 lock_count: 1
[00:01:07.771,057] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x20030d78: (nil) (prio: -1000)
[00:01:07.771,087] <dbg> os: z_impl_k_mutex_lock: 0x20032b88 took mutex 0x200301a8, count: 1, orig prio: 14
[00:01:07.771,118] <dbg> os: z_impl_k_mutex_unlock: mutex 0x200301a8 lock_count: 1
[00:01:07.771,118] <dbg> os: z_impl_k_mutex_unlock: new owner of mutex 0x200301a8: (nil) (prio: -1000)
Starting nrf7002dk with CPU frequency: 64 MHz
Bad!!! 
[00:01:07.885,375] <err> os: ***** SECURE FAULT *****
[00:01:07.885,375] <err> os: Address: 0x0
[00:01:07.885,375] <err> os: Attribution unit violation
[00:01:07.885,406] <err> os: r0/a1: 0x00000000 r1/a2: 0x00000000 r2/a3: 0x00000001
[00:01:07.885,437] <err> os: r3/a4: 0x00000000 r12/ip: 0x000beffb r14/lr: 0x0008189b
[00:01:07.885,437] <err> os: xpsr: 0x45000c00
[00:01:07.885,467] <err> os: s[ 0]: 0x200335d0 s[ 1]: 0x00000000 s[ 2]: 0x200335a8 s[ 3]: 0x00042813
[00:01:07.885,467] <err> os: s[ 4]: 0x00000000 s[ 5]: 0x000bcb7b s[ 6]: 0x00000000 s[ 7]: 0x00000000
[00:01:07.885,498] <err> os: s[ 8]: 0x00000002 s[ 9]: 0x00000020 s[10]: 0x00000000 s[11]: 0x00000000
[00:01:07.885,528] <err> os: s[12]: 0x0021e2b5 s[13]: 0x0007f9db s[14]: 0x20033818 s[15]: 0x0007f987
[00:01:07.885,528] <err> os: fpscr: 0x20033818
[00:01:07.885,528] <err> os: Faulting instruction address (r15/pc): 0x00081876
[00:01:07.885,589] <err> os: >>> ZEPHYR FATAL ERROR 41: Unknown error on CPU 0
[00:01:07.885,620] <err> os: Current thread: 0x200336f8 (mp_main)
[00:01:08.084,197] <err> os: Halting system


Which lead me to the suspicion that the network interface is not initialized and "net_if_get_default()" (line 19 in the above function) is returning NULL.

2). So I decided to see if I can do a "net_if_set_default()" via the "active" function:
 
STATIC mp_obj_t wlan_active(size_t n_args, const mp_obj_t *args) {
    wlan_obj_t *self = MP_OBJ_TO_PTR(args[0]);

    if (n_args == 1) {
        return mp_obj_new_bool(self->is_active);
    } else {
        self->is_active = mp_obj_is_true(args[1]);

        if (self->is_active) {
            if (self->iface == NULL) {
                // const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(wifi0));
				// const struct device *dev = DEVICE_DT_GET_ONE(nordic_nrf700x);
				const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_wifi));
				struct net_if *wifi_iface = net_if_lookup_by_dev(dev);

				/* As both are Ethernet, we need to set specific interface*/
				net_if_set_default(wifi_iface);

				net_config_init_app(dev, "Initializing network");

				/* TODO: Add proper synchronization to wait for WPA supplicant initialization */
				k_sleep(K_SECONDS(2));

                if (!device_is_ready(dev)) {
                    mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Wi-Fi device not ready"));
                }

                struct net_if *iface = net_if_lookup_by_dev(dev);
                if (!iface) {
                    mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("No network interface for Wi-Fi"));
                }

                self->iface = iface;
                net_if_set_default(self->iface);  // make net_if_get_default() work
            }

            // Bring the interface up if needed
            if (!net_if_is_up(self->iface)) {
                net_if_up(self->iface);
            }

        } else {
            if (self->iface && net_if_is_up(self->iface)) {
                net_if_down(self->iface);
            }
        }

        return mp_const_none;
    }
}


But this brings its own predicaments since the project won't build with this function; giving the error:
[16/20] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/build/zephyr/zephyr/zephyr_pre0.map 
: && ccache /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -Os -DNDEBUG -gdwarf-4 -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj tfm/api_ns/interface/lib/s_veneers.o -T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=/Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/build/zephyr/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/libarch__arm__core.a zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a zephyr/arch/arch/arm/core/cortex_m/cmse/libarch__arm__core__cortex_m__cmse.a zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a zephyr/lib/libc/newlib/liblib__libc__newlib.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/lib/posix/options/liblib__posix__options.a zephyr/lib/net_buf/liblib__net_buf.a zephyr/lib/os/zvfs/liblib__os__zvfs.a zephyr/soc/soc/nrf5340/libsoc__nordic.a zephyr/subsys/fs/libsubsys__fs.a zephyr/subsys/random/libsubsys__random.a zephyr/subsys/net/libsubsys__net.a zephyr/subsys/net/l2/offloaded_netdev/libsubsys__net__l2__offloaded_netdev.a zephyr/subsys/net/l2/ethernet/libsubsys__net__l2__ethernet.a zephyr/subsys/net/l2/wifi/libsubsys__net__l2__wifi.a zephyr/subsys/net/ip/libsubsys__net__ip.a zephyr/subsys/net/lib/config/libsubsys__net__lib__config.a zephyr/subsys/net/lib/dhcpv4/libsubsys__net__lib__dhcpv4.a zephyr/subsys/net/lib/dns/libsubsys__net__lib__dns.a zephyr/subsys/net/conn_mgr/libsubsys__net__conn_mgr.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/counter/libdrivers__counter.a zephyr/drivers/entropy/libdrivers__entropy.a zephyr/drivers/flash/libdrivers__flash.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/mbox/libdrivers__mbox.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/pwm/libdrivers__pwm.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/spi/libdrivers__spi.a zephyr/drivers/timer/libdrivers__timer.a zephyr/drivers/watchdog/libdrivers__watchdog.a modules/nrf/subsys/nrf_security/src/zephyr/libmbedtls_zephyr.a modules/nrf/subsys/net/lib/wifi_ready/libWIFI_READY_LIB.a modules/nrf/subsys/net/l2_wifi_if_conn/lib..__nrf__subsys__net__l2_wifi_if_conn.a modules/nrf/modules/trusted-firmware-m/lib..__nrf__modules__trusted-firmware-m.a modules/nrf/modules/trusted-firmware-m/libtfm_api_nrf.a modules/trusted-firmware-m/libtfm_api.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a -L/Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/build/zephyr/zephyr libmicropython.a zephyr/kernel/libkernel.a zephyr/arch/common/libisr_tables.a -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mfp16-format=ieee -fuse-ld=bfd -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,-no-pie -L"/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi"/lib/thumb/v8-m.main+fp/hard -specs=nano.specs modules/nrf/subsys/nrf_security/src/libmbedtls.a modules/nrf/subsys/nrf_security/src/libmbedx509.a modules/nrf/subsys/nrf_security/src/libmbedcrypto.a modules/nrf/subsys/nrf_security/src/libmbedcrypto_base.a modules/nrf/subsys/nrf_security/src/libnrf_security_utils.a zephyr/kernel/libkernel.a /opt/nordic/ncs/v2.9.1/nrfxlib/crypto/nrf_oberon/lib/cortex-m33/hard-float/liboberon_mbedtls_3.0.15.a /opt/nordic/ncs/v2.9.1/nrfxlib/crypto/nrf_oberon/lib/cortex-m33/hard-float/liboberon_3.0.15.a -lc -L"/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main+fp/hard" -lm -lc -lgcc -lc && cd /Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/build/zephyr/zephyr && /opt/homebrew/bin/cmake -E true
/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: libmicropython.a(modnetwork.c.obj): in function `wlan_active':
/Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/../../ports/zephyr/network_wlan.c:165: undefined reference to `__device_dts_ord_135'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FAILED: _sysbuild/sysbuild/images/zephyr-prefix/src/zephyr-stamp/zephyr-build /Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/build/_sysbuild/sysbuild/images/zephyr-prefix/src/zephyr-stamp/zephyr-build 
cd /Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/build/zephyr && /opt/homebrew/bin/cmake --build .
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/homebrew/bin/cmake --build /Users/tudor/Documents/GitHub/micropython_nRF/ports/zephyr/build


Where network_wlan.c:169: undefined reference to `__device_dts_ord_135' points to this line of code inside the "wlan_active()" function:
net_if_down(self->iface);


A bit of digging (github.com/.../41677) leads to the hypothesis that a few lines above, the definition of the Wifi interface doesn't actually work/ isn't instantiated and returns NULL:
const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_wifi));
struct net_if *wifi_iface = net_if_lookup_by_dev(dev);

Not sure if it makes a difference but: I'm using an Apple M1 MacBook.
I can provide any of the above files (or others) if needed, to be able to solve this mistery. I'm sure it's something trivial, but can't figure out what. -.-

Does anyone have any idea what might be causing these issues and what's the correct way of moving forward to be able to do a correct "wifi scan"? Thank you in advance and I hope you have a wonderful day!

Parents
  • A bit more trial and error was done that I'll document here. The initial suspicion about the default interface not being correctly initialised was on point. 

    The second error from the post ("undefined reference to `__device_dts_ord_135'") can be tracked down to the file "devicetree_generated.h", where I found:

    *   135 /soc/peripheral@40000000/qspi@2b000/nrf7002@1/wlan

    Looking over the various *.dts files, I found that the "zephyr_wifi" reference doesn't correctly link back to the .dts files that actually define it. Sadly I can't find a method of actually getting it to be correctly recognised.

Reply
  • A bit more trial and error was done that I'll document here. The initial suspicion about the default interface not being correctly initialised was on point. 

    The second error from the post ("undefined reference to `__device_dts_ord_135'") can be tracked down to the file "devicetree_generated.h", where I found:

    *   135 /soc/peripheral@40000000/qspi@2b000/nrf7002@1/wlan

    Looking over the various *.dts files, I found that the "zephyr_wifi" reference doesn't correctly link back to the .dts files that actually define it. Sadly I can't find a method of actually getting it to be correctly recognised.

Children
No Data
Related