Skip to content

Commit

Permalink
Add Mbed os port (project-chip#7926)
Browse files Browse the repository at this point in the history
* Add Mbed OS into chip platforms.
The platform supports the following features:
- Bluetooth
-  WiFi
- Mdns
- Key/Value store
The integration with network is made with the POSIX socket API

* Add Mbed os third party repo

* Add mbed os target config/build files

* Update pigweed environment for Mbed OS

* Integrate Mbed OS into chip build system

* Delay MDNS server start on Mbed OS

* Disable Mdns operations in WatchableEventManagerfor mbed os

* Force InterfaceAddressIterator::GetPrefixLength() to 64 on Mbed OS.

* Add Mbed OS shell streamer

* Add Mbed OS SystemMutex implementation

* Add script to build Mbed OS example

* Update devcontainer to flash and debug mbed boards

* Add workflow to build Mbed OS examples

* Add VSCode task to build Mbed OS examples

* Add Mbed OS lock app example.
Note: Bluetooth autostart as there is not enough physical button on
the board. This will be addressed by a subsequent update that enable
capacitive button.

* Add vscode debug configuration for mbed os examples
  • Loading branch information
pan- authored Jun 29, 2021
1 parent 91a1f67 commit cc13560
Show file tree
Hide file tree
Showing 87 changed files with 6,659 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ RUN apt-get -fy install git vim emacs sudo \
build-essential cmake cppcheck valgrind \
wget curl telnet \
docker.io \
iputils-ping net-tools
iputils-ping net-tools \
libncurses5

RUN groupadd -g $USER_GID $USERNAME
RUN useradd -s /bin/bash -u $USER_UID -g $USER_GID -G docker -m $USERNAME
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
Expand Down
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--network=host"
"--network=host",
"-v",
"/dev/bus/usb:/dev/bus/usb:ro",
"--device-cgroup-rule=a 189:* rmw",
"--add-host=host.docker.internal:host-gateway"
],
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/examples-mbed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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: Build example - Mbed OS

on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
cancel-in-progress: true

jobs:
mbedos:
strategy:
fail-fast: False
matrix:
EXAMPLE_APP: [lock-app]
EXAMPLE_TARGET: [CY8CPROTO_062_4343W]

name: "${{matrix.EXAMPLE_APP}}: ${{matrix.EXAMPLE_TARGET}}"

env:
BUILD_TYPE: mbedos
EXAMPLE_PROFILE: release

runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build-mbed-os:latest
volumes:
- "/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
run: scripts/examples/mbed_example.sh -a=${{matrix.EXAMPLE_APP}} -b=${{matrix.EXAMPLE_TARGET}} -p=$EXAMPLE_PROFILE

- name: Copy aside build products
run: |
mkdir -p example_binaries/$BUILD_TYPE-build/
cp examples/${{matrix.EXAMPLE_APP}}/mbed/build-${{matrix.EXAMPLE_TARGET}}/$EXAMPLE_PROFILE/chip-mbed-${{matrix.EXAMPLE_APP}}-example.hex \
example_binaries/$BUILD_TYPE-build/${{matrix.EXAMPLE_APP}}_${{matrix.EXAMPLE_TARGET}}_$EXAMPLE_PROFILE.hex
- name: Binary artifact suffix
id: outsuffix
uses: haya14busa/action-cond@v1.0.0
with:
cond: ${{ github.event.pull_request.number == '' }}
if_true: "${{ github.sha }}"
if_false: "pull-${{ github.event.pull_request.number }}"

- name: Copy aside 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 }}-${{matrix.EXAMPLE_APP}}-example-${{matrix.EXAMPLE_TARGET}}-${{ env.EXAMPLE_PROFILE}}-build-${{
steps.outsuffix.outputs.value }}
path: /tmp/output_binaries/${{ env.BUILD_TYPE }}-build/${{matrix.EXAMPLE_APP}}_${{matrix.EXAMPLE_TARGET}}_${{ env.EXAMPLE_PROFILE }}.hex
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/settings.json
!.vscode/extensions.json

# Platforms
.DS_Store
Expand Down
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@
[submodule "third_party/openthread/ot-efr32"]
path = third_party/openthread/ot-efr32
url = https://github.com/openthread/ot-efr32.git
[submodule "third_party/mbed-os/repo"]
path = third_party/mbed-os/repo
url = https://github.com/ARMmbed/mbed-os.git
branch = feature-chip
[submodule "third_party/wifi-ism43362/repo"]
path = third_party/wifi-ism43362/repo
url = https://github.com/ATmobica/wifi-ism43362.git
branch = master
[submodule "third_party/mbed-os-posix-socket/repo"]
path = third_party/mbed-os-posix-socket/repo
url = https://github.com/ARMmbed/mbed-os-posix-socket.git
branch = main
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": ["marus25.cortex-debug"],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
120 changes: 120 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,126 @@
"ignoreFailures": true
}
]
},

{
"name": "Debug Mbed CY8CPROTO_062_4343W",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example",
"servertype": "openocd",
"searchDir": [
"${workspaceRoot}/config/mbed/scripts",
"${env:OPENOCD_PATH/scripts}"
],
"configFiles": ["CY8CPROTO_062_4343W.tcl"],
"overrideLaunchCommands": [
"-enable-pretty-printing",
"monitor program {./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example.hex}",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"numberOfProcessors": 2,
"targetProcessor": 1, // Set to 0 for the CM0+, set to 1 for the CM4
"overrideRestartCommands": [
"monitor reset init",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"runToMain": true, // if true, program will halt at main. Not used for a restart
"showDevDebugOutput": false // When set to true, displays output of GDB.
},

{
"name": "Debug Mbed CY8CPROTO_062_4343W [remote]",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example",
"servertype": "external",
"gdbTarget": "host.docker.internal:3334", //port 3333 for the CM0+, 3334 for the CM4
"overrideLaunchCommands": [
"-enable-pretty-printing",
"monitor reset halt",
"load ./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example.hex",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"overrideRestartCommands": [
"monitor reset init",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"runToMain": true, // if true, program will halt at main. Not used for a restart
"showDevDebugOutput": false // When set to true, displays output of GDB.
},

{
"name": "Flash Mbed CY8CPROTO_062_4343W",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example",
"servertype": "openocd",
"searchDir": [
"${workspaceRoot}/config/mbed/scripts",
"${env:OPENOCD_PATH/scripts}"
],
"configFiles": ["CY8CPROTO_062_4343W.tcl"],
"overrideLaunchCommands": [
"monitor reset halt",
"monitor program {./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example.hex}",
"monitor reset run",
"quit"
],
"numberOfProcessors": 2,
"targetProcessor": 1, // Set to 0 for the CM0+, set to 1 for the CM4
"showDevDebugOutput": false // When set to true, displays output of GDB.
},

{
"name": "Flash Mbed CY8CPROTO_062_4343W [remote]",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example.hex",
"servertype": "external",
"gdbTarget": "host.docker.internal:3334", //port 3333 for the CM0+, 3334 for the CM4
"overrideLaunchCommands": [
"monitor reset halt",
"load ./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example.hex",
"monitor reset run",
"quit"
],
"showDevDebugOutput": false // When set to true, displays output of GDB.
}
],
"inputs": [
{
"type": "pickString",
"id": "mbedDebugProfile",
"description": "What mbed profile do you want to debug?",
"options": ["debug", "develop"],
"default": "debug"
},
{
"type": "pickString",
"id": "mbedFlashProfile",
"description": "What mbed profile do you want to flash?",
"options": ["release", "debug", "develop"],
"default": "release"
},
{
"type": "pickString",
"id": "mbedApp",
"description": "What mbed application do you want to use?",
"options": ["lock-app"],
"default": "shell"
}
]
}
67 changes: 67 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,73 @@
"${workspaceFolder}/examples/lighting-app/telink/build/tlsr9518adk80d"
]
}
},
{
"label": "Run Mbed Application",
"type": "shell",
"command": "scripts/examples/mbed_example.sh",
"args": [
"-c=${input:mbedCommand}",
"-a=${input:mbedApp}",
"-b=${input:mbedTarget}",
"-p=${input:mbedProfile}"
],
"group": "build",
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"relative",
"${workspaceFolder}/examples/${input:mbedApp}/mbed/build"
]
}
},
{
"label": "Run Mbed Unit Tests",
"type": "shell",
"command": "scripts/tests/mbed_tests.sh",
"args": [
"-c=${input:mbedCommand}",
"-b=${input:mbedTarget}",
"-p=${input:mbedProfile}"
],
"group": "build",
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"relative",
"${workspaceFolder}/src/test_driver/mbed/build"
]
}
}
],
"inputs": [
{
"type": "pickString",
"id": "mbedCommand",
"description": "What do you want to do?",
"options": ["build", "flash", "build-flash"],
"default": "build"
},
{
"type": "pickString",
"id": "mbedApp",
"description": "What mbed application do you want to use?",
"options": ["lock-app"],
"default": "shell"
},
{
"type": "pickString",
"id": "mbedTarget",
"description": "What mbed target do you want to use?",
"options": ["CY8CPROTO_062_4343W"],
"default": "CY8CPROTO_062_4343W"
},
{
"type": "pickString",
"id": "mbedProfile",
"description": "What mbed profile do you want to use?",
"options": ["develop", "release", "debug"],
"default": "develop"
}
]
}
28 changes: 28 additions & 0 deletions config/mbed/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
*
* Copyright (c) 2021 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.
*/

/**
* @file
* Project-specific default configuration overrides
*/

#pragma once

// ====== Project-specific Configuration Overrides Defaults =====

#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
Loading

0 comments on commit cc13560

Please sign in to comment.