From a43a0a83d0cd56e3394c64f088dcbf62f11a95f0 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Thu, 20 Aug 2020 15:30:44 +0530 Subject: [PATCH 1/4] Support external c/cc flags (as-is from rafal's PR) --- src/lib/core/BUILD.gn | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index 137c8f7537a065..8e02a327347b7c 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -20,6 +20,11 @@ import("${chip_root}/gn/chip/tests.gni") import("${chip_root}/src/inet/inet.gni") import("core.gni") +declare_args() { + cflags_c_ext = [] + cflags_cc_ext = [] +} + buildconfig_header("chip_buildconfig") { header = "CHIPBuildConfig.h" header_dir = "core" @@ -110,6 +115,9 @@ static_library("core") { "CHIPTLVWriter.cpp", ] + cflags_c = cflags_c_ext + cflags_cc = cflags_cc_ext + public_deps = [ ":chip_config_header", "${chip_root}/src/ble", From ba6388444b6c6427f0c052d42dcff44093cce2b1 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Thu, 20 Aug 2020 18:22:12 +0530 Subject: [PATCH 2/4] Use external mbedtls (used as-is from Rafal's PR) --- src/crypto/BUILD.gn | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index 718091d655f95f..2135257fd23cd8 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -60,7 +60,11 @@ static_library("crypto") { public_configs = [] if (chip_crypto == "mbedtls") { sources += [ "CHIPCryptoPALmbedTLS.cpp" ] - public_deps += [ "${mbedtls_root}:mbedtls" ] + + # ESP32 has its own mbedTLS + if (target_cpu != "esp32") { + public_deps += [ "${mbedtls_root}:mbedtls" ] + } } else if (chip_crypto == "openssl") { sources += [ "CHIPCryptoPALOpenSSL.cpp" ] public_configs += [ ":openssl_config" ] From f421f5590355085c46e0fac67909a4cd999066cf Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Mon, 24 Aug 2020 14:01:41 +0530 Subject: [PATCH 3/4] ESP32: Enable gn support (first cut) --- config/esp32/.gn | 29 +++++++++++++++++ config/esp32/BUILD.gn | 36 +++++++++++++++++++++ config/esp32/args.gni | 39 +++++++++++++++++++++++ config/esp32/build_overrides | 1 + config/esp32/components/chip/Kconfig | 9 ------ config/esp32/components/chip/component.mk | 39 +++++++++++++++++------ config/esp32/third_party/connectedhomeip | 1 + config/esp32/toolchain/BUILD.gn | 37 +++++++++++++++++++++ examples/wifi-echo/server/esp32/Makefile | 2 +- gn/build_overrides/esp32.gni | 13 ++++++++ src/ble/BUILD.gn | 8 +++-- src/inet/BUILD.gn | 5 +++ src/inet/RawEndPoint.cpp | 3 ++ src/inet/UDPEndPoint.cpp | 3 ++ src/lib/core/BUILD.gn | 8 ----- src/lwip/BUILD.gn | 19 +++++++---- src/platform/BUILD.gn | 30 +++++++++++++++++ src/platform/ESP32/CHIPPlatformConfig.h | 1 - src/platform/ESP32/args.gni | 30 +++++++++++++++++ src/platform/device.gni | 6 ++-- src/system/BUILD.gn | 6 ++-- 21 files changed, 283 insertions(+), 42 deletions(-) create mode 100644 config/esp32/.gn create mode 100644 config/esp32/BUILD.gn create mode 100644 config/esp32/args.gni create mode 120000 config/esp32/build_overrides create mode 120000 config/esp32/third_party/connectedhomeip create mode 100644 config/esp32/toolchain/BUILD.gn create mode 100644 gn/build_overrides/esp32.gni create mode 100644 src/platform/ESP32/args.gni diff --git a/config/esp32/.gn b/config/esp32/.gn new file mode 100644 index 00000000000000..0838a6445c984e --- /dev/null +++ b/config/esp32/.gn @@ -0,0 +1,29 @@ +# Copyright (c) 2020 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. + +# The location of the build configuration file. +buildconfig = "//build/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true + +# Allow loading paths relative to //gn. +secondary_source = "//third_party/connectedhomeip/gn/" + +default_args = { + target_cpu = "esp32" + target_os = "freertos" + + import("//args.gni") +} diff --git a/config/esp32/BUILD.gn b/config/esp32/BUILD.gn new file mode 100644 index 00000000000000..bbe2dc04bf06dd --- /dev/null +++ b/config/esp32/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2020 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 from standalone-chip.mk that differ from configure defaults. These +# options are used from examples/. + +import("//build_overrides/chip.gni") + +config("esp32_config") { + defines = [] + if (is_debug) { + defines = [ "BUILD_RELEASE=0" ] + } else { + defines = [ "BUILD_RELEASE=1" ] + } +} + +group("esp32") { + deps = [ + "${chip_root}/src/lib" + ] + public_configs = [ + ":esp32_config" + ] +} diff --git a/config/esp32/args.gni b/config/esp32/args.gni new file mode 100644 index 00000000000000..cc85f72b1b22af --- /dev/null +++ b/config/esp32/args.gni @@ -0,0 +1,39 @@ +# Copyright (c) 2020 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 from standalone-chip.mk that differ from configure defaults. These +# options are used from examples/. + +#import("//build_overrides/chip.gni") + +chip_device_platform = "esp32" + +chip_project_config_include = "" +chip_system_project_config_include = "" +chip_ble_project_config_include = "" + +lwip_platform = "esp32" +lwip_ipv6 = true +lwip_ipv4 = true +lwip_api = true + +chip_build_tests = false +chip_inet_config_enable_raw_endpoint = false +chip_inet_config_enable_dns_resolver = false +#Enabling this causes some error +#chip_inet_config_enable_tun_endpoint = false +chip_inet_config_enable_tcp_endpoint = true +chip_inet_config_enable_udp_endpoint = true + +custom_toolchain = "//third_party/connectedhomeip/config/esp32/toolchain:esp32" diff --git a/config/esp32/build_overrides b/config/esp32/build_overrides new file mode 120000 index 00000000000000..aea3e8d3b72a17 --- /dev/null +++ b/config/esp32/build_overrides @@ -0,0 +1 @@ +../../examples/build_overrides \ No newline at end of file diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 57231e8d11375a..5edd211570bd20 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -77,15 +77,6 @@ menu "CHIP Core" This value can be overridden by the application at runtime. - config SHORT_ERROR_STR - bool "Use Short Error Strings" - default n - help - Configure the CHIP ErrorStr() function to return short error strings - containing only the error, without any descriptive text. - - This option is generally used to reduce flash usage. - # TODO: add log level selection endmenu # "General Options" diff --git a/config/esp32/components/chip/component.mk b/config/esp32/components/chip/component.mk index 2f56f2927d4605..2646b24a15cbef 100644 --- a/config/esp32/components/chip/component.mk +++ b/config/esp32/components/chip/component.mk @@ -141,19 +141,17 @@ COMPONENT_ADD_INCLUDEDIRS = project-config \ $(REL_CHIP_ROOT)/src/include/ \ $(REL_CHIP_ROOT)/src/lib \ $(REL_CHIP_ROOT)/src/ \ + $(REL_OUTPUT_DIR)/src/include \ $(REL_CHIP_ROOT)/src/system \ $(IDF_PATH)/components/mbedtls/mbedtls/include \ $(REL_CHIP_ROOT)/src/app \ - + $(REL_CHIP_ROOT)/third_party/nlassert/repo/include \ + $(REL_OUTPUT_DIR)/gen/third_party/connectedhomeip/src/app/include \ + $(REL_OUTPUT_DIR)/gen/include # Linker flags to be included when building other components that use CHIP. COMPONENT_ADD_LDFLAGS = -L$(OUTPUT_DIR)/lib/ \ - -lCHIP \ - -lInetLayer \ - -lSystemLayer \ - -lDeviceLayer \ - -lChipCrypto \ - -lSetupPayload + -lCHIP ifneq (,$(findstring CHIP_SUPPORT_FOREIGN_TEST_DRIVERS,$(CXXFLAGS))) COMPONENT_ADD_LDFLAGS += -lnlfaultinjection @@ -193,13 +191,34 @@ $(OUTPUT_DIR) : echo "MKDIR $@" @mkdir -p "$@" -install-chip : configure-chip + +fix_cflags = $(filter-out -DHAVE_CONFIG_H,\ + $(filter-out -D,\ + $(filter-out IDF_VER%,\ + $(sort $(1)) -D$(filter IDF_VER%,$(1))\ + ))) +CHIP_CFLAGS = $(call fix_cflags,$(CFLAGS) $(CPPFLAGS)) +CHIP_CXXFLAGS = $(call fix_cflags,$(CXXFLAGS) $(CPPFLAGS)) + +install-chip : echo "INSTALL CHIP..." - MAKEFLAGS= make -C $(OUTPUT_DIR) --no-print-directory install + echo > $(OUTPUT_DIR)/args.gn + echo "import(\"//args.gni\")" >> $(OUTPUT_DIR)/args.gn + echo target_cflags_c = [$(foreach word,$(CHIP_CFLAGS),\"$(word)\",)] | sed -e 's/=\"/=\\"/g;s/\"\"/\\"\"/g;' >> $(OUTPUT_DIR)/args.gn + echo target_cflags_cc = [$(foreach word,$(CHIP_CXXFLAGS),\"$(word)\",)] | sed -e 's/=\"/=\\"/g;s/\"\"/\\"\"/g;' >> $(OUTPUT_DIR)/args.gn + echo ar_ext = \"$(AR)\" >> $(OUTPUT_DIR)/args.gn + echo cc_ext = \"$(CC)\" >> $(OUTPUT_DIR)/args.gn + echo cxx_ext = \"$(CXX)\" >> $(OUTPUT_DIR)/args.gn + echo cpu_ext = \"esp32\" >> $(OUTPUT_DIR)/args.gn + echo "Written file $(OUTPUT_DIR)/args.gn" +# MAKEFLAGS= make -C $(OUTPUT_DIR) --no-print-directory install + cd $(COMPONENT_PATH); gn gen $(OUTPUT_DIR) + cd $(COMPONENT_PATH); ninja -C $(OUTPUT_DIR) esp32 + build : install-chip echo "CHIP built and installed..." - cp ${OUTPUT_DIR}/lib/libCHIP.a ${OUTPUT_DIR}/libchip.a + cp -a ${OUTPUT_DIR}/lib/libCHIP.a ${OUTPUT_DIR}/libchip.a clean: echo "RM $(OUTPUT_DIR)" diff --git a/config/esp32/third_party/connectedhomeip b/config/esp32/third_party/connectedhomeip new file mode 120000 index 00000000000000..a8a4f8c2127bf7 --- /dev/null +++ b/config/esp32/third_party/connectedhomeip @@ -0,0 +1 @@ +../../.. \ No newline at end of file diff --git a/config/esp32/toolchain/BUILD.gn b/config/esp32/toolchain/BUILD.gn new file mode 100644 index 00000000000000..2890af96c6ebe2 --- /dev/null +++ b/config/esp32/toolchain/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) 2020 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("//build/toolchain/gcc_toolchain.gni") + +declare_args() { + ar_ext = "" + cc_ext = "" + cxx_ext = "" + cpu_ext = "" +} + +gcc_toolchain("esp32") { + ar = ar_ext + cc = cc_ext + cxx = cxx_ext + +toolchain_args = { + current_os = "freertos" + current_cpu = cpu_ext + is_clang = false + import("${chip_root}/src/platform/ESP32/args.gni") + } +} diff --git a/examples/wifi-echo/server/esp32/Makefile b/examples/wifi-echo/server/esp32/Makefile index 97bde5213c670a..e4b96a4ae6fb0f 100644 --- a/examples/wifi-echo/server/esp32/Makefile +++ b/examples/wifi-echo/server/esp32/Makefile @@ -27,7 +27,7 @@ EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/third_party/connectedhomeip/config/esp32 $(PROJECT_PATH)/../../../common/screen-framework \ CXXFLAGS += -std=c++11 -Os -CPPFLAGS += -Os +CPPFLAGS += -Os -DCHIP_SEPARATE_CONFIG_H CFLAGS += -Os include $(IDF_PATH)/make/project.mk diff --git a/gn/build_overrides/esp32.gni b/gn/build_overrides/esp32.gni new file mode 100644 index 00000000000000..3a2252cb67477c --- /dev/null +++ b/gn/build_overrides/esp32.gni @@ -0,0 +1,13 @@ +# Copyright (c) 2020 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. diff --git a/src/ble/BUILD.gn b/src/ble/BUILD.gn index 184a93f2d059b3..b28f7288decd49 100644 --- a/src/ble/BUILD.gn +++ b/src/ble/BUILD.gn @@ -37,8 +37,12 @@ buildconfig_header("ble_buildconfig") { [ "BLE_PROJECT_CONFIG_INCLUDE=${chip_ble_project_config_include}" ] } if (chip_ble_project_config_include != "") { - defines += - [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] + defines += + [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] + } + if (chip_device_platform == "esp32") { + defines += + [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] } } diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 39fe7be7829623..f36566997d7476 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -99,6 +99,11 @@ static_library("inet") { "${chip_root}/src/lib/support", "${chip_root}/src/system", "${nlio_root}:nlio", + "${chip_root}/src/lwip:lwip_buildconfig", + ] + + public_configs = [ + "${chip_root}/src/lwip:lwip_config", ] if (chip_inet_config_enable_raw_endpoint) { diff --git a/src/inet/RawEndPoint.cpp b/src/inet/RawEndPoint.cpp index 851d20bd89167e..05217cdf77118d 100644 --- a/src/inet/RawEndPoint.cpp +++ b/src/inet/RawEndPoint.cpp @@ -42,6 +42,9 @@ #include #include #include +#if CHIP_SEPARATE_CONFIG_H +#include +#endif // CHIP_SEPARATE_CONFIG_H #endif // CHIP_SYSTEM_CONFIG_USE_LWIP #if CHIP_SYSTEM_CONFIG_USE_SOCKETS diff --git a/src/inet/UDPEndPoint.cpp b/src/inet/UDPEndPoint.cpp index 05b7cec9f2dd7b..16882407ba5fc7 100644 --- a/src/inet/UDPEndPoint.cpp +++ b/src/inet/UDPEndPoint.cpp @@ -41,6 +41,9 @@ #include #include #include +#if CHIP_SEPARATE_CONFIG_H +#include +#endif // CHIP_SEPARATE_CONFIG_H #endif // CHIP_SYSTEM_CONFIG_USE_LWIP #if CHIP_SYSTEM_CONFIG_USE_SOCKETS diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index 8e02a327347b7c..137c8f7537a065 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -20,11 +20,6 @@ import("${chip_root}/gn/chip/tests.gni") import("${chip_root}/src/inet/inet.gni") import("core.gni") -declare_args() { - cflags_c_ext = [] - cflags_cc_ext = [] -} - buildconfig_header("chip_buildconfig") { header = "CHIPBuildConfig.h" header_dir = "core" @@ -115,9 +110,6 @@ static_library("core") { "CHIPTLVWriter.cpp", ] - cflags_c = cflags_c_ext - cflags_cc = cflags_cc_ext - public_deps = [ ":chip_config_header", "${chip_root}/src/ble", diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index cdfab8117c6f6f..22c5e9fed3a946 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -33,7 +33,7 @@ if (lwip_platform == "") { } assert(lwip_platform == "standalone" || lwip_platform == "nrf5" || - lwip_platform == "efr32", + lwip_platform == "esp32" || lwip_platform == "efr32", "Unsupported lwIP platform: ${lwip_platform}") if (lwip_platform == "nrf5") { @@ -47,13 +47,18 @@ buildconfig_header("lwip_buildconfig") { header_dir = "lwip" # Automatically enable LWIP_DEBUG for internal is_debug builds. - if (lwip_debug) { - lwip_debug = 1 - } else { - lwip_debug = 0 + defines = [] + if (lwip_platform != "esp32") { + if (lwip_debug) { + lwip_debug = 1 + } else { + lwip_debug = 0 + } + defines += [ + "LWIP_DEBUG=${lwip_debug}", + ] } - defines = [ - "LWIP_DEBUG=${lwip_debug}", + defines += [ "HAVE_LWIP_UDP_BIND_NETIF=1", ] diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 91d11bb0aedcdf..6666c16128e189 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -92,6 +92,12 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "CHIP_DEVICE_LAYER_TARGET=EFR32", ] } + if (chip_device_platform == "esp32") { + defines += [ + "CHIP_DEVICE_LAYER_TARGET_ESP32=1", + "CHIP_DEVICE_LAYER_TARGET=ESP32", + ] + } } config("platform_config") { @@ -261,6 +267,30 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "nRF5/ThreadStackManagerImpl.h", ] } + } else if (chip_device_platform == "esp32") { + sources += [ + "ESP32/BLEManagerImpl.cpp", + "ESP32/ConfigurationManagerImpl.cpp", + "ESP32/PlatformManagerImpl.cpp", + "ESP32/ConnectivityManagerImpl.cpp", + "ESP32/ESP32Config.cpp", + "ESP32/ESP32Utils.cpp", + "ESP32/Logging.cpp", + "ESP32/SystemTimeSupport.cpp", + "ESP32/LwIPCoreLock.cpp", + "ESP32/CHIPDevicePlatformConfig.h", + "ESP32/ConnectivityManagerImpl.h", + "ESP32/BLEManagerImpl.h", + "ESP32/ConfigurationManagerImpl.h", + "ESP32/PlatformManagerImpl.h", + "ESP32/SoftwareUpdateManagerImpl.h", + "ESP32/CHIPDevicePlatformEvent.h", + "ESP32/NetworkProvisioningServerImpl.h", + "ESP32/ESP32Utils.h", + "ESP32/ESP32Config.h", + "FreeRTOS/SystemTimeSupport.cpp", + ] +# public_configs += [ "${chip_root}/src/crypto:crypto_config" ] } else if (chip_device_platform == "efr32") { sources += [ "EFR32/BLEManagerImpl.cpp", diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index d3663277ad46de..0803880c62109a 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -84,7 +84,6 @@ #define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS #define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS CONFIG_MAX_EXCHANGE_CONTEXTS #define CHIP_CONFIG_RMP_TIMER_DEFAULT_PERIOD CONFIG_RMP_TIMER_DEFAULT_PERIOD -#define CHIP_CONFIG_SHORT_ERROR_STR CONFIG_SHORT_ERROR_STR #define CHIP_CONFIG_MAX_SESSION_KEYS CONFIG_MAX_SESSION_KEYS #define CHIP_CONFIG_USE_APP_GROUP_KEYS_FOR_MSG_ENC CONFIG_USE_APP_GROUP_KEYS_FOR_MSG_ENC #define CHIP_CONFIG_MAX_CACHED_MSG_ENC_APP_KEYS CONFIG_MAX_CACHED_MSG_ENC_APP_KEYS diff --git a/src/platform/ESP32/args.gni b/src/platform/ESP32/args.gni new file mode 100644 index 00000000000000..ec2ad21f16e03a --- /dev/null +++ b/src/platform/ESP32/args.gni @@ -0,0 +1,30 @@ +# Copyright (c) 2020 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") + +chip_device_platform = "esp32" + +lwip_platform = "esp32" +lwip_ipv6 = true +lwip_ipv4 = true +lwip_api = true + +chip_build_tests = false +chip_inet_config_enable_raw_endpoint = false +chip_inet_config_enable_dns_resolver = false +chip_inet_config_enable_tun_endpoint = false +chip_inet_config_enable_tcp_endpoint = true +chip_inet_config_enable_udp_endpoint = true + diff --git a/src/platform/device.gni b/src/platform/device.gni index 5b40b1a21dd308..617618e79e3217 100644 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") declare_args() { - # Device platform layer: darwin, linux, freertos, nrf5, efr32, external, none. + # Device platform layer: darwin, linux, freertos, nrf5, efr32, esp32, external, none. chip_device_platform = "auto" chip_platform_target = "" } @@ -49,6 +49,8 @@ if (chip_device_platform == "darwin") { _chip_device_layer = "nRF5" } else if (chip_device_platform == "efr32") { _chip_device_layer = "EFR32" +} else if (chip_device_platform == "esp32") { + _chip_device_layer = "ESP32" } if (chip_device_platform != "external") { @@ -83,5 +85,5 @@ if (_chip_device_layer != "none" && chip_device_platform != "external") { assert((current_os != "freertos" && chip_device_platform == "none") || chip_device_platform == "darwin" || chip_device_platform == "nrf5" || chip_device_platform == "efr32" || chip_device_platform == "linux" || - chip_device_platform == "external", + chip_device_platform == "external" || chip_device_platform == "esp32", "Please select a valid value for chip_device_platform") diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index dff7fd0df07256..bfc02579710862 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -106,8 +106,10 @@ source_set("system_config_header") { public_deps = [ ":system_buildconfig" ] - if (chip_system_config_use_lwip) { - public_deps += [ "${chip_root}/src/lwip" ] + if (target_cpu != "esp32") { + if (chip_system_config_use_lwip) { + public_deps += [ "${chip_root}/src/lwip" ] + } } } From 3ec66c4ed26fe13953d9a242fed68d01ac85fbf0 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 25 Aug 2020 14:49:42 +0000 Subject: [PATCH 4/4] Restyled by gn --- config/esp32/BUILD.gn | 8 ++----- config/esp32/args.gni | 1 + config/esp32/toolchain/BUILD.gn | 10 ++++---- src/ble/BUILD.gn | 8 +++---- src/crypto/BUILD.gn | 2 +- src/inet/BUILD.gn | 6 ++--- src/lwip/BUILD.gn | 18 ++++++-------- src/platform/BUILD.gn | 42 ++++++++++++++++----------------- src/platform/ESP32/args.gni | 1 - src/platform/device.gni | 11 +++++---- 10 files changed, 49 insertions(+), 58 deletions(-) diff --git a/config/esp32/BUILD.gn b/config/esp32/BUILD.gn index bbe2dc04bf06dd..e599e651d2f093 100644 --- a/config/esp32/BUILD.gn +++ b/config/esp32/BUILD.gn @@ -27,10 +27,6 @@ config("esp32_config") { } group("esp32") { - deps = [ - "${chip_root}/src/lib" - ] - public_configs = [ - ":esp32_config" - ] + deps = [ "${chip_root}/src/lib" ] + public_configs = [ ":esp32_config" ] } diff --git a/config/esp32/args.gni b/config/esp32/args.gni index cc85f72b1b22af..c37bc4c1163f4e 100644 --- a/config/esp32/args.gni +++ b/config/esp32/args.gni @@ -31,6 +31,7 @@ lwip_api = true chip_build_tests = false chip_inet_config_enable_raw_endpoint = false chip_inet_config_enable_dns_resolver = false + #Enabling this causes some error #chip_inet_config_enable_tun_endpoint = false chip_inet_config_enable_tcp_endpoint = true diff --git a/config/esp32/toolchain/BUILD.gn b/config/esp32/toolchain/BUILD.gn index 2890af96c6ebe2..5f416b2a692309 100644 --- a/config/esp32/toolchain/BUILD.gn +++ b/config/esp32/toolchain/BUILD.gn @@ -17,18 +17,18 @@ import("//build_overrides/chip.gni") import("//build/toolchain/gcc_toolchain.gni") declare_args() { - ar_ext = "" - cc_ext = "" + ar_ext = "" + cc_ext = "" cxx_ext = "" cpu_ext = "" } gcc_toolchain("esp32") { - ar = ar_ext - cc = cc_ext + ar = ar_ext + cc = cc_ext cxx = cxx_ext -toolchain_args = { + toolchain_args = { current_os = "freertos" current_cpu = cpu_ext is_clang = false diff --git a/src/ble/BUILD.gn b/src/ble/BUILD.gn index b28f7288decd49..f8d932e9870321 100644 --- a/src/ble/BUILD.gn +++ b/src/ble/BUILD.gn @@ -37,12 +37,12 @@ buildconfig_header("ble_buildconfig") { [ "BLE_PROJECT_CONFIG_INCLUDE=${chip_ble_project_config_include}" ] } if (chip_ble_project_config_include != "") { - defines += - [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] + defines += + [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] } if (chip_device_platform == "esp32") { - defines += - [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] + defines += + [ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ] } } diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index 2135257fd23cd8..ff284a0116f344 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -63,7 +63,7 @@ static_library("crypto") { # ESP32 has its own mbedTLS if (target_cpu != "esp32") { - public_deps += [ "${mbedtls_root}:mbedtls" ] + public_deps += [ "${mbedtls_root}:mbedtls" ] } } else if (chip_crypto == "openssl") { sources += [ "CHIPCryptoPALOpenSSL.cpp" ] diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index f36566997d7476..6ca7c540a34092 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -97,14 +97,12 @@ static_library("inet") { public_deps = [ ":inet_config_header", "${chip_root}/src/lib/support", + "${chip_root}/src/lwip:lwip_buildconfig", "${chip_root}/src/system", "${nlio_root}:nlio", - "${chip_root}/src/lwip:lwip_buildconfig", ] - public_configs = [ - "${chip_root}/src/lwip:lwip_config", - ] + public_configs = [ "${chip_root}/src/lwip:lwip_config" ] if (chip_inet_config_enable_raw_endpoint) { sources += [ diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index 22c5e9fed3a946..3bdc43531f78db 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -49,18 +49,14 @@ buildconfig_header("lwip_buildconfig") { # Automatically enable LWIP_DEBUG for internal is_debug builds. defines = [] if (lwip_platform != "esp32") { - if (lwip_debug) { - lwip_debug = 1 - } else { - lwip_debug = 0 - } - defines += [ - "LWIP_DEBUG=${lwip_debug}", - ] + if (lwip_debug) { + lwip_debug = 1 + } else { + lwip_debug = 0 + } + defines += [ "LWIP_DEBUG=${lwip_debug}" ] } - defines += [ - "HAVE_LWIP_UDP_BIND_NETIF=1", - ] + defines += [ "HAVE_LWIP_UDP_BIND_NETIF=1" ] if (current_os == "android") { defines += [ "LWIP_NO_STDINT_H=1" ] diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 6666c16128e189..d284383afce681 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -269,28 +269,28 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { } } else if (chip_device_platform == "esp32") { sources += [ - "ESP32/BLEManagerImpl.cpp", - "ESP32/ConfigurationManagerImpl.cpp", - "ESP32/PlatformManagerImpl.cpp", - "ESP32/ConnectivityManagerImpl.cpp", - "ESP32/ESP32Config.cpp", - "ESP32/ESP32Utils.cpp", - "ESP32/Logging.cpp", - "ESP32/SystemTimeSupport.cpp", - "ESP32/LwIPCoreLock.cpp", - "ESP32/CHIPDevicePlatformConfig.h", - "ESP32/ConnectivityManagerImpl.h", - "ESP32/BLEManagerImpl.h", - "ESP32/ConfigurationManagerImpl.h", - "ESP32/PlatformManagerImpl.h", - "ESP32/SoftwareUpdateManagerImpl.h", - "ESP32/CHIPDevicePlatformEvent.h", - "ESP32/NetworkProvisioningServerImpl.h", - "ESP32/ESP32Utils.h", - "ESP32/ESP32Config.h", - "FreeRTOS/SystemTimeSupport.cpp", + "ESP32/BLEManagerImpl.cpp", + "ESP32/BLEManagerImpl.h", + "ESP32/CHIPDevicePlatformConfig.h", + "ESP32/CHIPDevicePlatformEvent.h", + "ESP32/ConfigurationManagerImpl.cpp", + "ESP32/ConfigurationManagerImpl.h", + "ESP32/ConnectivityManagerImpl.cpp", + "ESP32/ConnectivityManagerImpl.h", + "ESP32/ESP32Config.cpp", + "ESP32/ESP32Config.h", + "ESP32/ESP32Utils.cpp", + "ESP32/ESP32Utils.h", + "ESP32/Logging.cpp", + "ESP32/LwIPCoreLock.cpp", + "ESP32/NetworkProvisioningServerImpl.h", + "ESP32/PlatformManagerImpl.cpp", + "ESP32/PlatformManagerImpl.h", + "ESP32/SoftwareUpdateManagerImpl.h", + "ESP32/SystemTimeSupport.cpp", + "FreeRTOS/SystemTimeSupport.cpp", ] -# public_configs += [ "${chip_root}/src/crypto:crypto_config" ] + # public_configs += [ "${chip_root}/src/crypto:crypto_config" ] } else if (chip_device_platform == "efr32") { sources += [ "EFR32/BLEManagerImpl.cpp", diff --git a/src/platform/ESP32/args.gni b/src/platform/ESP32/args.gni index ec2ad21f16e03a..0e477863220cbf 100644 --- a/src/platform/ESP32/args.gni +++ b/src/platform/ESP32/args.gni @@ -27,4 +27,3 @@ chip_inet_config_enable_dns_resolver = false chip_inet_config_enable_tun_endpoint = false chip_inet_config_enable_tcp_endpoint = true chip_inet_config_enable_udp_endpoint = true - diff --git a/src/platform/device.gni b/src/platform/device.gni index 617618e79e3217..07a8482caf1c5a 100644 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -82,8 +82,9 @@ if (_chip_device_layer != "none" && chip_device_platform != "external") { "" } -assert((current_os != "freertos" && chip_device_platform == "none") || - chip_device_platform == "darwin" || chip_device_platform == "nrf5" || - chip_device_platform == "efr32" || chip_device_platform == "linux" || - chip_device_platform == "external" || chip_device_platform == "esp32", - "Please select a valid value for chip_device_platform") +assert( + (current_os != "freertos" && chip_device_platform == "none") || + chip_device_platform == "darwin" || chip_device_platform == "nrf5" || + chip_device_platform == "efr32" || chip_device_platform == "linux" || + chip_device_platform == "external" || chip_device_platform == "esp32", + "Please select a valid value for chip_device_platform")