Skip to content

Commit 9a5b6df

Browse files
committed
Added compile support for NuttX system
This is a basic version of compile support and only x86 simulator lightning-app is supported now The compilation method is shown below: ./scripts/build/build_examples.py --target nuttx-x64-light build and compiled binaries are in the out/nuttx-x64-light directory. Detailed introduction about NuttX system can refer to this link: https://github.com/apache/nuttx Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
1 parent 242accd commit 9a5b6df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+12759
-9
lines changed

.github/.wordlist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ NTP
965965
nullable
966966
nullptr
967967
NUM
968+
NuttX
968969
NVM
969970
NVS
970971
nwdiag

.github/workflows/examples-nuttx.yaml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Build example - NuttX
16+
17+
on:
18+
push:
19+
pull_request:
20+
merge_group:
21+
workflow_dispatch:
22+
23+
concurrency:
24+
group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
25+
cancel-in-progress: true
26+
27+
env:
28+
CHIP_NO_LOG_TIMESTAMPS: true
29+
30+
jobs:
31+
nuttx:
32+
name: NuttX
33+
34+
runs-on: ubuntu-latest
35+
if: github.actor != 'restyled-io[bot]'
36+
37+
container:
38+
image: ghcr.io/project-chip/chip-build-nuttx:51
39+
volumes:
40+
- "/tmp/bloat_reports:/tmp/bloat_reports"
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
- name: Checkout submodules & Bootstrap
45+
uses: ./.github/actions/checkout-submodules-and-bootstrap
46+
with:
47+
platform: nuttx
48+
extra-submodule-parameters: " --recursive"
49+
- name: Set up environment for size reports
50+
uses: ./.github/actions/setup-size-reports
51+
if: ${{ !env.ACT }}
52+
with:
53+
gh-context: ${{ toJson(github) }}
54+
- name: Build example simulator NuttX Lighting App
55+
run: |
56+
./scripts/run_in_build_env.sh \
57+
"./scripts/build/build_examples.py \
58+
--target nuttx-x64-light \
59+
build \
60+
"

.github/workflows/lint.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
--skip-dir platform/webos \
9191
--skip-dir platform/Zephyr \
9292
--skip-dir test_driver \
93+
--skip-dir platform/NuttX \
9394
--known-failure app/app-platform/ContentApp.cpp \
9495
--known-failure app/app-platform/ContentApp.h \
9596
--known-failure app/app-platform/ContentAppPlatform.cpp \
@@ -205,7 +206,7 @@ jobs:
205206
# TODO: TLVDebug should ideally not be excluded here.
206207
# TODO: protocol_decoder.cpp should ideally not be excluded here.
207208
# TODO: PersistentStorageMacros.h should ideally not be excluded here.
208-
git grep -I -n "PRI.64" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)examples/chip-tool' ':(exclude)examples/tv-casting-app' ':(exclude)src/app/MessageDef/MessageDefHelper.cpp' ':(exclude)src/app/tests/integration/chip_im_initiator.cpp' ':(exclude)src/lib/core/TLVDebug.cpp' ':(exclude)src/lib/dnssd/tests/TestTxtFields.cpp' ':(exclude)src/lib/format/protocol_decoder.cpp' ':(exclude)src/lib/support/PersistentStorageMacros.h' ':(exclude)src/messaging/tests/echo/echo_requester.cpp' ':(exclude)src/platform/Linux' ':(exclude)src/platform/Ameba' ':(exclude)src/platform/ESP32' ':(exclude)src/platform/Darwin' ':(exclude)src/darwin' ':(exclude)src/platform/webos' ':(exclude)zzz_generated/chip-tool' ':(exclude)src/tools/chip-cert/Cmd_PrintCert.cpp' && exit 1 || exit 0
209+
git grep -I -n "PRI.64" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)examples/chip-tool' ':(exclude)examples/tv-casting-app' ':(exclude)src/app/MessageDef/MessageDefHelper.cpp' ':(exclude)src/app/tests/integration/chip_im_initiator.cpp' ':(exclude)src/lib/core/TLVDebug.cpp' ':(exclude)src/lib/dnssd/tests/TestTxtFields.cpp' ':(exclude)src/lib/format/protocol_decoder.cpp' ':(exclude)src/lib/support/PersistentStorageMacros.h' ':(exclude)src/messaging/tests/echo/echo_requester.cpp' ':(exclude)src/platform/Linux' ':(exclude)src/platform/Ameba' ':(exclude)src/platform/ESP32' ':(exclude)src/platform/Darwin' ':(exclude)src/darwin' ':(exclude)src/platform/webos' ':(exclude)zzz_generated/chip-tool' ':(exclude)src/tools/chip-cert/Cmd_PrintCert.cpp' ':(exclude)src/platform/NuttX' && exit 1 || exit 0
209210
210211
# git grep exits with 0 if it finds a match, but we want
211212
# to fail (exit nonzero) on match. And we want to exclude this file,

build/config/compiler/BUILD.gn

+5
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ config("strict_warnings") {
271271

272272
cflags_cc = [ "-Wnon-virtual-dtor" ]
273273

274+
if (current_os == "nuttx") {
275+
cflags -= [ "-Wshadow" ]
276+
cflags_cc -= [ "-Wnon-virtual-dtor" ]
277+
}
278+
274279
configs = []
275280
ldflags = []
276281

config/nuttx/chip-gn/.gn

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
18+
# The location of the build configuration file.
19+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
20+
21+
# CHIP uses angle bracket includes.
22+
check_system_includes = true
23+
24+
default_args = {
25+
target_cpu = ""
26+
target_os = "nuttx"
27+
28+
import("${chip_root}/config/nuttx/chip-gn/args.gni")
29+
}

config/nuttx/chip-gn/BUILD.gn

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
18+
import("${chip_root}/build/chip/tests.gni")
19+
20+
assert(current_os == "nuttx")
21+
22+
declare_args() {
23+
chip_build_example_providers = false
24+
chip_example_lighting = false
25+
}
26+
27+
static_library("nuttx") {
28+
output_name = "libchipnuttx"
29+
30+
public_deps = [
31+
"${chip_root}/examples/platform/linux:app-main",
32+
"${chip_root}/src/lib",
33+
]
34+
35+
if (chip_build_tests) {
36+
public_deps += [ "${chip_root}/src:tests" ]
37+
}
38+
39+
if (chip_build_example_providers) {
40+
public_deps += [ "${chip_root}/examples/providers:device_info_provider" ]
41+
}
42+
43+
if (chip_example_lighting) {
44+
public_deps += [
45+
"${chip_root}/examples/lighting-app/lighting-common",
46+
"${chip_root}/examples/lighting-app/lighting-common:lighting-manager",
47+
]
48+
}
49+
50+
output_dir = "${root_out_dir}/lib"
51+
52+
complete_static_lib = true
53+
}
54+
55+
group("default") {
56+
deps = [ ":nuttx" ]
57+
}

config/nuttx/chip-gn/args.gni

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
17+
import("${chip_root}/src/crypto/crypto.gni")
18+
19+
chip_device_platform = "nuttx"
20+
21+
chip_build_tests = false
22+
23+
chip_project_config_include = ""
24+
chip_system_project_config_include = ""
25+
chip_ble_project_config_include = ""
26+
27+
chip_crypto = "mbedtls"
28+
chip_external_mbedtls = true
29+
30+
custom_toolchain = "${chip_root}/config/nuttx/chip-gn/toolchain:nuttx"
31+
32+
pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/setup/constraints.txt" ]
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build/toolchain/gcc_toolchain.gni")
16+
import("//build_overrides/build.gni")
17+
18+
declare_args() {
19+
nuttx_ar = ""
20+
nuttx_cc = ""
21+
nuttx_cxx = ""
22+
}
23+
24+
gcc_toolchain("nuttx") {
25+
ar = nuttx_ar
26+
cc = nuttx_cc
27+
cxx = nuttx_cxx
28+
29+
toolchain_args = {
30+
current_os = "nuttx"
31+
is_clang = false
32+
}
33+
}

examples/lighting-app/linux/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void ApplicationShutdown()
9595
}
9696
}
9797

98-
int main(int argc, char * argv[])
98+
extern "C" int main(int argc, char * argv[])
9999
{
100100
if (ChipLinuxAppInit(argc, argv) != 0)
101101
{

scripts/build/build/targets.py

+18
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from builders.mbed import MbedApp, MbedBoard, MbedBuilder, MbedProfile
2828
from builders.mw320 import MW320App, MW320Builder
2929
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
30+
from builders.nuttx import NuttXApp, NuttXBoard, NuttXBuilder
3031
from builders.nxp import NxpApp, NxpBoard, NxpBuilder
3132
from builders.openiotsdk import OpenIotSdkApp, OpenIotSdkBuilder, OpenIotSdkCryptoBackend
3233
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
@@ -320,6 +321,22 @@ def BuildNrfTarget():
320321
return target
321322

322323

324+
def BuildNuttXTarget():
325+
target = BuildTarget('nuttx', NuttXBuilder)
326+
327+
# Boards
328+
target.AppendFixedTargets([
329+
TargetPart('x64', board=NuttXBoard.SIM),
330+
])
331+
332+
# Apps
333+
target.AppendFixedTargets([
334+
TargetPart('light', app=NuttXApp.LIGHT),
335+
])
336+
337+
return target
338+
339+
323340
def BuildAndroidTarget():
324341
target = BuildTarget('android', AndroidBuilder)
325342

@@ -790,6 +807,7 @@ def BuildOpenIotSdkTargets():
790807
BuildMW320Target(),
791808
BuildNrfTarget(),
792809
BuildNrfNativeTarget(),
810+
BuildNuttXTarget(),
793811
BuildQorvoTarget(),
794812
BuildStm32Target(),
795813
BuildTizenTarget(),

0 commit comments

Comments
 (0)