Skip to content

Commit

Permalink
[Bouffalolab] build bl602 example by dev board and support *.flash.py… (
Browse files Browse the repository at this point in the history
#23245)

* [Bouffalolab] build bl602 example by dev board and support *.flash.py for bl602 image download

* Fix Restyled

* update build-all.yaml for targets changed; change baudrate variable to number; change board variable to auto()

* Fix Restyled

* correct bouffalolab submodule commit id
  • Loading branch information
wy-hh authored and pull[bot] committed Nov 17, 2023
1 parent 3162f6d commit 11d6fb9
Show file tree
Hide file tree
Showing 34 changed files with 779 additions and 1,046 deletions.
79 changes: 0 additions & 79 deletions .github/workflows/examples-bl602.yaml

This file was deleted.

67 changes: 62 additions & 5 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Build example - Bouffalolab BL702
name: Build example - BouffaloLab

on:
push:
Expand All @@ -23,6 +23,62 @@ concurrency:
cancel-in-progress: true

jobs:
bl602:
name: BL602
timeout-minutes: 90

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

container:
image: connectedhomeip/chip-build:latest
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
- uses: Wandalen/[email protected]
name: Checkout
with:
action: actions/checkout@v3
with: |
token: ${{ github.token }}
attempt_limit: 3
attempt_delay: 2000
- name: Checkout submodules
run: scripts/checkout_submodules.py --shallow --platform bl602

- name: Set up environment for size reports
if: ${{ !env.ACT }}
env:
GH_CONTEXT: ${{ toJson(github) }}
run: scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}"

- name: Build example BL602 Lighting App
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light build"
- name: Get Lighting size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl602 bl602 lighting-app \
out/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.out /tmp/bloat_reports/
- name: Build example BL602 Lighting App with RPCs
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light-115200-rpc build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl602 bl602+rpc lighting-app \
out/bouffalolab-bl602-iot-matter-v1-light-115200-rpc/chip-bl602-lighting-example.out /tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
with:
name: Size,BL602-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
path: |
/tmp/bloat_reports/
bl702:
name: BL702
timeout-minutes: 90
Expand Down Expand Up @@ -52,21 +108,22 @@ jobs:
GH_CONTEXT: ${{ toJson(github) }}
run: scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}"


- name: Build example BL702 Lighting App
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-bl706-iot-dvk-light build"
"./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702 lighting-app \
out/bouffalolab-bl706-iot-dvk-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
out/bouffalolab-xt-zb6-devkit-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
- name: Build example BL702 Lighting App with RPCs
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-bl706-iot-dvk-light-rpc build"
"./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-115200-rpc build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702+rpc lighting-app \
out/bouffalolab-bl706-iot-dvk-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
out/bouffalolab-xt-zb6-devkit-light-115200-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
Expand Down
20 changes: 6 additions & 14 deletions examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ declare_args() {

# OTA periodic query timeout in seconds
ota_periodic_query_timeout = 86400
}

show_qr_code = false
board = "BL602-IoT-Matter-V1"

# BL-HWC-G1 (No LCD)
if (bl602_board == "BL-HWC-G1" || bl602_board == "IOT_DVK_3S") {
show_qr_code = false
baudrate = 2000000
}

bl602_sdk("sdk") {
Expand All @@ -68,6 +65,7 @@ bl602_sdk("sdk") {
"CONFIG_PSM_EASYFLASH_SIZE=16384",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"OTA_PERIODIC_QUERY_TIMEOUT=${ota_periodic_query_timeout}",
"CHIP_UART_BAUDRATE=${baudrate}",
]

if (chip_enable_pw_rpc) {
Expand Down Expand Up @@ -107,16 +105,10 @@ bl602_executable("lighting_app") {

include_dirs = [ "include" ]

if (bl602_board == "IOT_DVK_3S") {
defines = [ "BOARD_ID=0" ]
} else {
if ("BL602-IoT-Matter-V1" == board || "BL602-IOT-DVK-3S" == board) {
defines = [ "BOARD_ID=1" ]
}

if (show_qr_code) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]

defines += [ "DISPLAY_ENABLED" ]
} else {
defines = [ "BOARD_ID=0" ]
}

if (chip_enable_pw_rpc) {
Expand Down
67 changes: 41 additions & 26 deletions examples/lighting-app/bouffalolab/bl602/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# BL602

This example functions as a wifi light bulb device type, with on/off
capabilities. The steps were verified on BL602-IoT-Matter-V1 board.
capabilities. The steps were verified on following boards:

- BL602-IoT-Matter-V1, [here](https://www.amazon.com/dp/B0B9ZVGXD8) to
purchase.
- BL602-NIGHT-LIGHT

## BL602-IoT-Matter-V1 board

BL602-IoT-Matter-V1 board and
[purchase link](https://www.amazon.com/dp/B0B9ZVGXD8):
<img src="../../../platform/bouffalolab/bl602/doc/images/BL602-IoT-Matter_V1.png" style="zoom:25%;" />

## Initial setup

The steps in this document were validated on Ubuntu 18.04 and 20.04.

- Install dependencies as specified in the connectedhomeip repository:
[Building Matter](https://github.com/project-chip/connectedhomeip/blob/interop_testing_te9/docs/guides/BUILDING.md).
[Building Matter](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md).
- Install other dependencies:

```
Expand All @@ -31,20 +35,42 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
source ./scripts/activate.sh
```
## Build the image and flash the board
> Note, Bouffalolab flash tool, `bflb-iot-tool`, imports under this
> environment. If not, please try `scripts/bootstrap.sh` for matter
> environment update.
## Build CHIP BL602 Lighting App example
- Build the
[lighting-app](https://github.com/project-chip/connectedhomeip/tree/master/examples/lighting-app/bouffalolab/bl602)
```
./scripts/build/build_examples.py --target bl602-light build
./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light build
./scripts/build/build_examples.py --target bouffalolab-bl602-night-light-light build
```
- Build the lighting-app with Pigweed RPC:
- Build target name with `-115200` appended for UART baudrate 115200 command
enabled as following commands.
```shell
./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light-115200 build
```
./scripts/examples/gn_bl602_example.sh lighting-app ./out/bl602-light 'import("//with_pw_rpc.gni")'
```
> UART baudrate is 2000000 by default.
- Build target name with `-rpc` appended for rpc enabled as following
commands.
`shell ./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc build`
> For multiple build options, such as UART baudrate 115200 + rpc, please try
> build command as
> `./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc-115200 build`
## Download image
After building gets done, a python `chip-bl602-lighting-example.flash.py` will
generated under build output folder. Such as
chip-bl602-lighting-example.flash.py for lighting-app example. Please check
`help` option of script for more detail.
- Connect the board to your flashing station (MacOS, Ubuntu, Windows).
Expand All @@ -54,33 +80,22 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
- Press the RESET button and release it.
- Release the BOOT button.
- The device should present itself as a USB serial device on your computer.
You may look it up in /dev/ttyACM0
- Enter build out folder, download image as following execution under build
output folder:
```shell
./chip-bl602-lighting-example.flash.py --port /dev/tty.usbserial-3
```
ls -la /dev/tty*
```
If the device is at /dev/ttyACM0, flash the board using the following
commands:
```
cd third_party/bouffalolab/repo/tools/flash_tool
./bflb_iot_tool-ubuntu --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../out/bl602-light/chip-bl602-lighting-example.bin
```
```
If you want to erase previous network information in flash, you can add --erase parameters to the bflb_iot_tool-ubuntu18 command. For Windows and MacOS, replace bflb_iot_tool-ubuntu18 with bflb_iot_tool.exe and bflb_iot_tool-macos, respectively.
```
> Note, where `/dev/tty.usbserial-3` is UART port of device.
## Validate the example
1.You can open the serial console. For example, if the device is at
`/dev/ttyACM0`:
```
picocom -b 115200 /dev/ttyACM0
picocom -b 2000000 /dev/ttyACM0
```
2.To reset the board, press the RESET button, and you will see the log in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
* TODO: 3R
*/
//#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xF001
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8001
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
Expand Down
15 changes: 9 additions & 6 deletions examples/lighting-app/bouffalolab/bl702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declare_args() {
# Monitor & log memory usage at runtime.
enable_heap_monitoring = false

board = "BL706-IoT-DVK"
board = "XT-ZB6-DevKit"
module_type = "BL706C-22"
enable_psram = true
baudrate = 2000000
Expand Down Expand Up @@ -95,13 +95,16 @@ bl702_executable("lighting_app") {
defines += [ "CFG_USE_PSRAM=1" ]
}

if ("BL706-NIGHT-LIGHT" == board) {
defines += [ "APP_BOARD_LED_STATUS=0" ]
if ("BL706C-22" == module_type) {
defines += [ "BOARD_BTN_BOOT_PIN" ]
}

if ("XT-ZB6-DevKit" == board) {
defines += [ "XT_ZB6_DevKit" ]
} else if ("BL706-NIGHT-LIGHT" == board) {
defines += [ "BL706_NIGHT_LIGHT" ]
defines += [ "APP_BOARD_BTN=0" ]
} else if ("BL702-IoT-DVK" == board || "BL706-IoT-DVK" == board) {
defines += [ "APP_BOARD_LED_STATUS=1" ]
defines += [ "APP_BOARD_BTN=1" ]
defines += [ "BL706_IOT_DVK" ]
}

sources = [
Expand Down
Loading

0 comments on commit 11d6fb9

Please sign in to comment.