diff --git a/.github/workflows/examples-nxp.yaml b/.github/workflows/examples-nxp.yaml index 6fc6970ce2c51d..83506c6c070cb8 100644 --- a/.github/workflows/examples-nxp.yaml +++ b/.github/workflows/examples-nxp.yaml @@ -274,7 +274,7 @@ jobs: with: platform-name: RW61X zephyr: - name: ZEPHYR_RW61X + name: ZEPHYR runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -290,12 +290,13 @@ jobs: with: platform: nxp - - name: Build RW61x Zephyr examples + - name: Build NXP Zephyr examples run: | scripts/run_in_build_env.sh "\ ./scripts/build/build_examples.py \ --target nxp-rw61x-zephyr-all-clusters \ --target nxp-rw61x-zephyr-thermostat \ --target nxp-rw61x-zephyr-laundry-washer-factory \ + --target nxp-rw61x_eth-zephyr-thermostat-ethernet \ build \ " diff --git a/config/nxp/chip-module/CMakeLists.txt b/config/nxp/chip-module/CMakeLists.txt index 557cb6f8766a81..5024672e144e24 100644 --- a/config/nxp/chip-module/CMakeLists.txt +++ b/config/nxp/chip-module/CMakeLists.txt @@ -123,7 +123,7 @@ endif() if (CONFIG_NET_L2_OPENTHREAD) matter_add_gn_arg_string("chip_mdns" "platform") -elseif(CONFIG_WIFI_NXP) +elseif(CONFIG_WIFI_NXP OR CONFIG_CHIP_ETHERNET) matter_add_gn_arg_string("chip_mdns" "minimal") else() matter_add_gn_arg_string("chip_mdns" "none") diff --git a/config/nxp/chip-module/Kconfig.defaults b/config/nxp/chip-module/Kconfig.defaults index ba9fe9b4d3f4ab..3d0fcf08d75eac 100644 --- a/config/nxp/chip-module/Kconfig.defaults +++ b/config/nxp/chip-module/Kconfig.defaults @@ -252,10 +252,6 @@ choice SCHED_ALGORITHM default SCHED_MULTIQ endchoice -choice LIBC_IMPLEMENTATION - default NEWLIB_LIBC -endchoice - choice WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_CHOICE default WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_INF endchoice @@ -326,6 +322,22 @@ config CHIP_MALLOC_SYS_HEAP_SIZE endif +if CHIP_ETHERNET || CHIP_WIFI + +choice LIBC_IMPLEMENTATION + default NEWLIB_LIBC +endchoice + +endif + +if CHIP_ETHERNET + +choice NXP_ENET_DRIVER + default ETH_NXP_ENET +endchoice + +endif + # Configure MBEDTLS lib config MBEDTLS default y diff --git a/config/nxp/chip-module/Kconfig.features b/config/nxp/chip-module/Kconfig.features index 4b387464aecab4..9c388a20f9db72 100644 --- a/config/nxp/chip-module/Kconfig.features +++ b/config/nxp/chip-module/Kconfig.features @@ -76,4 +76,27 @@ config CHIP_WIFI_CONNECTION_RECOVERY_JITTER a random jitter interval is added to it to avoid periodicity. The random jitter is selected within range [-JITTER; +JITTER]. +config CHIP_ETHERNET + bool "Enable NXP Ethernet support" + default n + depends on !CHIP_WIFI + select NET_MGMT_EVENT + select NET_MGMT_EVENT_INFO + select NET_L2_ETHERNET + select NET_L2_ETHERNET_MGMT + select NET_UDP + select NET_IP + select NET_CONFIG_SETTINGS + select NET_MGMT + select NET_IPV4 + select NET_DHCPV4 + select NET_NATIVE_IPV4 + select NET_NATIVE + select NET_TCP + select DNS_RESOLVER + select MDNS_RESOLVER + select MBEDTLS_PKCS5_C + select MBEDTLS_HKDF_C + select MBEDTLS_ECDSA_C + select PSA_CRYPTO_ENABLE_ALL endif # CHIP diff --git a/config/nxp/cmake/common.cmake b/config/nxp/cmake/common.cmake index 8b0f379f502d09..df169ef7089343 100644 --- a/config/nxp/cmake/common.cmake +++ b/config/nxp/cmake/common.cmake @@ -44,6 +44,7 @@ matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_ matter_add_gn_arg_bool ("chip_automation_logging" FALSE) matter_add_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP) matter_add_gn_arg_bool ("chip_enable_wifi" CONFIG_CHIP_WIFI) +matter_add_gn_arg_bool ("chip_enable_ethernet" CONFIG_CHIP_ETHERNET) matter_add_gn_arg_bool ("chip_system_config_provide_statistics" CONFIG_CHIP_STATISTICS) matter_add_gn_arg_bool ("chip_enable_icd_server" CONFIG_CHIP_ENABLE_ICD_SUPPORT) matter_add_gn_arg_bool ("enable_eventlist_attribute" TRUE) diff --git a/examples/all-clusters-app/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay b/examples/all-clusters-app/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay new file mode 100644 index 00000000000000..49355e8ced5b75 --- /dev/null +++ b/examples/all-clusters-app/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http: //www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rd_rw612_bga.overlay" diff --git a/examples/all-clusters-app/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf b/examples/all-clusters-app/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf new file mode 100644 index 00000000000000..c788aa8569961a --- /dev/null +++ b/examples/all-clusters-app/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf @@ -0,0 +1,23 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CONFIG_SETTINGS_NVS_SECTOR_COUNT=16 + +# 0xA226 +CONFIG_CHIP_DEVICE_PRODUCT_ID=41510 +CONFIG_CHIP_DEVICE_PRODUCT_URL="https://www.nxp.com/products/wireless-connectivity/wi-fi-plus-bluetooth-plus-802-15-4/wireless-mcu-with-integrated-tri-radio-1x1-wi-fi-6-plus-bluetooth-low-energy-5-3-802-15-4:RW612" +CONFIG_CHIP_DEVICE_PRODUCT_LABEL="RW612" +CONFIG_CHIP_DEVICE_PART_NUMBER="RW612" diff --git a/examples/all-clusters-app/nxp/zephyr/prj_ethernet.conf b/examples/all-clusters-app/nxp/zephyr/prj_ethernet.conf new file mode 100644 index 00000000000000..4d94d84d91f259 --- /dev/null +++ b/examples/all-clusters-app/nxp/zephyr/prj_ethernet.conf @@ -0,0 +1,27 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Options needed for Ethernet are located in this file + +# ethernet discriminator +CONFIG_CHIP_DEVICE_DISCRIMINATOR=0x700 + +CONFIG_CHIP_WIFI=n +CONFIG_CHIP_ETHERNET=y + +CONFIG_NET_DEFAULT_IF_WIFI=n +CONFIG_BT=n +CONFIG_BT_DEVICE_NAME="" \ No newline at end of file diff --git a/examples/laundry-washer-app/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay b/examples/laundry-washer-app/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay new file mode 100644 index 00000000000000..49355e8ced5b75 --- /dev/null +++ b/examples/laundry-washer-app/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http: //www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rd_rw612_bga.overlay" diff --git a/examples/laundry-washer-app/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf b/examples/laundry-washer-app/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf new file mode 100644 index 00000000000000..c788aa8569961a --- /dev/null +++ b/examples/laundry-washer-app/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf @@ -0,0 +1,23 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CONFIG_SETTINGS_NVS_SECTOR_COUNT=16 + +# 0xA226 +CONFIG_CHIP_DEVICE_PRODUCT_ID=41510 +CONFIG_CHIP_DEVICE_PRODUCT_URL="https://www.nxp.com/products/wireless-connectivity/wi-fi-plus-bluetooth-plus-802-15-4/wireless-mcu-with-integrated-tri-radio-1x1-wi-fi-6-plus-bluetooth-low-energy-5-3-802-15-4:RW612" +CONFIG_CHIP_DEVICE_PRODUCT_LABEL="RW612" +CONFIG_CHIP_DEVICE_PART_NUMBER="RW612" diff --git a/examples/laundry-washer-app/nxp/zephyr/prj_ethernet.conf b/examples/laundry-washer-app/nxp/zephyr/prj_ethernet.conf new file mode 100644 index 00000000000000..0a1e798ca8425a --- /dev/null +++ b/examples/laundry-washer-app/nxp/zephyr/prj_ethernet.conf @@ -0,0 +1,27 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Options needed for Ethernet are located in this file + +# ethernet discriminator +CONFIG_CHIP_DEVICE_DISCRIMINATOR=0x700 + +CONFIG_CHIP_WIFI=n +CONFIG_CHIP_ETHERNET=y + +CONFIG_NET_DEFAULT_IF_WIFI=n +CONFIG_BT=n +CONFIG_BT_DEVICE_NAME="" diff --git a/examples/platform/nxp/common/app_task/include/AppTaskBase.h b/examples/platform/nxp/common/app_task/include/AppTaskBase.h index b9348eff3f7e69..38770fa0e5ec26 100644 --- a/examples/platform/nxp/common/app_task/include/AppTaskBase.h +++ b/examples/platform/nxp/common/app_task/include/AppTaskBase.h @@ -149,6 +149,8 @@ class AppTaskBase */ #if CONFIG_CHIP_WIFI || CHIP_DEVICE_CONFIG_ENABLE_WPA virtual chip::DeviceLayer::NetworkCommissioning::WiFiDriver * GetWifiDriverInstance(void) = 0; +#elif CONFIG_CHIP_ETHERNET + virtual chip::DeviceLayer::NetworkCommissioning::EthernetDriver * GetEthernetDriverInstance(void) = 0; #endif /** diff --git a/examples/platform/nxp/common/app_task/include/AppTaskZephyr.h b/examples/platform/nxp/common/app_task/include/AppTaskZephyr.h index 9a333a768e1f93..76ceb6db0b3145 100644 --- a/examples/platform/nxp/common/app_task/include/AppTaskZephyr.h +++ b/examples/platform/nxp/common/app_task/include/AppTaskZephyr.h @@ -51,6 +51,8 @@ class AppTaskZephyr : public AppTaskBase */ #if defined(CONFIG_CHIP_WIFI) virtual chip::DeviceLayer::NetworkCommissioning::WiFiDriver * GetWifiDriverInstance(void) override; +#elif defined(CONFIG_CHIP_ETHERNET) + virtual chip::DeviceLayer::NetworkCommissioning::EthernetDriver * GetEthernetDriverInstance(void) override; #endif /** diff --git a/examples/platform/nxp/common/app_task/source/AppTaskBase.cpp b/examples/platform/nxp/common/app_task/source/AppTaskBase.cpp index 10422121e5c81f..c62be98d22c9b1 100644 --- a/examples/platform/nxp/common/app_task/source/AppTaskBase.cpp +++ b/examples/platform/nxp/common/app_task/source/AppTaskBase.cpp @@ -115,6 +115,9 @@ chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; #if CONFIG_CHIP_WIFI || CHIP_DEVICE_CONFIG_ENABLE_WPA app::Clusters::NetworkCommissioning::Instance sNetworkCommissioningInstance(0, chip::NXP::App::GetAppTask().GetWifiDriverInstance()); +#elif CONFIG_CHIP_ETHERNET +app::Clusters::NetworkCommissioning::Instance + sNetworkCommissioningInstance(0, chip::NXP::App::GetAppTask().GetEthernetDriverInstance()); #endif #if CHIP_CONFIG_ENABLE_ICD_SERVER || (CONFIG_CHIP_TEST_EVENT && CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR) @@ -288,6 +291,8 @@ CHIP_ERROR chip::NXP::App::AppTaskBase::Init() #ifdef ENABLE_CHIP_SHELL Shell::SetWiFiDriver(chip::NXP::App::GetAppTask().GetWifiDriverInstance()); #endif +#elif CONFIG_CHIP_ETHERNET + sNetworkCommissioningInstance.Init(); #endif #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR if (err == CHIP_NO_ERROR) diff --git a/examples/platform/nxp/common/app_task/source/AppTaskZephyr.cpp b/examples/platform/nxp/common/app_task/source/AppTaskZephyr.cpp index 00554d8ee1a48c..d5fefcc133caa3 100644 --- a/examples/platform/nxp/common/app_task/source/AppTaskZephyr.cpp +++ b/examples/platform/nxp/common/app_task/source/AppTaskZephyr.cpp @@ -36,6 +36,10 @@ #include "AppCLIBase.h" #endif +#ifdef CONFIG_CHIP_ETHERNET +#include +#endif + #if CONFIG_CHIP_FACTORY_DATA #include #else @@ -69,7 +73,13 @@ chip::DeviceLayer::NetworkCommissioning::WiFiDriver * chip::NXP::App::AppTaskZep return static_cast( &(NetworkCommissioning::ZephyrWifiDriver::Instance())); } -#endif // CONFIG_CHIP_WIFI +#elif defined(CONFIG_CHIP_ETHERNET) +chip::DeviceLayer::NetworkCommissioning::EthernetDriver * chip::NXP::App::AppTaskZephyr::GetEthernetDriverInstance() +{ + return static_cast( + &(NetworkCommissioning::NxpEthDriver::Instance())); +} +#endif CHIP_ERROR chip::NXP::App::AppTaskZephyr::AppMatter_Register() { diff --git a/examples/thermostat/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay b/examples/thermostat/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay new file mode 100644 index 00000000000000..49355e8ced5b75 --- /dev/null +++ b/examples/thermostat/nxp/zephyr/boards/rd_rw612_bga_ethernet.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http: //www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rd_rw612_bga.overlay" diff --git a/examples/thermostat/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf b/examples/thermostat/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf new file mode 100644 index 00000000000000..c788aa8569961a --- /dev/null +++ b/examples/thermostat/nxp/zephyr/boards/rd_rw612_bga_ethernet_fdata.conf @@ -0,0 +1,23 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CONFIG_SETTINGS_NVS_SECTOR_COUNT=16 + +# 0xA226 +CONFIG_CHIP_DEVICE_PRODUCT_ID=41510 +CONFIG_CHIP_DEVICE_PRODUCT_URL="https://www.nxp.com/products/wireless-connectivity/wi-fi-plus-bluetooth-plus-802-15-4/wireless-mcu-with-integrated-tri-radio-1x1-wi-fi-6-plus-bluetooth-low-energy-5-3-802-15-4:RW612" +CONFIG_CHIP_DEVICE_PRODUCT_LABEL="RW612" +CONFIG_CHIP_DEVICE_PART_NUMBER="RW612" diff --git a/examples/thermostat/nxp/zephyr/prj_ethernet.conf b/examples/thermostat/nxp/zephyr/prj_ethernet.conf new file mode 100644 index 00000000000000..0a1e798ca8425a --- /dev/null +++ b/examples/thermostat/nxp/zephyr/prj_ethernet.conf @@ -0,0 +1,27 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Options needed for Ethernet are located in this file + +# ethernet discriminator +CONFIG_CHIP_DEVICE_DISCRIMINATOR=0x700 + +CONFIG_CHIP_WIFI=n +CONFIG_CHIP_ETHERNET=y + +CONFIG_NET_DEFAULT_IF_WIFI=n +CONFIG_BT=n +CONFIG_BT_DEVICE_NAME="" diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 0464c51f7b0e6b..a6e386ff4949c4 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -515,6 +515,7 @@ def BuildNxpTarget(): TargetPart('k32w0', board=NxpBoard.K32W0), TargetPart('k32w1', board=NxpBoard.K32W1), TargetPart('rw61x', board=NxpBoard.RW61X), + TargetPart('rw61x_eth', board=NxpBoard.RW61X_ETH), TargetPart('mcxw71', board=NxpBoard.MCXW71) ]) @@ -544,6 +545,7 @@ def BuildNxpTarget(): target.AppendModifier(name="sw-v2", has_sw_version_2=True) target.AppendModifier(name="ota", enable_ota=True).ExceptIfRe('zephyr') target.AppendModifier(name="wifi", enable_wifi=True).OnlyIfRe('rw61x') + target.AppendModifier(name="ethernet", enable_ethernet=True).OnlyIfRe('rw61x_eth-zephyr') target.AppendModifier(name="thread", enable_thread=True).ExceptIfRe('zephyr') target.AppendModifier(name="matter-shell", enable_shell=True).ExceptIfRe('k32w0|k32w1') target.AppendModifier('data-model-disabled', data_model_interface="disabled").ExceptIfRe('-data-model-enabled') diff --git a/scripts/build/builders/nxp.py b/scripts/build/builders/nxp.py index cdf06ac8b244da..7ab73633a4aed8 100644 --- a/scripts/build/builders/nxp.py +++ b/scripts/build/builders/nxp.py @@ -39,6 +39,7 @@ class NxpBoard(Enum): K32W0 = auto() K32W1 = auto() RW61X = auto() + RW61X_ETH = auto() MCXW71 = auto() def Name(self, os_env): @@ -46,9 +47,12 @@ def Name(self, os_env): return 'k32w0x' elif self == NxpBoard.K32W1: return 'k32w1' - elif self == NxpBoard.RW61X: + elif (self == NxpBoard.RW61X) or (self == NxpBoard.RW61X_ETH): if os_env == NxpOsUsed.ZEPHYR: - return 'rd_rw612_bga' + if self == NxpBoard.RW61X_ETH: + return 'rd_rw612_bga/rw612/ethernet' + else: + return 'rd_rw612_bga' else: return 'rw61x' elif self == NxpBoard.MCXW71: @@ -61,7 +65,7 @@ def FolderName(self, os_env): return 'k32w0' elif self == NxpBoard.K32W1: return 'k32w1' - elif self == NxpBoard.RW61X: + elif (self == NxpBoard.RW61X) or (self == NxpBoard.RW61X_ETH): if os_env == NxpOsUsed.ZEPHYR: return 'zephyr' else: @@ -135,6 +139,7 @@ def __init__(self, disable_ble: bool = False, enable_thread: bool = False, enable_wifi: bool = False, + enable_ethernet: bool = False, disable_ipv4: bool = False, enable_shell: bool = False, enable_ota: bool = False, @@ -159,6 +164,7 @@ def __init__(self, self.disable_ble = disable_ble self.enable_thread = enable_thread self.enable_wifi = enable_wifi + self.enable_ethernet = enable_ethernet self.enable_ota = enable_ota self.enable_shell = enable_shell self.data_model_interface = data_model_interface @@ -221,6 +227,9 @@ def WestBuildArgs(self): if self.enable_factory_data: args.append('-DFILE_SUFFIX=fdata') + if self.enable_ethernet: + args.append('-DEXTRA_CONF_FILE="prj_ethernet.conf"') + if self.has_sw_version_2: args.append('-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2') diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index dbbf90508b0245..a5a28f3fc28986 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -13,7 +13,7 @@ linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,therm linux-x64-efr32-test-runner[-clang] imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release] infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage][-trustm] -nxp-{k32w0,k32w1,rw61x,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-thread][-matter-shell][-data-model-disabled][-data-model-enabled] +nxp-{k32w0,k32w1,rw61x,rw61x_eth,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-ethernet][-thread][-matter-shell][-data-model-disabled][-data-model-enabled] mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug][-data-model-disabled][-data-model-enabled] mw320-all-clusters-app nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc][-data-model-disabled][-data-model-enabled] diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp index 2b1070af88ee77..b582f4a3180a97 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp +++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp @@ -227,8 +227,13 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) { +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET #if CHIP_DEVICE_CONFIG_ENABLE_WIFI const net_if * const iface = InetUtils::GetWiFiInterface(); +#else + const net_if * const iface = InetUtils::GetInterface(); +#endif + VerifyOrReturnError(iface != nullptr, CHIP_ERROR_INTERNAL); const auto linkAddrStruct = iface->if_dev->link_addr; diff --git a/src/platform/nxp/zephyr/BUILD.gn b/src/platform/nxp/zephyr/BUILD.gn index 91a746e1e4b41f..b00af4edb598de 100644 --- a/src/platform/nxp/zephyr/BUILD.gn +++ b/src/platform/nxp/zephyr/BUILD.gn @@ -23,9 +23,6 @@ static_library("nxp_zephyr") { defines = [] sources = [ "../../SingletonConfigurationManager.cpp", - "../../Zephyr/BLEAdvertisingArbiter.cpp", - "../../Zephyr/BLEAdvertisingArbiter.h", - "../../Zephyr/BLEManagerImpl.cpp", "../../Zephyr/ConfigurationManagerImpl.cpp", "../../Zephyr/DiagnosticDataProviderImpl.cpp", "../../Zephyr/DiagnosticDataProviderImpl.h", @@ -37,8 +34,6 @@ static_library("nxp_zephyr") { "../../Zephyr/ZephyrConfig.h", "../common/CHIPDeviceNXPPlatformDefaultConfig.h", "../common/CHIPNXPPlatformDefaultConfig.h", - "BLEManagerImpl.h", - "BlePlatformConfig.h", "CHIPDevicePlatformConfig.h", "CHIPDevicePlatformEvent.h", "CHIPPlatformConfig.h", @@ -81,11 +76,17 @@ static_library("nxp_zephyr") { "DeviceInstanceInfoProviderImpl.h", ] } - + if (chip_config_network_layer_ble) { + sources += [ + "../../Zephyr/BLEAdvertisingArbiter.cpp", + "../../Zephyr/BLEAdvertisingArbiter.h", + "../../Zephyr/BLEManagerImpl.cpp", + "BLEManagerImpl.h", + "BlePlatformConfig.h", + ] + } if (chip_enable_wifi) { sources += [ - "../../Zephyr/InetUtils.cpp", - "../../Zephyr/InetUtils.h", "../../Zephyr/wifi/ConnectivityManagerImplWiFi.cpp", "../../Zephyr/wifi/ConnectivityManagerImplWiFi.h", "../../Zephyr/wifi/WiFiManager.cpp", @@ -94,14 +95,28 @@ static_library("nxp_zephyr") { "../../Zephyr/wifi/ZephyrWifiDriver.h", ] } - + if (chip_enable_ethernet) { + sources += [ + "Ethernet/ConnectivityManagerImplEth.cpp", + "Ethernet/ConnectivityManagerImplEth.h", + "Ethernet/EthManager.cpp", + "Ethernet/EthManager.h", + "Ethernet/NxpEthDriver.cpp", + "Ethernet/NxpEthDriver.h", + ] + } if (chip_enable_ota_requestor) { sources += [ "ota/OTAImageProcessorImpl.cpp", "ota/OTAImageProcessorImpl.h", ] } - + if (chip_enable_wifi || chip_enable_ethernet) { + sources += [ + "../../Zephyr/InetUtils.cpp", + "../../Zephyr/InetUtils.h", + ] + } if (chip_malloc_sys_heap) { sources += [ "../../Zephyr/SysHeapMalloc.cpp" ] } diff --git a/src/platform/nxp/zephyr/ConnectivityManagerImpl.cpp b/src/platform/nxp/zephyr/ConnectivityManagerImpl.cpp index 4d183558c18953..33cdbcd9e47d19 100644 --- a/src/platform/nxp/zephyr/ConnectivityManagerImpl.cpp +++ b/src/platform/nxp/zephyr/ConnectivityManagerImpl.cpp @@ -69,7 +69,7 @@ CHIP_ERROR JoinLeaveMulticastGroup(net_if * iface, const Inet::IPAddress & addre } #endif -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET // The following code should also be valid for other interface types, such as Ethernet, // but they are not officially supported, so for now enable it for Wi-Fi only. const in6_addr in6Addr = InetUtils::ToZephyrAddr(address); @@ -104,11 +104,14 @@ CHIP_ERROR ConnectivityManagerImpl::_Init() #if CHIP_DEVICE_CONFIG_ENABLE_THREAD GenericConnectivityManagerImpl_Thread::_Init(); #endif + #if CHIP_DEVICE_CONFIG_ENABLE_WIFI ReturnErrorOnFailure(InitWiFi()); +#elif CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + ReturnErrorOnFailure(InitEth()); #endif -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD || CHIP_DEVICE_CONFIG_ENABLE_WIFI +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD || CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET UDPEndPointImplSockets::SetMulticastGroupHandler( [](InterfaceId interfaceId, const IPAddress & address, UDPEndPointImplSockets::MulticastOperation operation) { if (interfaceId.IsPresent()) diff --git a/src/platform/nxp/zephyr/ConnectivityManagerImpl.h b/src/platform/nxp/zephyr/ConnectivityManagerImpl.h index c43d6a35dcb841..96c0fe303d315e 100644 --- a/src/platform/nxp/zephyr/ConnectivityManagerImpl.h +++ b/src/platform/nxp/zephyr/ConnectivityManagerImpl.h @@ -41,6 +41,10 @@ #include #endif +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET +#include "Ethernet/ConnectivityManagerImplEth.h" +#endif + #include namespace chip { @@ -71,6 +75,9 @@ class ConnectivityManagerImpl final : public ConnectivityManager, #else public Internal::GenericConnectivityManagerImpl_NoThread, #endif +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + public ConnectivityManagerImplEth, +#endif #if CHIP_DEVICE_CONFIG_ENABLE_WIFI public ConnectivityManagerImplWiFi #else diff --git a/src/platform/nxp/zephyr/Ethernet/ConnectivityManagerImplEth.cpp b/src/platform/nxp/zephyr/Ethernet/ConnectivityManagerImplEth.cpp new file mode 100644 index 00000000000000..566c1c7c186af3 --- /dev/null +++ b/src/platform/nxp/zephyr/Ethernet/ConnectivityManagerImplEth.cpp @@ -0,0 +1,38 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "EthManager.h" + +#include +#include +#include + +#include "ConnectivityManagerImplEth.h" + +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET +using namespace ::chip; +namespace chip { +namespace DeviceLayer { +CHIP_ERROR ConnectivityManagerImplEth::InitEth() +{ + return EthManager::Instance().Init(); +} +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_ETHERNET diff --git a/src/platform/nxp/zephyr/Ethernet/ConnectivityManagerImplEth.h b/src/platform/nxp/zephyr/Ethernet/ConnectivityManagerImplEth.h new file mode 100644 index 00000000000000..b2f7a7d450883a --- /dev/null +++ b/src/platform/nxp/zephyr/Ethernet/ConnectivityManagerImplEth.h @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +namespace chip { +namespace DeviceLayer { +class ConnectivityManagerImplEth +{ + friend class ConnectivityManager; + friend class EthManager; + +protected: + CHIP_ERROR InitEth(); +}; +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/zephyr/Ethernet/EthManager.cpp b/src/platform/nxp/zephyr/Ethernet/EthManager.cpp new file mode 100644 index 00000000000000..1d40654dfb79fd --- /dev/null +++ b/src/platform/nxp/zephyr/Ethernet/EthManager.cpp @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * Copyright 2024 NXP + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "EthManager.h" + +#include +#include + +#include + +#include +#include + +#include + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR EthManager::Init() +{ + ChipLogDetail(DeviceLayer, "EthManager has been initialized"); + return CHIP_NO_ERROR; +} +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/zephyr/Ethernet/EthManager.h b/src/platform/nxp/zephyr/Ethernet/EthManager.h new file mode 100644 index 00000000000000..591dbb7ac5b3f1 --- /dev/null +++ b/src/platform/nxp/zephyr/Ethernet/EthManager.h @@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * Copyright 2024 NXP + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +namespace chip { +namespace DeviceLayer { +class EthManager +{ +public: + static EthManager & Instance() + { + static EthManager sInstance; + return sInstance; + } + CHIP_ERROR Init(); +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/zephyr/Ethernet/NxpEthDriver.cpp b/src/platform/nxp/zephyr/Ethernet/NxpEthDriver.cpp new file mode 100644 index 00000000000000..341c4daab97725 --- /dev/null +++ b/src/platform/nxp/zephyr/Ethernet/NxpEthDriver.cpp @@ -0,0 +1,36 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "NxpEthDriver.h" + +#include +#include + +using namespace ::chip; +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { + +CHIP_ERROR NxpEthDriver::Init(NetworkStatusChangeCallback * networkStatusChangeCallback) +{ + return CHIP_NO_ERROR; +} + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/zephyr/Ethernet/NxpEthDriver.h b/src/platform/nxp/zephyr/Ethernet/NxpEthDriver.h new file mode 100644 index 00000000000000..3a115a69ba4317 --- /dev/null +++ b/src/platform/nxp/zephyr/Ethernet/NxpEthDriver.h @@ -0,0 +1,78 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * Copyright 2024 NXP + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "EthManager.h" + +#include + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { +class NxpEthDriver final : public EthernetDriver +{ +public: + class EthernetNetworkIterator final : public NetworkIterator + { + public: + EthernetNetworkIterator(NxpEthDriver * aDriver) : mDriver(aDriver) {} + size_t Count() { return 1; } + bool Next(Network & item) override + { + if (exhausted) + { + return false; + } + exhausted = true; + memcpy(item.networkID, interfaceName, interfaceNameLen); + item.networkIDLen = interfaceNameLen; + item.connected = true; + return true; + } + void Release() override { delete this; } + ~EthernetNetworkIterator() = default; + + uint8_t interfaceName[kMaxNetworkIDLen]; + uint8_t interfaceNameLen = 0; + bool exhausted = false; + + private: + NxpEthDriver * mDriver; + }; + + // BaseDriver + NetworkIterator * GetNetworks() override { return new EthernetNetworkIterator(this); }; + uint8_t GetMaxNetworks() { return 1; } + CHIP_ERROR Init(NetworkStatusChangeCallback * networkStatusChangeCallback) override; + void Shutdown() + { + // TODO: This method can be implemented if Ethernet is used along with Wifi/Thread. + } + + static NxpEthDriver & Instance() + { + static NxpEthDriver instance; + return instance; + } +}; + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/zephyr/args.gni b/src/platform/nxp/zephyr/args.gni index e24f997ccdf64b..449cfe190020b2 100644 --- a/src/platform/nxp/zephyr/args.gni +++ b/src/platform/nxp/zephyr/args.gni @@ -17,4 +17,7 @@ declare_args() { # Enable factory data support chip_enable_factory_data = false + + # Enable Ethernet support + chip_enable_ethernet = false } diff --git a/src/platform/telink/CHIPDevicePlatformConfig.h b/src/platform/telink/CHIPDevicePlatformConfig.h index cc612b86499eba..989b9b2aaf3705 100644 --- a/src/platform/telink/CHIPDevicePlatformConfig.h +++ b/src/platform/telink/CHIPDevicePlatformConfig.h @@ -103,6 +103,11 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 #endif +// telink platform does not support ethernet yet, but we need this config defined as we share the Zephyr platform +#ifndef CHIP_DEVICE_CONFIG_ENABLE_ETHERNET +#define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET 0 +#endif // CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + #ifdef CONFIG_BT #define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT #else