Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix examples building when enabling external platform #31188

Merged
merged 5 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/examples-esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,6 @@ jobs:

- name: Build example Light Switch App (Target:ESP32C3)
run: scripts/examples/esp_example.sh light-switch-app sdkconfig.defaults.esp32c3

- name: Build example Lighting App (external platform)
run: scripts/examples/esp_example.sh lighting-app sdkconfig.ext_plat.defaults
1 change: 1 addition & 0 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ if (CONFIG_CHIP_ENABLE_EXTERNAL_PLATFORM)
chip_gn_arg_append("chip_shell_platform" "\"esp32\"")
endif()
chip_gn_arg_append("chip_platform_target" "\"//${CONFIG_CHIP_EXTERNAL_PLATFORM_DIR}\"")
chip_gn_arg_append("chip_external_platform_include_dir" "\"//${CONFIG_CHIP_EXTERNAL_PLATFORM_INCLUDE_DIR}\"")
endif()

# Set up CHIP project configuration file
Expand Down
6 changes: 6 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,12 @@ menu "CHIP Device Layer"
help
The directory of the external platform.

config CHIP_EXTERNAL_PLATFORM_INCLUDE_DIR
string "The external platform including directory"
depends on CHIP_ENABLE_EXTERNAL_PLATFORM
help
The including directory of the external platform.

endmenu

menu "Matter Manufacturing Options"
Expand Down
70 changes: 70 additions & 0 deletions examples/lighting-app/esp32/sdkconfig.ext_plat.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# Copyright (c) 2021 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.
#
# Description:
# Some useful defaults for the demo app configuration.
#

# Default to 921600 baud when flashing and monitoring device
CONFIG_ESPTOOLPY_BAUD_921600B=y
CONFIG_ESPTOOLPY_BAUD=921600
CONFIG_ESPTOOLPY_COMPRESSED=y
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200

#enable BT
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y

#disable BT connection reattempt
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n

#enable lwip ipv6 autoconfig
CONFIG_LWIP_IPV6_AUTOCONFIG=y

#enable debug shell
CONFIG_ENABLE_CHIP_SHELL=y

# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"

#enable lwIP route hooks
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y

# Serial Flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"

# Disable softap support by default
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
# This example uses the older version of RMT driver to work with both
# idf-v4.4.3 and idf-v5.0, so suppressing the warnings by setting below option
CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y

# Enable HKDF in mbedtls
CONFIG_MBEDTLS_HKDF_C=y

# Disable Read Client
CONFIG_DISABLE_READ_CLIENT=y

# Increase LwIP IPv6 address number
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6

CONFIG_CHIP_ENABLE_EXTERNAL_PLATFORM=y
CONFIG_CHIP_EXTERNAL_PLATFORM_DIR="../../examples/platform/esp32/external_platform/ESP32_custom/"
CONFIG_CHIP_EXTERNAL_PLATFORM_INCLUDE_DIR="../../examples/platform/esp32/"
162 changes: 162 additions & 0 deletions examples/platform/esp32/external_platform/ESP32_custom/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Copyright (c) 2023 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.

import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/src/platform/device.gni")

declare_args() {
# By default use default/example implementation of CommissionableDataProvider,
# DeviceAttestationCredentialsProvider and DeviceInstanceInfoProvider
chip_use_transitional_commissionable_data_provider = true
chip_use_factory_data_provider = false
chip_use_device_info_provider = false
chip_config_software_version_number = 0
chip_enable_chipoble = true
chip_bt_nimble_enabled = true
chip_bt_bluedroid_enabled = true
chip_max_discovered_ip_addresses = 5
chip_enable_route_hook = false
}

buildconfig_header("custom_buildconfig") {
header = "CHIPDeviceBuildConfig.h"
header_dir = "platform"

defines = [
"CHIP_DEVICE_CONFIG_ENABLE_WPA=false",
"CHIP_ENABLE_OPENTHREAD=${chip_enable_openthread}",
"CHIP_DEVICE_CONFIG_THREAD_FTD=${chip_openthread_ftd}",
"OPENTHREAD_CONFIG_ENABLE_TOBLE=false",
"CHIP_BYPASS_RENDEZVOUS=false",
"CHIP_STACK_LOCK_TRACKING_ENABLED=true",
"CHIP_STACK_LOCK_TRACKING_ERROR_FATAL=false",
"CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING=false",
"CHIP_DEVICE_CONFIG_RUN_AS_ROOT=false",
"CHIP_DEVICE_LAYER_TARGET_ESP32=1",
"CHIP_DEVICE_LAYER_TARGET=ESP32_custom",
"CHIP_USE_TRANSITIONAL_COMMISSIONABLE_DATA_PROVIDER=1",
"BLE_PLATFORM_CONFIG_INCLUDE=<external_platform/ESP32_custom/BlePlatformConfig.h>",
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<external_platform/ESP32_custom/CHIPDevicePlatformConfig.h>",
"CHIP_PLATFORM_CONFIG_INCLUDE=<external_platform/ESP32_custom/CHIPPlatformConfig.h>",
"INET_CONFIG_INCLUDE=<external_platform/ESP32_custom/InetPlatformConfig.h>",
"SYSTEM_PLATFORM_CONFIG_INCLUDE=<external_platform/ESP32_custom/SystemPlatformConfig.h>",
"EXTERNAL_CONFIGURATIONMANAGERIMPL_HEADER=<external_platform/ESP32_custom/ConfigurationManagerImpl.h>",
"EXTERNAL_CHIPDEVICEPLATFORMEVENT_HEADER=<external_platform/ESP32_custom/CHIPDevicePlatformEvent.h>",
"EXTERNAL_CONNECTIVITYMANAGERIMPL_HEADER=<external_platform/ESP32_custom/ConnectivityManagerImpl.h>",
"EXTERNAL_BLEMANAGERIMPL_HEADER=<external_platform/ESP32_custom/BLEManagerImpl.h>",
"EXTERNAL_KEYVALUESTOREMANAGERIMPL_HEADER=<external_platform/ESP32_custom/KeyValueStoreManagerImpl.h>",
"EXTERNAL_PLATFORMMANAGERIMPL_HEADER=<external_platform/ESP32_custom/PlatformManagerImpl.h>",
"CHIP_CONFIG_SOFTWARE_VERSION_NUMBER=${chip_config_software_version_number}",
"CHIP_DEVICE_CONFIG_MAX_DISCOVERED_IP_ADDRESSES=${chip_max_discovered_ip_addresses}",
]

if (chip_enable_ota_requestor) {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR=1" ]
}
}

group("platform_buildconfig") {
public_deps = [ ":custom_buildconfig" ]
}

static_library("ESP32_custom") {
sources = [
"${chip_root}/src/platform/SingletonConfigurationManager.cpp",
"CHIPDevicePlatformConfig.h",
"CHIPDevicePlatformEvent.h",
"ConfigurationManagerImpl.cpp",
"ConfigurationManagerImpl.h",
"ConnectivityManagerImpl.cpp",
"ConnectivityManagerImpl.h",
"DiagnosticDataProviderImpl.cpp",
"DiagnosticDataProviderImpl.h",
"ESP32Config.cpp",
"ESP32Config.h",
"ESP32Utils.cpp",
"ESP32Utils.h",
"KeyValueStoreManagerImpl.cpp",
"KeyValueStoreManagerImpl.h",
"Logging.cpp",
"LwIPCoreLock.cpp",
"PlatformManagerImpl.cpp",
"PlatformManagerImpl.h",
"SystemTimeSupport.cpp",
"SystemTimeSupport.h",
]

deps = [
"${chip_root}/src/lib/dnssd:platform_header",
"${chip_root}/src/platform/logging:headers",
"${chip_root}/src/setup_payload",
]

public_deps = [
":platform_buildconfig",
"${chip_root}/src/crypto",
"${chip_root}/src/platform:platform_base",
]

if (chip_enable_ota_requestor) {
sources += [
"OTAImageProcessorImpl.cpp",
"OTAImageProcessorImpl.h",
]
}

if (chip_enable_chipoble) {
sources += [ "BLEManagerImpl.h" ]
}

if (chip_bt_nimble_enabled) {
sources += [ "nimble/BLEManagerImpl.cpp" ]
}

if (chip_bt_bluedroid_enabled) {
sources += [ "bluedroid/BLEManagerImpl.cpp" ]
}

if (chip_enable_wifi) {
sources += [
"ConnectivityManagerImpl_WiFi.cpp",
"NetworkCommissioningDriver.cpp",
"NetworkCommissioningDriver.h",
"route_hook/ESP32RouteHook.c",
"route_hook/ESP32RouteHook.h",
"route_hook/ESP32RouteTable.c",
"route_hook/ESP32RouteTable.h",
]
if (chip_mdns == "platform") {
sources += [
"DnssdImpl.cpp",
"DnssdImpl.h",
]
}
}

if (chip_use_factory_data_provider) {
sources += [
"ESP32FactoryDataProvider.cpp",
"ESP32FactoryDataProvider.h",
]
}

if (chip_use_device_info_provider) {
sources += [
"ESP32DeviceInfoProvider.cpp",
"ESP32DeviceInfoProvider.h",
]
}
}
Loading
Loading