Skip to content

Commit

Permalink
[ST] Adding STM32 platform and lighting app example with STM32WB5MM-D…
Browse files Browse the repository at this point in the history
…K board (#28889)

* add stm32cubewb submodule

* move submodule stm32cubewb to tag v1.17.0

* fix align in gitmodules

* add st in third_party

* add builds and scripts to compile stm32 examples

* add stm32 platform in matter source files and modifi gn files to use st as a third party

* add stm32 lighting app example using stm32wb5mm-dk board

* put chip_detail_logging to false to optimize the size of the flash

* add support for st CI

* typo fixs for ci

* add st getting started readme

* remove duplicate license

* minor fixs in readme and stm32 getting started and add st getting started  to the guides/readme

* typo fix

* mispells fix

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Restyled by shellharden

* Restyled by shfmt

* Restyled by isort

* Revert "Restyled by clang-format"

This reverts commit 90c6d8f.

* move otp to example and fix misspell and remove case sensitive in wordlist

* remove unused defines and change return message for unused fonctions

* Update docs/guides/stm32_getting_started_guide.md

Co-authored-by: Boris Zbarsky <[email protected]>

* Update docs/guides/stm32_getting_started_guide.md

Co-authored-by: Boris Zbarsky <[email protected]>

* Restyled by whitespace

* convert windows to linux file

* convert windows to linux files

* Restyled by whitespace

* Restyled by clang-format

* add missing include

* removed unused arguments

* update shutdown to call the upper class

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Sep 12, 2023
1 parent 612440b commit 788a023
Show file tree
Hide file tree
Showing 120 changed files with 19,412 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,9 @@ StatusCode
stderr
stdout
sterm
stmicroelectronics
stm
stlink
storagepath
str
strcpy
Expand Down Expand Up @@ -1352,6 +1355,7 @@ ThreadNetworkDiagnostics
threadOperationalDataset
ThreadStackManager
ThreadStackManagerImpl
thread
ths
Thunderboard
timedInteractionTimeoutMs
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/examples-stm32.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2020-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.

name: Build example - stm32

on:
push:
pull_request:
merge_group:

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:
stm32:
name: stm32
timeout-minutes: 60

env:
BUILD_TYPE: gn_stm32

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build:1
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout submodules & Bootstrap
uses: ./.github/actions/checkout-submodules-and-bootstrap
with:
platform: stm32

- name: Set up environment for size reports
uses: ./.github/actions/setup-size-reports
if: ${{ !env.ACT }}
with:
gh-context: ${{ toJson(github) }}

- name: Build stm32 example apps
timeout-minutes: 20
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target stm32-STM32WB5MM-DK-light build \
"
- name: Uploading Size Reports
uses: ./.github/actions/upload-size-reports
if: ${{ !env.ACT }}
with:
platform-name: stm32

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,9 @@
url = https://github.com/SiliconLabs/wiseconnect
branch = master
platforms = efr32
[submodule "third_party/st/STM32CubeWB"]
path = third_party/st/STM32CubeWB
url = https://github.com/STMicroelectronics/STM32CubeWB.git
branch = v1.17.0
platform = stm32

3 changes: 3 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {

# Set this to true to enable genio builds by default.
enable_genio_builds = false

# Set this to true to enable stm32 builds by default.
enable_stm32_builds = false
}

# Pigweed does not provide a clang in some configurations.
Expand Down
18 changes: 18 additions & 0 deletions build_overrides/stm32_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2023 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.

declare_args() {
# Root directory for stm32 SDK build files.
stm32_sdk_build_root = "//third_party/st"
}
25 changes: 25 additions & 0 deletions config/stm32/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2023 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("${build_root}/toolchain/arm_gcc/arm_toolchain.gni")

arm_toolchain("stm32_lighting_app") {
toolchain_args = {
current_os = "freertos"
import("${chip_root}/examples/lighting-app/stm32/args.gni")
}
}
1 change: 1 addition & 0 deletions docs/guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Silicon Labs - Documentation](https://github.com/SiliconLabs/matter#readme)
- [Silicon Labs - Building](./silabs_efr32_building.md)
- [Silicon Labs - Software Update](./silabs_efr32_software_update.md)
- [STMicroelectronics (STM32)](./stm32_getting_started_guide.md)
- [TI - Platform Overview](./ti_platform_overview.md)
- [Open IoT SDK - Platform Overview](./openiotsdk_platform_overview.md)
- [Open IoT SDK - Examples](./openiotsdk_examples.md)
Expand Down
103 changes: 103 additions & 0 deletions docs/guides/stm32_getting_started_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# STM32 Getting Started Guide

The stm32 platform uses
[Matter](https://github.com/project-chip/connectedhomeip) sdk with FreeRTOS.

---

- [stm32 Getting Started Guide](#stm32-getting-started-guide)
- [Supported Chips](#supported-chips)
- [Matter Example Applications](#matter-example-applications)
- [Building the Example Application](#building-the-example-application)
- [Commissioning](#commissioning)
- [BLE-Thread mode](#ble-thread-mode)

---

## Supported Chips

The stm32 platform is supported on:

- [STM32WB5MM-DK](https://www.st.com/en/evaluation-tools/stm32wb5mm-dk.html)

## Matter Example Applications

Sample Matter applications are provided for the stm32 platform. They can be used
to speed up development. You can find them in the samples with `/stm32`
subfolder.

## Building the Example Application

- [Set Up Matter Environment](./BUILDING.md)

- Set up STLINK tools

```
apt-get install stlink-tools
```
- Building the Application
If the lighting example is to be built:
```
./scripts/build/build_examples.py --target stm32-$stm32_BOARD-lighting build
```
- The output image files are stored in the subdirectories under `out`, the
subdirectory name is the same as the argument specified after the option
`--target` when build the examples.
- After building the application, `ST-LINK` tool is used to flash it to the
board. Before flashing the application, you will need to flash the fuse and
the co processor binary. The co processor binary and fuse are available
[here](https://github.com/stm32-hotspot/stm32wb-matter-device-over-thread/tree/main/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x)
Dynamic Concurrent Mode BLE Thread for Matter (Supports Full BLE Stack 5.2
certified and Minimal Thread Device ready v1.3)
```
sudo st-flash write chip-stm32-lighting-example.bin 0x08000000
```
## Commissioning
There is one commissioning modes supported by stm32 platform:
### BLE-Thread mode
1. Build and Flash
2. The example will run automatically after booting the stm32 board.
3. Restore factory settings using B1 button by pressing at least 10 seconds
4. Commissioning with
[Chip-Tool](https://github.com/project-chip/connectedhomeip/tree/master/examples/chip-tool),for
example:
```
./chip-tool pairing ble-thread <node_id> <hex:xxx> <pin_code> <discriminator>
```
### Bluetooth LE advertising
In this example, to commission the device onto a Matter network, it must be
discoverable over Bluetooth LE. After powering up the device, the device will
advertise automatically for 30 seconds. After this delay, you will need to reset
the device to start the commissioning procedure.
### Bluetooth LE rendezvous
In Matter, the commissioning procedure is done over Bluetooth LE between a
Matter device and the Matter controller(, where the controller has the
commissioner role.
To start the rendezvous, the controller must get the commissioning information
from the Matter device. The data payload is encoded within a QR code, printed to
the UART console.
### Thread provisioning
The provisioning operation, which is the Last part of the rendezvous procedure,
involves sending the Thread network credentials from the Matter controller to
the Matter device. As a result, the device joins the Thread network via a
OpenThread border Router (OTBR) and can communicate with other devices in the
network.
18 changes: 18 additions & 0 deletions examples/build_overrides/stm32_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

declare_args() {
# Root directory for stm32 SDK.
stm32_sdk_build_root = "//third_party/connectedhomeip/third_party/st"
}
28 changes: 28 additions & 0 deletions examples/lighting-app/stm32/.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")
}
Loading

0 comments on commit 788a023

Please sign in to comment.