Skip to content

Commit

Permalink
[NXP][Zephyr] Add experimental Ethernet support to NXP zephyr platfor…
Browse files Browse the repository at this point in the history
…ms (#35643)

* [NXP][Zephyr] Add experimental Ethernet support to nxp zephyr platforms

* Enable Ethernet for RW61x platform
* Add ethernet support in following examples:
  * All-clusters-app
  * Laudry washer
  * Thermostat
* Support ethernet build with build_examples.py and add it to workflows

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>

* Restyled by gn

* [Telink] Define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET as required by shared Zephyr platform

Like nrfconnect platform, define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET to 0
as required by share Zephyr platform files.

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>

---------

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
axelnxp and restyled-commits authored Sep 18, 2024
1 parent e103352 commit 640f21a
Show file tree
Hide file tree
Showing 33 changed files with 601 additions and 24 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/examples-nxp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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 \
"
2 changes: 1 addition & 1 deletion config/nxp/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 16 additions & 4 deletions config/nxp/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions config/nxp/chip-module/Kconfig.features
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions config/nxp/cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
27 changes: 27 additions & 0 deletions examples/all-clusters-app/nxp/zephyr/prj_ethernet.conf
Original file line number Diff line number Diff line change
@@ -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=""
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
27 changes: 27 additions & 0 deletions examples/laundry-washer-app/nxp/zephyr/prj_ethernet.conf
Original file line number Diff line number Diff line change
@@ -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=""
2 changes: 2 additions & 0 deletions examples/platform/nxp/common/app_task/include/AppTaskBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
2 changes: 2 additions & 0 deletions examples/platform/nxp/common/app_task/include/AppTaskZephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
5 changes: 5 additions & 0 deletions examples/platform/nxp/common/app_task/source/AppTaskBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion examples/platform/nxp/common/app_task/source/AppTaskZephyr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#include "AppCLIBase.h"
#endif

#ifdef CONFIG_CHIP_ETHERNET
#include <platform/nxp/zephyr/Ethernet/NxpEthDriver.h>
#endif

#if CONFIG_CHIP_FACTORY_DATA
#include <platform/nxp/common/factory_data/FactoryDataProvider.h>
#else
Expand Down Expand Up @@ -69,7 +73,13 @@ chip::DeviceLayer::NetworkCommissioning::WiFiDriver * chip::NXP::App::AppTaskZep
return static_cast<chip::DeviceLayer::NetworkCommissioning::WiFiDriver *>(
&(NetworkCommissioning::ZephyrWifiDriver::Instance()));
}
#endif // CONFIG_CHIP_WIFI
#elif defined(CONFIG_CHIP_ETHERNET)
chip::DeviceLayer::NetworkCommissioning::EthernetDriver * chip::NXP::App::AppTaskZephyr::GetEthernetDriverInstance()
{
return static_cast<chip::DeviceLayer::NetworkCommissioning::EthernetDriver *>(
&(NetworkCommissioning::NxpEthDriver::Instance()));
}
#endif

CHIP_ERROR chip::NXP::App::AppTaskZephyr::AppMatter_Register()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
27 changes: 27 additions & 0 deletions examples/thermostat/nxp/zephyr/prj_ethernet.conf
Original file line number Diff line number Diff line change
@@ -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=""
2 changes: 2 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])

Expand Down Expand Up @@ -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')
Expand Down
Loading

0 comments on commit 640f21a

Please sign in to comment.