-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added compile support for NuttX system. (#31236)
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 <[email protected]>
- Loading branch information
Showing
63 changed files
with
12,740 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -965,6 +965,7 @@ NTP | |
nullable | ||
nullptr | ||
NUM | ||
NuttX | ||
NVM | ||
NVS | ||
nwdiag | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) 2024 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: Build example - NuttX | ||
|
||
on: | ||
push: | ||
pull_request: | ||
merge_group: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
CHIP_NO_LOG_TIMESTAMPS: true | ||
|
||
jobs: | ||
nuttx: | ||
name: NuttX | ||
|
||
runs-on: ubuntu-latest | ||
if: github.actor != 'restyled-io[bot]' | ||
|
||
container: | ||
image: ghcr.io/project-chip/chip-build-nuttx:51 | ||
volumes: | ||
- "/tmp/bloat_reports:/tmp/bloat_reports" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Checkout submodules & Bootstrap | ||
uses: ./.github/actions/checkout-submodules-and-bootstrap | ||
with: | ||
platform: nuttx | ||
extra-submodule-parameters: " --recursive" | ||
- name: Build example simulator NuttX Lighting App | ||
run: | | ||
./scripts/run_in_build_env.sh \ | ||
"./scripts/build/build_examples.py \ | ||
--target nuttx-x64-light \ | ||
build \ | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2024 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") | ||
import("//build_overrides/chip.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 = "" | ||
target_os = "nuttx" | ||
|
||
import("${chip_root}/config/nuttx/chip-gn/args.gni") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright (c) 2024 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") | ||
import("//build_overrides/chip.gni") | ||
|
||
import("${chip_root}/build/chip/tests.gni") | ||
|
||
assert(current_os == "nuttx") | ||
|
||
declare_args() { | ||
chip_build_example_providers = false | ||
chip_example_lighting = false | ||
} | ||
|
||
static_library("nuttx") { | ||
output_name = "libchipnuttx" | ||
|
||
public_deps = [ | ||
"${chip_root}/examples/platform/linux:app-main", | ||
"${chip_root}/src/lib", | ||
] | ||
|
||
if (chip_build_tests) { | ||
public_deps += [ "${chip_root}/src:tests" ] | ||
} | ||
|
||
if (chip_build_example_providers) { | ||
public_deps += [ "${chip_root}/examples/providers:device_info_provider" ] | ||
} | ||
|
||
if (chip_example_lighting) { | ||
public_deps += [ | ||
"${chip_root}/examples/lighting-app/lighting-common", | ||
"${chip_root}/examples/lighting-app/lighting-common:lighting-manager", | ||
] | ||
} | ||
|
||
output_dir = "${root_out_dir}/lib" | ||
|
||
complete_static_lib = true | ||
} | ||
|
||
group("default") { | ||
deps = [ ":nuttx" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2024 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}/src/crypto/crypto.gni") | ||
|
||
chip_device_platform = "nuttx" | ||
|
||
chip_build_tests = false | ||
|
||
chip_project_config_include = "" | ||
chip_system_project_config_include = "" | ||
chip_ble_project_config_include = "" | ||
|
||
chip_crypto = "mbedtls" | ||
chip_external_mbedtls = true | ||
|
||
custom_toolchain = "${chip_root}/config/nuttx/chip-gn/toolchain:nuttx" | ||
|
||
pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/setup/constraints.txt" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2024 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/toolchain/gcc_toolchain.gni") | ||
import("//build_overrides/build.gni") | ||
|
||
declare_args() { | ||
nuttx_ar = "" | ||
nuttx_cc = "" | ||
nuttx_cxx = "" | ||
} | ||
|
||
gcc_toolchain("nuttx") { | ||
ar = nuttx_ar | ||
cc = nuttx_cc | ||
cxx = nuttx_cxx | ||
|
||
toolchain_args = { | ||
current_os = "nuttx" | ||
is_clang = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Copyright (c) 2024 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 logging | ||
import os | ||
from enum import Enum, auto | ||
|
||
from .gn import Builder | ||
|
||
|
||
class NuttXApp(Enum): | ||
LIGHT = auto() | ||
|
||
def ExampleName(self): | ||
if self == NuttXApp.LIGHT: | ||
return 'lighting-app' | ||
else: | ||
raise Exception('Unknown app type: %r' % self) | ||
|
||
def AppNamePrefix(self, chip_name): | ||
if self == NuttXApp.LIGHT: | ||
return ('chip-%s-lighting-example' % chip_name) | ||
else: | ||
raise Exception('Unknown app type: %r' % self) | ||
|
||
|
||
class NuttXBoard(Enum): | ||
SIM = auto() | ||
|
||
|
||
def NuttXTarget(board, app): | ||
if board == NuttXBoard.SIM: | ||
if app == NuttXApp.LIGHT: | ||
return 'sim:matter' | ||
return 'none' | ||
|
||
|
||
class NuttXBuilder(Builder): | ||
|
||
def __init__(self, | ||
root, | ||
runner, | ||
app: NuttXApp = NuttXApp.LIGHT, | ||
board: NuttXBoard = NuttXBoard.SIM, | ||
): | ||
|
||
nuttx_chip = 'nuttx' | ||
|
||
super(NuttXBuilder, self).__init__( | ||
root=os.path.join(root, 'examples', | ||
app.ExampleName(), nuttx_chip), | ||
runner=runner | ||
) | ||
|
||
self.chip_name = nuttx_chip | ||
self.app = app | ||
self.board = board | ||
|
||
def generate(self): | ||
self._Execute(['mkdir', '-p', self.output_dir], | ||
title='Generating ' + self.identifier) | ||
|
||
def _build(self): | ||
logging.info('Compiling NuttX %s at %s, ', | ||
NuttXTarget(self.board, self.app), self.output_dir) | ||
nuttx_dir = os.path.join(os.sep, 'opt', 'nuttx', 'nuttx') | ||
|
||
self._Execute(['cmake', '-S', nuttx_dir, '-B', self.output_dir, '-DCHIP_ROOT=' + os.getenv('PW_PROJECT_ROOT'), | ||
'-DBOARD_CONFIG=' + NuttXTarget(self.board, self.app), | ||
'-DCMAKE_C_COMPILER=/opt/nuttx/gcc-13/bin/gcc', | ||
'-DCMAKE_CXX_COMPILER=/opt/nuttx/gcc-13/bin/g++', | ||
'-GNinja'], | ||
title='Building ' + self.identifier) | ||
self._Execute(['cmake', '--build', self.output_dir]) | ||
|
||
def build_outputs(self): | ||
logging.info('Compiling outputs NuttX at %s', self.output_dir) | ||
items = { | ||
'%s.out' % self.app.AppNamePrefix(self.chip_name): | ||
os.path.join(self.output_dir, '%s.out' % | ||
self.app.AppNamePrefix(self.chip_name)), | ||
'%s.out.map' % self.app.AppNamePrefix(self.chip_name): | ||
os.path.join(self.output_dir, | ||
'%s.out.map' % self.app.AppNamePrefix(self.chip_name)), | ||
} | ||
|
||
return items |
Oops, something went wrong.