Wifi Fundamentals Lesson 4 Exercise 2 not building, using nrf5340dk with nrf7002ek shield

Hello,

I am using the nrf5340dk with nrf7002ek shield and trying to build the wifi fundamentals lesson 4 exercise 2 code (connecting to MQTT over TLS) but it isn't building. I'm using the code from here: https://github.com/NordicDeveloperAcademy/wifi-fund/blob/main/lesson4/wififund_less4_exer2_solution/boards/nrf5340dk_nrf5340_cpuapp_ns.conf

Here are the build logs:
[433/443] Building C object zephyr/lib/posix/options/CMakeFiles/lib__posix__options.dir/uname.c.obj
[434/443] Building C object zephyr/kernel/CMakeFiles/kernel.dir/dynamic_disabled.c.obj
[435/443] Linking C static library modules/nrf/modules/hostap/lib..__nrf__modules__hostap.a
[436/443] Linking C static library zephyr/lib/posix/options/liblib__posix__options.a
[437/443] Linking C static library zephyr/kernel/libkernel.a
[438/443] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /Users/mayb/Documents/hello_world2/build/hello_world2/zephyr/zephyr_pre0.map
: && ccache /opt/nordic/ncs/toolchains/f8037e9b83/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -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 -fuse-ld=bfd -T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=/Users/mayb/Documents/hello_world2/build/hello_world2/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/soc/soc/nrf5340/libsoc__nordic.a zephyr/subsys/random/libsubsys__random.a zephyr/subsys/net/libsubsys__net.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/mqtt/libsubsys__net__lib__mqtt.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/entropy/libdrivers__entropy.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/mbox/libdrivers__mbox.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a modules/nrf/lib/dk_buttons_and_leds/lib..__nrf__lib__dk_buttons_and_leds.a modules/nrf/subsys/nrf_security/src/zephyr/libmbedtls_zephyr.a modules/nrf/subsys/net/lib/wifi_credentials/libwifi_credentials.a modules/nrf/subsys/net/lib/wifi_mgmt_ext/lib..__nrf__subsys__net__lib__wifi_mgmt_ext.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/nrf/modules/hostap/lib..__nrf__modules__hostap.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"/opt/nordic/ncs/toolchains/f8037e9b83/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main/nofp" -L/Users/mayb/Documents/hello_world2/build/hello_world2/zephyr -lgcc zephyr/arch/common/libisr_tables.a -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 -lm -Wl,-lc -L"/opt/nordic/ncs/toolchains/f8037e9b83/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi"/lib/thumb/v8-m.main/nofp -Wl,-lgcc -lc modules/nrf/subsys/nrf_security/src/libmbedtls.a modules/nrf/subsys/nrf_security/src/libmbedx509.a modules/nrf/subsys/nrf_security/src/libmbedcrypto.a /opt/nordic/ncs/v2.7.0/nrfxlib/crypto/nrf_oberon/lib/cortex-m33/soft-float/liboberon_mbedtls_3.0.15.a modules/nrf/subsys/nrf_security/src/libmbedcrypto_base.a -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee /opt/nordic/ncs/v2.7.0/nrfxlib/crypto/nrf_oberon/lib/cortex-m33/soft-float/liboberon_3.0.15.a -lc && cd /Users/mayb/Documents/hello_world2/build/hello_world2/zephyr && /opt/nordic/ncs/toolchains/f8037e9b83/Cellar/cmake/3.21.0/bin/cmake -E true
/opt/nordic/ncs/toolchains/f8037e9b83/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/modules/hostap/lib..__nrf__modules__hostap.a(supp_main.c.obj): in function `iface_cb':
/opt/nordic/ncs/v2.7.0/nrf/modules/hostap/src/supp_main.c:391: undefined reference to `__device_dts_ord_6'
/opt/nordic/ncs/toolchains/f8037e9b83/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/modules/hostap/lib..__nrf__modules__hostap.a(supp_main.c.obj): in function `z_wpas_start':
/opt/nordic/ncs/v2.7.0/nrf/modules/hostap/src/supp_main.c:623: undefined reference to `__device_dts_ord_6'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FAILED: _sysbuild/sysbuild/images/hello_world2-prefix/src/hello_world2-stamp/hello_world2-build /Users/mayb/Documents/hello_world2/build/_sysbuild/sysbuild/images/hello_world2-prefix/src/hello_world2-stamp/hello_world2-build
cd /Users/mayb/Documents/hello_world2/build/hello_world2 && /opt/nordic/ncs/toolchains/f8037e9b83/Cellar/cmake/3.21.0/bin/cmake --build .
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/f8037e9b83/bin/cmake --build /Users/mayb/Documents/hello_world2/build

* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.

and here is the build configuration i'm using:


other than that, i am using the code directly from the github file. i do not have a app.overlay file and I did not change the ca_certificate value. i tried to update my cmakelists.txt file to this but it didn't do anything to fix the issue:

cmake_minimum_required(VERSION 3.20.0)
set(SHIELD nrf7002ek)
set(CONF_FILE "prj.conf")
set(BOARD nrf5340dk_nrf5340)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_world2)
target_sources(app PRIVATE src/main.c)

I am building on a mac with the nrf connect SDK v2.7.0 arm64 and toolchain 2.7.20240620 with toolchain variant zephyr.

Can you help me fix this? Thank you so much in advance!
Parents
  • Hi,

    Sysbuild support has not been added to the exercises in this course yet, so please make sure that the "Use sysbuild" option is unchecked when creating the build configuration.

    Having this option checked will lead to the errors you are seeing.

    Best regards,
    Marte

  • hello, this fixed building the app but now i am still unable to connect to wifi and i see this error in the serial monitor:

    [00:00:00.487,884] <inf> wifi_nrf_bus: SPIM spi@a000: freq = 8 MHz
    [00:00:00.487,945] <inf> wifi_nrf_bus: SPIM spi@a000: latency = 0
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    [00:00:00.639,190] <inf> Lesson4_Exercise2: Initializing LED library
    [00:00:00.639,282] <inf> Lesson4_Exercise2: Successfully Initialized LED library
    [00:00:00.642,913] <dbg> net_sock_svc: socket_service_thread: (net_socket_service): Service WEST_TOPDIR/zephyr/subsys/net/lib/dns/resolve.c:70 has 2 pollable sockets
    [00:00:00.643,859] <dbg> net_sock_svc: socket_service_thread: (net_socket_service): Monitoring 2 socket entries
    [00:00:00.648,284] <dbg> net_ctx: net_context_bind: (wpa_supplicant_main): Context 0x2001cb14 bind to type 0x888e iface[1] 0x20019878 addr F4:CE:36:00:4F:67
    [00:00:01.639,373] <inf> Lesson4_Exercise2: Waiting to connect to Wi-Fi
    uart:~$ > wifi_cred add "wifiname" WPA2-PSK "wifipassword"
    wifi_cred add "wifiname" WPA2-PSK "wifipassword"
    uart:~$ > wifi_cred auto_connect
    wifi_cred auto_connect
    [00:00:07.781,097] <err> wifi_mgmt_ext: Connection request failed

    even though i did not change any code besides adding more logging to prj.conf and i verified that i can connect to my wifi with other devices.

    for context i am using an nrf5340dk with an nrf7002ek shield and here's what my build looks like:

    i do not have an app.overlay file because i just used the sample code from the course. can you help me figure out why this isnt connecting?

  • Hi,

    I can reproduce this issue using both nRF5340 DK with shield and nRF7002 DK.
    I have forwarded it internally, and the DevAcademy team will look into it.

    Best regards,
    Marte

  • thank you, looking forward to hearing back from you!

  • Hi,

    It seems like CONFIG_POSIX_MAX_FDS had to be increased to 16. I have fixed this in the affected exercises and pushed the fix. Can you test and see if you can connect with the fix?

    Best regards,
    Marte

  • I tested with this fix and even though it fixed the wifi connection issue, when I swapped in my own certificate.h file and my MQTT connection username and password, I got these error logs:

    [00:00:01.703,186] <inf> Familiar_Central_Hub: Waiting to connect to Wi-Fi
    uart:~$

    [00:00:00.488,800] <inf> wifi_nrf_bus: SPIM spi@a000: freq = 8 MHz
    [00:00:00.488,861] <inf> wifi_nrf_bus: SPIM spi@a000: latency = 0
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    [00:00:01.751,586] <inf> Central_Hub: Waiting to connect to Wi-Fi
    uart:~$ > wifi_cred add "<redacted>" WPA2-PSK "<redacted>"
    wifi_cred add"<redacted>" WPA2-PSK "<redacted>"
    uart:~$ > wifi_cred auto_connect
    wifi_cred auto_connect
    [00:00:17.987,243] <inf> wifi_mgmt_ext: Connection requested
    [00:00:23.979,217] <inf> Central_Hub: Network connected
    [00:00:23.979,827] <inf> Central_Hub: Connecting to MQTT broker
    [00:00:24.016,143] <inf> Central_Hub: IPv4 address of MQTT broker found <redacted-ipv4-address>
    [00:00:25.091,033] <err> Central_Hub: MQTT connect failed: 5
    [00:00:25.094,940] <inf> Central_Hub: MQTT client disconnected: -111
    [00:00:25.094,970] <err> Central_Hub: Error in mqtt_input: -111
    [00:00:25.094,970] <inf> Central_Hub: Disconnecting MQTT client
    [00:00:25.095,001] <err> Central_Hub: Could not disconnect MQTT client: -128
    uart:~$

    the only changes I had made were:
    1. adding this code to client_init:

    static struct mqtt_utf8 username = {
    .utf8 = (uint8_t *)CONFIG_MQTT_BROKER_USERNAME,
    .size = strlen(CONFIG_MQTT_BROKER_USERNAME)
    };
    client->user_name = &username;

    static struct mqtt_utf8 password = {
    .utf8 = (uint8_t *)CONFIG_MQTT_BROKER_PASSWORD,
    .size = strlen(CONFIG_MQTT_BROKER_PASSWORD)
    };
    client->password = &password;

    2. and adding these values to the prj.conf
    CONFIG_MQTT_BROKER_USERNAME="<redacted>"
    CONFIG_MQTT_BROKER_PASSWORD="<redacted>"

    3. and adding these values to the kconfig:

    config MQTT_BROKER_USERNAME
    string "MQTT broker username"
    default "<redacted>"

    config MQTT_BROKER_PASSWORD
    string "MQTT broker password"
    default "<redacted>"

    can you help me figure out why this is happening?
  • Hi,

    What host are you trying to connect to? I tested your code with broker.hivemq.com and MQTT Explorer, and it connected successfully.

    If you are testing against your own server, can you first check if you are able to connect to it using, for example, MQTT Explorer? Then you can verify that the certificate, username, and password are correct. Depending on the server, you might also need to provide client certificate and key in addition to the server certificate.

    Best regards,
    Marte

Reply
  • Hi,

    What host are you trying to connect to? I tested your code with broker.hivemq.com and MQTT Explorer, and it connected successfully.

    If you are testing against your own server, can you first check if you are able to connect to it using, for example, MQTT Explorer? Then you can verify that the certificate, username, and password are correct. Depending on the server, you might also need to provide client certificate and key in addition to the server certificate.

    Best regards,
    Marte

Children
No Data
Related