diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index 269a4c179e7007..43149d2306e3c1 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -194,7 +194,10 @@ matter_build(chip ) set_property(GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS chip) +# Enable visibility of POSIX.1-2008 functions, such as strnlen target_compile_definitions(chip INTERFACE _POSIX_C_SOURCE=200809) +# Make sure that kernel symbols that are only referenced by the Matter libraries are resolved. +target_link_libraries(chip INTERFACE $) if (CONFIG_CHIP_MALLOC_SYS_HEAP_OVERRIDE) target_link_options(chip INTERFACE diff --git a/examples/chef/chef.py b/examples/chef/chef.py index b663a49f495676..7e8de18787458e 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -75,6 +75,8 @@ def load_config() -> None: "for the vendor's SDK") configStream = open(configFile, 'w') config["nrfconnect"]["ZEPHYR_BASE"] = os.environ.get('ZEPHYR_BASE') + config["nrfconnect"]["ZEPHYR_SDK_INSTALL_DIR"] = os.environ.get( + 'ZEPHYR_SDK_INSTALL_DIR') config["nrfconnect"]["TTY"] = None config["esp32"]["IDF_PATH"] = os.environ.get('IDF_PATH') config["esp32"]["TTY"] = None @@ -374,9 +376,6 @@ def main() -> int: flush_print( f"{device_name} in CICD config but not {_DEVICE_FOLDER}!") exit(1) - if options.build_target == "nrfconnect": - shell.run_cmd( - "export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"") shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") command = f"./chef.py -cbr -d {device_name} -t {options.build_target}" flush_print(f"Building {command}", with_border=True) @@ -412,8 +411,6 @@ def main() -> int: command += " ".join(args) flush_print(f"Building {command}", with_border=True) shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") - shell.run_cmd( - "export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"") try: shell.run_cmd(command) except RuntimeError as build_fail_error: @@ -469,11 +466,29 @@ def main() -> int: elif options.build_target == "nrfconnect": if config['nrfconnect']['ZEPHYR_BASE'] is None: flush_print( - 'Path for nrfconnect SDK was not found. Make sure nrfconnect.ZEPHYR_BASE is set on your config.yaml file') + 'The path for nrfconnect SDK was not found. Make sure nrfconnect.ZEPHYR_BASE is set on your config.yaml file. This is typically /ncs/vX.X.X/zephyr') exit(1) - shell.run_cmd( - f'source {config["nrfconnect"]["ZEPHYR_BASE"]}/zephyr-env.sh') - shell.run_cmd("export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb") + if config['nrfconnect']['ZEPHYR_SDK_INSTALL_DIR'] is None: + flush_print( + 'The path for nrfconnect toolchain was not found. Make sure nrfconnect.ZEPHYR_SDK_INSTALL_DIR is set on your config.yaml file. This is typically /ncs/toolchains/vX.X.X/opt/zephyr-sdk') + exit(1) + zephyr_sdk_dir = config['nrfconnect']['ZEPHYR_SDK_INSTALL_DIR'] + shell.run_cmd("export ZEPHYR_TOOLCHAIN_VARIANT=zephyr") + shell.run_cmd(f"export ZEPHYR_SDK_INSTALL_DIR={zephyr_sdk_dir}") + shell.run_cmd(f"export ZEPHYR_BASE={config['nrfconnect']['ZEPHYR_BASE']}") + shell.run_cmd(f'source {config["nrfconnect"]["ZEPHYR_BASE"]}/zephyr-env.sh') + # QUIRK: + # When the Zephyr SDK is installed as a part of the NCS toolchain, the build system will use + # build tools from the NCS toolchain, but it will not update the PATH and LD_LIBRARY_PATH + # and hence the build will fail. This ideally, should be handled automatically by the NCS + # build system but until it is fixed, set the variables manually. + ncs_toolchain_dir = os.path.abspath(f"{zephyr_sdk_dir}/../..") + if os.path.exists(os.path.join(ncs_toolchain_dir, 'manifest.json')): + shell.run_cmd(f"export PATH=$PATH:{ncs_toolchain_dir}/usr/bin") + shell.run_cmd(f"export PATH=$PATH:{ncs_toolchain_dir}/usr/local/bin") + shell.run_cmd(f"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{ncs_toolchain_dir}/usr/lib") + shell.run_cmd( + f"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{ncs_toolchain_dir}/usr/local/lib") elif options.build_target == "linux": pass elif options.build_target == "silabs-thread": diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt index 4249001f35a0ec..c813a314a74264 100644 --- a/examples/chef/nrfconnect/CMakeLists.txt +++ b/examples/chef/nrfconnect/CMakeLists.txt @@ -32,7 +32,6 @@ set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${CONFIG_ if(NOT ${CONFIG_DEVICE_PRODUCT_NAME} STREQUAL "") set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\"${CONFIG_DEVICE_PRODUCT_NAME}\"") endif() -set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_PLATFORM_NRFCONNECT=1") if(NOT ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING} STREQUAL "") set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}\"") endif() @@ -76,7 +75,7 @@ target_include_directories(app PRIVATE ${NRFCONNECT_COMMON}/app/include ) -if (CONFIG_ENABLE_CHIP_SHELL) +if (CONFIG_CHIP_LIB_SHELL) target_sources(app PRIVATE ${CHEF}/shell_common/globals.cpp ${CHEF}/shell_common/cmd_misc.cpp @@ -86,7 +85,7 @@ if (CONFIG_ENABLE_CHIP_SHELL) target_include_directories(app PRIVATE ${CHEF}/shell_common/include ) -endif (CONFIG_ENABLE_CHIP_SHELL) +endif() target_sources(app PRIVATE ${CHEF}/nrfconnect/main.cpp diff --git a/examples/chef/nrfconnect/main.cpp b/examples/chef/nrfconnect/main.cpp index 17e207ead026cc..c4157798567e5b 100644 --- a/examples/chef/nrfconnect/main.cpp +++ b/examples/chef/nrfconnect/main.cpp @@ -138,7 +138,7 @@ int main() ChipLogError(AppServer, "OpenBasicCommissioningWindow() failed"); } -#if CONFIG_ENABLE_CHIP_SHELL || CONFIG_CHIP_LIB_SHELL +#if CONFIG_CHIP_LIB_SHELL int rc = Engine::Root().Init(); if (rc != 0) { @@ -154,7 +154,7 @@ int main() cmd_app_server_init(); #endif -#if CONFIG_ENABLE_CHIP_SHELL || CONFIG_CHIP_LIB_SHELL +#if CONFIG_CHIP_LIB_SHELL Engine::Root().RunMainLoop(); #endif