Skip to content

Commit

Permalink
[Rebased] Add new platform: Ameba (#9232)
Browse files Browse the repository at this point in the history
* Add Dockerfile for Ameba platform

* Add Ameba into vscode and amend the ENV

* Modify Dockerfile and update version

* Add new platform: Ameba

* Add docker_build and build_examples features

* Patch for adapting the changes up to Base0913

* Remove build.sh

* Rename platform and apply updates for the comments

* Fix undefined reference usleep

* Add cmake files for ameba

* Fix compile error after rebase and clean files

* Update cmake files

* Support build_example build

* Made modifications for the review questions

* Update based on comments and fix restyled errors

* Optimize the script with no env variable added

* Include chip_data_model.cmake into cmakelist

* Adapt the name change of mdns

* Update platform for unit test

* Fix the check-spellcheck failure
  • Loading branch information
pankore authored Oct 18, 2021
1 parent 2c53567 commit 544da73
Show file tree
Hide file tree
Showing 54 changed files with 2,843 additions and 13 deletions.
21 changes: 15 additions & 6 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ AE
aef
algs
alloc
Ameba
ameba
amebad
amebaiot
AnnounceOTAProvider
APIs
apk
Expand All @@ -44,6 +48,7 @@ args
argv
armeabi
armv
asdk
ASYNC
att
attId
Expand All @@ -52,6 +57,7 @@ attrListName
attrMask
attSizeBytes
attType
ATW
AudioOutput
auth
autoconnect
Expand Down Expand Up @@ -113,7 +119,6 @@ CAfile
cancelled
CBB
cbd
CMD
CCMP
CCS
CCSTUDIO
Expand All @@ -139,8 +144,8 @@ ChipImInitiator
ChipImResponder
ChipLight
ChipMessageLayer
CHIPTool
CHIPTest
CHIPTool
chmod
chrpath
cipd
Expand All @@ -160,6 +165,7 @@ clusterListName
ClusterRevision
ClusterTestGeneration
cmake
CMD
CMSIS
CMVH
cn
Expand Down Expand Up @@ -269,6 +275,7 @@ DISTRO
Distutils
DK
DL
DM
DMG
DNS
Dnsmasq
Expand Down Expand Up @@ -659,6 +666,7 @@ PacketBuffer
PAI
PairDevice
PAKE
pankore
param
params
PartNumber
Expand All @@ -679,9 +687,9 @@ PID
Pigweed
PinCode
pkgconfig
plaintext
PlatformManager
PlatformManagerImpl
plaintext
plt
png
polymorphism
Expand Down Expand Up @@ -768,6 +776,7 @@ RPi
rsn
RSSI
rsync
RTL
rtld
RTOS
RTT
Expand All @@ -785,9 +794,9 @@ ScriptBinding
SDC
SDHC
SDK
SDK's
sdkconfig
SDKs
SDK's
SDKTARGETSYSROOT
sdl
segger
Expand All @@ -798,8 +807,8 @@ SERIALDEVICE
SerialNumber
ServiceId
SetDns
SetUpPINCode
SetpointRaiseLower
SetUpPINCode
SetupQRCode
sexualized
SIGINT
Expand Down Expand Up @@ -910,8 +919,8 @@ ttyUSB
TvChannel
txt
uart
udhcpc
UART
udhcpc
UDP
UDPEndPoint
udpPort
Expand Down
1 change: 1 addition & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
"id": "exampleTarget",
"description": "What target to build",
"options": [
"ameba-amebad-all-clusters",
"android-arm-chip-tool",
"android-arm64-chip-test",
"android-arm64-chip-tool",
Expand Down
28 changes: 28 additions & 0 deletions config/ameba/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
target_cpu = "arm"
target_os = "freertos"

import("//args.gni")
}
37 changes: 37 additions & 0 deletions config/ameba/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.

# Options from standalone-chip.mk that differ from configure defaults. These
# options are used from examples/.

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

import("${chip_root}/build/chip/tests.gni")

declare_args() {
chip_build_pw_rpc_lib = false
}

group("ameba") {
deps = [ "${chip_root}/src/lib" ]

if (chip_build_pw_rpc_lib) {
deps += [ "//lib/pw_rpc" ]
}

if (chip_build_tests) {
deps += [ "${chip_root}/src:tests" ]
}
}
36 changes: 36 additions & 0 deletions config/ameba/args.gni
Original file line number Diff line number Diff line change
@@ -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/.

chip_device_platform = "ameba"

chip_project_config_include = ""
chip_system_project_config_include = ""
chip_ble_project_config_include = ""

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

chip_build_tests = true
chip_inet_config_enable_dns_resolver = false

chip_inet_config_enable_tcp_endpoint = true
chip_inet_config_enable_udp_endpoint = true

chip_bypass_rendezvous = true
chip_config_network_layer_ble = false

custom_toolchain = "//third_party/connectedhomeip/config/ameba/toolchain:ameba"
1 change: 1 addition & 0 deletions config/ameba/build
1 change: 1 addition & 0 deletions config/ameba/build_overrides
116 changes: 116 additions & 0 deletions config/ameba/chip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
cmake_minimum_required(VERSION 3.6)

project(chip-gn)

set(chip_dir "${ameba_matter_root}")
set(chip_dir_output "${matter_output_path}/chip")
set(chip_c_flags "")
set(chip_cpp_flags "")
set(chip-gn chip-gn)

get_filename_component(CHIP_ROOT ${chip_dir} REALPATH)
get_filename_component(CHIP_OUTPUT ${chip_dir_output} REALPATH)
get_filename_component(LIB_ROOT ${prj_root}/GCC-RELEASE/project_hp/asdk/lib/application REALPATH)

include(ExternalProject)

# FOR CHIP
string(APPEND CHIP_GN_ARGS)

list(
APPEND CHIP_CFLAGS

-DCHIP_PROJECT=1
-DCONFIG_PLATFORM_8721D
-DCONFIG_USE_MBEDTLS_ROM_ALG
-DCONFIG_FUNCION_O0_OPTIMIZE
-DDM_ODM_SUPPORT_TYPE=32
-DCHIP_DEVICE_LAYER_TARGET=Ameba
-DMBEDTLS_CONFIG_FILE=\\\"mbedtls_config.h\\\"
)

list(
APPEND CHIP_CXXFLAGS

-DFD_SETSIZE=10
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-but-set-variable
-Wno-unused-variable
-Wno-deprecated-declarations
-Wno-unused-parameter
-Wno-format
)

list(
APPEND CHIP_INC

${CHIP_ROOT}/config/ameba
${CHIP_ROOT}/src/include
${CHIP_ROOT}/src/lib
${CHIP_ROOT}/src
${CHIP_ROOT}/src/system
${CHIP_ROOT}/src/app
${CHIP_ROOT}/third_party/nlassert/repo/include
${CHIP_ROOT}/third_party/nlio/repo/include
${CHIP_ROOT}/third_party/nlunit-test/repo/src
)

execute_process(
COMMAND echo "mkdir CHIP output folder ..."
COMMAND mkdir -p ${CHIP_OUTPUT}
)

foreach(tmp IN LISTS CHIP_CFLAGS)
string(CONCAT appended "\"" ${tmp} "\", ")
string(APPEND chip_c_flags "${appended}")
endforeach()
foreach(tmp IN LISTS GLOBAL_C_FLAGS)
string(CONCAT appended "\"" ${tmp} "\", ")
string(APPEND chip_c_flags "${appended}")
endforeach()
foreach(tmp IN LISTS inc_path)
string(CONCAT appended "\"-I" ${tmp} "\", ")
string(APPEND chip_c_flags "${appended}")
endforeach()
foreach(tmp IN LISTS CHIP_INC)
string(CONCAT appended "\"-I" ${tmp} "\", ")
string(APPEND chip_c_flags "${appended}")
endforeach()
foreach(tmp IN LISTS CHIP_CXXFLAGS)
string(CONCAT appended "\"" ${tmp} "\", ")
string(APPEND chip_cpp_flags "${appended}")
endforeach()
foreach(tmp IN LISTS GLOBAL_CPP_FLAGS)
string(CONCAT appended "\"" ${tmp} "\", ")
string(APPEND chip_cpp_flags "${appended}")
endforeach()
string(APPEND chip_cpp_flags "${chip_c_flags}")

set(import_str "import(\"//args.gni\")\n" )

string(APPEND CHIP_GN_ARGS "${import_str}")
string(APPEND CHIP_GN_ARGS "target_cflags_c = [${chip_c_flags}]\n")
string(APPEND CHIP_GN_ARGS "target_cflags_cc = [${chip_cpp_flags}]\n")
string(APPEND CHIP_GN_ARGS "ameba_ar = \"arm-none-eabi-ar\"\n")
string(APPEND CHIP_GN_ARGS "ameba_cc = \"arm-none-eabi-gcc\"\n")
string(APPEND CHIP_GN_ARGS "ameba_cxx = \"arm-none-eabi-c++\"\n")
string(APPEND CHIP_GN_ARGS "ameba_cpu = \"ameba\"\n")
string(APPEND CHIP_GN_ARGS "chip_build_tests = false\n")

file(GENERATE OUTPUT ${CHIP_OUTPUT}/args.gn CONTENT ${CHIP_GN_ARGS})

ExternalProject_Add(
chip-gn
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
SOURCE_DIR ${CHIP_ROOT}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
CONFIGURE_COMMAND gn --root=${CHIP_ROOT}/config/ameba gen --check --fail-on-unused-args ${CHIP_OUTPUT}
BUILD_COMMAND ninja -C ${CHIP_OUTPUT}
INSTALL_COMMAND ""
BUILD_BYPRODUCTS -lCHIP
CONFIGURE_ALWAYS TRUE
BUILD_ALWAYS TRUE
USES_TERMINAL_CONFIGURE TRUE
USES_TERMINAL_BUILD TRUE
)
22 changes: 22 additions & 0 deletions config/ameba/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")

# Ameba has its own mbedtls, so nothing to do, just provide a target
group("mbedtls") {
}
1 change: 1 addition & 0 deletions config/ameba/third_party/connectedhomeip
Loading

0 comments on commit 544da73

Please sign in to comment.