diff --git a/.github/workflows/examples-bl602.yaml b/.github/workflows/examples-bl602.yaml deleted file mode 100644 index 56166d9e667756..00000000000000 --- a/.github/workflows/examples-bl602.yaml +++ /dev/null @@ -1,79 +0,0 @@ -# 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 - BL602 - -on: - push: - pull_request: - -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 - -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/wretry.action@v1.0.15 - 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 bl602-light build" - - - name: Get Lighting size stats - run: | - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl602 bl602 lighting-app \ - out/bl602-light/chip-bl602-lighting-example.out /tmp/bloat_reports/ - - - name: Build example BL602 Lighting App with RPCs - timeout-minutes: 30 - run: | - scripts/examples/gn_bl602_example.sh lighting-app ./out/bl602-light-rpc 'import("//with_pw_rpc.gni")' - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl602 bl602+rpc lighting-app \ - out/bl602-light-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/ diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index 3b53d17b35d726..e34c54882624fc 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -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: @@ -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/wretry.action@v1.0.15 + 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 @@ -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 diff --git a/examples/lighting-app/bouffalolab/bl602/BUILD.gn b/examples/lighting-app/bouffalolab/bl602/BUILD.gn index a00a5a47503269..f6a9513561d049 100644 --- a/examples/lighting-app/bouffalolab/bl602/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl602/BUILD.gn @@ -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") { @@ -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) { @@ -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) { diff --git a/examples/lighting-app/bouffalolab/bl602/README.md b/examples/lighting-app/bouffalolab/bl602/README.md index 1c66c73ecc5c83..cbf2b90d62c90c 100644 --- a/examples/lighting-app/bouffalolab/bl602/README.md +++ b/examples/lighting-app/bouffalolab/bl602/README.md @@ -1,10 +1,14 @@ # 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): ## Initial setup @@ -12,7 +16,7 @@ BL602-IoT-Matter-V1 board and 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: ``` @@ -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). @@ -54,25 +80,14 @@ 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 @@ -80,7 +95,7 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04. `/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 diff --git a/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h b/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h index d36ef3e7326b4d..db99b4c1a72ef7 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h +++ b/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h @@ -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 diff --git a/examples/lighting-app/bouffalolab/bl702/BUILD.gn b/examples/lighting-app/bouffalolab/bl702/BUILD.gn index 1101a90630c0d4..8243bb9924a97f 100644 --- a/examples/lighting-app/bouffalolab/bl702/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl702/BUILD.gn @@ -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 @@ -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 = [ diff --git a/examples/lighting-app/bouffalolab/bl702/README.md b/examples/lighting-app/bouffalolab/bl702/README.md index f02b1b84758f86..09f709643268bc 100644 --- a/examples/lighting-app/bouffalolab/bl702/README.md +++ b/examples/lighting-app/bouffalolab/bl702/README.md @@ -7,12 +7,11 @@ This example is powered by BL706 and functions as a Thread light bulb device type, with on/off, level and color capabilities. The steps were verified with following boards: - - BL706-IoT-DVK - - BL706-NIGHT-LIGHT +- `XT-ZB6-DevKit` +- `BL706-IoT-DVK` +- `BL706-NIGHT-LIGHT` -## Build - -### Prerequisite +## Prerequisite - Clone connectedhomeip github repo and update all submodule; - Install all tools (likely already present for CHIP developers). @@ -24,143 +23,106 @@ following boards: ```shell source scripts/bootstrap.sh ``` - > Note, `scripts/bootstrap.sh` only installs `bflb-iot-tool` under - > connectedhomeip build context. + > Note, `bflb-iot-tool` is only installed under connectedhomeip build + > context by matter environment setup `scripts/bootstrap.sh`. - Others, please execute the following script before any build commands - executed; and `bflb-iot-tool` will import under this environment. + executed; and `bflb-iot-tool` imports under this environment. ```shell source scripts/activate.sh ``` ## Build CHIP BL702 Lighting App example -- Build with script `gn_bouffalolab_example.sh` under root folder of - connectedhomeip repo +- Build for `XT-ZB6-DevKit` and BL706-NIGHT-LIGHT as following commands. - - Command format: + ```shell + ./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light build + ./scripts/build/build_examples.py --target bouffalolab-bl706-night-light-light build + ``` - ```shell - ./scripts/examples/gn_bouffalolab_example.sh [] - ``` +- Build target name with `-115200` appended for UART baudrate 115200 command + enabled as following commands. - - Build lighting-app for board BL706-IoT-DVK. + ```shell + ./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc build + ``` - ```shell - ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK - ``` + > UART baudrate is 2000000 by default. - - Build lighting-app for board BL706-NIGHT-LIGHT +- Build target name with `-shell` appended for UART shell command enabled as + following commands. - ```shell - ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT - ``` + ```shell + ./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-shell build + ``` - - With UART shell command enabled: +- 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` - ```shell - ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK chip_build_libshell=true - ``` +## Download image - - With pigweed RPC enabled: - ```shell - ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK 'import("//with_pw_rpc.gni")' - ``` - > Note, UART shell command and pigweed RPC can not build together. +- Using script `chip-bl702-lighting-example.flash.py`. -- Build with `build_examples.py` + After building gets done, a python `chip-bl702-lighting-example.flash.py` + will generated under build output folder. Such as + chip-bl702-lighting-example.flash.py for lighting-app example. Please check + `--help` option of script for more detail. - - Build for BL706-IoT-DVK and BL706-NIGHT-LIGHT as following commands. + - Hold BOOT pin and reset chip, let it be in download mode. + - Enter build out folder, download image as following execution under + build output folder: ```shell - ./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build - ./scripts/build/build_examples.py --target bouffalolab-BL706-NIGHT-LIGHT-light build + ./chip-bl702-lighting-example.flash.py --port /dev/tty.usbserial-3 ``` - - Build with pigweed RPC enabled as following commands. + > Note, where `/dev/tty.usbserial-3` is UART port of device. + + - Build Bouffalolab OTA image as following execution under build output + folder: ```shell - ./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build + ./chip-bl702-lighting-example.flash.py --build ``` - -- Build options - - - Build options list There are some build options for function and debug - purpose as below. - - `chip_build_libshell`, whether to enable shell command line. It is - set to false by default. - - `baudrate`, UART baudrate for log output or shell command line. - - `enable_psram`, whether to enable `PSRAM`. It is set to true by - default. - - How to use Before using these build options, please check whether they - are available to configure in BUILD.gn file under example application - folder. - - build with `build_examples.py` Modify value of build options in - BUILD.gn file under example application folder. - - build with gn_bouffalolab_example.sh Input build options, such as - ``` - ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK chip_build_libshell=true - ``` - -- Download image - - - Using script `chip-bl702-lighting-example.flash.py`. - - After building gets done, a python - `chip-bl702-lighting-example.flash.py` will generated under build output - folder. Such as chip-bl702-lighting-example.flash.py for lighting-app - example. Please check `help` option of script for more detail. - - - Hold BOOT pin and reset chip, let it be in download mode. - - Download image as following execution under build output folder: - - ```shell - ./chip-bl702-lighting-example.flash.py --port /dev/tty.usbserial-3 - ``` - - > Note, where `/dev/tty.usbserial-3` is UART port of device. - - - Build Bouffalolab OTA image as following execution under build - output folder: - ```shell - ./chip-bl702-lighting-example.flash.py --build - ``` - After script executed, a folder `ota_images` and image - `FW_OTA.bin.xz.hash` will generated. `FW_OTA.bin.xz.hash` is - compressed with hash verification with - `chip-bl702-lighting-example.bin`. - - > Note, `chip-bl702-lighting-example.flash.py` uses Python module - > `bflb-iot-tool` to flash device. Please make sure current terminal is - > under matter build environment, otherwise, Python module - > `bflb-iot-tool` should be installed with default Python. - - - Using `Bouffalo Lab` flash tool`BLDevCube` - - Hold BOOT pin and reset chip, let it be in download mode. - - Select `DTS` file - `/examples/platform/bouffalolab/bl702/flash_config/bl_factory_params_IoTKitA_32M.dts`; - - Select Partition Table - `/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml`; - - Select Firmware Bin chip-bl702-lighting-example.bin; - - Select Chip Erase if need; - - Choose Target COM port. - - Then click Create & Download. - > Where `connectedhomeip_repo_path` is the root path of repo - > connectedhomeip. - -- Firmware Behavior - - - IOT Dev board Status LED: TX0
Lighting LED: RX1
Factory Reset: - Short `IO11` to `GND` over 3 seconds
- - - Night Light Unprovisioned state: light shows yellow. Provisioned state: - light show white. Factory Reset: Power cycle 3 times before light is on; - at 3rd time, light shows green and does factory reset after 3 seconds - later. And factory reset can be cancelled during 3 seconds wait time. - -- UART baudrate for log and shell command - - By default, UART baudrate is 2000000 - - To change UART baudrate, please run script `gn_bouffalolab_example.sh` - with `baudrate=[uart baudrate]` followed, such as - `./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT module_type="BL702" baudrate=115200` + After script executed, a folder `ota_images` and an image + `FW_OTA.bin.xz.hash` will be generated. `FW_OTA.bin.xz.hash` is + compressed with hash verification for `chip-bl702-lighting-example.bin`. + + > Note, `chip-bl702-lighting-example.flash.py` uses Python module + > `bflb-iot-tool` to flash device. Please make sure current terminal is + > under matter build environment; otherwise, Python module `bflb-iot-tool` + > should be installed under default Python environment using command + > `pip install bflb-iot-tool`. + +- Using `Bouffalo Lab` flash tool`BLDevCube` + - Hold BOOT pin and reset chip, let it be in download mode. + - Select `DTS` file; + - Select Partition Table + `/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml`; + - Select Firmware Bin chip-bl702-lighting-example.bin; + - Select Chip Erase if need; + - Choose Target COM port. + - Then click Create & Download. + > Where `connectedhomeip_repo_path` is the root path of repo + > connectedhomeip. + +## Firmware Behavior + +- `XT-ZB6-DevKit` board + + - Lighting LED, controlled by on/off command, level command and identify + command. + - Factory Reset: Press down boot pin over 4 seconds, and release boot pin + +- `Night Light` board + - Unprovisioned state: light shows yellow. + - Provisioned state: light show white. + - Factory Reset: Power cycle 3 times before light is on; at 3rd time, + light shows green and does factory reset after 3 seconds later. And + factory reset can be cancelled during 3 seconds wait time. ## Test with chip-tool @@ -204,7 +166,7 @@ which `` is how many seconds to execute identify command. - Under connectedhomeip repo path ```shell - $ ./src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8005 -vn 1 -vs "1.0" -da sha256 lighting-app.ota + $ ./src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8005 -vn 10 -vs "1.0" -da sha256 lighting-app.ota ``` diff --git a/examples/lighting-app/bouffalolab/bl702/include/AppTask.h b/examples/lighting-app/bouffalolab/bl702/include/AppTask.h index b56f746f04763e..b9be603d96e7b6 100644 --- a/examples/lighting-app/bouffalolab/bl702/include/AppTask.h +++ b/examples/lighting-app/bouffalolab/bl702/include/AppTask.h @@ -48,18 +48,20 @@ class AppTask { APP_EVENT_NONE = 0x00000000, - APP_EVENT_STARTED = 0x00000001, APP_EVENT_BTN_FACTORY_RESET_CANCEL = 0x00000002, APP_EVENT_BTN_FACTORY_RESET_IND = 0x00000004, - APP_EVENT_BTN_FACTORY_RESET_PW_PRC = 0x00000008, + APP_EVENT_BTN_FACTORY_RESET_PRESS = 0x00000008, - APP_EVENT_INIT_ALL_MASK = APP_EVENT_STARTED | APP_EVENT_BTN_FACTORY_RESET_CANCEL | APP_EVENT_BTN_FACTORY_RESET_IND, - APP_EVENT_TIMER = 0x00000010, + APP_EVENT_BTN_ALL_MASK = + APP_EVENT_BTN_FACTORY_RESET_CANCEL | APP_EVENT_BTN_FACTORY_RESET_IND | APP_EVENT_BTN_FACTORY_RESET_PRESS, + APP_EVENT_TIMER = 0x00000010, + APP_EVENT_BTN_SHORT = 0x00000020, - APP_EVENT_SYS_BLE_ADV = 0x00000100, - APP_EVENT_SYS_BLE_CONN = 0x00000200, - APP_EVENT_SYS_PROVISIONED = 0x00000400, - APP_EVENT_FACTORY_RESET = 0x00001000, + APP_EVENT_SYS_BLE_ADV = 0x00000100, + APP_EVENT_SYS_BLE_CONN = 0x00000200, + APP_EVENT_SYS_PROVISIONED = 0x00000400, + APP_EVENT_SYS_LIGHT_TOGGLE = 0x00000800, + APP_EVENT_FACTORY_RESET = 0x00001000, APP_EVENT_SYS_ALL_MASK = APP_EVENT_SYS_BLE_ADV | APP_EVENT_SYS_BLE_CONN | APP_EVENT_SYS_PROVISIONED | APP_EVENT_FACTORY_RESET, @@ -67,18 +69,16 @@ class AppTask APP_EVENT_LIGHTING_ONOFF = 0x00010000, APP_EVENT_LIGHTING_LEVEL = 0x00020000, APP_EVENT_LIGHTING_COLOR = 0x00040000, - APP_EVENT_LIGHTING_CHECK = 0x00080000, APP_EVENT_LIGHTING_GO_THROUGH = 0x00100000, - APP_EVENT_LIGHTING_MASK = - APP_EVENT_LIGHTING_ONOFF | APP_EVENT_LIGHTING_LEVEL | APP_EVENT_LIGHTING_COLOR | APP_EVENT_LIGHTING_CHECK, + APP_EVENT_LIGHTING_MASK = APP_EVENT_LIGHTING_ONOFF | APP_EVENT_LIGHTING_LEVEL | APP_EVENT_LIGHTING_COLOR, APP_EVENT_IDENTIFY_START = 0x01000000, APP_EVENT_IDENTIFY_IDENTIFY = 0x02000000, APP_EVENT_IDENTIFY_STOP = 0x04000000, APP_EVENT_IDENTIFY_MASK = APP_EVENT_IDENTIFY_START | APP_EVENT_IDENTIFY_IDENTIFY | APP_EVENT_IDENTIFY_STOP, - APP_EVENT_ALL_MASK = - APP_EVENT_LIGHTING_MASK | APP_EVENT_INIT_ALL_MASK | APP_EVENT_SYS_ALL_MASK | APP_EVENT_TIMER | APP_EVENT_IDENTIFY_MASK, + APP_EVENT_ALL_MASK = APP_EVENT_LIGHTING_MASK | APP_EVENT_BTN_ALL_MASK | APP_EVENT_SYS_ALL_MASK | APP_EVENT_TIMER | + APP_EVENT_BTN_SHORT | APP_EVENT_IDENTIFY_MASK, }; void SetEndpointId(EndpointId endpointId) @@ -112,15 +112,12 @@ class AppTask static void LightingUpdate(app_event_t event = APP_EVENT_NONE); -#if APP_BOARD_LED_STATUS || APP_BOARD_BTN static bool StartTimer(void); static void CancelTimer(void); - static void TimerEventHandler(void); - static void TimerDutyCycle(app_event_t event); + static void TimerEventHandler(app_event_t event); static void TimerCallback(TimerHandle_t xTimer); -#endif -#if APP_BOARD_BTN +#ifdef LED_BTN_RESET static void ButtonInit(void); static bool ButtonPressed(void); static void ButtonEventHandler(void * arg); @@ -136,9 +133,9 @@ class AppTask TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; TimerHandle_t sTimer; - uint32_t mBlinkOnTimeMS; - uint32_t mBlinkOffTimeMS; - uint64_t buttonPressedTimeout; + uint32_t mTimerIntvl; + uint64_t mButtonPressedTime; + bool mIsFactoryResetIndicat; static StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; static StaticTask_t appTaskStruct; diff --git a/examples/lighting-app/bouffalolab/bl702/include/board.h b/examples/lighting-app/bouffalolab/bl702/include/board.h index e0e47c6a194f4f..2185ce86448d65 100644 --- a/examples/lighting-app/bouffalolab/bl702/include/board.h +++ b/examples/lighting-app/bouffalolab/bl702/include/board.h @@ -57,22 +57,31 @@ #define LED_G_PIN_PORT 1 #define LED_G_PIN 16 -#define LED1_PIN LED_B_PIN_PORT - #define MAX_PWM_CHANNEL 3 -#else +#elif defined(XT_ZB6_DevKit) + +#define LED_B_PIN_PORT 3 +#define LED_B_PIN 18 -#define LED1_PIN 22 +#define LED_R_PIN_PORT 4 +#define LED_R_PIN 19 -#define LED_B_PIN_PORT 1 -#define LED_B_PIN 31 +#define LED_G_PIN_PORT 0 +#define LED_G_PIN 20 + +#define MAX_PWM_CHANNEL 1 + +#else + +#define LED_B_PIN_PORT 2 +#define LED_B_PIN 22 #define MAX_PWM_CHANNEL 1 #endif -#if APP_BOARD_BTN -#define LED_BTN_RESET 11 +#if defined(BOARD_BTN_BOOT_PIN) +#define LED_BTN_RESET 31 #endif #define SPI_WIFI_MISO_PIN 4 diff --git a/examples/lighting-app/bouffalolab/bl702/src/AppTask.cpp b/examples/lighting-app/bouffalolab/bl702/src/AppTask.cpp index 641562bd520cf5..bc8944a10f14e1 100644 --- a/examples/lighting-app/bouffalolab/bl702/src/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/bl702/src/AppTask.cpp @@ -17,7 +17,6 @@ * limitations under the License. */ -#include "AppTask.h" #include "AppConfig.h" #include "LEDWidget.h" #include @@ -49,7 +48,6 @@ #endif #if CHIP_ENABLE_OPENTHREAD -#include #include #include #include @@ -77,8 +75,12 @@ extern "C" { #include } -#define FACTORY_RESET_TRIGGER_TIMEOUT 3000 -#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 +#include "AppTask.h" + +#define APP_BUTTON_PRESS_JITTER 50 +#define APP_BUTTON_PRESS_SHORT 1000 +#define APP_BUTTON_PRESS_LONG 4000 + #define APP_TASK_PRIORITY 2 #define EXT_DISCOVERY_TIMEOUT_SECS 20 #define APP_LIGHT_ENDPOINT_ID 1 @@ -86,10 +88,6 @@ extern "C" { #define APP_REBOOT_RESET_COUNT_KEY "app_reset_cnt" namespace { -#if APP_BOARD_LED_STATUS -LEDWidget sStatusLED; -#endif - #ifdef BL706_NIGHT_LIGHT ColorLEDWidget sLightLED; #else @@ -100,11 +98,7 @@ Identify sIdentify = { APP_LIGHT_ENDPOINT_ID, AppTask::IdentifyStartHandler, AppTask::IdentifyStopHandler, -#if APP_BOARD_LED_STATUS - EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, -#else EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LIGHT, -#endif }; } // namespace @@ -148,9 +142,7 @@ void PlatformManagerImpl::PlatformInit(void) chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName("BL702_LIGHT"); - ot_alarmInit(); - ot_radioInit(); -#if CONFIG_ENABLE_CHIP_SHELL +#if CHIP_ENABLE_OPENTHREAD && CONFIG_ENABLE_CHIP_SHELL cmd_otcli_init(); #endif ChipLogProgress(NotSpecified, "Initializing OpenThread stack"); @@ -214,9 +206,7 @@ void PlatformManagerImpl::PlatformInit(void) chip::rpc::Init(); #endif -#if APP_BOARD_LED_STATUS || APP_BOARD_BTN GetAppTask().PostEvent(AppTask::APP_EVENT_TIMER); -#endif vTaskResume(GetAppTask().sAppTaskHandle); } @@ -272,16 +262,11 @@ void AppTask::PostEvent(app_event_t event) void AppTask::AppTaskMain(void * pvParameter) { app_event_t appEvent; - static uint32_t taskDelay = portMAX_DELAY; - bool isStateReady = false; - -#if APP_BOARD_LED_STATUS - sStatusLED.Init(); -#endif + bool isStateReady = false; sLightLED.Init(); -#if APP_BOARD_BTN +#ifdef LED_BTN_RESET ButtonInit(); #else uint32_t resetCnt = 0; @@ -290,13 +275,14 @@ void AppTask::AppTaskMain(void * pvParameter) ef_get_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt), &saved_value_len); if (resetCnt >= APP_REBOOT_RESET_COUNT) { - GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); + GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_IND); } else { resetCnt++; ef_set_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt)); } + GetAppTask().mButtonPressedTime = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); #endif ChipLogProgress(NotSpecified, "Starting Platform Manager Event Loop"); @@ -308,49 +294,49 @@ void AppTask::AppTaskMain(void * pvParameter) } vTaskSuspend(NULL); -#if APP_BOARD_LED_STATUS || APP_BOARD_BTN GetAppTask().sTimer = xTimerCreate("lightTmr", pdMS_TO_TICKS(1000), false, NULL, AppTask::TimerCallback); if (GetAppTask().sTimer == NULL) { ChipLogError(NotSpecified, "Failed to create timer task"); appError(APP_ERROR_EVENT_QUEUE_FAILED); } -#endif ChipLogProgress(NotSpecified, "App Task started, with heap %d left\r\n", xPortGetFreeHeapSize()); + StartTimer(); + while (true) { appEvent = APP_EVENT_NONE; - BaseType_t eventReceived = xTaskNotifyWait(0, APP_EVENT_ALL_MASK, (uint32_t *) &appEvent, taskDelay); + BaseType_t eventReceived = xTaskNotifyWait(0, APP_EVENT_ALL_MASK, (uint32_t *) &appEvent, portMAX_DELAY); if (eventReceived) { -#if APP_BOARD_LED_STATUS || APP_BOARD_BTN - TimerDutyCycle(appEvent); -#endif - PlatformMgr().LockChipStack(); if (APP_EVENT_SYS_BLE_ADV & appEvent) { LightingSetStatus(APP_EVENT_SYS_BLE_ADV); + LightingUpdate(APP_EVENT_LIGHTING_GO_THROUGH); + isStateReady = false; } if (APP_EVENT_SYS_PROVISIONED & appEvent) { LightingSetStatus(APP_EVENT_SYS_PROVISIONED); + LightingUpdate(APP_EVENT_LIGHTING_GO_THROUGH); + isStateReady = true; } + if (APP_EVENT_BTN_SHORT & appEvent) + { + LightingSetStatus(APP_EVENT_SYS_LIGHT_TOGGLE); + LightingUpdate(APP_EVENT_LIGHTING_GO_THROUGH); + } + if ((APP_EVENT_LIGHTING_MASK & appEvent) && isStateReady) { -#if APP_BOARD_LED_STATUS || APP_BOARD_BTN - if (APP_EVENT_LIGHTING_CHECK & appEvent) - { - TimerDutyCycle(APP_EVENT_SYS_PROVISIONED); - } -#endif LightingUpdate((app_event_t)(APP_EVENT_LIGHTING_MASK & appEvent)); } @@ -361,27 +347,12 @@ void AppTask::AppTaskMain(void * pvParameter) if (APP_EVENT_FACTORY_RESET & appEvent) { -#if !APP_BOARD_LED_STATUS - LightingSetStatus(APP_EVENT_FACTORY_RESET); - LightingUpdate(APP_EVENT_LIGHTING_GO_THROUGH); - vTaskDelay(FACTORY_RESET_TRIGGER_TIMEOUT); -#endif DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); } - if (APP_EVENT_BTN_FACTORY_RESET_PW_PRC & appEvent) - { - vTaskDelay(FACTORY_RESET_TRIGGER_TIMEOUT); - DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); - } + TimerEventHandler(appEvent); PlatformMgr().UnlockChipStack(); -#if APP_BOARD_LED_STATUS || APP_BOARD_BTN - if (APP_EVENT_TIMER & appEvent) - { - TimerEventHandler(); - } -#endif } } } @@ -421,27 +392,10 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg) void AppTask::LightingUpdate(app_event_t event) { - static uint32_t updateOpCnt = 0; uint8_t v, onoff, hue, sat; EmberAfAttributeType dataType; EndpointId endpoint = GetAppTask().GetEndpointId(); - if (APP_EVENT_LIGHTING_CHECK & event) - { - if (updateOpCnt++ < 2) - { - GetAppTask().PostEvent(APP_EVENT_LIGHTING_CHECK); - return; - } - updateOpCnt = 0; - } - else if (APP_EVENT_LIGHTING_MASK & event) - { - updateOpCnt = 0; - GetAppTask().PostEvent(APP_EVENT_LIGHTING_CHECK); - return; - } - do { if (EMBER_ZCL_STATUS_SUCCESS != @@ -501,42 +455,17 @@ void AppTask::LightingSetOnoff(uint8_t bonoff) void AppTask::LightingSetStatus(app_event_t status) { - uint8_t level, hue, sat; + uint8_t onoff = 1, level, hue, sat; EndpointId endpoint = GetAppTask().GetEndpointId(); static bool isProvisioned = false; -#if !APP_BOARD_BTN - uint32_t resetCnt = 0; - size_t saved_value_len = 0; - - if ((APP_EVENT_SYS_BLE_ADV | APP_EVENT_SYS_PROVISIONED) & status) + if (APP_EVENT_SYS_LIGHT_TOGGLE == status) { - - if (0 == GetAppTask().buttonPressedTimeout) - { - - GetAppTask().buttonPressedTimeout = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); - ef_get_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt), &saved_value_len); - if (resetCnt >= APP_REBOOT_RESET_COUNT) - { - GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); - } - else - { - resetCnt = 0; - ef_set_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt)); - } - } + emberAfReadAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, + ZCL_BOOLEAN_ATTRIBUTE_TYPE); + onoff = 1 - onoff; } - else if (APP_EVENT_FACTORY_RESET & status) - { - /** reset resetCnt to zero before factory reset, just in case to cancel factory reset */ - resetCnt = 0; - ef_set_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt)); - } -#endif - - if (APP_EVENT_SYS_BLE_ADV == status) + else if (APP_EVENT_SYS_BLE_ADV == status) { hue = 35; emberAfWriteAttribute(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, (uint8_t *) &hue, @@ -544,6 +473,10 @@ void AppTask::LightingSetStatus(app_event_t status) sat = 254; emberAfWriteAttribute(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, (uint8_t *) &sat, ZCL_INT8U_ATTRIBUTE_TYPE); + level = 254; + emberAfWriteAttribute(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level, + ZCL_INT8U_ATTRIBUTE_TYPE); + isProvisioned = false; } else if (APP_EVENT_SYS_PROVISIONED == status) @@ -556,55 +489,27 @@ void AppTask::LightingSetStatus(app_event_t status) sat = 0; emberAfWriteAttribute(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, (uint8_t *) &sat, ZCL_INT8U_ATTRIBUTE_TYPE); - } - else if (APP_EVENT_FACTORY_RESET == status) - { - hue = 84; - emberAfWriteAttribute(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, (uint8_t *) &hue, + level = 254; + emberAfWriteAttribute(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level, ZCL_INT8U_ATTRIBUTE_TYPE); - sat = 254; - emberAfWriteAttribute(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - (uint8_t *) &sat, ZCL_INT8U_ATTRIBUTE_TYPE); } - level = 254; - emberAfWriteAttribute(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level, - ZCL_INT8U_ATTRIBUTE_TYPE); - - level = 1; - emberAfWriteAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &level, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + emberAfWriteAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -#if APP_BOARD_LED_STATUS || APP_BOARD_BTN bool AppTask::StartTimer(void) { - uint32_t aTimeoutMs = GetAppTask().mBlinkOnTimeMS; - -#if APP_BOARD_LED_STATUS - if (GetAppTask().mBlinkOffTimeMS) - { - aTimeoutMs = sStatusLED.GetOnoff() ? GetAppTask().mBlinkOnTimeMS : GetAppTask().mBlinkOffTimeMS; - sStatusLED.Toggle(); - } - else - { - if (!sStatusLED.GetOnoff()) - { - sStatusLED.SetOnoff(1); - } - } -#endif - if (xTimerIsTimerActive(GetAppTask().sTimer)) { CancelTimer(); } - if (aTimeoutMs == 0) + + if (GetAppTask().mTimerIntvl == 0) { - aTimeoutMs = 1000; + GetAppTask().mTimerIntvl = 1000; } - if (xTimerChangePeriod(GetAppTask().sTimer, pdMS_TO_TICKS(aTimeoutMs), pdMS_TO_TICKS(100)) != pdPASS) + if (xTimerChangePeriod(GetAppTask().sTimer, pdMS_TO_TICKS(GetAppTask().mTimerIntvl), pdMS_TO_TICKS(100)) != pdPASS) { ChipLogProgress(NotSpecified, "Failed to access timer with 100 ms delay."); } @@ -622,61 +527,104 @@ void AppTask::TimerCallback(TimerHandle_t xTimer) GetAppTask().PostEvent(APP_EVENT_TIMER); } -void AppTask::TimerEventHandler(void) +void AppTask::TimerEventHandler(app_event_t event) { -#if APP_BOARD_BTN - if (GetAppTask().buttonPressedTimeout) + if (event & APP_EVENT_BTN_FACTORY_RESET_PRESS) { - /** device is being in factory reset confirm state*/ - if (ButtonPressed()) - { - if (GetAppTask().buttonPressedTimeout < chip::System::SystemClock().GetMonotonicMilliseconds64().count()) - { - GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); - } - } - else + GetAppTask().mTimerIntvl = APP_BUTTON_PRESS_JITTER; + StartTimer(); + } + else if (event & APP_EVENT_BTN_FACTORY_RESET_IND) + { + if (GetAppTask().mButtonPressedTime) { - /** factory reset cancelled */ - GetAppTask().buttonPressedTimeout = 0; - GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_CANCEL); + GetAppTask().mIsFactoryResetIndicat = true; +#ifdef BL706_NIGHT_LIGHT + sLightLED.SetColor(254, 0, 210); +#ifndef LED_BTN_RESET + uint32_t resetCnt = 0; + GetAppTask().mButtonPressedTime = 0; + ef_set_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt)); + + vTaskDelay(APP_BUTTON_PRESS_LONG); + GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); +#endif +#else + sLightLED.Toggle(); + GetAppTask().mTimerIntvl = 100; + StartTimer(); +#endif } } -#endif - StartTimer(); -} - -void AppTask::TimerDutyCycle(app_event_t event) -{ - static uint32_t backup_blinkOnTimeMS, backup_blinkOffTimeMS; - - if (event & APP_EVENT_SYS_PROVISIONED) + if (event & APP_EVENT_BTN_FACTORY_RESET_CANCEL) { - GetAppTask().mBlinkOnTimeMS = 1000, GetAppTask().mBlinkOffTimeMS = 0; - } - else if (event & APP_EVENT_SYS_BLE_CONN) - { - GetAppTask().mBlinkOnTimeMS = 100, GetAppTask().mBlinkOffTimeMS = 100; - } - else if (event & APP_EVENT_SYS_BLE_ADV) - { - GetAppTask().mBlinkOnTimeMS = 100, GetAppTask().mBlinkOffTimeMS = 900; - } - else if (event & APP_EVENT_BTN_FACTORY_RESET_IND) - { - if (500 != backup_blinkOffTimeMS || 500 != backup_blinkOnTimeMS) + GetAppTask().mTimerIntvl = 1000; + StartTimer(); + if (GetAppTask().mIsFactoryResetIndicat) { - backup_blinkOnTimeMS = GetAppTask().mBlinkOnTimeMS, backup_blinkOffTimeMS = GetAppTask().mBlinkOffTimeMS; + LightingUpdate(APP_EVENT_LIGHTING_GO_THROUGH); } - GetAppTask().mBlinkOnTimeMS = 500, GetAppTask().mBlinkOffTimeMS = 500; + GetAppTask().mIsFactoryResetIndicat = false; + GetAppTask().mButtonPressedTime = 0; } - else if (event & APP_EVENT_BTN_FACTORY_RESET_CANCEL) + + if (APP_EVENT_TIMER & event) { - GetAppTask().mBlinkOnTimeMS = backup_blinkOnTimeMS, GetAppTask().mBlinkOffTimeMS = backup_blinkOffTimeMS; + + if (GetAppTask().mButtonPressedTime) + { + if (GetAppTask().mIsFactoryResetIndicat) + { + if (chip::System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime >= + APP_BUTTON_PRESS_LONG) + { + /** factory reset indicat done. */ + sLightLED.SetOnoff(false); + GetAppTask().mTimerIntvl = 1000; + } + else + { +#ifndef BL706_NIGHT_LIGHT + sLightLED.Toggle(); +#endif + } + } + else + { + +#ifdef BL706_NIGHT_LIGHT + if (GetAppTask().mButtonPressedTime && + chip::System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime > + APP_BUTTON_PRESS_LONG) + { + uint32_t resetCnt = 0; + GetAppTask().mButtonPressedTime = 0; + ef_set_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt)); + } +#else +#ifdef LED_BTN_RESET + if (ButtonPressed()) + { + if (!GetAppTask().mIsFactoryResetIndicat && + chip::System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime >= + APP_BUTTON_PRESS_SHORT) + { + GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_IND); + } + } + else + { + GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_CANCEL); + } +#endif +#endif + } + } + + StartTimer(); } } -#endif void AppTask::IdentifyStartHandler(Identify *) { @@ -714,36 +662,61 @@ void AppTask::IdentifyHandleOp(app_event_t event) void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) { - GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_PW_PRC); - GetAppTask().buttonPressedTimeout = - chip::System::SystemClock().GetMonotonicMilliseconds64().count() + FACTORY_RESET_TRIGGER_TIMEOUT - 100; + GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); } -#if APP_BOARD_BTN -hosal_gpio_dev_t gpio_key = { .port = LED_BTN_RESET, .config = INPUT_PULL_UP, .priv = NULL }; +#ifdef LED_BTN_RESET +hosal_gpio_dev_t gpio_key = { .port = LED_BTN_RESET, .config = INPUT_HIGH_IMPEDANCE, .priv = NULL }; void AppTask::ButtonInit(void) { - GetAppTask().buttonPressedTimeout = 0; + GetAppTask().mButtonPressedTime = 0; + GetAppTask().mIsFactoryResetIndicat = false; hosal_gpio_init(&gpio_key); - hosal_gpio_irq_set(&gpio_key, HOSAL_IRQ_TRIG_NEG_PULSE, GetAppTask().ButtonEventHandler, NULL); + hosal_gpio_irq_set(&gpio_key, HOSAL_IRQ_TRIG_POS_PULSE, GetAppTask().ButtonEventHandler, NULL); } bool AppTask::ButtonPressed(void) { uint8_t val = 1; hosal_gpio_input_get(&gpio_key, &val); - return val == 0; + return val == 1; } void AppTask::ButtonEventHandler(void * arg) { + uint32_t presstime; if (ButtonPressed()) { - GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_IND); - GetAppTask().buttonPressedTimeout = - chip::System::SystemClock().GetMonotonicMilliseconds64().count() + FACTORY_RESET_TRIGGER_TIMEOUT - 100; + hosal_gpio_irq_set(&gpio_key, HOSAL_IRQ_TRIG_NEG_LEVEL, GetAppTask().ButtonEventHandler, NULL); + + GetAppTask().mButtonPressedTime = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); + GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_PRESS); + } + else + { + hosal_gpio_irq_set(&gpio_key, HOSAL_IRQ_TRIG_POS_PULSE, GetAppTask().ButtonEventHandler, NULL); + + if (GetAppTask().mButtonPressedTime) + { + + presstime = chip::System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime; + if (presstime >= APP_BUTTON_PRESS_LONG) + { + GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); + } + else if (presstime <= APP_BUTTON_PRESS_SHORT && presstime >= APP_BUTTON_PRESS_JITTER) + { + GetAppTask().PostEvent(APP_EVENT_BTN_SHORT); + } + else + { + GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_CANCEL); + } + } + + GetAppTask().mButtonPressedTime = 0; } } #endif diff --git a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml new file mode 100644 index 00000000000000..4705a3891e0a25 --- /dev/null +++ b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml @@ -0,0 +1,94 @@ +[pt_table] +#partition table is 4K in size +address0 = 0xE000 +address1 = 0xF000 + +[[pt_entry]] +type = 0 +name = "FW" +device = 0 +address0 = 0x10000 +size0 = 0x15C000 +address1 = 0x16C000 +size1 = 0x4000 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 2 +name = "mfg" +device = 0 +address0 = 0x16C000 +size0 = 0x4000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 3 +name = "media" +device = 0 +address0 = 0x1A2000 +size0 = 0x47000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 4 +name = "PSM" +device = 0 +address0 = 0x1E9000 +size0 = 0x8000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 5 +name = "KEY" +device = 0 +address0 = 0x1F1000 +size0 = 0x2000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 6 +name = "DATA" +device = 0 +address0 = 0x1F3000 +size0 = 0x5000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + + +[[pt_entry]] +type = 7 +name = "factory" +device = 0 +address0 = 0x1F8000 +size0 = 0x7000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +#if user want to put RF calibration data on flash, uncomment following pt entry +#[[pt_entry]] +#type = 8 +#name = "rf_para" +#device = 0 +#address0 = 0x1FF000 +#size0 = 0x1000 +#address1 = 0 +#size1 = 0 +## compressed image must set len,normal image can left it to 0 +#len = 0 diff --git a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml new file mode 100644 index 00000000000000..c7812b9cb70fa9 --- /dev/null +++ b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml @@ -0,0 +1,94 @@ +[pt_table] +#partition table is 4K in size +address0 = 0xE000 +address1 = 0xF000 + +[[pt_entry]] +type = 0 +name = "FW" +device = 0 +address0 = 0x10000 +size0 = 0x160000 +address1 = 0x170000 +size1 = 0x100000 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 2 +name = "mfg" +device = 0 +address0 = 0x270000 +size0 = 0x2F000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 3 +name = "media" +device = 0 +address0 = 0x272000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 4 +name = "PSM" +device = 0 +address0 = 0x273000 +size0 = 0x33000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 5 +name = "KEY" +device = 0 +address0 = 0x2A6000 +size0 = 0x2000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +[[pt_entry]] +type = 6 +name = "DATA" +device = 0 +address0 = 0x2A8000 +size0 = 0x5000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + + +[[pt_entry]] +type = 7 +name = "factory" +device = 0 +address0 = 0x2AD000 +size0 = 0x7000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + +#if user want to put RF calibration data on flash, uncomment following pt entry +#[[pt_entry]] +#type = 8 +#name = "rf_para" +#device = 0 +#address0 = 0x1FF000 +#size0 = 0x1000 +#address1 = 0 +#size1 = 0 +## compressed image must set len,normal image can left it to 0 +#len = 0 diff --git a/examples/platform/bouffalolab/bl702/LEDWidget.cpp b/examples/platform/bouffalolab/bl702/LEDWidget.cpp index ed7f7735034425..6eddbceaee0778 100644 --- a/examples/platform/bouffalolab/bl702/LEDWidget.cpp +++ b/examples/platform/bouffalolab/bl702/LEDWidget.cpp @@ -1,7 +1,6 @@ /* * * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,12 +27,14 @@ void LEDWidget::Init() { +#ifdef LED1_PIN mPin = LED1_PIN; hosal_gpio_dev_t gpio_led = { .config = OUTPUT_OPEN_DRAIN_NO_PULL, .priv = NULL }; gpio_led.port = mPin; hosal_gpio_init(&gpio_led); +#endif SetOnoff(false); } @@ -44,6 +45,7 @@ void LEDWidget::Toggle(void) void LEDWidget::SetOnoff(bool state) { +#ifdef LED1_PIN hosal_gpio_dev_t gpio_led = { .port = mPin, .config = OUTPUT_OPEN_DRAIN_NO_PULL, .priv = NULL }; mOnoff = state; @@ -56,6 +58,7 @@ void LEDWidget::SetOnoff(bool state) { hosal_gpio_output_set(&gpio_led, 0); } +#endif } bool LEDWidget::GetOnoff(void) @@ -67,8 +70,10 @@ void DimmableLEDWidget::Init() { mOnoff = light_v = 0; +#ifdef MAX_PWM_CHANNEL demo_hosal_pwm_init(); demo_hosal_pwm_start(); +#endif } void DimmableLEDWidget::Toggle(void) @@ -79,6 +84,7 @@ void DimmableLEDWidget::Toggle(void) void DimmableLEDWidget::SetOnoff(bool state) { mOnoff = state; +#ifdef MAX_PWM_CHANNEL if (mOnoff) { if (light_v) @@ -94,11 +100,14 @@ void DimmableLEDWidget::SetOnoff(bool state) { set_level(0); } +#endif } void DimmableLEDWidget::SetLevel(uint8_t level) { +#ifdef MAX_PWM_CHANNEL set_level(level); +#endif light_v = level; mOnoff = light_v > 0; } @@ -106,9 +115,10 @@ void DimmableLEDWidget::SetLevel(uint8_t level) void ColorLEDWidget::Init() { mOnoff = light_v = light_s = light_h = 0; - +#ifdef MAX_PWM_CHANNEL demo_hosal_pwm_init(); demo_hosal_pwm_start(); +#endif } void ColorLEDWidget::Toggle(void) @@ -118,6 +128,7 @@ void ColorLEDWidget::Toggle(void) void ColorLEDWidget::SetOnoff(bool state) { +#ifdef MAX_PWM_CHANNEL mOnoff = state; if (mOnoff) { @@ -134,6 +145,7 @@ void ColorLEDWidget::SetOnoff(bool state) { set_color(0, light_h, light_s); } +#endif } void ColorLEDWidget::SetLevel(uint8_t level) @@ -143,7 +155,9 @@ void ColorLEDWidget::SetLevel(uint8_t level) void ColorLEDWidget::SetColor(uint8_t level, uint8_t hue, uint8_t sat) { +#ifdef MAX_PWM_CHANNEL set_color(level, hue, sat); +#endif light_v = level; light_h = hue; light_s = sat; diff --git a/examples/platform/bouffalolab/bl702/LEDWidget.h b/examples/platform/bouffalolab/bl702/LEDWidget.h index e332f33fc0847c..935a1750620066 100644 --- a/examples/platform/bouffalolab/bl702/LEDWidget.h +++ b/examples/platform/bouffalolab/bl702/LEDWidget.h @@ -1,7 +1,6 @@ /* * * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/examples/platform/bouffalolab/bl702/demo_pwm.c b/examples/platform/bouffalolab/bl702/demo_pwm.c index 321b12089615f0..5f0104ffc7bc67 100644 --- a/examples/platform/bouffalolab/bl702/demo_pwm.c +++ b/examples/platform/bouffalolab/bl702/demo_pwm.c @@ -94,25 +94,21 @@ void set_level(uint8_t currLevel) para.duty_cycle = currLevel * PWM_DUTY_CYCLE / 254; para.freq = PWM_FREQ; - printf("[set_level] currLevel:0x%02x\r\n", currLevel); demo_hosal_pwm_change_param(¶); } void set_color_red(uint8_t currLevel) { - printf("set_color_red\r\n"); set_color(currLevel, 0, 254); } void set_color_green(uint8_t currLevel) { - printf("set_color_green\r\n"); set_color(currLevel, 84, 254); } void set_color_yellow(uint8_t currLevel) { - printf("set_color_yellow\r\n"); set_color(currLevel, 42, 254); } @@ -183,10 +179,6 @@ void set_color(uint8_t currLevel, uint8_t currHue, uint8_t currSat) para[2].duty_cycle = green * PWM_DUTY_CYCLE / 254; para[2].freq = PWM_FREQ; - printf("[set_color] currLevel:0x%02x, currHue:0x%02x, currSat:0x%02x, hue:0x%04x, sat:0x%02x, red:0x%lx, green:0x%lx, " - "blue:0x%lx \r\n", - currLevel, currHue, currSat, hue, sat, red, green, blue); - demo_hosal_pwm_change_param(para); #else set_level(currLevel); diff --git a/examples/platform/bouffalolab/bl702/flash_config/bl_factory_params_IoTKitA_32M.dts b/examples/platform/bouffalolab/bl702/flash_config/bl_factory_params_IoTKitA_32M.dts deleted file mode 100755 index 71afea9235a174..00000000000000 --- a/examples/platform/bouffalolab/bl702/flash_config/bl_factory_params_IoTKitA_32M.dts +++ /dev/null @@ -1,116 +0,0 @@ -/dts-v1/; -// version: 17 -// last_comp_version: 16 -// boot_cpuid_phys: 0x0 - -/ { - model = "bl bl702 AVB board"; - compatible = "bl,bl702-sample", "bl,bl702-common"; - #address-cells = <0x1>; - #size-cells = <0x1>; - gpio { - #address-cells = <1>; - #size-cells = <1>; - max_num = <40>; - gpio0 { - status = "okay"; - pin = <22>; - feature = "led"; - active = "Hi"; //Hi or Lo - mode = "onoff"; //blink or hearbeat or onoff - time = <100>; //duration for this mode - }; - gpio1 { - status = "disable"; - pin = <6>; - feature = "led"; - active = "Hi"; //Hi or Lo - mode = "blink"; //blink or hearbeat or onoff - time = <100>; //duration for this mode - }; - gpio2 { - status = "disable"; - pin = <5>; - feature = "button"; - active = "Hi"; - mode = "multipress"; - button { - debounce = <10>; - short_press_ms { - start = <30>; - end = <4000>; - kevent = <2>; - }; - long_press_ms { - start = <4001>; - end = <10000>; - kevent = <3>; - }; - longlong_press_ms { - start = <10001>; - kevent = <4>; - }; - trig_level = "Lo"; - }; - hbn_use = "disable"; - }; - }; - uart { - #address-cells = <1>; - #size-cells = <1>; - uart@4000A000 { - status = "okay"; - id = <0>; - compatible = "bl702_uart"; - path = "/dev/ttyS0"; - baudrate = <2000000>; - pin { - rx = <15>; - tx = <14>; - }; - feature { - tx = "okay"; - rx = "okay"; - cts = "disable"; - rts = "disable"; - }; - }; - uart@4000A100 { - status = "disable"; - id = <1>; - compatible = "bl702_uart"; - path = "/dev/ttyS1"; - baudrate = <115200>; - pin { - rx = <3>; - tx = <4>; - }; - feature { - tx = "okay"; - rx = "okay"; - cts = "disable"; - rts = "disable"; - }; - }; - }; - wireless { - #address-cells = <1>; - #size-cells = <1>; - mac { - mode = "MBF"; // 'M': manufacture; 'B': efuse; 'F': flash - mac_addr = [C8 43 57 82 73 40 88 88]; - }; - brd_rf { - xtal_mode = "MF"; - xtal = <36 36 0 60 60>; - pwr = <14>; - pwr_mode = "bf";//B: only use power offset in EFUSE; b: use power offset in EFUSE with incremental mode; F: only use power offset in Flash; f: use power offset in Flash with incremental mode - //pwr_offset = <10 10>;//due to the limit of current DTC, negative value is used. So we work around by adding all the poweroffset with 10. so 8 represents -2; 10 represents 0; 13 represents 3 - pwr_offset_zigbee = <10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10>; - pwr_offset_ble = <10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10>; - }; - rf_temp { - en_tcal = <0>; - }; - }; -}; diff --git a/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml b/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml index ec51ddbc63d4f1..f6a22deaf30a27 100644 --- a/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml +++ b/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml @@ -8,8 +8,8 @@ type = 0 name = "FW" device = 0 address0 = 0x3000 -size0 = 0x127000 -address1 = 0x12A000 +size0 = 0x12b000 +address1 = 0x12e000 size1 = 0xC9000 # compressed image must set len,normal image can left it to 0 len = 0 @@ -33,8 +33,8 @@ age = 0 type = 2 name = "PSM" device = 0 -address0 = 0x1F3000 -size0 = 0x8000 +address0 = 0x1F7000 +size0 = 0x4000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 40ecf820ee845c..731ac180fb1a63 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -34,8 +34,8 @@ steps: --target android-arm64-tv-casting-app --target android-arm64-tv-server --target android-x64-chip-tool - --target bl602-light - --target bouffalolab-BL706-IoT-DVK-light-rpc + --target bouffalolab-bl602-iot-matter-v1-light + --target bouffalolab-xt-zb6-devkit-light-rpc --target cc13x2x7_26x2x7-lock-ftd --target cc13x2x7_26x2x7-lock-mtd --target cc13x2x7_26x2x7-shell diff --git a/scripts/build/BUILD.gn b/scripts/build/BUILD.gn index 9ea50936d5382a..60356666c0f6ae 100644 --- a/scripts/build/BUILD.gn +++ b/scripts/build/BUILD.gn @@ -41,7 +41,6 @@ pw_python_package("build_examples") { "builders/__init__.py", "builders/ameba.py", "builders/android.py", - "builders/bl602.py", "builders/bouffalolab.py", "builders/builder.py", "builders/efr32.py", diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index cd5c8cd87ceaa4..71440e607c8c97 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -34,7 +34,6 @@ from builders.qpg import QpgApp, QpgBoard, QpgBuilder from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder from builders.tizen import TizenApp, TizenBoard, TizenBuilder -from builders.bl602 import Bl602App, Bl602Board, Bl602Builder from builders.bouffalolab import BouffalolabApp, BouffalolabBoard, BouffalolabBuilder from builders.imx import IMXApp, IMXBuilder from builders.genio import GenioApp, GenioBuilder @@ -442,21 +441,15 @@ def BuildTizenTarget(): return target -def BuildBl602Target(): - target = BuildTarget('bl602', Bl602Builder) - - target.AppendFixedTargets([ - TargetPart('light', board=Bl602Board.BL602BOARD, app=Bl602App.LIGHT), - ]) - - return target - - def BuildBouffalolabTarget(): target = BuildTarget('bouffalolab', BouffalolabBuilder) # Boards target.AppendFixedTargets([ + TargetPart('BL602-IoT-Matter-V1', board=BouffalolabBoard.BL602_IoT_Matter_V1, module_type="BL602"), + TargetPart('BL602-IOT-DVK-3S', board=BouffalolabBoard.BL602_IOT_DVK_3S, module_type="BL602"), + TargetPart('BL602-NIGHT-LIGHT', board=BouffalolabBoard.BL602_NIGHT_LIGHT, module_type="BL602"), + TargetPart('XT-ZB6-DevKit', board=BouffalolabBoard.BL706_IoT_DVK, module_type="BL706C-22"), TargetPart('BL706-IoT-DVK', board=BouffalolabBoard.BL706_IoT_DVK, module_type="BL706C-22"), TargetPart('BL706-NIGHT-LIGHT', board=BouffalolabBoard.BL706_NIGHT_LIGHT, module_type="BL702"), ]) @@ -466,6 +459,8 @@ def BuildBouffalolabTarget(): TargetPart('light', app=BouffalolabApp.LIGHT), ]) + target.AppendModifier('shell', enable_shell=True) + target.AppendModifier('115200', baudrate=115200) target.AppendModifier('rpc', enable_rpcs=True) return target @@ -516,7 +511,6 @@ def BuildTelinkTarget(): BUILD_TARGETS = [ BuildAmebaTarget(), BuildAndroidTarget(), - BuildBl602Target(), BuildBouffalolabTarget(), Buildcc13x2x7_26x2x7Target(), BuildCyw30739Target(), diff --git a/scripts/build/builders/bl602.py b/scripts/build/builders/bl602.py deleted file mode 100644 index f8fd4cacf32a5f..00000000000000 --- a/scripts/build/builders/bl602.py +++ /dev/null @@ -1,89 +0,0 @@ -# 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. - -import os -import platform -from enum import Enum, auto - -from .gn import GnBuilder - - -class Bl602App(Enum): - LOCK = auto() - LIGHT = auto() - ALL_CLUSTERS = auto() - - def ExampleName(self): - if self == Bl602App.LIGHT: - return 'lighting-app' - else: - raise Exception('Unknown app type: %r' % self) - - def AppNamePrefix(self): - if self == Bl602App.LIGHT: - return 'chip-bl602-lighting-example' - else: - raise Exception('Unknown app type: %r' % self) - - def FlashBundleName(self): - if self == Bl602App.LOCK: - return 'lighting_app.flashbundle.txt' - else: - raise Exception('Unknown app type: %r' % self) - - -class Bl602Board(Enum): - BL602BOARD = 1 - - def GnArgName(self): - if self == Bl602Board.BL602BOARD: - return 'BL-HWC-G1' - - -class Bl602Builder(GnBuilder): - - def __init__(self, - root, - runner, - app: Bl602App = Bl602App.LIGHT, - board: Bl602Board = Bl602Board.BL602BOARD): - super(Bl602Builder, self).__init__( - root=os.path.join(root, 'examples', - app.ExampleName(), 'bouffalolab', 'bl602'), - runner=runner) - - self.argsOpt = [] - - toolchain = os.path.join(root, '../../examples/platform/bouffalolab/common/toolchain') - toolchain = 'custom_toolchain="{}:riscv_gcc"'.format(toolchain) - if toolchain: - self.argsOpt.append(toolchain) - - self.app = app - self.board = board - - def GnBuildArgs(self): - return self.argsOpt + ['bl602_board="%s"' % self.board.GnArgName()] - - def build_outputs(self): - items = { - '%s.out' % self.app.AppNamePrefix(): - os.path.join(self.output_dir, '%s.out' % - self.app.AppNamePrefix()), - '%s.out.map' % self.app.AppNamePrefix(): - os.path.join(self.output_dir, - '%s.out.map' % self.app.AppNamePrefix()), - } - - return items diff --git a/scripts/build/builders/bouffalolab.py b/scripts/build/builders/bouffalolab.py index b391251093653f..2137949a325ff2 100644 --- a/scripts/build/builders/bouffalolab.py +++ b/scripts/build/builders/bouffalolab.py @@ -42,11 +42,23 @@ def FlashBundleName(self): class BouffalolabBoard(Enum): - BL706_IoT_DVK = 1 - BL706_NIGHT_LIGHT = 2 + BL602_IoT_Matter_V1 = auto() + BL602_IOT_DVK_3S = auto() + BL602_NIGHT_LIGHT = auto() + XT_ZB6_DevKit = auto() + BL706_IoT_DVK = auto() + BL706_NIGHT_LIGHT = auto() def GnArgName(self): - if self == BouffalolabBoard.BL706_IoT_DVK: + if self == BouffalolabBoard.BL602_IoT_Matter_V1: + return 'BL602-IoT-Matter-V1' + elif self == BouffalolabBoard.BL602_IOT_DVK_3S: + return 'BL602-IOT-DVK-3S' + elif self == BouffalolabBoard.BL602_NIGHT_LIGHT: + return 'BL602-NIGHT-LIGHT' + elif self == BouffalolabBoard.XT_ZB6_DevKit: + return 'XT-ZB6-DevKit' + elif self == BouffalolabBoard.BL706_IoT_DVK: return 'BL706-IoT-DVK' elif self == BouffalolabBoard.BL706_NIGHT_LIGHT: return 'BL706-NIGHT-LIGHT' @@ -63,6 +75,8 @@ def __init__(self, board: BouffalolabBoard = BouffalolabBoard.BL706_IoT_DVK, enable_rpcs: bool = False, module_type: str = "BL706C-22", + baudrate=2000000, + enable_shell: bool = False ): bouffalo_chip = "bl702" if "BL70" in module_type else "bl602" @@ -83,7 +97,12 @@ def __init__(self, self.board = board self.argsOpt.append('board=\"{}\"'.format(self.board.GnArgName())) - self.argsOpt.append('module_type=\"{}\"'.format(module_type)) + self.argsOpt.append('baudrate=\"{}\"'.format(baudrate)) + + if bouffalo_chip == "bl702": + self.argsOpt.append('module_type=\"{}\"'.format(module_type)) + if enable_shell and not enable_rpcs: + self.argsOpt.append('chip_build_libshell=true') if enable_rpcs: self.argsOpt.append('import("//with_pw_rpc.gni")') diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index 8073f89ff0dfa6..90c216a9afb0f9 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -1,7 +1,6 @@ ameba-amebad-{all-clusters,all-clusters-minimal,light,pigweed} android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x86,androidstudio-x64}-{chip-tool,chip-test,tv-server,tv-casting-app,java-matter-controller} -bl602-light -bouffalolab-{bl706-iot-dvk,bl706-night-light}-light[-rpc] +bouffalolab-{bl602-iot-matter-v1,bl602-iot-dvk-3s,bl602-night-light,xt-zb6-devkit,bl706-iot-dvk,bl706-night-light}-light[-shell][-115200][-rpc] cc13x2x7_26x2x7-{all-clusters,all-clusters-minimal,lock,pump,pump-controller,shell}[-ftd][-mtd] cyw30739-cyw930739m2evb_01-{light,lock,ota-requestor}[-no-progress-logging] efr32-{brd4161a,brd4187c,brd4163a,brd4164a,brd4166a,brd4170a,brd4186a,brd4187a,brd4304a}-{window-covering,switch,unit-test,light,lock}[-rpc][-with-ota-requestor] diff --git a/scripts/examples/gn_bl602_example.sh b/scripts/examples/gn_bl602_example.sh deleted file mode 100755 index 9ae95a0a960d2d..00000000000000 --- a/scripts/examples/gn_bl602_example.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -# -# 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. -# - -set -e - -BL602_BOARD=BL-HWC-G1 - -# Build script for GN examples GitHub workflow. - -MATTER_ROOT=$(dirname "$(readlink -f "$0")")/../../ - -source "$(dirname "$0")/../../scripts/activate.sh" - -USAGE="./scripts/examples/gn_bl602_example.sh example_dir output_dir" - -if [ $# -lt 2 ]; then - echo "Usage: $USAGE" - exit 1 -fi - -EXAMPLE_DIR=examples/$1/bouffalolab/bl602/ -shift -OUTPUT_DIR=$1 -shift - -GN_ARGS=() - -NINJA_ARGS=() - -for arg; do - case $arg in - -v) - NINJA_ARGS+=(-v) - ;; - *=*) - GN_ARGS+=("$arg") - ;; - *import*) - GN_ARGS+=("$arg") - ;; - *) - echo >&2 "invalid argument: $arg" - exit 2 - ;; - esac -done - -gn gen --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="${GN_ARGS[*]} custom_toolchain=\"$MATTER_ROOT/examples/platform/bouffalolab/common/toolchain:riscv_gcc\"" - -ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}" diff --git a/scripts/examples/gn_bouffalolab_example.sh b/scripts/examples/gn_bouffalolab_example.sh index f04307607ba30b..a719563f38cb03 100755 --- a/scripts/examples/gn_bouffalolab_example.sh +++ b/scripts/examples/gn_bouffalolab_example.sh @@ -23,29 +23,23 @@ set -e MATTER_ROOT=$(dirname "$(readlink -f "$0")")/../../ source "$MATTER_ROOT/scripts/activate.sh" -# export BL_IOT_SDK_PATH=$MATTER_ROOT/third_party/bouffalolab/repo +bl602_boards=("BL602-IoT-Matter-V1" "BL602-NIGHT-LIGHT") +bl602_module_type="BL602" -# if [[ "$OSTYPE" == "linux-gnu"* ]]; then -# export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Linux/bin:$PATH" -# elif [[ "$OSTYPE" == "darwin"* ]]; then -# export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Darwin/bin:$PATH" -# fi - -bl702_boards=("BL706-IoT-DVK" "BL706-NIGHT-LIGHT") +bl702_boards=("XT-ZB6-DevKit" "BL706-IoT-DVK" "BL706-NIGHT-LIGHT") bl702_modules=("BL702" "BL706C-22") bl702_module_type="BL706C-22" print_help() { + bl602_boards_help="" + for board in "${bl602_boards[@]}"; do + bl602_boards_help=$bl602_boards_help$board"\n " + done bl702_boards_help="" for board in "${bl702_boards[@]}"; do bl702_boards_help=$bl702_boards_help$board"\n " done - bl702_modules_help="" - for module in "${bl702_modules[@]}"; do - bl702_modules_help=$bl702_modules_help$module"\n " - done - echo -e "Build script for Bouffalolab Matter examples Format: ./scripts/examples/gn_bouffalolab_example.sh [] @@ -59,6 +53,7 @@ print_help() { Identifier of the board for which this app is built Currently Supported : + $bl602_boards_help $bl702_boards_help - optional noteworthy build options for Bouffalolab IOT Matter examples chip_build_libshell @@ -80,8 +75,7 @@ print_help() { baudrate UART baudrate for log output and UART shell command, e.g, baudrate=2000000, by default. module_type - Bouffalolab chip module, e.g, module_type=\"BL706C-22\". Currently Supported: - $bl702_modules_help + Bouffalolab chip module. " } @@ -120,7 +114,14 @@ else shift done - if [[ "${bl702_boards[@]}" =~ "$board_name" ]]; then + if [[ "${bl602_boards[@]}" =~ "$board_name" ]]; then + bouffalo_chip="bl602" + + optArgs=board=\"$board_name\"" "$optArgs + optArgs=module_type=\"$bl602_module_type\"" "$optArgs + optArgs=baudrate=\"$baudrate\"" "$optArgs + + elif [[ "${bl702_boards[@]}" =~ "$board_name" ]]; then bouffalo_chip="bl702" optArgs=board=\"$board_name\"" "$optArgs diff --git a/scripts/flashing/bl602_firmware_utils.py b/scripts/flashing/bl602_firmware_utils.py deleted file mode 100755 index a07e7dbf51c3e2..00000000000000 --- a/scripts/flashing/bl602_firmware_utils.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env python3 -# 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. -"""Flash an BL602 device. - -This is layered so that a caller can perform individual operations -through an `Flasher` instance, or operations according to a command line. -For `Flasher`, see the class documentation. For the parse_command() -interface or standalone execution: - -usage: bl602_firmware_utils.py [-h] [--verbose] [--erase] [--application FILE] - [--verify_application] [--reset] [--skip_reset] - [--commander FILE] [--device DEVICE] - [--serialno SERIAL] - -Flash BL602 device - -optional arguments: - -h, --help show this help message and exit - -configuration: - --verbose, -v Report more verbosely - --commander FILE File name of the commander executable - --device DEVICE, -d DEVICE - Device family or platform to target - --serialno SERIAL, -s SERIAL - Serial number of device to flash - -operations: - --erase Erase device - --application FILE Flash an image - --verify_application, --verify-application - Verify the image after flashing - --reset Reset device after flashing - --skip_reset, --skip-reset - Do not reset device after flashing -""" - -import sys - -import firmware_utils - -# Additional options that can be use to configure an `Flasher` -# object (as dictionary keys) and/or passed as command line options. -BL602_OPTIONS = { - # Configuration options define properties used in flashing operations. - 'configuration': { - # Tool configuration options. - 'commander': { - 'help': 'File name of the commander executable', - 'default': 'commander', - 'argparse': { - 'metavar': 'FILE' - }, - 'verify': ['{commander}', '--version'], - 'error': - """\ - Unable to execute {commander}. - - Please ensure that this tool is installed and - available. See the BL602 example README for - installation instructions. - - """, - }, - 'device': { - 'help': 'Device family or platform to target', - 'default': 'BL602', - 'alias': ['-d'], - 'argparse': { - 'metavar': 'DEVICE' - }, - }, - 'serialno': { - 'help': 'Serial number of device to flash', - 'default': None, - 'alias': ['-s'], - 'argparse': { - 'metavar': 'SERIAL' - }, - }, - }, -} - - -class Flasher(firmware_utils.Flasher): - """Manage bl602 flashing.""" - - def __init__(self, **options): - super().__init__(platform='BL602', module=__name__, **options) - self.define_options(BL602_OPTIONS) - - # Common command line arguments for commander device subcommands. - DEVICE_ARGUMENTS = [{'optional': 'serialno'}, {'optional': 'device'}] - - def erase(self): - """Perform `commander device masserase`.""" - return self.run_tool( - 'commander', ['device', 'masserase', self.DEVICE_ARGUMENTS], - name='Erase device') - - def verify(self, image): - """Verify image.""" - return self.run_tool( - 'commander', - ['verify', self.DEVICE_ARGUMENTS, image], - name='Verify', - pass_message='Verified', - fail_message='Not verified', - fail_level=2) - - def flash(self, image): - """Flash image.""" - return self.run_tool( - 'commander', - ['flash', self.DEVICE_ARGUMENTS, image], - name='Flash') - - def reset(self): - """Reset the device.""" - return self.run_tool( - 'commander', - ['device', 'reset', self.DEVICE_ARGUMENTS], - name='Reset') - - def actions(self): - """Perform actions on the device according to self.option.""" - self.log(3, 'Options:', self.option) - - if self.option.erase: - if self.erase().err: - return self - - application = self.optional_file(self.option.application) - if application: - if self.flash(application).err: - return self - if self.option.verify_application: - if self.verify(application).err: - return self - if self.option.reset is None: - self.option.reset = True - - if self.option.reset: - if self.reset().err: - return self - - return self - - -if __name__ == '__main__': - sys.exit(Flasher().flash_command(sys.argv)) diff --git a/scripts/flashing/bouffalolab_firmware_utils.py b/scripts/flashing/bouffalolab_firmware_utils.py index 01473dcc04c3ba..9bbccde7621265 100644 --- a/scripts/flashing/bouffalolab_firmware_utils.py +++ b/scripts/flashing/bouffalolab_firmware_utils.py @@ -19,7 +19,8 @@ import pathlib import firmware_utils -from bflb_iot_tool.__main__ import run_main +import bflb_iot_tool +import bflb_iot_tool.__main__ # Additional options that can be use to configure an `Flasher` @@ -98,6 +99,28 @@ def __init__(self, **options): super().__init__(platform=None, module=__name__, **options) self.define_options(BOUFFALO_OPTIONS) + def get_boot_image(self, config_path): + + boot_image_guess = None + + for root, dirs, files in os.walk(config_path, topdown=False): + for name in files: + if name == "boot2_isp_release.bin": + return os.path.join(root, name) + elif not boot_image_guess and name.find("release") >= 0: + boot_image_guess = os.path.join(root, name) + + return boot_image_guess + + def get_dts_file(self, config_path, xtal_value): + + for root, dirs, files in os.walk(config_path, topdown=False): + for name in files: + if name.find(xtal_value) >= 0: + return os.path.join(config_path, name) + + return None + def verify(self): """Not supported""" self.log(0, "Verification is done after image flashed.") @@ -110,6 +133,8 @@ def actions(self): """Perform actions on the device according to self.option.""" self.log(3, 'Options:', self.option) + tool_path = os.path.dirname(bflb_iot_tool.__file__) + options_keys = BOUFFALO_OPTIONS["configuration"].keys() arguments = [__file__] work_dir = None @@ -121,6 +146,12 @@ def actions(self): if self.option.verify_application: self.verify() + chip_name = None + chip_config_path = None + boot_image = None + dts_path = None + xtal_value = None + command_args = {} for (key, value) in dict(vars(self.option)).items(): @@ -147,20 +178,45 @@ def actions(self): else: arg = ("--{}={}".format(key, value)).strip() + if key == "chipname": + chip_name = value + elif key == "xtal": + xtal_value = value + elif key == "dts": + dts_path = value + arguments.append(arg) + print(key, value) + + print(dts_path, xtal_value) + if not dts_path and xtal_value: + chip_config_path = os.path.join(tool_path, "chips", chip_name, "device_tree") + dts_path = self.get_dts_file(chip_config_path, xtal_value) + arguments.append("--dts") + arguments.append(dts_path) + if self.option.erase: arguments.append("--erase") + if chip_name == "bl602": + chip_config_path = os.path.join(tool_path, "chips", chip_name, "builtin_imgs") + boot_image = self.get_boot_image(chip_config_path) + arguments.append("--boot2") + arguments.append(boot_image) + os.chdir(work_dir) arguments[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', arguments[0]) sys.argv = arguments - run_main() + print("arguments", arguments) + bflb_iot_tool.__main__.run_main() return self if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(Flasher().flash_command(sys.argv)) diff --git a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp index 73a96a90a6e853..be9d29619aae4f 100644 --- a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp @@ -48,6 +48,9 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) { CHIP_ERROR err = CHIP_NO_ERROR; + ot_alarmInit(); + ot_radioInit(); + // Initialize the generic implementation base classes. err = GenericThreadStackManagerImpl_FreeRTOS::DoInit(); SuccessOrExit(err); diff --git a/src/platform/bouffalolab/BL702/bl702Config.cpp b/src/platform/bouffalolab/BL702/bl702Config.cpp index 0c51dd6d9afbbc..809ed940e9d6c4 100644 --- a/src/platform/bouffalolab/BL702/bl702Config.cpp +++ b/src/platform/bouffalolab/BL702/bl702Config.cpp @@ -207,23 +207,10 @@ CHIP_ERROR BL702Config::ReadKVS(const char * key, void * value, size_t value_siz ef_port_env_lock(); - char * p = (char *) malloc((sizeof(KCONFIG_SECT_KVS) + strlen(key) + sizeof(size_t))); - if (!p) - { - ef_port_env_unlock(); - return CHIP_ERROR_NO_MEMORY; - } - - memcpy(p, KCONFIG_SECT_KVS, sizeof(KCONFIG_SECT_KVS) - 1); - p[sizeof(KCONFIG_SECT_KVS) - 1] = '_'; - strcpy(p + sizeof(KCONFIG_SECT_KVS), key); - - if (true == ef_get_env_obj(p, &node)) + if (true == ef_get_env_obj(key, &node)) { - if (offset_bytes > node.value_len) { - free(p); ef_port_env_unlock(); return CHIP_ERROR_INVALID_ARGUMENT; } @@ -256,13 +243,11 @@ CHIP_ERROR BL702Config::ReadKVS(const char * key, void * value, size_t value_siz } } - free(p); ef_port_env_unlock(); return CHIP_NO_ERROR; } - free(p); ef_port_env_unlock(); return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; @@ -274,23 +259,11 @@ CHIP_ERROR BL702Config::WriteKVS(const char * key, const void * value, size_t va ef_port_env_lock(); - char * p = (char *) malloc((sizeof(KCONFIG_SECT_KVS) + strlen(key) + sizeof(size_t))); - if (!p) - { - ef_port_env_unlock(); - return CHIP_ERROR_NO_MEMORY; - } - - memcpy(p, KCONFIG_SECT_KVS, sizeof(KCONFIG_SECT_KVS) - 1); - p[sizeof(KCONFIG_SECT_KVS) - 1] = '_'; - strcpy(p + sizeof(KCONFIG_SECT_KVS), key); - if (value && value_size) { - ret = ef_set_env_blob(p, value, value_size); + ret = ef_set_env_blob(key, value, value_size); } - free(p); ef_port_env_unlock(); if (ret == EF_NO_ERR) @@ -307,20 +280,8 @@ CHIP_ERROR BL702Config::ClearKVS(const char * key) { ef_port_env_lock(); - char * p = (char *) malloc((sizeof(KCONFIG_SECT_KVS) + strlen(key) + sizeof(size_t))); - if (!p) - { - ef_port_env_unlock(); - return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; - } - - memcpy(p, KCONFIG_SECT_KVS, sizeof(KCONFIG_SECT_KVS) - 1); - p[sizeof(KCONFIG_SECT_KVS) - 1] = '_'; - strcpy(p + sizeof(KCONFIG_SECT_KVS), key); - - ef_del_env(p); + ef_del_env(key); - free(p); ef_port_env_unlock(); return CHIP_NO_ERROR; diff --git a/src/platform/bouffalolab/BL702/bl702Config.h b/src/platform/bouffalolab/BL702/bl702Config.h index 967dfcdfcf8aa7..dc9450f4986c61 100644 --- a/src/platform/bouffalolab/BL702/bl702Config.h +++ b/src/platform/bouffalolab/BL702/bl702Config.h @@ -25,13 +25,7 @@ namespace chip { namespace DeviceLayer { namespace Internal { -#define KCONFIG_SECT_FACTORY "chip-factory" -#define KCONFIG_SECT_CONFIG "chip-config" -#define KCONFIG_SECT_COUTNER "chip-counter" -#define KCONFIG_SECT_KVS "chip-kvs" -#define KCONFIG_SECT_PSV "chip-psv" -#define KCONFIG_MAX_LEN sizeof(KCONFIG_SECT_FACTORY) - +#define KCONFIG_SECT_PSV "PSV" /** * Provides functions and definitions for accessing device configuration information on the BL702 platform. * @@ -45,41 +39,41 @@ class BL702Config /** Key definitions for well-known keys */ /** Manufacturing config keys, which should be saved in a specified place */ - static constexpr const char * kConfigKey_SerialNum = (KCONFIG_SECT_FACTORY "_serial-num"); - static constexpr const char * kConfigKey_MfrDeviceId = (KCONFIG_SECT_FACTORY "_device-id"); - static constexpr const char * kConfigKey_MfrDeviceCert = (KCONFIG_SECT_FACTORY "_device-cert"); - static constexpr const char * kConfigKey_MfrDeviceICACerts = (KCONFIG_SECT_FACTORY "_device-ca-certs"); - static constexpr const char * kConfigKey_MfrDevicePrivateKey = (KCONFIG_SECT_FACTORY "_device-key"); - static constexpr const char * kConfigKey_ManufacturingDate = (KCONFIG_SECT_FACTORY "_mfg-date"); - static constexpr const char * kConfigKey_SetupPinCode = (KCONFIG_SECT_FACTORY "_pin-code"); - static constexpr const char * kConfigKey_SetupDiscriminator = (KCONFIG_SECT_FACTORY "_discriminator"); - static constexpr const char * kConfigKey_Spake2pIterationCount = (KCONFIG_SECT_FACTORY "_iteration-count"); - static constexpr const char * kConfigKey_Spake2pSalt = (KCONFIG_SECT_FACTORY "_salt"); - static constexpr const char * kConfigKey_Spake2pVerifier = (KCONFIG_SECT_FACTORY "_verifier"); - static constexpr const char * kConfigKey_UniqueId = (KCONFIG_SECT_FACTORY "_unique-id"); + static constexpr const char * kConfigKey_SerialNum = ("serial-num"); + static constexpr const char * kConfigKey_MfrDeviceId = ("device-id"); + static constexpr const char * kConfigKey_MfrDeviceCert = ("device-cert"); + static constexpr const char * kConfigKey_MfrDeviceICACerts = ("device-ca-certs"); + static constexpr const char * kConfigKey_MfrDevicePrivateKey = ("device-key"); + static constexpr const char * kConfigKey_ManufacturingDate = ("mfg-date"); + static constexpr const char * kConfigKey_SetupPinCode = ("pin-code"); + static constexpr const char * kConfigKey_SetupDiscriminator = ("discriminator"); + static constexpr const char * kConfigKey_Spake2pIterationCount = ("iteration-count"); + static constexpr const char * kConfigKey_Spake2pSalt = ("salt"); + static constexpr const char * kConfigKey_Spake2pVerifier = ("verifier"); + static constexpr const char * kConfigKey_UniqueId = ("unique-id"); /** Config keys, which should be droped after a factory reset */ - static constexpr const char * kConfigKey_FabricId = (KCONFIG_SECT_CONFIG "_fabric-id"); - static constexpr const char * kConfigKey_ServiceConfig = (KCONFIG_SECT_CONFIG "_service-config"); - static constexpr const char * kConfigKey_PairedAccountId = (KCONFIG_SECT_CONFIG "_account-id"); - static constexpr const char * kConfigKey_ServiceId = (KCONFIG_SECT_CONFIG "_service-id"); - static constexpr const char * kConfigKey_FabricSecret = (KCONFIG_SECT_CONFIG "_fabric-secret"); - static constexpr const char * kConfigKey_HardwareVersion = (KCONFIG_SECT_CONFIG "_hardware-rev"); - static constexpr const char * kConfigKey_LastUsedEpochKeyId = (KCONFIG_SECT_CONFIG "_last-ek-id"); - static constexpr const char * kConfigKey_FailSafeArmed = (KCONFIG_SECT_CONFIG "_fail-safe-armed"); - static constexpr const char * kConfigKey_WiFiStationSecType = (KCONFIG_SECT_CONFIG "_sta-sec-type"); - static constexpr const char * kConfigKey_RegulatoryLocation = (KCONFIG_SECT_CONFIG "_regulatory-location"); - static constexpr const char * kConfigKey_CountryCode = (KCONFIG_SECT_CONFIG "_country-code"); - static constexpr const char * kConfigKey_ActiveLocale = (KCONFIG_SECT_CONFIG "_active-locale"); - static constexpr const char * kConfigKey_Breadcrumb = (KCONFIG_SECT_CONFIG "_breadcrumb"); - static constexpr const char * kConfigKey_GroupKeyIndex = (KCONFIG_SECT_CONFIG "_group-key-index"); - static constexpr const char * kBLConfigKey_wifissid = (KCONFIG_SECT_CONFIG "blConfig_wifi-ssid"); - static constexpr const char * kBLConfigKey_wifipassword = (KCONFIG_SECT_CONFIG "blConfig_wifi-pwd"); + static constexpr const char * kConfigKey_FabricId = ("fabric-id"); + static constexpr const char * kConfigKey_ServiceConfig = ("service-config"); + static constexpr const char * kConfigKey_PairedAccountId = ("account-id"); + static constexpr const char * kConfigKey_ServiceId = ("service-id"); + static constexpr const char * kConfigKey_FabricSecret = ("fabric-secret"); + static constexpr const char * kConfigKey_HardwareVersion = ("hardware-rev"); + static constexpr const char * kConfigKey_LastUsedEpochKeyId = ("last-ek-id"); + static constexpr const char * kConfigKey_FailSafeArmed = ("fail-safe-armed"); + static constexpr const char * kConfigKey_WiFiStationSecType = ("sta-sec-type"); + static constexpr const char * kConfigKey_RegulatoryLocation = ("regulatory-location"); + static constexpr const char * kConfigKey_CountryCode = ("country-code"); + static constexpr const char * kConfigKey_ActiveLocale = ("active-locale"); + static constexpr const char * kConfigKey_Breadcrumb = ("breadcrumb"); + static constexpr const char * kConfigKey_GroupKeyIndex = ("group-key-index"); + static constexpr const char * kBLConfigKey_wifissid = ("blConfig_wifi-ssid"); + static constexpr const char * kBLConfigKey_wifipassword = ("blConfig_wifi-pwd"); /** Counter Keys, diagnostic information */ - static constexpr const char * kCounterKey_BootCount = (KCONFIG_SECT_COUTNER "_boot-count"); - static constexpr const char * kCounterKey_TotalOperationalHours = (KCONFIG_SECT_COUTNER "_total-hours"); - static constexpr const char * kCounterKey_UpTime = (KCONFIG_SECT_COUTNER "_up-time"); + static constexpr const char * kCounterKey_BootCount = ("boot-count"); + static constexpr const char * kCounterKey_TotalOperationalHours = ("total-hours"); + static constexpr const char * kCounterKey_UpTime = ("up-time"); static CHIP_ERROR Init(void); diff --git a/third_party/bouffalolab/bl602/bl602_executable.gni b/third_party/bouffalolab/bl602/bl602_executable.gni index 8f775f6292ccbc..b2e6ae85485ae4 100644 --- a/third_party/bouffalolab/bl602/bl602_executable.gni +++ b/third_party/bouffalolab/bl602/bl602_executable.gni @@ -23,6 +23,7 @@ template("bl602_executable") { objcopy_image_name = output_base_name + ".bin" objcopy_image_format = "binary" + objcopy = "riscv64-unknown-elf-objcopy" if ("linux" == host_os) { objcopy = @@ -36,11 +37,13 @@ template("bl602_executable") { # is collectively self-contained; this allows flashing to work reliably # even if the build and flashing steps take place on different machines # or in different containers. - flashing_runtime_target = target_name + ".flashing_runtime" flashing_script_inputs = [ + "${chip_root}/scripts/flashing/bouffalolab_firmware_utils.py", "${chip_root}/scripts/flashing/firmware_utils.py", - "${chip_root}/scripts/flashing/bl602_firmware_utils.py", + + "${chip_root}/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml", + "${chip_root}/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml", ] copy(flashing_runtime_target) { sources = flashing_script_inputs @@ -50,7 +53,27 @@ template("bl602_executable") { flashing_script_generator = "${chip_root}/scripts/flashing/gen_flashing_script.py" flashing_script_name = output_base_name + ".flash.py" - flashing_options = [ "bl602" ] + flashing_options = [ "bouffalolab" ] + flashing_options += [ "--chipname" ] + flashing_options += [ "bl602" ] + flashing_options += [ "--xtal" ] + flashing_options += [ "40M" ] + flashing_options += [ "--pt" ] + + if (invoker.board == "BL602-IOT-DVK-3S") { + flashing_options += + [ rebase_path("partition_cfg_2M.toml", root_out_dir, root_out_dir) ] + } else { + flashing_options += + [ rebase_path("partition_cfg_4M.toml", root_out_dir, root_out_dir) ] + } + + flashing_options += [ "--ota" ] + flashing_options += [ "ota_images/" ] + + # set 2000000 baudrate for image download by default + flashing_options += [ "--baudrate" ] + flashing_options += [ "2000000" ] flashable_executable(target_name) { forward_variables_from(invoker, "*") diff --git a/third_party/bouffalolab/bl602/portable/bfl_main.c b/third_party/bouffalolab/bl602/portable/bfl_main.c index 9bb2f4c9ed986f..e199a0963ddb5f 100644 --- a/third_party/bouffalolab/bl602/portable/bfl_main.c +++ b/third_party/bouffalolab/bl602/portable/bfl_main.c @@ -35,7 +35,7 @@ #include #endif -HOSAL_UART_DEV_DECL(uart_stdio, 0, 16, 7, 115200); +HOSAL_UART_DEV_DECL(uart_stdio, 0, 16, 7, CHIP_UART_BAUDRATE); extern uint8_t _heap_start; extern uint8_t _heap_size; // @suppress("Type cannot be resolved") diff --git a/third_party/bouffalolab/bl702/bl702_executable.gni b/third_party/bouffalolab/bl702/bl702_executable.gni index 7fa34fa759a46a..8d72c59b48acf7 100644 --- a/third_party/bouffalolab/bl702/bl702_executable.gni +++ b/third_party/bouffalolab/bl702/bl702_executable.gni @@ -42,7 +42,6 @@ template("bl702_executable") { "${chip_root}/scripts/flashing/bouffalolab_firmware_utils.py", "${chip_root}/scripts/flashing/firmware_utils.py", - "${chip_root}/examples/platform/bouffalolab/bl702/flash_config/bl_factory_params_IoTKitA_32M.dts", "${chip_root}/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml", ] copy(flashing_runtime_target) { @@ -61,10 +60,6 @@ template("bl702_executable") { flashing_options += [ "--pt" ] flashing_options += [ rebase_path("partition_cfg_2M.toml", root_out_dir, root_out_dir) ] - flashing_options += [ "--dts" ] - flashing_options += [ rebase_path("bl_factory_params_IoTKitA_32M.dts", - root_out_dir, - root_out_dir) ] flashing_options += [ "--ota" ] flashing_options += [ "ota_images/" ] diff --git a/third_party/bouffalolab/repo b/third_party/bouffalolab/repo index 9563086f233769..dc526317d2903c 160000 --- a/third_party/bouffalolab/repo +++ b/third_party/bouffalolab/repo @@ -1 +1 @@ -Subproject commit 9563086f233769db0163163307272f739d969cca +Subproject commit dc526317d2903c4d3a8466226983ce34dc8f23d1