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

ESP32 gn support #2325

Merged
merged 21 commits into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from 19 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
66 changes: 66 additions & 0 deletions .github/workflows/examples-gn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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.

name: Examples - GN

on:
push:
pull_request:

jobs:
esp32:
name: ESP32

env:
BUILD_TYPE: esp32

runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build-esp32:0.4.1
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
- "/tmp/output_binaries:/tmp/output_binaries"

steps:
- name: Checkout
uses: actions/checkout@v2
# Fetch depth 0 to get all history and be able to check mergepoint for bloat report
with:
fetch-depth: 0
submodules: true
- name: Build example Echo App
run: scripts/examples/esp_echo_app.sh CHIP_BUILD_WITH_GN=y
- name: Copy aside build products
run: |
mkdir -p example_binaries/$BUILD_TYPE-build
cp examples/wifi-echo/server/esp32/build/chip-wifi-echo.elf \
example_binaries/$BUILD_TYPE-build/chip-wifi-echo.elf
- name: Binary artifact suffix
id: outsuffix
uses: haya14busa/[email protected]
with:
cond: ${{ github.event.pull_request.number == '' }}
if_true: "${{ github.sha }}"
if_false: "pull-${{ github.event.pull_request.number }}"
- name: Copy aside bloat report & binaries
run: |
cp -r example_binaries/$BUILD_TYPE-build /tmp/output_binaries/
- name: Uploading Binaries
uses: actions/upload-artifact@v1
with:
name:
${{ env.BUILD_TYPE }}-example-build-${{
steps.outsuffix.outputs.value }}
path: /tmp/output_binaries/${{ env.BUILD_TYPE }}-build
29 changes: 29 additions & 0 deletions config/esp32/.gn
Original file line number Diff line number Diff line change
@@ -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")
}
32 changes: 32 additions & 0 deletions config/esp32/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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" ]
}
38 changes: 38 additions & 0 deletions config/esp32/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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 = ""

mbedtls_target = "//mbedtls:mbedtls"
lwip_platform = "external"

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"
1 change: 1 addition & 0 deletions config/esp32/build_overrides
9 changes: 0 additions & 9 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
52 changes: 45 additions & 7 deletions config/esp32/components/chip/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,29 @@ COMPONENT_ADD_INCLUDEDIRS = project-config \
$(REL_CHIP_ROOT)/src/ \
$(REL_CHIP_ROOT)/src/system \
$(IDF_PATH)/components/mbedtls/mbedtls/include \
$(REL_CHIP_ROOT)/src/app \

$(REL_CHIP_ROOT)/src/app

# Linker flags to be included when building other components that use CHIP.
COMPONENT_ADD_LDFLAGS = -L$(OUTPUT_DIR)/lib/ \
-lCHIP \
-lInetLayer \
-lCHIP

CHIP_BUILD_WITH_GN ?= ""

ifeq ($(CHIP_BUILD_WITH_GN),y)
COMPONENT_ADD_INCLUDEDIRS += $(REL_OUTPUT_DIR)/src/include \
$(REL_CHIP_ROOT)/third_party/nlassert/repo/include \
$(REL_OUTPUT_DIR)/gen/third_party/connectedhomeip/src/app/include \
$(REL_OUTPUT_DIR)/gen/include
else # CHIP_BUILD_WITH_GN == y
COMPONENT_ADD_LDFLAGS += -lInetLayer \
-lSystemLayer \
-lDeviceLayer \
-lChipCrypto \
-lSetupPayload

ifneq (,$(findstring CHIP_SUPPORT_FOREIGN_TEST_DRIVERS,$(CXXFLAGS)))
COMPONENT_ADD_LDFLAGS += -lnlfaultinjection
endif
endif # CHIP_BUILD_WITH_GN == y

# Tell the ESP-IDF build system that the CHIP component defines its own build
# and clean targets.
Expand Down Expand Up @@ -193,13 +201,43 @@ $(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-with-gn : $(OUTPUT_DIR)
echo "INSTALL CHIP..."
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 esp32_ar = \"$(AR)\" >> $(OUTPUT_DIR)/args.gn
echo esp32_cc = \"$(CC)\" >> $(OUTPUT_DIR)/args.gn
echo esp32_cxx = \"$(CXX)\" >> $(OUTPUT_DIR)/args.gn
echo esp32_cpu = \"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

install-chip-with-automake: configure-chip
echo "INSTALL CHIP..."
MAKEFLAGS= make -C $(OUTPUT_DIR) --no-print-directory install

ifeq ($(CHIP_BUILD_WITH_GN),y)
install-chip: install-chip-with-gn
else
install-chip: install-chip-with-automake
endif

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)"
Expand Down
22 changes: 22 additions & 0 deletions config/esp32/mbedtls/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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")

# ESP32 has its own mbedtls, so nothing to do, just provide a target
group("mbedtls") {
}
1 change: 1 addition & 0 deletions config/esp32/third_party/connectedhomeip
37 changes: 37 additions & 0 deletions config/esp32/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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() {
esp32_ar = ""
esp32_cc = ""
esp32_cxx = ""
esp32_cpu = ""
}

gcc_toolchain("esp32") {
ar = esp32_ar
cc = esp32_cc
cxx = esp32_cxx

toolchain_args = {
current_os = "freertos"
current_cpu = esp32_cpu
is_clang = false
import("${chip_root}/src/platform/ESP32/args.gni")
}
}
6 changes: 6 additions & 0 deletions examples/wifi-echo/server/esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ CXXFLAGS += -std=c++11 -Os
CPPFLAGS += -Os
CFLAGS += -Os

CHIP_BUILD_WITH_GN ?= ""

ifeq ($(CHIP_BUILD_WITH_GN),y)
CPPFLAGS += -DCHIP_SEPARATE_CONFIG_H
endif
export CHIP_BUILD_WITH_GN
include $(IDF_PATH)/make/project.mk
13 changes: 13 additions & 0 deletions gn/build_overrides/esp32.gni
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 4 additions & 4 deletions scripts/examples/esp_echo_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ root=examples/wifi-echo/server/esp32/
source "$root"/idf.sh

rm -f "$root"/sdkconfig
SDKCONFIG_DEFAULTS=sdkconfig_devkit.defaults idf make -j V=1 -C "$root" defconfig
idf make -j V=1 -C "$root" || {
SDKCONFIG_DEFAULTS=sdkconfig_devkit.defaults idf make -j V=1 -C "$root" defconfig $1
idf make -j V=1 -C "$root" $1 || {
echo 'build DevKit-C failed'
exit 1
}

rm -f "$root"/sdkconfig
SDKCONFIG_DEFAULTS=sdkconfig_m5stack.defaults idf make -j V=1 -C "$root" defconfig
idf make -j V=1 -C "$root" || {
SDKCONFIG_DEFAULTS=sdkconfig_m5stack.defaults idf make -j V=1 -C "$root" defconfig $1
idf make -j V=1 -C "$root" $1 || {
echo 'build M5Stack failed'
exit 1
}
2 changes: 1 addition & 1 deletion src/ble/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ buildconfig_header("ble_buildconfig") {
defines +=
[ "BLE_PROJECT_CONFIG_INCLUDE=${chip_ble_project_config_include}" ]
}
if (chip_ble_project_config_include != "") {
if (chip_ble_platform_config_include != "") {
defines +=
[ "BLE_PLATFORM_CONFIG_INCLUDE=${chip_ble_platform_config_include}" ]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this block intended to be added? It looks like BLE_PLATFORM_CONFIG_INCLUDE is set twice here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the upper 'if' condition had a typo, fixed.

Expand Down
1 change: 1 addition & 0 deletions src/inet/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static_library("inet") {
public_deps = [
":inet_config_header",
"${chip_root}/src/lib/support",
"${chip_root}/src/lwip",
"${chip_root}/src/system",
"${nlio_root}:nlio",
]
Expand Down
Loading