MQTT sample for nRF9161_ns compilation error

Hello, I.m using SDK 2.6.1 with VSCode.

I created a new application based on the sample /nrf/samples/net/mqtt configured for nRF9161_ns which is listed as a compatible board.

When I build the application I get 2 compilation errors:

C:/ncs/MyApp/mqtt_clean/src/modules/network/network.c:16:30: error: 'CONFIG_MQTT_SAMPLE_NETWORK_LOG_LEVEL' undeclared here (not in a function); did you mean 'CONFIG_MQTT_SAMPLE_ERROR_LOG_LEVEL'?

C:/ncs/MyApp/mqtt_clean/src/modules/network/network.c:110:17: error: 'CONFIG_MQTT_SAMPLE_NETWORK_THREAD_STACK_SIZE' undeclared here (not in a function); did you mean 'CONFIG_MQTT_SAMPLE_SAMPLER_THREAD_STACK_SIZE'?

Substituting,  as the compiler is suggesting, CONFIG_MQTT_SAMPLE_NETWORK_LOG_LEVEL with CONFIG_MQTT_SAMPLE_ERROR_LOG_LEVEL and CONFIG_MQTT_SAMPLE_NETWORK_THREAD_STACK_SIZE with CONFIG_MQTT_SAMPLE_SAMPLER_THREAD_STACK_SIZE fixes the compilation errors.

Not sure the above correction is correct, since when I start the application I do not see any meaningful trace on the serial port with exception of  "*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***" which isn't the output one would expect considering what reported in https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/net/mqtt/README.html.

Im running the MQTT sample on a nRF9161_DK board with a properly working ONOMONDO  LTE CatM SIM.

Could you confirm that SDK 2.6.1 nrf MQTT sample is generating the above listed error ?

Is the fix succested by the compiler correct (CONFIG_MQTT_SAMPLE_NETWORK_LOG_LEVEL ->CONFIG_MQTT_SAMPLE_ERROR_LOG_LEVEL and CONFIG_MQTT_SAMPLE_NETWORK_THREAD_STACK_SIZE->CONFIG_MQTT_SAMPLE_SAMPLER_THREAD_STACK_SIZE )?

regards, Joel

  • Hello Joel,

    Are you sure that you are using the MQTT sample from 2.6.1 with the NCS 2.6.1?

    I can build it without any issues for nrf9161dk_9161_ns board.

    Best regards,

    Michal

  • Hello Michal .... yes 100% sure

    nrf/samples/net/mqtt


    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/ncs/MyApp/mqtt
    -- CMake version: 3.21.0
    -- Found Python3: C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.6.1/zephyr/.cache
    -- Zephyr version: 3.5.99 (C:/ncs/v2.6.1/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf9161dk_nrf9161_ns, Revision: 0.9.0
    -- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v2.6.1/zephyr/boards/arm/nrf9161dk_nrf9161/nrf9161dk_nrf9161_ns.dts
    -- Found devicetree overlay: C:/ncs/MyApp/mqtt/boards/nrf9161dk_nrf9161_ns.overlay
    -- Generated zephyr.dts: C:/ncs/MyApp/mqtt/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/ncs/MyApp/mqtt/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/ncs/MyApp/mqtt/build/zephyr/dts.cmake

    warning: Experimental symbol NET_CONNECTION_MANAGER is enabled.

    Regards Joel

  • Hello, to make a double check, yesterday at home I installed "from scratch" Nordic SDK and toolchain 2.6.1 on my Win11 laptop. As before, I generated a new application starting from nrf MQTT sample and i configured the build for nRF9161 NS... the result was exactly the same ... same errors... unless this is an error affecting only Switzerland, there is definitively an issue in the source code... 

    Using a Cygwin console:

    > grep -Rnw . -e 'CONFIG_MQTT_SAMPLE_NETWORK_LOG_LEVEL'
    ./src/modules/network/network.c:16:LOG_MODULE_REGISTER(network, CONFIG_MQTT_SAMPLE_NETWORK_LOG_LEVEL);


    shows that the CONFIG_MQTT_SAMPLE_NETWORK_LOG_LEVEL macro appears only in network.c and has no definition.

    Where is CONFIG_MQTT_SAMPLE_NETWORK_LOG_LEVEL supposed to be defined ?

    Thx for any input ...

    Regards, Joel

  • Hi Joel,

    Michial is not available now, and I will continue to help you.

    I just have two questions:

    1) Do you have problem to build the original sample in C:\NCS\v2.6.1\nrf\samples\net\mqtt ?

    2) How do you "generated a new application starting from nrf MQTT sample"? Do you use "Copy a sample" to copy the original MQTT sample? if not, can you have a try?

    Attached is a log when I build from nRF VS Code extension GUI.

     *  Executing task: nRF Connect: Generate config nrf9161dk_nrf9161_ns for c:\NCS\myApps\mqtt 
    
    Building mqtt
    C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir c:/NCS/myApps/mqtt/build c:/NCS/myApps/mqtt --pristine --board nrf9161dk_nrf9161_ns -- -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=c:/ncs/myapps/mqtt"
    
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/NCS/myApps/mqtt
    -- CMake version: 3.21.0
    -- Found Python3: C:/NCS/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: C:/NCS/v2.6.1/zephyr/.cache
    -- Zephyr version: 3.5.99 (C:/NCS/v2.6.1/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf9161dk_nrf9161_ns, Revision: 0.9.0
    -- Found host-tools: zephyr 0.16.5 (C:/NCS/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (C:/NCS/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found Dtc: C:/NCS/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
    -- Found BOARD.dts: C:/NCS/v2.6.1/zephyr/boards/arm/nrf9161dk_nrf9161/nrf9161dk_nrf9161_ns.dts
    -- Found devicetree overlay: C:/NCS/myApps/mqtt/boards/nrf9161dk_nrf9161_ns.overlay
    -- Generated zephyr.dts: C:/NCS/myApps/mqtt/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/NCS/myApps/mqtt/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/NCS/myApps/mqtt/build/zephyr/dts.cmake
    
    warning: Experimental symbol NET_CONNECTION_MANAGER is enabled.
    
    Parsing C:/NCS/myApps/mqtt/Kconfig
    Loaded configuration 'C:/NCS/v2.6.1/zephyr/boards/arm/nrf9161dk_nrf9161/nrf9161dk_nrf9161_ns_defconfig'
    Merged configuration 'C:/NCS/myApps/mqtt/prj.conf'
    Merged configuration 'C:/NCS/myApps/mqtt/boards/nrf9161dk_nrf9161_ns.conf'
    Configuration saved to 'C:/NCS/myApps/mqtt/build/zephyr/.config'
    Kconfig header saved to 'C:/NCS/myApps/mqtt/build/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38") 
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/NCS/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at C:/NCS/v2.6.1/zephyr/CMakeLists.txt:1957 (message):
      __ASSERT() statements are globally ENABLED
    
    
    Dropping partition 'nonsecure_storage' since it is empty.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/NCS/myApps/mqtt/build
    -- west build: building application
    [2/321] Generating include/generated/version.h
    -- Zephyr version: 3.5.99 (C:/NCS/v2.6.1/zephyr), build: v3.5.99-ncs1-1-4-ga681edb8d456
    [3/321] Generating ../../tfm/CMakeCache.txt
    CMake Warning at cmake/version.cmake:22 (message):
      Actual TF-M version is not available from Git repository.  Settled to
      v2.0.0
    Call Stack (most recent call first):
      CMakeLists.txt:22 (include)
    
    
    -- Found Git: C:/NCS/toolchains/cf2149caf2/mingw64/bin/git.exe (found version "2.37.3.windows.1") 
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/NCS/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/NCS/toolchains/cf2149caf2/opt/bin/python.exe (found version "3.9.13") found components: Interpreter 
    CMake Deprecation Warning at C:/NCS/v2.6.1/zephyr/cmake/modules/FindDeprecated.cmake:121 (message):
      'PYTHON_PREFER' variable is deprecated.  Please use Python3_EXECUTABLE
      instead.
    Call Stack (most recent call first):
      C:/NCS/v2.6.1/zephyr/cmake/modules/python.cmake:16 (find_package)
      C:/NCS/v2.6.1/zephyr/cmake/modules/user_cache.cmake:30 (include)
      C:/NCS/v2.6.1/zephyr/cmake/modules/extensions.cmake:5 (include)
      C:/NCS/v2.6.1/nrf/subsys/nrf_security/tfm/CMakeLists.txt:38 (include)
    
    
    -- Found Python3: C:/NCS/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: C:/NCS/v2.6.1/zephyr/.cache
    -- Configuring done
    -- Generating done
    CMake Warning:
      Manually-specified variables were not used by the project:
    
        CRYPTO_RNG_MODULE_ENABLED
        MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE
        PYTHON_PREFER
    
    
    -- Build files have been written to: C:/NCS/myApps/mqtt/build/tfm
    [163/167] Linking C executable bin\tfm_s.axf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       32096 B        32 KB     97.95%
                 RAM:       10416 B        32 KB     31.79%
    [15/321] Performing install step for 'tfm'
    -- Install configuration: "MinSizeRel"
    ----- Installing platform NS -----
    [319/321] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:      181476 B       992 KB     17.87%
                 RAM:       56716 B     195224 B     29.05%
            IDT_LIST:          0 GB        32 KB      0.00%
    [321/321] Generating zephyr/merged.hex
     *  Terminal will be reused by tasks, press any key to close it. 

    Best regards,

    Charlie

  • Hello Charlie...

    1) building the sample directly returns the same errors (VSC -> Browse Samples)

    2) I generated the application from VSC-> Create a new application-> Copy a sample-> nrf/samples/net/mqtt configuring for nrf9161_nc target.

    No code modifications at all...

    Regards, Jel

Related