From d845f1fdc42761aca1c489368cc784f4f657f2bd Mon Sep 17 00:00:00 2001 From: Haiwen Xia Date: Tue, 17 Dec 2024 17:13:09 +0800 Subject: [PATCH] riscv: telink: add dual mode for b92 and buteo and CI. - clean the boot flag in init part . - add the kDnsstimer to protect from init to dnss . - add special proc for ikea. - add the user-para proc in matter. - add 2m flash for buteo ,and 4m for b92. - update CI for b92 and tl3218x . - fix the switch logic part . Signed-off-by: Haiwen Xia --- .github/workflows/chef.yaml | 6 +- .github/workflows/examples-telink.yaml | 237 +----------------- config/telink/app/bootloader.conf | 6 +- config/telink/chip-module/Kconfig.defaults | 5 + examples/chef/chef.py | 2 +- examples/lighting-app/telink/src/AppTask.cpp | 8 + .../telink/common/include/AppTaskCommon.h | 26 ++ .../telink/common/src/AppTaskCommon.cpp | 70 ++++++ .../telink/zephyr_ext/zephyr_pwm_pool.c | 3 +- src/platform/telink/tl3218x_2m_flash.overlay | 56 +++-- src/platform/telink/tlsr9528a.overlay | 8 +- .../telink/tlsr9528a_4m_flash.overlay | 59 ++++- 12 files changed, 215 insertions(+), 271 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index c897952d45107c..f0417475e222a7 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -109,9 +109,9 @@ jobs: uses: ./.github/actions/checkout-submodules-and-bootstrap with: platform: telink - # - name: Update Zephyr to specific revision (for developers purpose) - # shell: bash - # run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 8b29ee6b118ebe6eeec3224dbe343474e11403d8" + - name: Update Zephyr to specific revision (for developers purpose) + shell: bash + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py d11c4e0b8c816b4d15b13c6736ec49b9a99618de" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 1b6fd20aa72260..8deca79657a578 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -57,77 +57,8 @@ jobs: with: gh-context: ${{ toJson(github) }} - # - name: Update Zephyr to specific revision (for developers purpose) - # run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 8b29ee6b118ebe6eeec3224dbe343474e11403d8" - - - name: Build example Telink (B92 retention) Air Quality Sensor App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-air-quality-sensor' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a_retention air-quality-sensor-app \ - out/telink-tlsr9528a_retention-air-quality-sensor/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (W91) All Clusters App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - continue-on-error: true - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-all-clusters' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9118bdk40d all-clusters-app \ - out/telink-tlsr9118bdk40d-all-clusters/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92) All Clusters Minimal App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a-all-clusters-minimal' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a all-clusters-minimal-app \ - out/telink-tlsr9528a-all-clusters-minimal/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B95) Bridge App - # Run test for master and all PRs - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9258a-bridge' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9258a bridge-app \ - out/telink-tlsr9258a-bridge/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92 retention) Contact Sensor App - # Run test for master and all PRs - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-contact-sensor' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a_retention contact-sensor-app \ - out/telink-tlsr9528a_retention-contact-sensor/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out + - name: Update Zephyr to specific revision (for developers purpose) + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py d11c4e0b8c816b4d15b13c6736ec49b9a99618de" - name: Build tools required for Factory Data # Run test for master and all PRs @@ -140,33 +71,6 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (W91) Lighting App with OTA, Factory Data - # Run test for master and all PRs - continue-on-error: true - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-light-ota-factory-data' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9118bdk40d lighting-app-ota-factory-data \ - out/telink-tlsr9118bdk40d-light-ota-factory-data/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output (keep tools) - run: rm -rf ./out/telink* - - - name: Build example Telink (B91) Lighting App with OTA, RPC, Factory Data and 4Mb flash - # Run test for master and all PRs - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-light-ota-rpc-factory-data-4mb' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d lighting-app-ota-rpc-factory-data-4mb \ - out/telink-tlsr9518adk80d-light-ota-rpc-factory-data-4mb/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output (keep tools) - run: rm -rf ./out/telink* - - name: Build example Telink (tl321x) Lighting App with OTA (LZMA), Shell, Factory Data # Run test for master and all PRs run: | @@ -180,144 +84,17 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (B92) Light Switch App with OTA (LZMA), Shell, Factory Data + - name: Build example Telink (B92) Lighting App with OTA, Shell, Factory Data # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a-light-switch-ota-compress-lzma-shell-factory-data' build" + "./scripts/build/build_examples.py --target 'telink-tlsr9528a-light-ota-4mb-shell-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a light-switch-app-ota-compress-lzma-shell-factory-data \ - out/telink-tlsr9528a-light-switch-ota-compress-lzma-shell-factory-data/zephyr/zephyr.elf \ + telink tlsr9528a light-app-ota-4mb-shell-factory-data \ + out/telink-tlsr9528a-light-ota-4mb-shell-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92) Lock App with DFU - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a-lock-dfu' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a lock-app-dfu \ - out/telink-tlsr9528a-lock-dfu/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B95) OTA Requestor App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9258a-ota-requestor' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9258a ota-requestor-app \ - out/telink-tlsr9258a-ota-requestor/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91 USB) Pump App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-pump-usb' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d pump-app-usb \ - out/telink-tlsr9518adk80d-pump-usb/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91) Pump Controller App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-pump-controller' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d pump-controller-app \ - out/telink-tlsr9518adk80d-pump-controller/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91) Shell App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-shell' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d shell \ - out/telink-tlsr9518adk80d-shell/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92 retention) Smoke CO Alarm App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-smoke-co-alarm' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a_retention smoke_co_alarm-app \ - out/telink-tlsr9528a_retention-smoke-co-alarm/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91 Mars) Temperature Measurement App with OTA - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-temperature-measurement-mars-ota' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d temperature-measurement-app-mars-ota \ - out/telink-tlsr9518adk80d-temperature-measurement-mars-ota/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91) Thermostat App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-thermostat' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d thermostat \ - out/telink-tlsr9518adk80d-thermostat/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (W91) Window Covering App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - continue-on-error: true - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-window-covering' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9118bdk40d window-covering \ - out/telink-tlsr9118bdk40d-window-covering/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output + - name: clean out build output (keep tools) run: rm -rf ./out - name: Uploading Size Reports diff --git a/config/telink/app/bootloader.conf b/config/telink/app/bootloader.conf index 0ffacc8c0b052b..441a83cda1c6c1 100644 --- a/config/telink/app/bootloader.conf +++ b/config/telink/app/bootloader.conf @@ -14,9 +14,9 @@ # limitations under the License. # -# Enable this option in case if restoring the slot0 partition is expected from slot1 +# Enable this option in case if restoring the slot0 partition is expected from slot1 # partition in case if slot0 is not bootable or damaged -CONFIG_BOOT_BOOTSTRAP=y +CONFIG_BOOT_BOOTSTRAP=n # Enable this option in case if SWAP_MOVE logic need to be used CONFIG_BOOT_SWAP_USING_MOVE=y @@ -27,7 +27,7 @@ CONFIG_BOOT_SWAP_USING_SCRATCH=n # Enable this option in case if the whole slot0 image need to be validated # With disabled option the only image magic is validated -CONFIG_BOOT_VALIDATE_SLOT0=y +CONFIG_BOOT_VALIDATE_SLOT0=n # Maximum number of image sectors supported by the bootloader. # Maximum signed image size: 512 * 4096 = 2M Bytes diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 3503aae4000f06..f9f32a06f864b7 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -260,6 +260,11 @@ config NVS_LOOKUP_CACHE_SIZE default 400 if SOC_RISCV_TELINK_TL321X default 2048 if !PM +config COMPRESS_LZMA + depends on CHIP_OTA_REQUESTOR + default y if SOC_RISCV_TELINK_TL321X + default n + # Set multiplicator of Name Value Storage (NVS) as 1 to reach NVS sector size 4KB # nvs_sector_size = flash_page_size * mult = 4KB * 1 = 4KB config SETTINGS_NVS_SECTOR_SIZE_MULT diff --git a/examples/chef/chef.py b/examples/chef/chef.py index 8c54ee8dbbc6fb..cba18ff18de2e8 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -798,7 +798,7 @@ def main() -> int: shell.run_cmd("make is") elif options.build_target == "telink": shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/telink") - telink_build_cmds = ["west build -b tlsr9518adk80d"] + telink_build_cmds = ["west build -b tl3218x"] if options.do_clean: telink_build_cmds.append("-p always") if options.do_rpc: diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index 9e419150712c3c..0f35734e043e68 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -60,6 +60,14 @@ CHIP_ERROR AppTask::Init(void) SetExampleButtonCallbacks(LightingActionEventHandler); InitCommonParts(); + if(sBoot_zb){ + /* Switch from the touch link, need to restore previous values */ + sfixture_on = user_para.onoff; + sBrightness = user_para.lightness; + sAppTask.UpdateClusterState(); + printk("Matter: Updated ZB On/Off state and brightness.\n"); + } + Protocols::InteractionModel::Status status; app::DataModel::Nullable brightness; diff --git a/examples/platform/telink/common/include/AppTaskCommon.h b/examples/platform/telink/common/include/AppTaskCommon.h index ac10ef587d2be9..828a527e792285 100644 --- a/examples/platform/telink/common/include/AppTaskCommon.h +++ b/examples/platform/telink/common/include/AppTaskCommon.h @@ -37,6 +37,31 @@ #include +#include +#include +#include +#include + +#define USER_INIT_VAL 0xff +#define USER_ZB_SW_VAL 0xaa +#define USER_MATTER_PAIR_VAL 0x55 +#define USER_PARA_MAC_OFFSET 0x100 +#define USER_PARTITION user_para_partition +#define USER_PARTITION_DEVICE FIXED_PARTITION_DEVICE(USER_PARTITION) +#define USER_PARTITION_OFFSET FIXED_PARTITION_OFFSET(USER_PARTITION) +#define USER_PARTITION_SIZE FIXED_PARTITION_SIZE(USER_PARTITION) + +typedef struct{ + uint8_t val ; + uint8_t rfu; + uint8_t onoff; + uint8_t lightness; +}user_para_t; + +extern user_para_t user_para; +extern uint8_t para_lightness; +extern uint8_t sBoot_zb; + #include using namespace ::chip; @@ -97,6 +122,7 @@ class AppTaskCommon virtual void LinkButtons(ButtonManager & buttonManager); static void FactoryResetTimerTimeoutCallback(k_timer * timer); + static void DnssTimerTimeoutCallback(k_timer * timer); static void FactoryResetTimerEventHandler(AppEvent * aEvent); static void FactoryResetButtonEventHandler(void); static void FactoryResetHandler(AppEvent * aEvent); diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 479e746a4aac62..3ad4f80d6852e9 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -51,6 +51,10 @@ #include #include +uint8_t sBoot_zb = 0; +user_para_t user_para; +uint8_t para_lightness = 0; + using namespace chip::app; LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); @@ -59,6 +63,9 @@ namespace { constexpr int kFactoryResetCalcTimeout = 3000; constexpr int kFactoryResetTriggerCntr = 3; constexpr int kAppEventQueueSize = 10; +const struct device * flash_para_dev = USER_PARTITION_DEVICE; +constexpr int kDnssTimeout = 60000; +k_timer sDnssTimer; constexpr uint32_t kIdentifyBlinkRateMs = 200; constexpr uint32_t kIdentifyOkayOnRateMs = 50; @@ -127,6 +134,12 @@ class AppCallbacks : public AppDelegate AppCallbacks sCallbacks; } // namespace +void FactoryResetExtHandler(void) +{ + // Erase the user parameters partition to reset mode settings + flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE); +} + class AppFabricTableDelegate : public FabricTable::Delegate { void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) @@ -160,6 +173,10 @@ class AppFabricTableDelegate : public FabricTable::Delegate { ChipLogError(DeviceLayer, "Storage clearance failed: %d", status); } + + printk("Erasing user parameters and resetting to Zigbee mode"); + FactoryResetExtHandler(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } } @@ -207,8 +224,36 @@ void AppTaskCommon::PowerOnFactoryReset(void) } #endif /* CONFIG_CHIP_ENABLE_POWER_ON_FACTORY_RESET */ +void AppTaskCommon::DnssTimerTimeoutCallback(k_timer * timer) +{ + if (!timer){ + return; + } + /*If initialization of Dnss takes longer than 60 seconds, the device will reboot and revert to Zigbee mode*/ + printk("Matter: DnssTimer expired.\r\n"); + sys_reboot(0); +} + CHIP_ERROR AppTaskCommon::StartApp(void) { + /* Proc ota boot flag , and erase flag */ + flash_read(flash_para_dev, USER_PARTITION_OFFSET, &user_para, sizeof(user_para)); + /* Boot from Zigbee , need to clean the user parameters sector first and set a flag */ + if (user_para.val == USER_ZB_SW_VAL){ + sBoot_zb = 1; + /* Ensure lightness is at least 2 to avoid display error on HomePod Mini */ + if(user_para.lightness < 2){ + user_para.lightness = 2; + } + /* Pass the value to the init part to avoid gaps in pwm_pool init */ + if(user_para.onoff){ + para_lightness = user_para.lightness; + } + k_timer_init(&sDnssTimer, &AppTask::DnssTimerTimeoutCallback, nullptr); + k_timer_start(&sDnssTimer, K_MSEC(kDnssTimeout), K_NO_WAIT); + printk("Matter: start timer to protect Dnss initialized %x \r\n",*(int *)(&user_para)); + } + CHIP_ERROR err = GetAppTask().Init(); if (err != CHIP_NO_ERROR) @@ -590,6 +635,8 @@ void AppTaskCommon::FactoryResetHandler(AppEvent * aEvent) k_timer_stop(&sFactoryResetTimer); sFactoryResetCntr = 0; + printk("Factory reset triggered by button, resetting to Zigbee mode"); + FactoryResetExtHandler(); chip::Server::GetInstance().ScheduleFactoryReset(); } } @@ -747,6 +794,25 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* } #endif break; + + case DeviceEventType::kCommissioningComplete: + { + uint8_t val = USER_MATTER_PAIR_VAL; + flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE); + flash_write(flash_para_dev, USER_PARTITION_OFFSET, &val, 1); + printk("Commissioning complete, set Matter commissionined flag"); + } + break; + case DeviceEventType::kFailSafeTimerExpired: + /* Reset to Zigbee mode if commissioning fails */ + if (sBoot_zb){ + printk("FailSafeTimer expired, Matter commissioning failed, rebooting to Zigbee mode.\r\n"); + sys_reboot(0); + }else{ + printk("FailSafeTimer expired, Matter commissioning failed.\r\n"); + } + break; + #if CHIP_DEVICE_CONFIG_ENABLE_THREAD case DeviceEventType::kDnssdInitialized: #if CONFIG_CHIP_OTA_REQUESTOR @@ -760,6 +826,10 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* #if CONFIG_CHIP_OTA_REQUESTOR } #endif + if(sBoot_zb){ + k_timer_stop(&sDnssTimer); + printk("Dnss Timer stopped, Matter commissioning kDnssdInitialized.\r\n"); + } break; case DeviceEventType::kThreadStateChange: sIsNetworkProvisioned = ConnectivityMgr().IsThreadProvisioned(); diff --git a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c index 3f1651844f1cec..f665f70b98da04 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c @@ -175,7 +175,8 @@ bool pwm_pool_init(struct pwm_pool_data * pwm_pool) /* init all PWMs are ready */ for (size_t i = 0; i < pwm_pool->out_len; i++) { - if (pwm_set_dt(&pwm_pool->out[i], pwm_pool->out[i].period, 0)) + extern unsigned char para_lightness ; + if (pwm_set_dt(&pwm_pool->out[i], pwm_pool->out[i].period, para_lightness*pwm_pool->out[i].period/255)) { result = false; break; diff --git a/src/platform/telink/tl3218x_2m_flash.overlay b/src/platform/telink/tl3218x_2m_flash.overlay index 53114e6ac6054d..3ecedd05659b2d 100644 --- a/src/platform/telink/tl3218x_2m_flash.overlay +++ b/src/platform/telink/tl3218x_2m_flash.overlay @@ -9,31 +9,55 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x13000>; + reg = <0x00000000 0x12000>;// bootloader should use the size optimize to low down to 72k,reserve 4k for user. }; - slot0_partition: partition@13000 { + slot0_partition: partition@10000 { label = "image-0"; - reg = <0x13000 0xef000>; + reg = <0x12000 0x122000>;// 0x10000 is matter, and reserve 912k for matter , 0xF6000 is zb reserve 248k for zigbee }; - factory_partition: partition@102000 { - label = "factory-data"; - reg = <0x102000 0x800>; - }; - factory_rfu_partition: partition@102800 { - label = "factory-data-rfu"; - reg = <0x102800 0x800>; + slot1_partition: partition@134000 { + label = "image-1"; + reg = <0x134000 0xb2000>;// the slot1 is use LZMA to save binsize . (920k + 248k)*60% = 712k, zb nvs will locate here }; - storage_partition: partition@103000 { + storage_partition: partition@1e6000 { label = "storage"; - reg = <0x103000 0xc000>; + reg = <0x1e6000 0xb000>; // matter nvs part }; - slot1_partition: partition@10f000 { - label = "image-1"; - reg = <0x10f000 0xef000>; + user_token_partition: partition@1f1000 { + label = "user-token"; + reg = <0x1f1000 0x1000>; //user:store token info, if don't use ,can delete + }; + user_para_partition: partition@1f2000 { + label = "user-para"; + reg = <0x1f2000 0x1000>; //user:store the mode info and the key info part. + }; + user_cluster_partition: partition@1f3000 { + label = "user-cluster"; + reg = <0x1f3000 0x1000>; //user_cluster: reserve 4k for user storage cluster para. proc transition part + }; + stack_extend_partition: partition@1f4000 { + label = "stack_extend"; + reg = <0x1f4000 0x4000>; //reserved for matter stack extend proc,reserve 16k for extend. + }; + secure_partition: partition@1f8000 { + label = "secure"; + reg = <0x1f8000 0x1000>; //secure info ,reserved for secure boot .if not use , can beused by other way . + }; + factory_partition: partition@1f9000 { + label = "factory-data"; + reg = <0x1f9000 0x1000>; // factory data info and dac info + }; + dac_keypair_partition: partition@1f9800 { + label = "dac-keypair"; + reg = <0x1f9800 0x800>; //store dac and key pair. }; + user_rfu_partition: partition@1fa000 { + label = "user_rfu"; + reg = <0x1fa000 0x4000>; //user_rfu: reserve 16k for user extend. + }; vendor_partition: partition@1fe000 { label = "vendor-data"; - reg = <0x1fe000 0x2000>; + reg = <0x1fe000 0x2000>;// mac and adc info. }; }; }; diff --git a/src/platform/telink/tlsr9528a.overlay b/src/platform/telink/tlsr9528a.overlay index fcd51928576ecf..d80b61f12434cf 100644 --- a/src/platform/telink/tlsr9528a.overlay +++ b/src/platform/telink/tlsr9528a.overlay @@ -34,9 +34,10 @@ pwm_pool { compatible = "pwm-leds"; out { - pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>, - <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>, - <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + pwms = <&pwm0 2 PWM_MSEC(1) PWM_POLARITY_NORMAL>, + <&pwm0 0 PWM_MSEC(1) PWM_POLARITY_NORMAL>, + <&pwm0 1 PWM_MSEC(1) PWM_POLARITY_NORMAL>, + <&pwm0 2 PWM_MSEC(1) PWM_POLARITY_NORMAL>; }; }; }; @@ -59,4 +60,3 @@ pinmux = ; }; }; - diff --git a/src/platform/telink/tlsr9528a_4m_flash.overlay b/src/platform/telink/tlsr9528a_4m_flash.overlay index 9ab2890d4a58ff..9d993ad2de6b11 100644 --- a/src/platform/telink/tlsr9528a_4m_flash.overlay +++ b/src/platform/telink/tlsr9528a_4m_flash.overlay @@ -6,42 +6,75 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - + /delete-node/ partition@0; + /delete-node/ partition@20000; + /delete-node/ partition@88000; + /delete-node/ partition@f0000; + /delete-node/ partition@f4000; + /delete-node/ partition@fe000; boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x13000>; + reg = <0x00000000 0x14000>; }; - slot0_partition: partition@13000 { + slot0_partition: partition@14000 { label = "image-0"; - reg = <0x13000 0x1ea000>; + reg = <0x14000 0x1a5000>;// 0x14000 is matter , 0x154000 is zigbee , 0x1b4000~0x1b9000 reserved for trailor and move sector, should be 20k }; - slot1_partition: partition@1fd000 { + slot1_partition: partition@1b9000 { label = "image-1"; - reg = <0x1fd000 0x1ea000>; + reg = <0x1b9000 0x1a5000>; }; - storage_partition: partition@3e7000 { + rfu_partition: partition@35e000 { + label = "rfu"; + reg = <0x35e000 0x22000>; //reserved for next step flash protect to keep 3.5k,now use all protect + }; + storage_partition: partition@380000 { label = "storage"; - reg = <0x3e7000 0xf000>; // matter nvs part + reg = <0x380000 0xb000>; // matter nvs part }; + zigbee_partition: partition@38b000 { + label = "zigbee"; + reg = <0x38b000 0x1a000>; // zigbee nvs part , total is 104k. + }; + user_token_partition: partition@3a5000 { + label = "user-token"; + reg = <0x3a5000 0x1000>; //user:store token info, for customer to config. + }; + user_para_partition: partition@3a6000 { + label = "user-para"; + reg = <0x3a6000 0x1000>; //user:store the mode info and the key info part. + }; + user_rfu_partition: partition@3a7000 { + label = "user_rfu"; + reg = <0x3a7000 0x19000>; //user_rfu: reserve 100k for user extend. + }; + user_cluster_partition: partition@3c0000 { + label = "user-cluster"; + reg = <0x3c0000 0x1000>; //user_cluster: reserve 4k for user storage cluster para. + }; + stack_extend_partition: partition@3c1000 { + label = "stack_extend"; + reg = <0x3c1000 0x35000>; //reserved for matter stack extend proc,about 212k. + }; dac_keypair_partition: partition@3f6000 { label = "dac-keypair"; - reg = <0x3f6000 0x1000>; // store dac and key pair. + reg = <0x3f6000 0x1000>; //store dac and key pair. }; factory_partition: partition@3f7000 { label = "factory-data"; - reg = <0x3f7000 0x1000>; // factory data info. + reg = <0x3f7000 0x1000>; // factory data info }; secure_partition: partition@3f8000 { label = "secure"; - reg = <0x3f8000 0x4000>; // secure info, reserved for secure boot. if not use, can be used by other way. + reg = <0x3f8000 0x4000>; //secure info ,reserved for secure boot .if not use , can beused by other way . }; vendor_rfu_partition: partition@3fc000 { label = "vendor-rfu"; - reg = <0x3fc000 0x2000>; // reserved for chip extend. + reg = <0x3fc000 0x2000>;// reserved for chip extend. }; vendor_partition: partition@3fe000 { label = "vendor-data"; - reg = <0x3fe000 0x2000>; // mac and adc info. + reg = <0x3fe000 0x2000>;// mac and adc info. }; }; };