From 3663762de6b4dbf96a0e038d0852880529b7ca86 Mon Sep 17 00:00:00 2001 From: interfer Date: Mon, 2 Dec 2024 15:35:26 +0000 Subject: [PATCH 01/51] [Telink] Zephyr v3.7 update changes Adopted changes for Telink B9x board series for upcoming update of Zephyr version. Fixed err output from InitChipStack in mainCommon. Tested advertisement tested manually. --- config/telink/chip-module/Kconfig.defaults | 20 ++++++++++++++++++- .../platform/telink/common/src/mainCommon.cpp | 2 +- .../telink/zephyr_ext/zephyr_key_matrix.c | 3 ++- .../telink/zephyr_ext/zephyr_key_pool.c | 3 ++- .../telink/zephyr_ext/zephyr_led_pool.c | 3 ++- .../telink/zephyr_ext/zephyr_pwm_pool.c | 3 ++- src/platform/telink/BLEManagerImpl.cpp | 16 +++++++++++++-- src/platform/telink/SystemPlatformConfig.h | 3 +++ 8 files changed, 45 insertions(+), 8 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 3503aae4000f06..b7c05b33571fcf 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -80,12 +80,30 @@ config SYSTEM_WORKQUEUE_STACK_SIZE default 616 if PM config HEAP_MEM_POOL_SIZE - default 256 + default 1280 config COMMON_LIBC_MALLOC_ARENA_SIZE default 20716 if SOC_RISCV_TELINK_TL321X || SOC_SERIES_RISCV_TELINK_B9X_RETENTION default 12288 +choice LIBC_IMPLEMENTATION + default NEWLIB_LIBC +endchoice + +config MBEDTLS_ENTROPY_ENABLED + bool + default y + +config MBEDTLS_ZEPHYR_ENTROPY + bool + default y + +config MBEDTLS_CTR_DRBG_ENABLED + default y + +config MBEDTLS_CIPHER_AES_ENABLED + default y + config NET_IPV6_MLD default n if PM default y diff --git a/examples/platform/telink/common/src/mainCommon.cpp b/examples/platform/telink/common/src/mainCommon.cpp index 583d61c0082c57..79b0cff876c06f 100644 --- a/examples/platform/telink/common/src/mainCommon.cpp +++ b/examples/platform/telink/common/src/mainCommon.cpp @@ -174,6 +174,6 @@ int main(void) err = GetAppTask().StartApp(); exit: - LOG_ERR("Exit err %" CHIP_ERROR_FORMAT, err.Format()); + LOG_ERR("Exit err %d" , err.Format()); return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c b/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c index 00ea46c82d0e2f..03002751649418 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c +++ b/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c @@ -47,7 +47,8 @@ static void key_matrix_poll(struct key_matrix_data * key_matrix, bool init) /* Key matrix scan worker */ static void key_matrix_scan_work(struct k_work * item) { - struct key_matrix_data * key_matrix = CONTAINER_OF(item, struct key_matrix_data, work); + struct key_matrix_data * key_matrix = + CONTAINER_OF(k_work_delayable_from_work(item), struct key_matrix_data, work); (void) k_work_schedule(&key_matrix->work, K_MSEC(KEY_MATRIX_SCAN_PERIOD_MS)); key_matrix_poll(key_matrix, false); diff --git a/examples/platform/telink/zephyr_ext/zephyr_key_pool.c b/examples/platform/telink/zephyr_ext/zephyr_key_pool.c index 5a88d15303fde9..31f782ec555fc4 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_key_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_key_pool.c @@ -75,7 +75,8 @@ static void key_pool_poll(struct key_pool_data * key_pool, bool init) /* Key pool scan worker */ static void key_pool_event_work(struct k_work * item) { - struct key_pool_data * key_pool = CONTAINER_OF(item, struct key_pool_data, work); + struct key_pool_data * key_pool = + CONTAINER_OF(k_work_delayable_from_work(item), struct key_pool_data, work); key_pool_poll(key_pool, false); } diff --git a/examples/platform/telink/zephyr_ext/zephyr_led_pool.c b/examples/platform/telink/zephyr_ext/zephyr_led_pool.c index f8ced2d413fd63..19f8b9a3f93cda 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_led_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_led_pool.c @@ -80,7 +80,8 @@ static void led_pool_aux_update(const struct led_pool_data * led_pool) /* Led pool worker */ static void led_pool_event_work(struct k_work * item) { - struct led_pool_data * led_pool = CONTAINER_OF(item, struct led_pool_data, work); + struct led_pool_data * led_pool = + CONTAINER_OF(k_work_delayable_from_work(item), struct led_pool_data, work); led_pool_aux_update(led_pool); (void) k_work_reschedule(&led_pool->work, led_pool_aux_timeout(led_pool)); diff --git a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c index 3f1651844f1cec..26c0164a50796c 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c @@ -140,7 +140,8 @@ static void pwm_pool_aux_update(const struct pwm_pool_data * pwm_pool) /* Pwm pool worker */ static void pwm_pool_event_work(struct k_work * item) { - struct pwm_pool_data * pwm_pool = CONTAINER_OF(item, struct pwm_pool_data, work); + struct pwm_pool_data * pwm_pool = + CONTAINER_OF(k_work_delayable_from_work(item), struct pwm_pool_data, work); pwm_pool_aux_update(pwm_pool); (void) k_work_reschedule(&pwm_pool->work, pwm_pool_aux_timeout(pwm_pool)); diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index 819d2614ce349d..1617c0fbfe4aa3 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -40,13 +40,25 @@ #include #include #include -#include +#include #include #include #include extern "C" { -extern __attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t * bt_mac); + +#ifdef CONFIG_BT_B9X + +extern __attribute__((noinline)) int b9x_bt_blc_mac_init(uint8_t *bt_mac); +/** + * @brief bt mac initialization + */ +__attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t *bt_mac) +{ + b9x_bt_blc_mac_init(bt_mac); +} +#endif + } #if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE) diff --git a/src/platform/telink/SystemPlatformConfig.h b/src/platform/telink/SystemPlatformConfig.h index 9f77a54b223169..07b58cbb8c8157 100644 --- a/src/platform/telink/SystemPlatformConfig.h +++ b/src/platform/telink/SystemPlatformConfig.h @@ -62,3 +62,6 @@ struct ChipDeviceEvent; #endif // ========== Platform-specific Configuration Overrides ========= + +// Disable Zephyr Socket extensions module, as the Zephyr RTOS now implements recvmsg() +#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKET_EXTENSIONS 0 \ No newline at end of file From f0d697ebfb72652324ff8f76a1f7edcb4ee21973 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 25 Nov 2024 10:41:09 +0000 Subject: [PATCH 02/51] [Telink] Manual Zephyr SDK update to check CI jobs --- .github/workflows/chef.yaml | 7 ++++--- .github/workflows/examples-telink.yaml | 17 ++++++++++++----- .../images/stage-2/chip-build-telink/Dockerfile | 12 ++++++------ .../images/vscode/chip-build-vscode/Dockerfile | 4 ++-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index c897952d45107c..2d555bf16078a2 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -19,6 +19,7 @@ on: branches: - master - 'v*-branch' + - update_zephyr_3.7 pull_request: merge_group: @@ -109,9 +110,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 46ac12b997d6f1ced2c5cc86a7e21d880d4b114e" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 1b6fd20aa72260..4fc374777f71c0 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -19,6 +19,7 @@ on: branches: - master - 'v*-branch' + - update_zephyr_3.7 pull_request: merge_group: @@ -57,8 +58,17 @@ 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: Update Zephyr SDK (Temporary change for debugging purpose) + run: | + cd /opt/telink \ + rm -rf zephyr-sdk-0.16.1 \ + curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ + tar xvf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ + rm -rf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ + zephyr-sdk-0.17.0/setup.sh -t riscv64-zephyr-elf + + - name: Update Zephyr to specific revision (for developers purpose) + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 46ac12b997d6f1ced2c5cc86a7e21d880d4b114e" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs @@ -77,7 +87,6 @@ jobs: - 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" @@ -142,7 +151,6 @@ jobs: - 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" @@ -308,7 +316,6 @@ jobs: - 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" diff --git a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile index e028e0b9f64142..ea3bd41825d146 100644 --- a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile @@ -11,10 +11,10 @@ RUN set -x \ # Setup toolchain WORKDIR /opt/telink RUN set -x \ - && curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.1/zephyr-sdk-0.16.1_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.16.1_linux-x86_64_minimal.tar.xz \ - && tar xvf zephyr-sdk-0.16.1_linux-x86_64_minimal.tar.xz \ - && rm -rf zephyr-sdk-0.16.1_linux-x86_64_minimal.tar.xz \ - && zephyr-sdk-0.16.1/setup.sh -t riscv64-zephyr-elf \ + && curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ + && tar xvf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ + && rm -rf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ + && zephyr-sdk-0.17.0/setup.sh -t riscv64-zephyr-elf \ && : # last line # Setup Zephyr @@ -34,7 +34,7 @@ RUN set -x \ FROM ghcr.io/project-chip/chip-build:${VERSION} -COPY --from=build /opt/telink/zephyr-sdk-0.16.1/ /opt/telink/zephyr-sdk-0.16.1/ +COPY --from=build /opt/telink/zephyr-sdk-0.17.0/ /opt/telink/zephyr-sdk-0.17.0/ COPY --from=build /opt/telink/zephyrproject/ /opt/telink/zephyrproject/ RUN set -x \ @@ -45,4 +45,4 @@ RUN set -x \ && : # last line ENV TELINK_ZEPHYR_BASE=/opt/telink/zephyrproject/zephyr -ENV TELINK_ZEPHYR_SDK_DIR=/opt/telink/zephyr-sdk-0.16.1 +ENV TELINK_ZEPHYR_SDK_DIR=/opt/telink/zephyr-sdk-0.17.0 diff --git a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile index dbec645d4c1c45..f7b262f9950e30 100644 --- a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile @@ -38,7 +38,7 @@ COPY --from=android /usr/lib/kotlinc /usr/lib/kotlinc COPY --from=psoc6 /opt/Tools/ModusToolbox /opt/Tools/ModusToolbox COPY --from=telink /opt/telink/zephyrproject /opt/telink/zephyrproject -COPY --from=telink /opt/telink/zephyr-sdk-0.16.1 /opt/telink/zephyr-sdk-0.16.1 +COPY --from=telink /opt/telink/zephyr-sdk-0.17.0 /opt/telink/zephyr-sdk-0.17.0 COPY --from=tizen /opt/tizen-sdk /opt/tizen-sdk @@ -125,7 +125,7 @@ ENV QEMU_ESP32=/opt/espressif/qemu/qemu-system-xtensa ENV QEMU_ESP32_DIR=/opt/espressif/qemu ENV SYSROOT_AARCH64=/opt/ubuntu-22.04.1-aarch64-sysroot ENV TELINK_ZEPHYR_BASE=/opt/telink/zephyrproject/zephyr -ENV TELINK_ZEPHYR_SDK_DIR=/opt/telink/zephyr-sdk-0.16.1 +ENV TELINK_ZEPHYR_SDK_DIR=/opt/telink/zephyr-sdk-0.17.0 ENV TI_SYSCONFIG_ROOT=/opt/ti/sysconfig_1.18.1 ENV ZEPHYR_BASE=/opt/NordicSemiconductor/nrfconnect/zephyr ENV ZEPHYR_SDK_INSTALL_DIR=/opt/NordicSemiconductor/nRF5_tools/zephyr-sdk-0.16.5 From 794dc599c3f77cafd6341b9f66b14dab11acd012 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 25 Nov 2024 12:33:52 +0000 Subject: [PATCH 03/51] [Telink] Fix build errors: - STREAM_FLASH_ERASE has direct dependencies STREAM_FLASH - GETOPT_LONG multiple definition error --- config/telink/chip-module/Kconfig | 1 - config/telink/chip-module/Kconfig.defaults | 4 ---- 2 files changed, 5 deletions(-) diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 2937b2b0c66094..91e6cbcc336461 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -45,7 +45,6 @@ config BOOTLOADER_MCUBOOT bool select IMG_MANAGER select STREAM_FLASH - select STREAM_FLASH_ERASE select TELINK_W91_N22_MATTER_OTA_LAYOUT if BOARD_TLSR9118BDK40D config CHIP_OTA_REQUESTOR_BUFFER_SIZE diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index b7c05b33571fcf..28ef870e1e0bb1 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -460,10 +460,6 @@ config MBEDTLS_ECDH_C config MBEDTLS_ECDSA_C default y -# getopt version -config GETOPT_LONG - default y - # Disable not used shell modules config SHELL_WILDCARD From bf1b9c844ad1efcfe022a5dd9957fb77dddf80b6 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 26 Nov 2024 09:35:29 +0000 Subject: [PATCH 04/51] [Telink] CONFIG_BOOT_MAX_IMG_SECTORS_AUTO used --- config/telink/app/bootloader.conf | 4 ---- config/telink/app/bootloader_compress_lzma.conf | 4 ---- 2 files changed, 8 deletions(-) diff --git a/config/telink/app/bootloader.conf b/config/telink/app/bootloader.conf index 0ffacc8c0b052b..6f60d1b102a7b4 100644 --- a/config/telink/app/bootloader.conf +++ b/config/telink/app/bootloader.conf @@ -29,10 +29,6 @@ CONFIG_BOOT_SWAP_USING_SCRATCH=n # With disabled option the only image magic is validated CONFIG_BOOT_VALIDATE_SLOT0=y -# Maximum number of image sectors supported by the bootloader. -# Maximum signed image size: 512 * 4096 = 2M Bytes -CONFIG_BOOT_MAX_IMG_SECTORS=512 - # Sets log level for modules which don't specify it explicitly. # When set to 0 it means log will not be activated for those modules. # Levels are: diff --git a/config/telink/app/bootloader_compress_lzma.conf b/config/telink/app/bootloader_compress_lzma.conf index cb349eed0ce387..606665c72c78e2 100644 --- a/config/telink/app/bootloader_compress_lzma.conf +++ b/config/telink/app/bootloader_compress_lzma.conf @@ -22,10 +22,6 @@ CONFIG_BOOT_UPGRADE_ONLY=y # With disabled option the only image magic is validated CONFIG_BOOT_VALIDATE_SLOT0=y -# Maximum number of image sectors supported by the bootloader. -# Maximum signed image size: 512 * 4096 = 2M Bytes -CONFIG_BOOT_MAX_IMG_SECTORS=512 - # Sets log level for modules which don't specify it explicitly. # When set to 0 it means log will not be activated for those modules. # Levels are: From 951f73a28edbc59f5ca07e4f24c56b0416a09e87 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 26 Nov 2024 09:36:39 +0000 Subject: [PATCH 05/51] [Telink] Fix build errors --- config/telink/chip-module/CMakeLists.txt | 2 +- config/telink/chip-module/Kconfig | 2 +- config/telink/chip-module/Kconfig.defaults | 4 ++-- src/platform/telink/FactoryDataParser.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 0f925cdeffc904..ed460acd6acd3a 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -174,7 +174,7 @@ add_dependencies(process_binaries ${ZEPHYR_FINAL_EXECUTABLE}) # Define 'build_mcuboot' target for building the MCUBoot bootloader # ============================================================================== -if (CONFIG_BOOTLOADER_MCUBOOT AND (CONFIG_SOC_SERIES_RISCV_TELINK_B9X OR CONFIG_SOC_SERIES_RISCV_TELINK_TLX)) +if (CONFIG_BOOTLOADER_MCUBOOT AND (CONFIG_SOC_RISCV_TELINK_B9X OR CONFIG_SOC_RISCV_TELINK_TLX)) add_custom_target(build_mcuboot ALL COMMAND west build -b ${BASE_BOARD} -d build_mcuboot ${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 91e6cbcc336461..26e99dff180687 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -251,5 +251,5 @@ config CHIP_TASK_STACK_SIZE config CHIP_USE_MARS_SENSOR bool "Use Mars board sensor" - depends on SOC_SERIES_RISCV_TELINK_B9X && (BOARD_TLSR9518ADK80D || BOARD_TLSR9518ADK80D_RETENTION) + depends on CONFIG_SOC_RISCV_TELINK_B9X && (BOARD_TLSR9518ADK80D || BOARD_TLSR9518ADK80D_RETENTION) default n diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 28ef870e1e0bb1..c4ed4426e1498b 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -196,7 +196,7 @@ config BT_DEVICE_NAME_GATT_WRITABLE bool default n -if SOC_SERIES_RISCV_TELINK_B9X || SOC_SERIES_RISCV_TELINK_TLX +if SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX config TL_BLE_CTRL_THREAD_STACK_SIZE default 648 @@ -216,7 +216,7 @@ choice TL_BLE_CTRL_MAC_TYPE default TL_BLE_CTRL_MAC_TYPE_RANDOM_STATIC endchoice -endif # SOC_SERIES_RISCV_TELINK_B9X || SOC_SERIES_RISCV_TELINK_TLX +endif # SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX endif # BT diff --git a/src/platform/telink/FactoryDataParser.c b/src/platform/telink/FactoryDataParser.c index 12260631262342..f271b8bfdcfb7e 100644 --- a/src/platform/telink/FactoryDataParser.c +++ b/src/platform/telink/FactoryDataParser.c @@ -43,7 +43,7 @@ static inline bool uint16_decode(zcbor_state_t * states, uint16_t * value) bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData * factoryData) { memset(factoryData, 0, sizeof(*factoryData)); - ZCBOR_STATE_D(states, MAX_FACTORY_DATA_NESTING_LEVEL, buffer, bufferSize, 1); + ZCBOR_STATE_D(states, MAX_FACTORY_DATA_NESTING_LEVEL, buffer, bufferSize, 1, 0); bool res = zcbor_map_start_decode(states); struct zcbor_string currentString; From 5f207284bd90ab6072a7203ec661454d8c79b4fa Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 2 Dec 2024 16:09:55 +0000 Subject: [PATCH 06/51] [Telink] Reduce mcuboot partition size to 60Kb - Apply change for flash overlays <=2Mb - Possible after reducing CONFIG_BOOT_MAX_IMG_SECTORS --- src/platform/telink/tl3218x_2m_flash.overlay | 22 ++++++++-------- .../telink/tlsr9258a_2m_flash.overlay | 18 ++++++------- .../telink/tlsr9518adk80d_1m_flash.overlay | 6 ++--- .../telink/tlsr9518adk80d_2m_flash.overlay | 18 ++++++------- .../telink/tlsr9528a_2m_flash.overlay | 26 +++++++++---------- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/platform/telink/tl3218x_2m_flash.overlay b/src/platform/telink/tl3218x_2m_flash.overlay index 53114e6ac6054d..bff368eea1578a 100644 --- a/src/platform/telink/tl3218x_2m_flash.overlay +++ b/src/platform/telink/tl3218x_2m_flash.overlay @@ -9,27 +9,27 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x13000>; + reg = <0x00000000 0xf000>; }; - slot0_partition: partition@13000 { + slot0_partition: partition@f000 { label = "image-0"; - reg = <0x13000 0xef000>; + reg = <0xf000 0xf1000>; }; - factory_partition: partition@102000 { + factory_partition: partition@100000 { label = "factory-data"; - reg = <0x102000 0x800>; + reg = <0x100000 0x800>; }; - factory_rfu_partition: partition@102800 { + factory_rfu_partition: partition@100800 { label = "factory-data-rfu"; - reg = <0x102800 0x800>; + reg = <0x100800 0x800>; }; - storage_partition: partition@103000 { + storage_partition: partition@101000 { label = "storage"; - reg = <0x103000 0xc000>; + reg = <0x101000 0xc000>; }; - slot1_partition: partition@10f000 { + slot1_partition: partition@10d000 { label = "image-1"; - reg = <0x10f000 0xef000>; + reg = <0x10d000 0xf1000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; diff --git a/src/platform/telink/tlsr9258a_2m_flash.overlay b/src/platform/telink/tlsr9258a_2m_flash.overlay index bdfc0a45709fc1..d08d0e4ff4a6ba 100644 --- a/src/platform/telink/tlsr9258a_2m_flash.overlay +++ b/src/platform/telink/tlsr9258a_2m_flash.overlay @@ -9,23 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x13000>; + reg = <0x00000000 0xf000>; }; - slot0_partition: partition@13000 { + slot0_partition: partition@f000 { label = "image-0"; - reg = <0x13000 0xef000>; + reg = <0xf000 0xf1000>; }; - factory_partition: partition@102000 { + factory_partition: partition@100000 { label = "factory-data"; - reg = <0x102000 0x1000>; + reg = <0x100000 0x1000>; }; - storage_partition: partition@103000 { + storage_partition: partition@101000 { label = "storage"; - reg = <0x103000 0xc000>; + reg = <0x101000 0xc000>; }; - slot1_partition: partition@10f000 { + slot1_partition: partition@10d000 { label = "image-1"; - reg = <0x10f000 0xef000>; + reg = <0x10d000 0xf1000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; diff --git a/src/platform/telink/tlsr9518adk80d_1m_flash.overlay b/src/platform/telink/tlsr9518adk80d_1m_flash.overlay index ba55da341398f5..1a49a150cf3206 100644 --- a/src/platform/telink/tlsr9518adk80d_1m_flash.overlay +++ b/src/platform/telink/tlsr9518adk80d_1m_flash.overlay @@ -9,11 +9,11 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x19000>; + reg = <0x00000000 0xf000>; }; - slot0_partition: partition@19000 { + slot0_partition: partition@f000 { label = "image-0"; - reg = <0x19000 0xd9000>; + reg = <0xf000 0xe3000>; }; factory_partition: partition@f2000 { label = "factory-data"; diff --git a/src/platform/telink/tlsr9518adk80d_2m_flash.overlay b/src/platform/telink/tlsr9518adk80d_2m_flash.overlay index 4fd5fd13086046..d08d0e4ff4a6ba 100644 --- a/src/platform/telink/tlsr9518adk80d_2m_flash.overlay +++ b/src/platform/telink/tlsr9518adk80d_2m_flash.overlay @@ -9,23 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x19000>; + reg = <0x00000000 0xf000>; }; - slot0_partition: partition@19000 { + slot0_partition: partition@f000 { label = "image-0"; - reg = <0x19000 0xec000>; + reg = <0xf000 0xf1000>; }; - factory_partition: partition@105000 { + factory_partition: partition@100000 { label = "factory-data"; - reg = <0x105000 0x1000>; + reg = <0x100000 0x1000>; }; - storage_partition: partition@106000 { + storage_partition: partition@101000 { label = "storage"; - reg = <0x106000 0xc000>; + reg = <0x101000 0xc000>; }; - slot1_partition: partition@112000 { + slot1_partition: partition@10d000 { label = "image-1"; - reg = <0x112000 0xec000>; + reg = <0x10d000 0xf1000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; diff --git a/src/platform/telink/tlsr9528a_2m_flash.overlay b/src/platform/telink/tlsr9528a_2m_flash.overlay index 35d72affa95023..d86a001d5ef86a 100644 --- a/src/platform/telink/tlsr9528a_2m_flash.overlay +++ b/src/platform/telink/tlsr9528a_2m_flash.overlay @@ -9,31 +9,31 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x13000>; + reg = <0x00000000 0xf000>; }; - slot0_partition: partition@13000 { + slot0_partition: partition@f000 { label = "image-0"; - reg = <0x13000 0xec000>; + reg = <0xf000 0xee000>; }; - factory_partition: partition@ff000 { + factory_partition: partition@fd000 { label = "factory-data"; - reg = <0xff000 0x1000>; + reg = <0xfd000 0x1000>; }; - dac_keypair_partition: partition@100000 { + dac_keypair_partition: partition@fe000 { label = "dac-keypair"; - reg = <0x100000 0x1000>; //store dac and key pair. + reg = <0xfe000 0x1000>; //store dac and key pair. }; - descriptor_partition: partition@101000 { + descriptor_partition: partition@ff000 { label = "sboot-descriptor"; - reg = <0x101000 0x2000>; + reg = <0xff000 0x2000>; }; - storage_partition: partition@103000 { + storage_partition: partition@101000 { label = "storage"; - reg = <0x103000 0xf000>; + reg = <0x101000 0xf000>; }; - slot1_partition: partition@112000 { + slot1_partition: partition@110000 { label = "image-1"; - reg = <0x112000 0xec000>; + reg = <0x110000 0xee000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; From cda4887cba7b31325098f1ced7925b7a8dec8691 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Wed, 27 Nov 2024 10:29:26 +0000 Subject: [PATCH 07/51] [Telink] Reduce NET_BUF_*_COUNT (to be tested) --- config/telink/chip-module/Kconfig.defaults | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index c4ed4426e1498b..cbf55eab570550 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -122,11 +122,11 @@ config NET_PKT_TX_COUNT default 8 config NET_BUF_RX_COUNT - default 12 if PM || SOC_RISCV_TELINK_TL321X + default 4 if PM || SOC_RISCV_TELINK_TL321X default 32 config NET_BUF_TX_COUNT - default 12 if PM || SOC_RISCV_TELINK_TL321X + default 4 if PM || SOC_RISCV_TELINK_TL321X default 32 config GPIO From d304e94f01fac5c2e68e25a01590820dec881fa9 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 2 Dec 2024 16:16:32 +0000 Subject: [PATCH 08/51] [Telink] avoid using NEWLIB_LIBC (use PICOLIB) --- config/telink/chip-module/Kconfig.defaults | 4 ---- src/platform/telink/CHIPDevicePlatformConfig.h | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index cbf55eab570550..8e8a06f3006af7 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -86,10 +86,6 @@ config COMMON_LIBC_MALLOC_ARENA_SIZE default 20716 if SOC_RISCV_TELINK_TL321X || SOC_SERIES_RISCV_TELINK_B9X_RETENTION default 12288 -choice LIBC_IMPLEMENTATION - default NEWLIB_LIBC -endchoice - config MBEDTLS_ENTROPY_ENABLED bool default y diff --git a/src/platform/telink/CHIPDevicePlatformConfig.h b/src/platform/telink/CHIPDevicePlatformConfig.h index 655ac128953bee..8229b781a22a94 100644 --- a/src/platform/telink/CHIPDevicePlatformConfig.h +++ b/src/platform/telink/CHIPDevicePlatformConfig.h @@ -145,6 +145,8 @@ #if !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC) /// Use mallinfo() to obtain the heap usage statistics exposed by SoftwareDiagnostics cluster attributes. #define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 1 +#else +#define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 0 #endif // !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC) #endif // CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO From 1ea583198e8c36172fb615a254224ffea95a1a6b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 2 Dec 2024 16:17:13 +0000 Subject: [PATCH 09/51] Restyled by whitespace --- src/platform/telink/SystemPlatformConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/telink/SystemPlatformConfig.h b/src/platform/telink/SystemPlatformConfig.h index 07b58cbb8c8157..3ac718ce1fb143 100644 --- a/src/platform/telink/SystemPlatformConfig.h +++ b/src/platform/telink/SystemPlatformConfig.h @@ -64,4 +64,4 @@ struct ChipDeviceEvent; // ========== Platform-specific Configuration Overrides ========= // Disable Zephyr Socket extensions module, as the Zephyr RTOS now implements recvmsg() -#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKET_EXTENSIONS 0 \ No newline at end of file +#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKET_EXTENSIONS 0 From 368924c55d8798cdebcd779d66b6237cdb966f26 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 2 Dec 2024 16:17:18 +0000 Subject: [PATCH 10/51] Restyled by clang-format --- examples/platform/telink/common/src/mainCommon.cpp | 2 +- examples/platform/telink/zephyr_ext/zephyr_key_matrix.c | 3 +-- examples/platform/telink/zephyr_ext/zephyr_key_pool.c | 3 +-- examples/platform/telink/zephyr_ext/zephyr_led_pool.c | 3 +-- examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c | 3 +-- src/platform/telink/BLEManagerImpl.cpp | 7 +++---- 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/examples/platform/telink/common/src/mainCommon.cpp b/examples/platform/telink/common/src/mainCommon.cpp index 79b0cff876c06f..099ffec0debc41 100644 --- a/examples/platform/telink/common/src/mainCommon.cpp +++ b/examples/platform/telink/common/src/mainCommon.cpp @@ -174,6 +174,6 @@ int main(void) err = GetAppTask().StartApp(); exit: - LOG_ERR("Exit err %d" , err.Format()); + LOG_ERR("Exit err %d", err.Format()); return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c b/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c index 03002751649418..e81fe8d3eff908 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c +++ b/examples/platform/telink/zephyr_ext/zephyr_key_matrix.c @@ -47,8 +47,7 @@ static void key_matrix_poll(struct key_matrix_data * key_matrix, bool init) /* Key matrix scan worker */ static void key_matrix_scan_work(struct k_work * item) { - struct key_matrix_data * key_matrix = - CONTAINER_OF(k_work_delayable_from_work(item), struct key_matrix_data, work); + struct key_matrix_data * key_matrix = CONTAINER_OF(k_work_delayable_from_work(item), struct key_matrix_data, work); (void) k_work_schedule(&key_matrix->work, K_MSEC(KEY_MATRIX_SCAN_PERIOD_MS)); key_matrix_poll(key_matrix, false); diff --git a/examples/platform/telink/zephyr_ext/zephyr_key_pool.c b/examples/platform/telink/zephyr_ext/zephyr_key_pool.c index 31f782ec555fc4..c3fa044dc1f924 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_key_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_key_pool.c @@ -75,8 +75,7 @@ static void key_pool_poll(struct key_pool_data * key_pool, bool init) /* Key pool scan worker */ static void key_pool_event_work(struct k_work * item) { - struct key_pool_data * key_pool = - CONTAINER_OF(k_work_delayable_from_work(item), struct key_pool_data, work); + struct key_pool_data * key_pool = CONTAINER_OF(k_work_delayable_from_work(item), struct key_pool_data, work); key_pool_poll(key_pool, false); } diff --git a/examples/platform/telink/zephyr_ext/zephyr_led_pool.c b/examples/platform/telink/zephyr_ext/zephyr_led_pool.c index 19f8b9a3f93cda..a00544c403861f 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_led_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_led_pool.c @@ -80,8 +80,7 @@ static void led_pool_aux_update(const struct led_pool_data * led_pool) /* Led pool worker */ static void led_pool_event_work(struct k_work * item) { - struct led_pool_data * led_pool = - CONTAINER_OF(k_work_delayable_from_work(item), struct led_pool_data, work); + struct led_pool_data * led_pool = CONTAINER_OF(k_work_delayable_from_work(item), struct led_pool_data, work); led_pool_aux_update(led_pool); (void) k_work_reschedule(&led_pool->work, led_pool_aux_timeout(led_pool)); diff --git a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c index 26c0164a50796c..0322e812b62a92 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c @@ -140,8 +140,7 @@ static void pwm_pool_aux_update(const struct pwm_pool_data * pwm_pool) /* Pwm pool worker */ static void pwm_pool_event_work(struct k_work * item) { - struct pwm_pool_data * pwm_pool = - CONTAINER_OF(k_work_delayable_from_work(item), struct pwm_pool_data, work); + struct pwm_pool_data * pwm_pool = CONTAINER_OF(k_work_delayable_from_work(item), struct pwm_pool_data, work); pwm_pool_aux_update(pwm_pool); (void) k_work_reschedule(&pwm_pool->work, pwm_pool_aux_timeout(pwm_pool)); diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index 1617c0fbfe4aa3..8a94141fd37f91 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -49,16 +49,15 @@ extern "C" { #ifdef CONFIG_BT_B9X -extern __attribute__((noinline)) int b9x_bt_blc_mac_init(uint8_t *bt_mac); +extern __attribute__((noinline)) int b9x_bt_blc_mac_init(uint8_t * bt_mac); /** * @brief bt mac initialization */ -__attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t *bt_mac) +__attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t * bt_mac) { - b9x_bt_blc_mac_init(bt_mac); + b9x_bt_blc_mac_init(bt_mac); } #endif - } #if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE) From 44b20d64c48ff5c181217e13d25b22ac67a1177a Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 2 Dec 2024 20:48:28 +0000 Subject: [PATCH 11/51] [Telink] Update Zephyr revision & SDK --- .github/workflows/chef.yaml | 13 ++++++++- .github/workflows/examples-telink.yaml | 38 +++++++++++++++++++------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 2d555bf16078a2..15c8cdec2b78a8 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -29,6 +29,8 @@ concurrency: env: CHIP_NO_LOG_TIMESTAMPS: true + # Required to Update Zephyr SDK (for developers purpose) + TELINK_ZEPHYR_SDK_DIR: /opt/telink/zephyr-sdk-0.17.0 jobs: chef_linux: @@ -106,13 +108,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Update Zephyr SDK (for developers purpose) + run: | + set -e + cd /opt/telink + rm -rf zephyr-sdk-0.16.1 + curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz + tar xvf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz + rm -rf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz + zephyr-sdk-0.17.0/setup.sh -t riscv64-zephyr-elf - name: Checkout submodules & Bootstrap 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 46ac12b997d6f1ced2c5cc86a7e21d880d4b114e" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py ed365fdadcf380a0b2e543a7d4ba88ed4f227466" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 4fc374777f71c0..cf1c04f030f98b 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -29,6 +29,8 @@ concurrency: env: CHIP_NO_LOG_TIMESTAMPS: true + # Required to Update Zephyr SDK (for developers purpose) + TELINK_ZEPHYR_SDK_DIR: /opt/telink/zephyr-sdk-0.17.0 jobs: telink: @@ -47,6 +49,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + + - name: Update Zephyr SDK (for developers purpose) + run: | + set -e + cd /opt/telink + rm -rf zephyr-sdk-0.16.1 + curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz + tar xvf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz + rm -rf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz + zephyr-sdk-0.17.0/setup.sh -t riscv64-zephyr-elf + - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: @@ -58,21 +71,14 @@ jobs: with: gh-context: ${{ toJson(github) }} - - name: Update Zephyr SDK (Temporary change for debugging purpose) - run: | - cd /opt/telink \ - rm -rf zephyr-sdk-0.16.1 \ - curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ - tar xvf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ - rm -rf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz \ - zephyr-sdk-0.17.0/setup.sh -t riscv64-zephyr-elf - - name: Update Zephyr to specific revision (for developers purpose) - run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 46ac12b997d6f1ced2c5cc86a7e21d880d4b114e" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py ed365fdadcf380a0b2e543a7d4ba88ed4f227466" - 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' + # TODO: remove continue-on-error + continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-air-quality-sensor' build" @@ -87,6 +93,8 @@ jobs: - 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' + # TODO: remove continue-on-error + continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-all-clusters' build" @@ -127,6 +135,8 @@ jobs: - name: Build example Telink (B92 retention) Contact Sensor App # Run test for master and all PRs + # TODO: remove continue-on-error + continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-contact-sensor' build" @@ -151,6 +161,8 @@ jobs: - name: Build example Telink (W91) Lighting App with OTA, Factory Data # Run test for master and all PRs + # TODO: remove continue-on-error + continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-light-ota-factory-data' build" @@ -274,6 +286,8 @@ jobs: - 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' + # TODO: remove continue-on-error + continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-smoke-co-alarm' build" @@ -288,6 +302,8 @@ jobs: - 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' + # TODO: remove continue-on-error + continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-temperature-measurement-mars-ota' build" @@ -316,6 +332,8 @@ jobs: - 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' + # TODO: remove continue-on-error + continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-window-covering' build" From 05f54f9f2636df4a40d48f6ecf538dbfeeac8903 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 2 Dec 2024 22:27:24 +0000 Subject: [PATCH 12/51] [Telink] Adopt TL3218 to latest Zephyr version --- .github/workflows/examples-telink.yaml | 8 +++---- config/telink/chip-module/Kconfig.defaults | 2 +- scripts/build/build/targets.py | 2 +- scripts/build/builders/telink.py | 6 +++--- .../build/testdata/all_targets_linux_x64.txt | 2 +- src/platform/telink/BLEManagerImpl.cpp | 21 ++++++++++--------- .../{tl3218x.overlay => tl3218.overlay} | 0 ..._flash.overlay => tl3218_2m_flash.overlay} | 0 8 files changed, 21 insertions(+), 20 deletions(-) rename src/platform/telink/{tl3218x.overlay => tl3218.overlay} (100%) rename src/platform/telink/{tl3218x_2m_flash.overlay => tl3218_2m_flash.overlay} (100%) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index cf1c04f030f98b..57f32153e317e1 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -187,14 +187,14 @@ jobs: - 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 + - name: Build example Telink (TL3218) Lighting App with OTA (LZMA), Shell, Factory Data # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tl3218x-light-ota-compress-lzma-shell-factory-data' build" + "./scripts/build/build_examples.py --target 'telink-tl3218-light-ota-compress-lzma-shell-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl3218x light-app-ota-compress-lzma-shell-factory-data \ - out/telink-tl3218x-light-ota-compress-lzma-shell-factory-data/zephyr/zephyr.elf \ + telink tl3218 light-app-ota-compress-lzma-shell-factory-data \ + out/telink-tl3218-light-ota-compress-lzma-shell-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output (keep tools) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 8e8a06f3006af7..94bc082d3ceca9 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -235,7 +235,7 @@ endif # Board non-retention config if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 || \ - BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D || BOARD_TL3218X + BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D || BOARD_TL3218 config PWM default y endif diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 0bb25ef9a06b75..6a2f94fce92d0a 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -770,7 +770,7 @@ def BuildTelinkTarget(): TargetPart('tlsr9528a_retention', board=TelinkBoard.TLSR9528A_RETENTION), TargetPart('tlsr9258a', board=TelinkBoard.TLSR9258A), TargetPart('tlsr9258a_retention', board=TelinkBoard.TLSR9258A_RETENTION), - TargetPart('tl3218x', board=TelinkBoard.TL3218X), + TargetPart('tl3218', board=TelinkBoard.TL3218), ]) target.AppendFixedTargets([ diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index bf2bb1900a5842..4a02c8e47c3c73 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -121,7 +121,7 @@ class TelinkBoard(Enum): TLSR9528A_RETENTION = auto() TLSR9258A = auto() TLSR9258A_RETENTION = auto() - TL3218X = auto() + TL3218 = auto() def GnArgName(self): if self == TelinkBoard.TLRS9118BDK40D: @@ -136,8 +136,8 @@ def GnArgName(self): return 'tlsr9258a' elif self == TelinkBoard.TLSR9258A_RETENTION: return 'tlsr9258a_retention' - elif self == TelinkBoard.TL3218X: - return 'tl3218x' + elif self == TelinkBoard.TL3218: + return 'tl3218' else: raise Exception('Unknown board type: %r' % self) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index f3330ffc3fe090..48201d3f66a6a7 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -22,5 +22,5 @@ nuttx-x64-light qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage] stm32-stm32wb5mm-dk-light tizen-arm-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-coverage][-with-ui] -telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218x}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] +telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] openiotsdk-{shell,lock}[-mbedtls][-psa] diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index 8a94141fd37f91..911f91bdb9213f 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -46,17 +46,12 @@ #include extern "C" { - -#ifdef CONFIG_BT_B9X - +#if defined(CONFIG_BT_B9X) extern __attribute__((noinline)) int b9x_bt_blc_mac_init(uint8_t * bt_mac); -/** - * @brief bt mac initialization - */ -__attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t * bt_mac) -{ - b9x_bt_blc_mac_init(bt_mac); -} +#elif defined(CONFIG_BT_TLX) +extern __attribute__((noinline)) int tlx_bt_blc_mac_init(uint8_t * bt_mac); +#elif defined(CONFIG_BT_W91) +extern __attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t * bt_mac); #endif } @@ -128,7 +123,13 @@ CHIP_ERROR InitBLEMACAddress() int error = 0; bt_addr_le_t addr; +#if defined(CONFIG_BT_B9X) + b9x_bt_blc_mac_init(addr.a.val); +#elif defined(CONFIG_BT_TLX) + tlx_bt_blc_mac_init(addr.a.val); +#elif defined(CONFIG_BT_W91) telink_bt_blc_mac_init(addr.a.val); +#endif if (BT_ADDR_IS_STATIC(&addr.a)) // in case of Random static address, create a new id { diff --git a/src/platform/telink/tl3218x.overlay b/src/platform/telink/tl3218.overlay similarity index 100% rename from src/platform/telink/tl3218x.overlay rename to src/platform/telink/tl3218.overlay diff --git a/src/platform/telink/tl3218x_2m_flash.overlay b/src/platform/telink/tl3218_2m_flash.overlay similarity index 100% rename from src/platform/telink/tl3218x_2m_flash.overlay rename to src/platform/telink/tl3218_2m_flash.overlay From 79c54e32ed1227074150d02e80f519e3e7d4e32f Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 3 Dec 2024 07:55:09 +0000 Subject: [PATCH 13/51] [Telink] Use 4mb flash for (B92) Light Switch App target build --- .github/workflows/examples-telink.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 57f32153e317e1..d05f152037ec5a 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -174,7 +174,7 @@ jobs: - 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 + - name: Build example Telink (B91) Lighting App with OTA, RPC, Factory Data, 4Mb flash # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ @@ -200,14 +200,14 @@ 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) Light Switch App with OTA (LZMA), Shell, Factory Data, 4Mb flash # 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-switch-ota-compress-lzma-shell-factory-data-4mb' 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-switch-app-ota-compress-lzma-shell-factory-data-4mb \ + out/telink-tlsr9528a-light-switch-ota-compress-lzma-shell-factory-data-4mb/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output From 2b614142cd95d62fc8f2b4d7e31ed61b117bedd9 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 3 Dec 2024 10:46:08 +0000 Subject: [PATCH 14/51] [Telink] Fix W91 target build --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 8 +------ config/telink/app/enable-gnu-std.cmake | 23 ++++--------------- config/telink/chip-module/Kconfig.defaults | 18 ++++----------- config/zephyr/chip-module/Kconfig.mbedtls | 4 ---- scripts/tools/telink/process_binaries.py | 2 +- src/platform/Zephyr/InetUtils.cpp | 10 -------- .../telink/ConnectivityManagerImpl.cpp | 3 ++- src/platform/telink/telink-mbedtls-config.h | 5 ++++ 9 files changed, 19 insertions(+), 56 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 15c8cdec2b78a8..332ee961b524b1 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -123,7 +123,7 @@ jobs: 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 ed365fdadcf380a0b2e543a7d4ba88ed4f227466" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py ac713b037c18444628319ac5fedc23a31966213c" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index d05f152037ec5a..6d3234849840d3 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -72,7 +72,7 @@ jobs: 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 ed365fdadcf380a0b2e543a7d4ba88ed4f227466" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py ac713b037c18444628319ac5fedc23a31966213c" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs @@ -93,8 +93,6 @@ jobs: - 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' - # TODO: remove continue-on-error - continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-all-clusters' build" @@ -161,8 +159,6 @@ jobs: - name: Build example Telink (W91) Lighting App with OTA, Factory Data # Run test for master and all PRs - # TODO: remove continue-on-error - continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-light-ota-factory-data' build" @@ -332,8 +328,6 @@ jobs: - 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' - # TODO: remove continue-on-error - continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-window-covering' build" diff --git a/config/telink/app/enable-gnu-std.cmake b/config/telink/app/enable-gnu-std.cmake index b165900d31866a..37c18235d0f513 100644 --- a/config/telink/app/enable-gnu-std.cmake +++ b/config/telink/app/enable-gnu-std.cmake @@ -1,19 +1,6 @@ -# -# 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. -# - add_library(gnu17 INTERFACE) -target_compile_options(gnu17 INTERFACE $<$:-std=gnu++17> $<$:-Wno-register> -D_DEFAULT_SOURCE) -target_link_libraries(app PRIVATE gnu17) +target_compile_options(gnu17 + INTERFACE + $<$:-std=gnu++17> + -D_DEFAULT_SOURCE) +target_link_libraries(app PRIVATE gnu17) \ No newline at end of file diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 94bc082d3ceca9..bcab07a74fb5e2 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -86,20 +86,6 @@ config COMMON_LIBC_MALLOC_ARENA_SIZE default 20716 if SOC_RISCV_TELINK_TL321X || SOC_SERIES_RISCV_TELINK_B9X_RETENTION default 12288 -config MBEDTLS_ENTROPY_ENABLED - bool - default y - -config MBEDTLS_ZEPHYR_ENTROPY - bool - default y - -config MBEDTLS_CTR_DRBG_ENABLED - default y - -config MBEDTLS_CIPHER_AES_ENABLED - default y - config NET_IPV6_MLD default n if PM default y @@ -363,6 +349,7 @@ config CHIP_WIFI select NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements select NET_IPV6_NBR_CACHE select NET_STATISTICS_USER_API + imply MBEDTLS_ENTROPY_C if CHIP_WIFI @@ -438,6 +425,9 @@ config MBEDTLS_USER_CONFIG_ENABLE config MBEDTLS_USER_CONFIG_FILE default "telink-mbedtls-config.h" +config MBEDTLS_CIPHER_AES_ENABLED + default y + config MBEDTLS_CIPHER_CCM_ENABLED default y diff --git a/config/zephyr/chip-module/Kconfig.mbedtls b/config/zephyr/chip-module/Kconfig.mbedtls index 72b1563b1e808d..f4b3947db6a22e 100644 --- a/config/zephyr/chip-module/Kconfig.mbedtls +++ b/config/zephyr/chip-module/Kconfig.mbedtls @@ -22,9 +22,6 @@ config MBEDTLS config MBEDTLS_ENTROPY_ENABLED default y -config MBEDTLS_ENTROPY_ENABLED - default y - config MBEDTLS_ZEPHYR_ENTROPY default y @@ -68,4 +65,3 @@ config MBEDTLS_PK_WRITE_C default y endif #CHIP - diff --git a/scripts/tools/telink/process_binaries.py b/scripts/tools/telink/process_binaries.py index 5144920dd86823..27443ba072e5d6 100755 --- a/scripts/tools/telink/process_binaries.py +++ b/scripts/tools/telink/process_binaries.py @@ -103,7 +103,7 @@ def compress_lzma_firmware(input_file, output_file): os.remove('merged.bin') # Telink W91 dual-core SoC binary operations -if build_conf.getboolean('CONFIG_SOC_SERIES_RISCV_TELINK_W91'): +if build_conf.getboolean('CONFIG_SOC_RISCV_TELINK_W91'): n22_partition_offset = build_conf['CONFIG_TELINK_W91_N22_PARTITION_ADDR'] if build_conf.getboolean('CONFIG_BOOTLOADER_MCUBOOT'): n22_partition_offset -= build_conf['CONFIG_FLASH_LOAD_OFFSET'] diff --git a/src/platform/Zephyr/InetUtils.cpp b/src/platform/Zephyr/InetUtils.cpp index a4879884da41f0..07d2a302dacbf3 100644 --- a/src/platform/Zephyr/InetUtils.cpp +++ b/src/platform/Zephyr/InetUtils.cpp @@ -15,8 +15,6 @@ * limitations under the License. */ -#include - #include "InetUtils.h" #include @@ -40,18 +38,10 @@ net_if * GetInterface(Inet::InterfaceId ifaceId) return ifaceId.IsPresent() ? net_if_get_by_index(ifaceId.GetPlatformInterface()) : net_if_get_default(); } -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI net_if * GetWiFiInterface() { -// TODO: Remove dependency after Telink Zephyr update -// net_if_get_first_wifi() is not available in Zephyr 3.3.99 -#if !defined(CONFIG_SOC_SERIES_RISCV_TELINK_W91) return net_if_get_first_wifi(); -#else - return GetInterface(); -#endif } -#endif } // namespace InetUtils } // namespace DeviceLayer diff --git a/src/platform/telink/ConnectivityManagerImpl.cpp b/src/platform/telink/ConnectivityManagerImpl.cpp index 9b2b651dab93b8..ba167ead9d1bd9 100644 --- a/src/platform/telink/ConnectivityManagerImpl.cpp +++ b/src/platform/telink/ConnectivityManagerImpl.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -76,7 +77,7 @@ CHIP_ERROR JoinLeaveMulticastGroup(net_if * iface, const Inet::IPAddress & addre if (maddr && !net_if_ipv6_maddr_is_joined(maddr)) { - net_if_ipv6_maddr_join(maddr); + net_if_ipv6_maddr_join(iface, maddr); } } else if (operation == UDPEndPointImplSockets::MulticastOperation::kLeave) diff --git a/src/platform/telink/telink-mbedtls-config.h b/src/platform/telink/telink-mbedtls-config.h index c9a79ee88f32fb..0e74676ea69321 100644 --- a/src/platform/telink/telink-mbedtls-config.h +++ b/src/platform/telink/telink-mbedtls-config.h @@ -37,6 +37,11 @@ #define MBEDTLS_X509_CREATE_C #define MBEDTLS_X509_CSR_WRITE_C +#ifdef CONFIG_WIFI +#define MBEDTLS_OID_C +#define MBEDTLS_PK_PARSE_C +#endif /* CONFIG_WIFI */ + #undef MBEDTLS_ERROR_C #endif /* MBEDTLS_TSLR9_CONF_H */ From 2064da85d4ea49b5eba625535e91f26db4823472 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 3 Dec 2024 11:27:48 +0000 Subject: [PATCH 15/51] [Telink] Fix B91 Mars target build --- .github/workflows/examples-telink.yaml | 2 -- config/telink/chip-module/Kconfig | 2 +- .../platform/telink/common/include/SensorManagerCommon.h | 2 +- examples/platform/telink/common/src/AppTaskCommon.cpp | 6 +++--- examples/platform/telink/util/include/PWMManager.h | 4 ++-- examples/platform/telink/util/src/PWMManager.cpp | 4 ++-- src/platform/telink/tlsr9518adk80d_mars.conf | 1 - src/platform/telink/tlsr9518adk80d_mars.overlay | 2 +- 8 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 6d3234849840d3..007f7468cd2a52 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -298,8 +298,6 @@ jobs: - 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' - # TODO: remove continue-on-error - continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-temperature-measurement-mars-ota' build" diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 26e99dff180687..08dc0beb5f953c 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -251,5 +251,5 @@ config CHIP_TASK_STACK_SIZE config CHIP_USE_MARS_SENSOR bool "Use Mars board sensor" - depends on CONFIG_SOC_RISCV_TELINK_B9X && (BOARD_TLSR9518ADK80D || BOARD_TLSR9518ADK80D_RETENTION) + depends on SOC_RISCV_TELINK_B9X && (BOARD_TLSR9518ADK80D || BOARD_TLSR9518ADK80D_RETENTION) default n diff --git a/examples/platform/telink/common/include/SensorManagerCommon.h b/examples/platform/telink/common/include/SensorManagerCommon.h index 25e800b078e021..6cce353f25439d 100644 --- a/examples/platform/telink/common/include/SensorManagerCommon.h +++ b/examples/platform/telink/common/include/SensorManagerCommon.h @@ -26,7 +26,7 @@ #include #include -#if defined(CONFIG_CHIP_USE_MARS_SENSOR) && defined(CONFIG_WS2812_STRIP) && !defined(CONFIG_PM) +#if defined(CONFIG_CHIP_USE_MARS_SENSOR) && defined(CONFIG_WS2812_STRIP_GPIO_TELINK) && !defined(CONFIG_PM) #define USE_COLOR_TEMPERATURE_LIGHT #endif diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 479e746a4aac62..e228fbce980449 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -424,7 +424,7 @@ void AppTaskCommon::InitPwms() LinkPwms(pwmManager); -#if CONFIG_WS2812_STRIP +#if CONFIG_WS2812_STRIP_GPIO_TELINK pwmManager.linkBackend(Ws2812Strip::getInstance()); #elif CONFIG_PWM pwmManager.linkBackend(PwmPool::getInstance()); @@ -437,7 +437,7 @@ void AppTaskCommon::LinkPwms(PwmManager & pwmManager) { #if CONFIG_BOARD_TLSR9118BDK40D_V1 && CONFIG_PWM // TLSR9118BDK40D_V1 EVK supports single LED PWM channel pwmManager.linkPwm(PwmManager::EAppPwm_Red, 0); -#elif CONFIG_WS2812_STRIP +#elif CONFIG_WS2812_STRIP_GPIO_TELINK pwmManager.linkPwm(PwmManager::EAppPwm_Red, 0); pwmManager.linkPwm(PwmManager::EAppPwm_Green, 1); pwmManager.linkPwm(PwmManager::EAppPwm_Blue, 2); @@ -446,7 +446,7 @@ void AppTaskCommon::LinkPwms(PwmManager & pwmManager) pwmManager.linkPwm(PwmManager::EAppPwm_Red, 1); pwmManager.linkPwm(PwmManager::EAppPwm_Green, 2); pwmManager.linkPwm(PwmManager::EAppPwm_Blue, 3); -#endif // CONFIG_WS2812_STRIP +#endif } void AppTaskCommon::InitButtons(void) diff --git a/examples/platform/telink/util/include/PWMManager.h b/examples/platform/telink/util/include/PWMManager.h index 717180a9fa4f01..eced61e7614286 100644 --- a/examples/platform/telink/util/include/PWMManager.h +++ b/examples/platform/telink/util/include/PWMManager.h @@ -110,7 +110,7 @@ class PwmManager PwmBackend * m_backend; }; -#if CONFIG_WS2812_STRIP +#if CONFIG_WS2812_STRIP_GPIO_TELINK class Ws2812Strip : public PwmBackend { @@ -170,4 +170,4 @@ class PwmDummy : public PwmBackend PwmDummy(){}; }; -#endif // CONFIG_WS2812_STRIP +#endif // CONFIG_WS2812_STRIP_GPIO_TELINK diff --git a/examples/platform/telink/util/src/PWMManager.cpp b/examples/platform/telink/util/src/PWMManager.cpp index aa747974c93b31..b3502723dbf4d4 100644 --- a/examples/platform/telink/util/src/PWMManager.cpp +++ b/examples/platform/telink/util/src/PWMManager.cpp @@ -142,7 +142,7 @@ void PwmManager::linkBackend(PwmBackend & backend) } } -#if CONFIG_WS2812_STRIP +#if CONFIG_WS2812_STRIP_GPIO_TELINK #include @@ -297,4 +297,4 @@ void PwmDummy::setPwmHWBreath(size_t pwm, size_t breathMs) LOG_WRN("PWM Dummy setPwmHWBreath not supported"); } -#endif // CONFIG_WS2812_STRIP +#endif // CONFIG_WS2812_STRIP_GPIO_TELINK diff --git a/src/platform/telink/tlsr9518adk80d_mars.conf b/src/platform/telink/tlsr9518adk80d_mars.conf index 1b7b4a47378f6c..268a64d1d03c91 100644 --- a/src/platform/telink/tlsr9518adk80d_mars.conf +++ b/src/platform/telink/tlsr9518adk80d_mars.conf @@ -8,7 +8,6 @@ CONFIG_SENSOR=y # WS2812 CONFIG_LED_STRIP=y CONFIG_LED_STRIP_LOG_LEVEL_DBG=y -CONFIG_WS2812_STRIP=y CONFIG_WS2812_STRIP_GPIO_TELINK=y # DFU via USB diff --git a/src/platform/telink/tlsr9518adk80d_mars.overlay b/src/platform/telink/tlsr9518adk80d_mars.overlay index a8a130aa2cac85..6c00b211cd667d 100644 --- a/src/platform/telink/tlsr9518adk80d_mars.overlay +++ b/src/platform/telink/tlsr9518adk80d_mars.overlay @@ -28,7 +28,7 @@ color-mapping = ; - in-gpios = <&gpiob 4 0>; + gpios = <&gpiob 4 0>; }; }; From 95eface79a19379302210da9335f3002d37124ea Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 3 Dec 2024 11:28:11 +0000 Subject: [PATCH 16/51] [Telink] Use correct if SOC_RISCV_TELINK_TL321X --- config/telink/chip-module/Kconfig.defaults | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index bcab07a74fb5e2..d659a1569b9b63 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -148,8 +148,7 @@ config BT_BUF_ACL_TX_SIZE default 107 if SOC_RISCV_TELINK_TL321X default 251 - -#ifdef CONFIG_SOC_RISCV_TELINK_TL321X +if SOC_RISCV_TELINK_TL321X config BT_BUF_EVT_RX_COUNT default 4 @@ -161,8 +160,7 @@ config BT_GATT_CACHING bool default n - -#endif +endif # SOC_RISCV_TELINK_TL321X config BT_RX_STACK_SIZE default 1352 if BT_B9X From a1b1a162bf1624b1d81e950ed82d6a78bdb86750 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 3 Dec 2024 11:58:55 +0000 Subject: [PATCH 17/51] [Telink] Fix retention target builds --- .github/workflows/chef.yaml | 1 - .github/workflows/examples-telink.yaml | 7 ------- config/telink/chip-module/Kconfig.defaults | 8 ++------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 332ee961b524b1..0461eddecf7153 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -19,7 +19,6 @@ on: branches: - master - 'v*-branch' - - update_zephyr_3.7 pull_request: merge_group: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 007f7468cd2a52..df11dc7017e8cd 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -19,7 +19,6 @@ on: branches: - master - 'v*-branch' - - update_zephyr_3.7 pull_request: merge_group: @@ -77,8 +76,6 @@ jobs: - 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' - # TODO: remove continue-on-error - continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-air-quality-sensor' build" @@ -133,8 +130,6 @@ jobs: - name: Build example Telink (B92 retention) Contact Sensor App # Run test for master and all PRs - # TODO: remove continue-on-error - continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-contact-sensor' build" @@ -282,8 +277,6 @@ jobs: - 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' - # TODO: remove continue-on-error - continue-on-error: true run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-smoke-co-alarm' build" diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index d659a1569b9b63..880a6389d9118b 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -201,13 +201,9 @@ endif # SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX endif # BT -# Board retention config -# Cut down the ram cost by matter's change,it can keep ramcode (driver). -# No need load the ramcode every time in thread mode (retention mode). -# If the ram is not enough , can change it back , initial setting is n. if BOARD_TLSR9528A_RETENTION || BOARD_TLSR9258A_RETENTION || BOARD_TLSR9518ADK80D_RETENTION config SOC_SERIES_RISCV_TELINK_B9X_NON_RETENTION_RAM_CODE - default n if PM + default y if PM config TELINK_B9X_MATTER_RETENTION_LAYOUT default y if PM @@ -347,7 +343,7 @@ config CHIP_WIFI select NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements select NET_IPV6_NBR_CACHE select NET_STATISTICS_USER_API - imply MBEDTLS_ENTROPY_C + imply MBEDTLS_ENTROPY_C if CHIP_WIFI From d9371be7ad4882e181468f015d54732270ce4717 Mon Sep 17 00:00:00 2001 From: interfer Date: Wed, 4 Dec 2024 14:37:53 +0200 Subject: [PATCH 18/51] [Telink] fixed W91 WiFi interface init reverted GetWifiInterface in InetUtils changes, added syntax fixes to Kconfigs.default --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- config/telink/chip-module/Kconfig.defaults | 9 +++++++++ src/platform/Zephyr/InetUtils.cpp | 10 ++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 0461eddecf7153..a2f6cf92e016ac 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 ac713b037c18444628319ac5fedc23a31966213c" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 8a4cff658226da1e4877e7f045747fa345a8b135" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index df11dc7017e8cd..4cc21daf0ce843 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 ac713b037c18444628319ac5fedc23a31966213c" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 8a4cff658226da1e4877e7f045747fa345a8b135" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 880a6389d9118b..a3ee1107096353 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -179,21 +179,30 @@ config BT_DEVICE_NAME_GATT_WRITABLE if SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX config TL_BLE_CTRL_THREAD_STACK_SIZE + int default 648 config TL_BLE_CTRL_MASTER_MAX_NUM + int default 0 config TL_BLE_CTRL_SLAVE_MAX_NUM + int default 1 config TL_BLE_CTRL_RF_POWER + int default 3 if PM default 8 if BT_TLX default 9 choice TL_BLE_CTRL_MAC_TYPE + prompt "MAC address type" default TL_BLE_CTRL_MAC_TYPE_RANDOM_STATIC + +config TL_BLE_CTRL_MAC_TYPE_RANDOM_STATIC + bool "Random Static MAC Address" + endchoice endif # SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX diff --git a/src/platform/Zephyr/InetUtils.cpp b/src/platform/Zephyr/InetUtils.cpp index 07d2a302dacbf3..b692cdafa80c59 100644 --- a/src/platform/Zephyr/InetUtils.cpp +++ b/src/platform/Zephyr/InetUtils.cpp @@ -15,6 +15,8 @@ * limitations under the License. */ +#include + #include "InetUtils.h" #include @@ -38,10 +40,18 @@ net_if * GetInterface(Inet::InterfaceId ifaceId) return ifaceId.IsPresent() ? net_if_get_by_index(ifaceId.GetPlatformInterface()) : net_if_get_default(); } +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI net_if * GetWiFiInterface() { +// TODO: Remove dependency after Telink Zephyr update +// net_if_get_first_wifi() is not available in Zephyr 3.3.99 +#if !defined(CONFIG_SOC_RISCV_TELINK_W91) return net_if_get_first_wifi(); +#else + return GetInterface(); +#endif } +#endif } // namespace InetUtils } // namespace DeviceLayer From 6893758fd99842cc0a29737d96e53e486a64f94b Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Wed, 4 Dec 2024 16:20:40 +0000 Subject: [PATCH 19/51] [Telink] Update to latest zephyr (develop_new_matter_fixes) hash --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index a2f6cf92e016ac..4b625f7ecff136 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 8a4cff658226da1e4877e7f045747fa345a8b135" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 80ba99a8fd90427d10513255c25104d8ea94b3b1" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 4cc21daf0ce843..6bb5feff1e963c 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 8a4cff658226da1e4877e7f045747fa345a8b135" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 80ba99a8fd90427d10513255c25104d8ea94b3b1" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs From c643c5e60458e30bbe10626cda089ceedb59b9aa Mon Sep 17 00:00:00 2001 From: interfer Date: Fri, 6 Dec 2024 17:48:31 +0200 Subject: [PATCH 20/51] [Telink] memory layout and default config changes Reduced mcuboot partition by 0x1000 and removed two other partitions getting 0x3000 to distribute 0x4000 between slot0 and slot 1. Kconfig.defaults changes to reduce ROM usage on B92 lighting OTA. To be improved [Telink] reduced MCUboot partition for most targets increase of slot0,1, bootloader config changes [Telink] Fixed B9x platform startup Lack of MBEDTLS_ZEPHYR_ENTROPY config in defaults which led to InitChipStack 172 error. As result entropy failed in src/platform/Zephyr/PlatformManagerImpl.cpp [Telink] fixed B9x commissioning Reverted network buffers configs [Telink] TL3218 commissioning fixes Changes to fix TLx commissioning on new Zephyr [Telink] Zephyr revision update After merge updates. Kconfig change to fix TL3218 commissioning Reduced RAM usage to build TL3218 by COMMON_LIBC_MALLOC_ARENA_SIZE changing [Telink] zephyr version change, cleanup Changed MCUBOOT logs config, same for LZMA --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 10 +++---- config/telink/app/bootloader.conf | 21 ++++++++------- .../telink/app/bootloader_compress_lzma.conf | 16 +++++------- config/telink/chip-module/Kconfig.defaults | 17 +++++++----- .../telink/tlsr9258a_2m_flash.overlay | 18 ++++++------- .../telink/tlsr9518adk80d_2m_flash.overlay | 18 ++++++------- .../telink/tlsr9528a_2m_flash.overlay | 26 +++++++------------ 8 files changed, 62 insertions(+), 66 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 4b625f7ecff136..705f4e23bb3f29 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 80ba99a8fd90427d10513255c25104d8ea94b3b1" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 7c5d3acfbeb25d115cfb6542616f0e7906b4c70a" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 6bb5feff1e963c..d21bffc470224e 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 80ba99a8fd90427d10513255c25104d8ea94b3b1" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 7c5d3acfbeb25d115cfb6542616f0e7906b4c70a" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs @@ -178,14 +178,14 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (TL3218) Lighting App with OTA (LZMA), Shell, Factory Data + - name: Build example Telink (TL3218) Lighting App with OTA (LZMA), Factory Data # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tl3218-light-ota-compress-lzma-shell-factory-data' build" + "./scripts/build/build_examples.py --target 'telink-tl3218-light-ota-compress-lzma-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl3218 light-app-ota-compress-lzma-shell-factory-data \ - out/telink-tl3218-light-ota-compress-lzma-shell-factory-data/zephyr/zephyr.elf \ + telink tl3218 light-app-ota-compress-lzma-factory-data \ + out/telink-tl3218-light-ota-compress-lzma-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output (keep tools) diff --git a/config/telink/app/bootloader.conf b/config/telink/app/bootloader.conf index 6f60d1b102a7b4..1c69c00e44d111 100644 --- a/config/telink/app/bootloader.conf +++ b/config/telink/app/bootloader.conf @@ -29,12 +29,15 @@ CONFIG_BOOT_SWAP_USING_SCRATCH=n # With disabled option the only image magic is validated CONFIG_BOOT_VALIDATE_SLOT0=y -# Sets log level for modules which don't specify it explicitly. -# When set to 0 it means log will not be activated for those modules. -# Levels are: -# - 0 OFF, do not write by default -# - 1 ERROR, default to only write LOG_LEVEL_ERR -# - 2 WARNING, default to write LOG_LEVEL_WRN -# - 3 INFO, default to write LOG_LEVEL_INFO -# - 4 DEBUG, default to write LOG_LEVEL_DBG -CONFIG_LOG_DEFAULT_LEVEL=3 +# MCUBOOT log levels are: +# - OFF, LOG_LEVEL_ERR_OFF +# - ERROR, LOG_LEVEL_ERR +# - WARNING, LOG_LEVEL_WRN +# - INFO, LOG_LEVEL_INF +# - DEBUG, LOG_LEVEL_DBG +CONFIG_MCUBOOT_LOG_LEVEL_ERR=y + +# TODO: revert before merge (made to first run Jenkins) +CONFIG_EXCEPTION_DEBUG=n +CONFIG_PICOLIBC=y +CONFIG_GPIO=n diff --git a/config/telink/app/bootloader_compress_lzma.conf b/config/telink/app/bootloader_compress_lzma.conf index 606665c72c78e2..c4de1f7323e882 100644 --- a/config/telink/app/bootloader_compress_lzma.conf +++ b/config/telink/app/bootloader_compress_lzma.conf @@ -22,15 +22,13 @@ CONFIG_BOOT_UPGRADE_ONLY=y # With disabled option the only image magic is validated CONFIG_BOOT_VALIDATE_SLOT0=y -# Sets log level for modules which don't specify it explicitly. -# When set to 0 it means log will not be activated for those modules. -# Levels are: -# - 0 OFF, do not write by default -# - 1 ERROR, default to only write LOG_LEVEL_ERR -# - 2 WARNING, default to write LOG_LEVEL_WRN -# - 3 INFO, default to write LOG_LEVEL_INFO -# - 4 DEBUG, default to write LOG_LEVEL_DBG -CONFIG_LOG_DEFAULT_LEVEL=3 +# MCUBOOT log levels are: +# - OFF, LOG_LEVEL_ERR_OFF +# - ERROR, LOG_LEVEL_ERR +# - WARNING, LOG_LEVEL_WRN +# - INFO, LOG_LEVEL_INF +# - DEBUG, LOG_LEVEL_DBG +CONFIG_MCUBOOT_LOG_LEVEL_INF=y # LZMA used sys_heap based allocators CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=78000 diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index a3ee1107096353..4194645b0ebad3 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -83,7 +83,8 @@ config HEAP_MEM_POOL_SIZE default 1280 config COMMON_LIBC_MALLOC_ARENA_SIZE - default 20716 if SOC_RISCV_TELINK_TL321X || SOC_SERIES_RISCV_TELINK_B9X_RETENTION + default 20716 if SOC_SERIES_RISCV_TELINK_B9X_RETENTION + default 16384 if SOC_RISCV_TELINK_TL321X default 12288 config NET_IPV6_MLD @@ -104,11 +105,13 @@ config NET_PKT_TX_COUNT default 8 config NET_BUF_RX_COUNT - default 4 if PM || SOC_RISCV_TELINK_TL321X + default 4 if PM + default 16 if SOC_RISCV_TELINK_TL321X default 32 config NET_BUF_TX_COUNT - default 4 if PM || SOC_RISCV_TELINK_TL321X + default 4 if PM + default 16 if SOC_RISCV_TELINK_TL321X default 32 config GPIO @@ -148,8 +151,6 @@ config BT_BUF_ACL_TX_SIZE default 107 if SOC_RISCV_TELINK_TL321X default 251 -if SOC_RISCV_TELINK_TL321X - config BT_BUF_EVT_RX_COUNT default 4 @@ -160,8 +161,6 @@ config BT_GATT_CACHING bool default n -endif # SOC_RISCV_TELINK_TL321X - config BT_RX_STACK_SIZE default 1352 if BT_B9X default 1010 if BT_TLX @@ -428,6 +427,10 @@ config MBEDTLS_USER_CONFIG_ENABLE config MBEDTLS_USER_CONFIG_FILE default "telink-mbedtls-config.h" +config MBEDTLS_ZEPHYR_ENTROPY + bool + default y + config MBEDTLS_CIPHER_AES_ENABLED default y diff --git a/src/platform/telink/tlsr9258a_2m_flash.overlay b/src/platform/telink/tlsr9258a_2m_flash.overlay index d08d0e4ff4a6ba..2e41751980112e 100644 --- a/src/platform/telink/tlsr9258a_2m_flash.overlay +++ b/src/platform/telink/tlsr9258a_2m_flash.overlay @@ -9,23 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0xf000>; + reg = <0x00000000 0xb000>; }; - slot0_partition: partition@f000 { + slot0_partition: partition@b000 { label = "image-0"; - reg = <0xf000 0xf1000>; + reg = <0xb000 0xf3000>; }; - factory_partition: partition@100000 { + factory_partition: partition@fe000 { label = "factory-data"; - reg = <0x100000 0x1000>; + reg = <0xfe000 0x1000>; }; - storage_partition: partition@101000 { + storage_partition: partition@ff000 { label = "storage"; - reg = <0x101000 0xc000>; + reg = <0xff000 0xc000>; }; - slot1_partition: partition@10d000 { + slot1_partition: partition@10b000 { label = "image-1"; - reg = <0x10d000 0xf1000>; + reg = <0x10b000 0xf3000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; diff --git a/src/platform/telink/tlsr9518adk80d_2m_flash.overlay b/src/platform/telink/tlsr9518adk80d_2m_flash.overlay index d08d0e4ff4a6ba..62c17e96bd0031 100644 --- a/src/platform/telink/tlsr9518adk80d_2m_flash.overlay +++ b/src/platform/telink/tlsr9518adk80d_2m_flash.overlay @@ -9,23 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0xf000>; + reg = <0x00000000 0xd000>; }; - slot0_partition: partition@f000 { + slot0_partition: partition@d000 { label = "image-0"; - reg = <0xf000 0xf1000>; + reg = <0xd000 0xf2000>; }; - factory_partition: partition@100000 { + factory_partition: partition@ff000 { label = "factory-data"; - reg = <0x100000 0x1000>; + reg = <0xff000 0x1000>; }; - storage_partition: partition@101000 { + storage_partition: partition@100000 { label = "storage"; - reg = <0x101000 0xc000>; + reg = <0x100000 0xc000>; }; - slot1_partition: partition@10d000 { + slot1_partition: partition@10c000 { label = "image-1"; - reg = <0x10d000 0xf1000>; + reg = <0x10c000 0xf2000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; diff --git a/src/platform/telink/tlsr9528a_2m_flash.overlay b/src/platform/telink/tlsr9528a_2m_flash.overlay index d86a001d5ef86a..62c17e96bd0031 100644 --- a/src/platform/telink/tlsr9528a_2m_flash.overlay +++ b/src/platform/telink/tlsr9528a_2m_flash.overlay @@ -9,31 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0xf000>; + reg = <0x00000000 0xd000>; }; - slot0_partition: partition@f000 { + slot0_partition: partition@d000 { label = "image-0"; - reg = <0xf000 0xee000>; + reg = <0xd000 0xf2000>; }; - factory_partition: partition@fd000 { + factory_partition: partition@ff000 { label = "factory-data"; - reg = <0xfd000 0x1000>; + reg = <0xff000 0x1000>; }; - dac_keypair_partition: partition@fe000 { - label = "dac-keypair"; - reg = <0xfe000 0x1000>; //store dac and key pair. - }; - descriptor_partition: partition@ff000 { - label = "sboot-descriptor"; - reg = <0xff000 0x2000>; - }; - storage_partition: partition@101000 { + storage_partition: partition@100000 { label = "storage"; - reg = <0x101000 0xf000>; + reg = <0x100000 0xc000>; }; - slot1_partition: partition@110000 { + slot1_partition: partition@10c000 { label = "image-1"; - reg = <0x110000 0xee000>; + reg = <0x10c000 0xf2000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; From a3093b664ef6f9cc82921e92224c43db87c036f3 Mon Sep 17 00:00:00 2001 From: interfer Date: Mon, 16 Dec 2024 17:47:34 +0200 Subject: [PATCH 21/51] [Telink] W91 OTA, Factory data commissioning fix Fixes full config target commissioning for W91. Been failing on `SendAttestationRequest` step, finished with `general error 0x01`. Tested manually with chip-tool on RPi on tlsr9118bdk40d --- config/telink/chip-module/Kconfig.defaults | 1 + 1 file changed, 1 insertion(+) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 4194645b0ebad3..8eb6dfd6227d99 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -352,6 +352,7 @@ config CHIP_WIFI select NET_IPV6_NBR_CACHE select NET_STATISTICS_USER_API imply MBEDTLS_ENTROPY_C + imply MBEDTLS_KEY_EXCHANGE_RSA_ENABLED if CHIP_WIFI From f887453a5b46bfb410c09e385001e1101d27b3a8 Mon Sep 17 00:00:00 2001 From: interfer Date: Tue, 17 Dec 2024 14:12:50 +0200 Subject: [PATCH 22/51] [Telink] W91 stacks increase Increased NET_MGMT_EVENT_STACK_SIZE by 122 B and IPC_SERVICE_BACKEND_ICMSG_WQ_STACK_SIZE by 256 B so that net_mgmt and icmsg_workq stack were used <90%. Jenkins reported thread analyzer warnings on that. --- config/telink/chip-module/Kconfig.defaults | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 8eb6dfd6227d99..30701246f652eb 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -83,8 +83,8 @@ config HEAP_MEM_POOL_SIZE default 1280 config COMMON_LIBC_MALLOC_ARENA_SIZE - default 20716 if SOC_SERIES_RISCV_TELINK_B9X_RETENTION - default 16384 if SOC_RISCV_TELINK_TL321X + default 20716 if SOC_SERIES_RISCV_TELINK_B9X_RETENTION + default 16384 if SOC_RISCV_TELINK_TL321X default 12288 config NET_IPV6_MLD @@ -407,7 +407,10 @@ config CHIP_WIFI_CONNECTION_RECOVERY_JITTER within range [-JITTER; +JITTER]. config NET_MGMT_EVENT_STACK_SIZE - default 1128 + default 1250 + +config IPC_SERVICE_BACKEND_ICMSG_WQ_STACK_SIZE + default 2304 if TELINK_W91_IPC_DISPATCHER endif # CHIP_WIFI From 3c4d2728a671cd4f4d64183a1506b647f9aff7c2 Mon Sep 17 00:00:00 2001 From: interfer Date: Tue, 17 Dec 2024 15:39:31 +0200 Subject: [PATCH 23/51] [Telink] review changes draft Reverted NET_BUF_RX/TX_COUNT --- config/telink/app/bootloader.conf | 7 +++---- config/telink/chip-module/Kconfig.defaults | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/config/telink/app/bootloader.conf b/config/telink/app/bootloader.conf index 1c69c00e44d111..2a9cb468631490 100644 --- a/config/telink/app/bootloader.conf +++ b/config/telink/app/bootloader.conf @@ -35,9 +35,8 @@ CONFIG_BOOT_VALIDATE_SLOT0=y # - WARNING, LOG_LEVEL_WRN # - INFO, LOG_LEVEL_INF # - DEBUG, LOG_LEVEL_DBG -CONFIG_MCUBOOT_LOG_LEVEL_ERR=y +CONFIG_MCUBOOT_LOG_LEVEL_INF=y -# TODO: revert before merge (made to first run Jenkins) -CONFIG_EXCEPTION_DEBUG=n -CONFIG_PICOLIBC=y +# Reduced footprint CONFIG_GPIO=n +CONFIG_PICOLIBC=y diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 30701246f652eb..5f26f406913d4e 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -105,13 +105,11 @@ config NET_PKT_TX_COUNT default 8 config NET_BUF_RX_COUNT - default 4 if PM - default 16 if SOC_RISCV_TELINK_TL321X + default 12 if PM || SOC_RISCV_TELINK_TL321X default 32 config NET_BUF_TX_COUNT - default 4 if PM - default 16 if SOC_RISCV_TELINK_TL321X + default 12 if PM || SOC_RISCV_TELINK_TL321X default 32 config GPIO @@ -407,9 +405,11 @@ config CHIP_WIFI_CONNECTION_RECOVERY_JITTER within range [-JITTER; +JITTER]. config NET_MGMT_EVENT_STACK_SIZE + int default 1250 config IPC_SERVICE_BACKEND_ICMSG_WQ_STACK_SIZE + int default 2304 if TELINK_W91_IPC_DISPATCHER endif # CHIP_WIFI From 0d36905a785391b68f5d5bc762654e16b5f1b8e4 Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Mon, 30 Dec 2024 11:52:36 +0000 Subject: [PATCH 24/51] [Telink] Add tl7218 board. --- .github/workflows/examples-telink.yaml | 12 ++++ scripts/build/build/targets.py | 1 + scripts/build/builders/telink.py | 3 + .../build/testdata/all_targets_linux_x64.txt | 2 +- src/platform/telink/tl7218.overlay | 61 +++++++++++++++++++ src/platform/telink/tl7218_2m_flash.overlay | 35 +++++++++++ 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/platform/telink/tl7218.overlay create mode 100644 src/platform/telink/tl7218_2m_flash.overlay diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 439fe50bf44699..6232320fe26df6 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -191,6 +191,18 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* + - name: Build example Telink (TL7218) 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-tl7218-light-ota-shell-factory-data' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tl7218 light-app-ota-shell-factory-data \ + out/telink-tl7218-light-ota-shell-factory-data/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + - 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, 4Mb flash # Run test for master and all PRs run: | diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 3e880fd745a6a4..2b6a73d2779b27 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -772,6 +772,7 @@ def BuildTelinkTarget(): TargetPart('tlsr9258a', board=TelinkBoard.TLSR9258A), TargetPart('tlsr9258a_retention', board=TelinkBoard.TLSR9258A_RETENTION), TargetPart('tl3218', board=TelinkBoard.TL3218), + TargetPart('tl7218', board=TelinkBoard.TL7218), ]) target.AppendFixedTargets([ diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 4a02c8e47c3c73..5e0c246d99cf8e 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -122,6 +122,7 @@ class TelinkBoard(Enum): TLSR9258A = auto() TLSR9258A_RETENTION = auto() TL3218 = auto() + TL7218 = auto() def GnArgName(self): if self == TelinkBoard.TLRS9118BDK40D: @@ -138,6 +139,8 @@ def GnArgName(self): return 'tlsr9258a_retention' elif self == TelinkBoard.TL3218: return 'tl3218' + elif self == TelinkBoard.TL7218: + return 'tl7218' else: raise Exception('Unknown board type: %r' % self) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index 5a5cdece317552..299bb4a1437401 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -22,5 +22,5 @@ nuttx-x64-light qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage] stm32-stm32wb5mm-dk-light tizen-arm-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-coverage][-with-ui] -telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] +telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218,tl7218}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] openiotsdk-{shell,lock}[-mbedtls][-psa] diff --git a/src/platform/telink/tl7218.overlay b/src/platform/telink/tl7218.overlay new file mode 100644 index 00000000000000..2a764c5e3b2e86 --- /dev/null +++ b/src/platform/telink/tl7218.overlay @@ -0,0 +1,61 @@ +/ { + /* Short TL_Key3 (J6 pin 31) to ground (J4 pin 3, 5, 9) */ + key_pool { + compatible = "gpio-keys"; + + inp { + gpios = <&gpiod 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpiod 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + }; + + key_matrix { + compatible = "gpio-keys"; + + col { + gpios = <&gpiod 5 GPIO_ACTIVE_HIGH>, + <&gpiod 7 GPIO_ACTIVE_HIGH>; + }; + + row { + gpios = <&gpiod 4 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>, + <&gpiod 6 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; + }; + }; + + led_pool { + compatible = "gpio-leds"; + + out { + gpios = <&gpioc 3 GPIO_ACTIVE_HIGH>; + }; + }; + + 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>; + }; + }; +}; + +&pwm0 { + /* On board RGB LEDs */ + pinctrl-ch0 = <&pwm_ch0_pc1_default>; + pinctrl-ch2 = <&pwm_ch1_pc0_default>; + pinctrl-ch1 = <&pwm_ch2_pc2_default>; +}; + +&pinctrl { + pwm_ch0_pc1_default: pwm_ch0_pc1_default { + pinmux = ; + }; + pwm_ch1_pc0_default: pwm_ch1_pc0_default { + pinmux = ; + }; + pwm_ch2_pc2_default: pwm_ch2_pc2_default { + pinmux = ; + }; +}; diff --git a/src/platform/telink/tl7218_2m_flash.overlay b/src/platform/telink/tl7218_2m_flash.overlay new file mode 100644 index 00000000000000..2e41751980112e --- /dev/null +++ b/src/platform/telink/tl7218_2m_flash.overlay @@ -0,0 +1,35 @@ +&flash { + reg = <0x20000000 0x200000>; + + /delete-node/ partitions; + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0xb000>; + }; + slot0_partition: partition@b000 { + label = "image-0"; + reg = <0xb000 0xf3000>; + }; + factory_partition: partition@fe000 { + label = "factory-data"; + reg = <0xfe000 0x1000>; + }; + storage_partition: partition@ff000 { + label = "storage"; + reg = <0xff000 0xc000>; + }; + slot1_partition: partition@10b000 { + label = "image-1"; + reg = <0x10b000 0xf3000>; + }; + vendor_partition: partition@1fe000 { + label = "vendor-data"; + reg = <0x1fe000 0x2000>; + }; + }; +}; From 3cc4d9f5ccca46b7791d9c6bab5a0f95a568928a Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Mon, 30 Dec 2024 11:52:37 +0000 Subject: [PATCH 25/51] [Telink] Fix compilation warnings. --- examples/platform/telink/util/src/ColorFormat.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/platform/telink/util/src/ColorFormat.cpp b/examples/platform/telink/util/src/ColorFormat.cpp index 0c92c9bc0a02e6..ac648e0ddc1d9b 100644 --- a/examples/platform/telink/util/src/ColorFormat.cpp +++ b/examples/platform/telink/util/src/ColorFormat.cpp @@ -116,9 +116,9 @@ RgbColor_t XYToRgb(uint8_t Level, uint16_t currentX, uint16_t currentY) b = (X * 0.0557f) - (Y * 0.2040f) + (Z * 1.0570f); // apply gamma 2.2 correction - r = (r <= 0.0031308f ? 12.92f * r : (1.055f) * pow(r, (1.0f / 2.4f)) - 0.055f); - g = (g <= 0.0031308f ? 12.92f * g : (1.055f) * pow(g, (1.0f / 2.4f)) - 0.055f); - b = (b <= 0.0031308f ? 12.92f * b : (1.055f) * pow(b, (1.0f / 2.4f)) - 0.055f); + r = (r <= 0.0031308f ? 12.92f * r : (1.055f) * powf(r, (1.0f / 2.4f)) - 0.055f); + g = (g <= 0.0031308f ? 12.92f * g : (1.055f) * powf(g, (1.0f / 2.4f)) - 0.055f); + b = (b <= 0.0031308f ? 12.92f * b : (1.055f) * powf(b, (1.0f / 2.4f)) - 0.055f); // Round off r = clamp(r, 0, 1); @@ -150,17 +150,17 @@ RgbColor_t CTToRgb(CtColor_t ct) } else { - r = 329.698727446f * pow(ctCentiKelvin - 60, -0.1332047592f); + r = 329.698727446f * powf(ctCentiKelvin - 60, -0.1332047592f); } // Green if (ctCentiKelvin <= 66) { - g = 99.4708025861f * log(ctCentiKelvin) - 161.1195681661f; + g = 99.4708025861f * logf(ctCentiKelvin) - 161.1195681661f; } else { - g = 288.1221695283f * pow(ctCentiKelvin - 60, -0.0755148492f); + g = 288.1221695283f * powf(ctCentiKelvin - 60, -0.0755148492f); } // Blue From 99b861de9cafff37a8278b53bb05186e38906087 Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Mon, 30 Dec 2024 12:08:00 +0000 Subject: [PATCH 26/51] [Telink] Fix config option. --- config/telink/chip-module/Kconfig.defaults | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 5f26f406913d4e..d80a16a7b773dd 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -431,8 +431,7 @@ config MBEDTLS_USER_CONFIG_ENABLE config MBEDTLS_USER_CONFIG_FILE default "telink-mbedtls-config.h" -config MBEDTLS_ZEPHYR_ENTROPY - bool +config MBEDTLS_ENTROPY_POLL_ZEPHYR default y config MBEDTLS_CIPHER_AES_ENABLED From 04ee5ac8f4b696b71b5ffdac6a5474050ccc6bfa Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Mon, 30 Dec 2024 12:08:01 +0000 Subject: [PATCH 27/51] [Telink] Cleanup MbedTLS configuration. --- config/telink/chip-module/CMakeLists.txt | 2 +- config/telink/chip-module/Kconfig.defaults | 18 +++++--- src/platform/telink/telink-mbedtls-config.h | 47 --------------------- 3 files changed, 13 insertions(+), 54 deletions(-) delete mode 100644 src/platform/telink/telink-mbedtls-config.h diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index ed460acd6acd3a..2d41f811c31caf 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -64,7 +64,7 @@ matter_add_cxxflags("${ZEPHYR_CFLAGS_CC}") zephyr_get_gnu_cpp_standard(ZEPHYR_GNU_CPP_STD) matter_add_cxxflags(${ZEPHYR_GNU_CPP_STD}) -matter_add_flags(-DMBEDTLS_USER_CONFIG_FILE=) +matter_add_flags(-DMBEDTLS_USER_CONFIG_FILE=<${CONFIG_MBEDTLS_CFG_FILE}>) # Set up custom OpenThread configuration diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index d80a16a7b773dd..e1f34fa058288b 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -425,12 +425,6 @@ config CHIP_ENABLE_PAIRING_AUTOSTART config MBEDTLS default y -config MBEDTLS_USER_CONFIG_ENABLE - default y - -config MBEDTLS_USER_CONFIG_FILE - default "telink-mbedtls-config.h" - config MBEDTLS_ENTROPY_POLL_ZEPHYR default y @@ -455,6 +449,18 @@ config MBEDTLS_ECDH_C config MBEDTLS_ECDSA_C default y +config MBEDTLS_HKDF_C + default y + +config MBEDTLS_PKCS5_C + default y + +config MBEDTLS_X509_CSR_WRITE_C + default y + +config MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + default y + # Disable not used shell modules config SHELL_WILDCARD diff --git a/src/platform/telink/telink-mbedtls-config.h b/src/platform/telink/telink-mbedtls-config.h deleted file mode 100644 index 0e74676ea69321..00000000000000 --- a/src/platform/telink/telink-mbedtls-config.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright (c) 2022-2024 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Telink mbedtls configuration file. - * - */ - -#ifndef MBEDTLS_TSLR9_CONF_H -#define MBEDTLS_TSLR9_CONF_H - -#ifdef MBEDTLS_PLATFORM_MEMORY -#undef MBEDTLS_PLATFORM_MEMORY -#endif - -#ifdef MBEDTLS_MEMORY_BUFFER_ALLOC_C -#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C -#endif - -#define MBEDTLS_HKDF_C -#define MBEDTLS_PKCS5_C -#define MBEDTLS_X509_CREATE_C -#define MBEDTLS_X509_CSR_WRITE_C - -#ifdef CONFIG_WIFI -#define MBEDTLS_OID_C -#define MBEDTLS_PK_PARSE_C -#endif /* CONFIG_WIFI */ - -#undef MBEDTLS_ERROR_C - -#endif /* MBEDTLS_TSLR9_CONF_H */ From 5d8f6fb5e1793ed7e4f45279030cae28cb4d7635 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 30 Dec 2024 12:08:35 +0000 Subject: [PATCH 28/51] [Telink] Update tl721x default Kconfig - update the default values for BT_RX_STACK_SIZE and COMMON_LIBC_MALLOC_ARENA_SIZE for TL721X Signed-off-by: Jinmiao Yu --- config/telink/chip-module/Kconfig.defaults | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index e1f34fa058288b..f8b2cab08bc266 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -84,7 +84,7 @@ config HEAP_MEM_POOL_SIZE config COMMON_LIBC_MALLOC_ARENA_SIZE default 20716 if SOC_SERIES_RISCV_TELINK_B9X_RETENTION - default 16384 if SOC_RISCV_TELINK_TL321X + default 16384 if SOC_RISCV_TELINK_TL321X || SOC_RISCV_TELINK_TL721X default 12288 config NET_IPV6_MLD @@ -160,13 +160,11 @@ config BT_GATT_CACHING default n config BT_RX_STACK_SIZE - default 1352 if BT_B9X - default 1010 if BT_TLX + default 1352 if BT_B9X || BT_TLX default 2048 if BT_W91 config BT_HCI_TX_STACK_SIZE - default 640 if BT_B9X - default 640 if BT_TLX + default 640 if BT_B9X || BT_TLX default 2048 if BT_W91 config BT_DEVICE_NAME_GATT_WRITABLE From 11422fd2fb6382b0118484702540f62044f5123c Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 30 Dec 2024 12:34:10 +0000 Subject: [PATCH 29/51] [Telink] Remove unused files --- src/platform/telink/tl3218.overlay | 61 ------------------------------ src/platform/telink/tl7218.overlay | 61 ------------------------------ 2 files changed, 122 deletions(-) delete mode 100644 src/platform/telink/tl3218.overlay delete mode 100644 src/platform/telink/tl7218.overlay diff --git a/src/platform/telink/tl3218.overlay b/src/platform/telink/tl3218.overlay deleted file mode 100644 index 4c74bb14ea216c..00000000000000 --- a/src/platform/telink/tl3218.overlay +++ /dev/null @@ -1,61 +0,0 @@ -/ { - /* Short TL_Key3 (J6 pin 21) to ground */ - key_pool { - compatible = "gpio-keys"; - - inp { - gpios = <&gpiob 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, - <&gpiob 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; - }; - }; - - key_matrix { - compatible = "gpio-keys"; - - col { - gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>, - <&gpiob 7 GPIO_ACTIVE_HIGH>; - }; - - row { - gpios = <&gpiob 3 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>, - <&gpiob 5 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; - }; - }; - - led_pool { - compatible = "gpio-leds"; - - out { - gpios = <&gpiod 0 GPIO_ACTIVE_HIGH>; - }; - }; - - 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>; - }; - }; -}; - -&pwm0 { - /* On board RGB LEDs */ - pinctrl-ch0 = <&pwm_ch0_pb1_default>; - pinctrl-ch2 = <&pwm_ch1_pb2_default>; - pinctrl-ch1 = <&pwm_ch2_pb0_default>; -}; - -&pinctrl { - pwm_ch0_pb1_default: pwm_ch0_pb1_default { - pinmux = ; - }; - pwm_ch1_pb2_default: pwm_ch1_pb2_default { - pinmux = ; - }; - pwm_ch2_pb0_default: pwm_ch2_pb0_default { - pinmux = ; - }; -}; diff --git a/src/platform/telink/tl7218.overlay b/src/platform/telink/tl7218.overlay deleted file mode 100644 index 2a764c5e3b2e86..00000000000000 --- a/src/platform/telink/tl7218.overlay +++ /dev/null @@ -1,61 +0,0 @@ -/ { - /* Short TL_Key3 (J6 pin 31) to ground (J4 pin 3, 5, 9) */ - key_pool { - compatible = "gpio-keys"; - - inp { - gpios = <&gpiod 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, - <&gpiod 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; - }; - }; - - key_matrix { - compatible = "gpio-keys"; - - col { - gpios = <&gpiod 5 GPIO_ACTIVE_HIGH>, - <&gpiod 7 GPIO_ACTIVE_HIGH>; - }; - - row { - gpios = <&gpiod 4 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>, - <&gpiod 6 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; - }; - }; - - led_pool { - compatible = "gpio-leds"; - - out { - gpios = <&gpioc 3 GPIO_ACTIVE_HIGH>; - }; - }; - - 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>; - }; - }; -}; - -&pwm0 { - /* On board RGB LEDs */ - pinctrl-ch0 = <&pwm_ch0_pc1_default>; - pinctrl-ch2 = <&pwm_ch1_pc0_default>; - pinctrl-ch1 = <&pwm_ch2_pc2_default>; -}; - -&pinctrl { - pwm_ch0_pc1_default: pwm_ch0_pc1_default { - pinmux = ; - }; - pwm_ch1_pc0_default: pwm_ch1_pc0_default { - pinmux = ; - }; - pwm_ch2_pc2_default: pwm_ch2_pc2_default { - pinmux = ; - }; -}; From 79c7f01ceef883702d44e1900635787605c599c6 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 30 Dec 2024 19:19:11 +0000 Subject: [PATCH 30/51] [Telink] Update Zephyr revision --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index c791e97ab4c783..83e2ea3133d926 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 d80e19ccf62967103b82125bda8e5374d3c3ddbd" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 50481106f8055428f7324d66f2f0d986ea7d0982" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 6232320fe26df6..580bd9bb54081a 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 d80e19ccf62967103b82125bda8e5374d3c3ddbd" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 50481106f8055428f7324d66f2f0d986ea7d0982" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs From 01524da8e08a6affe5f7274e8900597f16004d6f Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Thu, 2 Jan 2025 21:11:53 +0000 Subject: [PATCH 31/51] [Telink] Clean config types --- config/telink/chip-module/Kconfig | 8 -------- config/telink/chip-module/Kconfig.defaults | 17 ++--------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 08dc0beb5f953c..5a834382159268 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -224,15 +224,7 @@ config CHIP_ENABLE_PM_DURING_BLE help Enable PM during BLE operation. -config CHIP_OPENTHREAD_TX_POWER - int "OpenThread Transmission power" - range -30 9 - default 0 - help - OpenThread Transmission power in dBm. - config SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE - int default 255 if SHELL_BACKEND_SERIAL config CHIP_ENABLE_POWER_ON_FACTORY_RESET diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index f8b2cab08bc266..9b5c4f2721cb3d 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -156,7 +156,6 @@ config BT_BUF_ACL_RX_COUNT default 4 config BT_GATT_CACHING - bool default n config BT_RX_STACK_SIZE @@ -168,36 +167,27 @@ config BT_HCI_TX_STACK_SIZE default 2048 if BT_W91 config BT_DEVICE_NAME_GATT_WRITABLE - bool default n if SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX config TL_BLE_CTRL_THREAD_STACK_SIZE - int default 648 config TL_BLE_CTRL_MASTER_MAX_NUM - int default 0 config TL_BLE_CTRL_SLAVE_MAX_NUM - int default 1 config TL_BLE_CTRL_RF_POWER - int default 3 if PM default 8 if BT_TLX default 9 choice TL_BLE_CTRL_MAC_TYPE - prompt "MAC address type" default TL_BLE_CTRL_MAC_TYPE_RANDOM_STATIC -config TL_BLE_CTRL_MAC_TYPE_RANDOM_STATIC - bool "Random Static MAC Address" - endchoice endif # SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX @@ -219,7 +209,7 @@ endif # Board non-retention config if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 || \ - BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D || BOARD_TL3218 + BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D || BOARD_TL3218 || BOARD_TL7218 config PWM default y endif @@ -325,7 +315,6 @@ config NET_RX_STACK_SIZE # Disable certain parts of Zephyr IPv6 stack config NET_IPV6_NBR_CACHE - bool default n config NET_MAX_CONN @@ -348,7 +337,7 @@ config CHIP_WIFI select NET_IPV6_NBR_CACHE select NET_STATISTICS_USER_API imply MBEDTLS_ENTROPY_C - imply MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + imply MBEDTLS_KEY_EXCHANGE_RSA_ENABLED if CHIP_WIFI @@ -403,11 +392,9 @@ config CHIP_WIFI_CONNECTION_RECOVERY_JITTER within range [-JITTER; +JITTER]. config NET_MGMT_EVENT_STACK_SIZE - int default 1250 config IPC_SERVICE_BACKEND_ICMSG_WQ_STACK_SIZE - int default 2304 if TELINK_W91_IPC_DISPATCHER endif # CHIP_WIFI From d4a39142551202aa4691620ff3b8a052a129781b Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 3 Jan 2025 10:19:10 +0000 Subject: [PATCH 32/51] [Telink] Update Zephyr revision --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 83e2ea3133d926..a012c1526708f5 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 50481106f8055428f7324d66f2f0d986ea7d0982" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py f927253d5dec5867f9f1adc43d39045b23481048" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 580bd9bb54081a..e9a4f5b6dc9a38 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 50481106f8055428f7324d66f2f0d986ea7d0982" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py f927253d5dec5867f9f1adc43d39045b23481048" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs From 55364c409fdf52166a6ab16b54459c3f85ae1c99 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 6 Jan 2025 22:05:34 +0000 Subject: [PATCH 33/51] [Telink] Increase BLE_CTRL_THREAD_STACK_SIZE (B92 SoC retention test) --- config/telink/chip-module/Kconfig.defaults | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 9b5c4f2721cb3d..e07fa07ff68d2e 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -172,7 +172,7 @@ config BT_DEVICE_NAME_GATT_WRITABLE if SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX config TL_BLE_CTRL_THREAD_STACK_SIZE - default 648 + default 680 config TL_BLE_CTRL_MASTER_MAX_NUM default 0 From 7548e357eac816f7ae80cd9519f82b4a323dee5d Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 7 Jan 2025 12:39:33 +0000 Subject: [PATCH 34/51] [Telink] Fix compilation warninig --- examples/platform/telink/common/include/AppTaskCommon.h | 5 ++++- examples/window-app/telink/prj.conf | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/platform/telink/common/include/AppTaskCommon.h b/examples/platform/telink/common/include/AppTaskCommon.h index ac10ef587d2be9..25e0e4c8da481c 100644 --- a/examples/platform/telink/common/include/AppTaskCommon.h +++ b/examples/platform/telink/common/include/AppTaskCommon.h @@ -76,8 +76,11 @@ class AppTaskCommon { kButtonId_ExampleAction = 1, kButtonId_FactoryReset, - kButtonId_StartWiFi, +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD kButtonId_StartThread, +#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI + kButtonId_StartWiFi, +#endif kButtonId_StartBleAdv } ButtonId; #endif diff --git a/examples/window-app/telink/prj.conf b/examples/window-app/telink/prj.conf index f45bdb047cd75a..da6db7f21feed7 100644 --- a/examples/window-app/telink/prj.conf +++ b/examples/window-app/telink/prj.conf @@ -41,4 +41,4 @@ CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n # Enable Power Management -CONFIG_PM=y +CONFIG_PM=n From 53fb1921931f46616120797f50767674ed03667d Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 7 Jan 2025 12:40:38 +0000 Subject: [PATCH 35/51] [Telink] TL7218 upgrade to support version A2 --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- src/platform/telink/tl7218_2m_flash.overlay | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index a012c1526708f5..2b236ccf5b72fb 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 f927253d5dec5867f9f1adc43d39045b23481048" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py a7da81c749aa3fba2e97089d62cd5bf04c7b4680" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index e9a4f5b6dc9a38..735e8ff7d479f7 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 f927253d5dec5867f9f1adc43d39045b23481048" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py a7da81c749aa3fba2e97089d62cd5bf04c7b4680" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs diff --git a/src/platform/telink/tl7218_2m_flash.overlay b/src/platform/telink/tl7218_2m_flash.overlay index 2e41751980112e..afb6f531805c05 100644 --- a/src/platform/telink/tl7218_2m_flash.overlay +++ b/src/platform/telink/tl7218_2m_flash.overlay @@ -9,23 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0xb000>; + reg = <0x00000000 0xd000>; }; - slot0_partition: partition@b000 { + slot0_partition: partition@d000 { label = "image-0"; - reg = <0xb000 0xf3000>; + reg = <0xd000 0xf2000>; }; - factory_partition: partition@fe000 { + factory_partition: partition@ff000 { label = "factory-data"; - reg = <0xfe000 0x1000>; + reg = <0xff000 0x1000>; }; - storage_partition: partition@ff000 { + storage_partition: partition@0x100000 { label = "storage"; - reg = <0xff000 0xc000>; + reg = <0x100000 0xc000>; }; - slot1_partition: partition@10b000 { + slot1_partition: partition@10c000 { label = "image-1"; - reg = <0x10b000 0xf3000>; + reg = <0x10c000 0xf2000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; From fd0ff22f8985da41cddb0f3636aa7b43e2fcaca4 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 7 Jan 2025 19:33:14 +0000 Subject: [PATCH 36/51] [Telink] Remove unused file after resolve merge conflict --- src/platform/telink/tl7218x_2m_flash.overlay | 39 -------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/platform/telink/tl7218x_2m_flash.overlay diff --git a/src/platform/telink/tl7218x_2m_flash.overlay b/src/platform/telink/tl7218x_2m_flash.overlay deleted file mode 100644 index 53114e6ac6054d..00000000000000 --- a/src/platform/telink/tl7218x_2m_flash.overlay +++ /dev/null @@ -1,39 +0,0 @@ -&flash { - reg = <0x20000000 0x200000>; - - /delete-node/ partitions; - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - boot_partition: partition@0 { - label = "mcuboot"; - reg = <0x00000000 0x13000>; - }; - slot0_partition: partition@13000 { - label = "image-0"; - reg = <0x13000 0xef000>; - }; - factory_partition: partition@102000 { - label = "factory-data"; - reg = <0x102000 0x800>; - }; - factory_rfu_partition: partition@102800 { - label = "factory-data-rfu"; - reg = <0x102800 0x800>; - }; - storage_partition: partition@103000 { - label = "storage"; - reg = <0x103000 0xc000>; - }; - slot1_partition: partition@10f000 { - label = "image-1"; - reg = <0x10f000 0xef000>; - }; - vendor_partition: partition@1fe000 { - label = "vendor-data"; - reg = <0x1fe000 0x2000>; - }; - }; -}; From 493c81a11ed91527189f925707edfa77dcc4c25a Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 20 Jan 2025 18:07:27 +0000 Subject: [PATCH 37/51] [Telink] Add tl7218_retention target --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 13 ++++++++++++- config/telink/chip-module/Kconfig.defaults | 12 ++++++++++++ scripts/build/build/targets.py | 1 + scripts/build/builders/telink.py | 3 +++ .../build/testdata/all_targets_linux_x64.txt | 2 +- src/platform/telink/tl7218_2m_flash.overlay | 18 +++++++++--------- 7 files changed, 39 insertions(+), 12 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index ca3a9a06e8f506..d3ed70f9389d35 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 a7da81c749aa3fba2e97089d62cd5bf04c7b4680" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 10c1c1cbee585531c7c1e09cd855b3d63b697a9e" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 527dbec4566f62..62044582872ec6 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 a7da81c749aa3fba2e97089d62cd5bf04c7b4680" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 10c1c1cbee585531c7c1e09cd855b3d63b697a9e" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs @@ -203,6 +203,17 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* + - name: Build example Telink (TL7218 retention) Light Switch App with OTA (LZMA), Factory Data + # 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-tl7218_retention-light-switch-ota-compress-lzma-factory-data' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tl7218_retention light-switch-app-ota-compress-lzma-factory-data \ + out/telink-tl7218_retention-light-switch-ota-compress-lzma-factory-data/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + - name: Build example Telink (B92) Light Switch App with OTA (LZMA), Shell, Factory Data, 4Mb flash # Run test for master and all PRs run: | diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index e07fa07ff68d2e..424d898a5cdcc3 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -207,6 +207,18 @@ config PWM endif +if BOARD_TL7218_RETENTION || BOARD_TL3218_RETENTION +config SOC_SERIES_RISCV_TELINK_TLX_NON_RETENTION_RAM_CODE + default n if PM + +config TELINK_TLX_MATTER_RETENTION_LAYOUT + default y if PM + +config PWM + default n + +endif + # Board non-retention config if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 || \ BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D || BOARD_TL3218 || BOARD_TL7218 diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index a704eaeb61d781..51a316157562f9 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -779,6 +779,7 @@ def BuildTelinkTarget(): TargetPart('tlsr9258a_retention', board=TelinkBoard.TLSR9258A_RETENTION), TargetPart('tl3218', board=TelinkBoard.TL3218), TargetPart('tl7218', board=TelinkBoard.TL7218), + TargetPart('tl7218_retention', board=TelinkBoard.TL7218_RETENTION), ]) target.AppendFixedTargets([ diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 5e0c246d99cf8e..38249b4150e324 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -123,6 +123,7 @@ class TelinkBoard(Enum): TLSR9258A_RETENTION = auto() TL3218 = auto() TL7218 = auto() + TL7218_RETENTION = auto() def GnArgName(self): if self == TelinkBoard.TLRS9118BDK40D: @@ -141,6 +142,8 @@ def GnArgName(self): return 'tl3218' elif self == TelinkBoard.TL7218: return 'tl7218' + elif self == TelinkBoard.TL7218_RETENTION: + return 'tl7218_retention' else: raise Exception('Unknown board type: %r' % self) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index 4b4edd7b29c4cb..a9354064dc3a0d 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -22,5 +22,5 @@ nuttx-x64-light qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage] stm32-stm32wb5mm-dk-light tizen-arm-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-coverage][-with-ui] -telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218,tl7218}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] +telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218,tl7218,tl7218_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] openiotsdk-{shell,lock}[-mbedtls][-psa] diff --git a/src/platform/telink/tl7218_2m_flash.overlay b/src/platform/telink/tl7218_2m_flash.overlay index afb6f531805c05..d08d0e4ff4a6ba 100644 --- a/src/platform/telink/tl7218_2m_flash.overlay +++ b/src/platform/telink/tl7218_2m_flash.overlay @@ -9,23 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0xd000>; + reg = <0x00000000 0xf000>; }; - slot0_partition: partition@d000 { + slot0_partition: partition@f000 { label = "image-0"; - reg = <0xd000 0xf2000>; + reg = <0xf000 0xf1000>; }; - factory_partition: partition@ff000 { + factory_partition: partition@100000 { label = "factory-data"; - reg = <0xff000 0x1000>; + reg = <0x100000 0x1000>; }; - storage_partition: partition@0x100000 { + storage_partition: partition@101000 { label = "storage"; - reg = <0x100000 0xc000>; + reg = <0x101000 0xc000>; }; - slot1_partition: partition@10c000 { + slot1_partition: partition@10d000 { label = "image-1"; - reg = <0x10c000 0xf2000>; + reg = <0x10d000 0xf1000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; From 41eab7f519fa4b638e7e2531a3d49e601c82324c Mon Sep 17 00:00:00 2001 From: Haiwen Xia Date: Tue, 21 Jan 2025 05:37:42 +0000 Subject: [PATCH 38/51] riscv: telink: seperate ram for tl3218x . - use retention mode to seperate ram. - reserve more ram for ilm. Signed-off-by: Haiwen Xia --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- config/telink/chip-module/Kconfig.defaults | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index d3ed70f9389d35..39061be0660e1e 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 10c1c1cbee585531c7c1e09cd855b3d63b697a9e" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 28deded4d225ac5c112d9c6e3659970434a6203a" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 62044582872ec6..f3f67bc94ac57a 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 10c1c1cbee585531c7c1e09cd855b3d63b697a9e" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 28deded4d225ac5c112d9c6e3659970434a6203a" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 424d898a5cdcc3..00570e2967c958 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -207,15 +207,15 @@ config PWM endif -if BOARD_TL7218_RETENTION || BOARD_TL3218_RETENTION +if BOARD_TL7218_RETENTION || BOARD_TL3218_RETENTION || BOARD_TL3218 config SOC_SERIES_RISCV_TELINK_TLX_NON_RETENTION_RAM_CODE default n if PM config TELINK_TLX_MATTER_RETENTION_LAYOUT - default y if PM + default y if PM || BOARD_TL3218X config PWM - default n + default n if PM endif From c2a0df0af34c079d73393d7fcc23551aaa700cd5 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 24 Jan 2025 11:51:13 +0000 Subject: [PATCH 39/51] [Telink] Fix broken GitHub CI after adding tl721x target --- .github/workflows/examples-telink.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index f3f67bc94ac57a..a2ce3607726599 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -203,7 +203,7 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (TL7218 retention) Light Switch App with OTA (LZMA), Factory Data + - name: Build example Telink (TL7218 retention) Light Switch App with OTA (LZMA), Factory Data # 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: | From 6f48c087e02ffcecb4d35937f7e2a7fbf4dba362 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 24 Jan 2025 14:14:18 +0000 Subject: [PATCH 40/51] [Telink] remove temporary LZMA for tl321x due to bug --- .github/workflows/examples-telink.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index a2ce3607726599..b870abc87965ec 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -178,14 +178,14 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (TL3218) Lighting App with OTA (LZMA), Factory Data + - name: Build example Telink (TL3218) Lighting App with OTA, Factory Data # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tl3218-light-ota-compress-lzma-factory-data' build" + "./scripts/build/build_examples.py --target 'telink-tl3218-light-ota-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl3218 light-app-ota-compress-lzma-factory-data \ - out/telink-tl3218-light-ota-compress-lzma-factory-data/zephyr/zephyr.elf \ + telink tl3218 light-app-ota-factory-data \ + out/telink-tl3218-light-ota-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output (keep tools) From 984b1be034519ff53c4f5ff39503a2fbabd79407 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 24 Jan 2025 17:06:39 +0000 Subject: [PATCH 41/51] [Telink] Fix TELINK_TLX_MATTER_RETENTION_LAYOUT typo for BOARD_TL3218 --- config/telink/chip-module/Kconfig.defaults | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 00570e2967c958..30c282bd9354f5 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -212,7 +212,7 @@ config SOC_SERIES_RISCV_TELINK_TLX_NON_RETENTION_RAM_CODE default n if PM config TELINK_TLX_MATTER_RETENTION_LAYOUT - default y if PM || BOARD_TL3218X + default y if PM || BOARD_TL3218 config PWM default n if PM From a880ad4633b51f2d89b1216cb312b3246ce9d504 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 27 Jan 2025 11:48:07 +0000 Subject: [PATCH 42/51] [Telink] Add GPIO/PWM required for TL721X https://github.com/telink-semi/hal_telink/commit/62edeab7cde786a1403cb062e7cef7d13edae520 --- config/telink/app/bootloader.conf | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/telink/app/bootloader.conf b/config/telink/app/bootloader.conf index 2a9cb468631490..887d1b66a0f661 100644 --- a/config/telink/app/bootloader.conf +++ b/config/telink/app/bootloader.conf @@ -37,6 +37,4 @@ CONFIG_BOOT_VALIDATE_SLOT0=y # - DEBUG, LOG_LEVEL_DBG CONFIG_MCUBOOT_LOG_LEVEL_INF=y -# Reduced footprint -CONFIG_GPIO=n CONFIG_PICOLIBC=y From b5a1722e386607e83a969a67e5134a4cb356037f Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 27 Jan 2025 12:52:16 +0000 Subject: [PATCH 43/51] [Telink] Temporary disable B95 OTA failed build B95 will be removed fully in next commits --- .github/workflows/examples-telink.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index b870abc87965ec..6859f8d7ed316a 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -241,16 +241,16 @@ jobs: - 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: 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 From 28b98869c92d28f341283a841bd6f1fa32993679 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 27 Jan 2025 14:40:21 +0000 Subject: [PATCH 44/51] [Telink] Add missed clean out build output step --- .github/workflows/examples-telink.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 6859f8d7ed316a..0744ec6bc44f9a 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -200,6 +200,7 @@ jobs: telink tl7218 light-app-ota-shell-factory-data \ out/telink-tl7218-light-ota-shell-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ + - name: clean out build output (keep tools) run: rm -rf ./out/telink* @@ -214,6 +215,9 @@ jobs: out/telink-tl7218_retention-light-switch-ota-compress-lzma-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ + - 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, 4Mb flash # Run test for master and all PRs run: | @@ -252,8 +256,8 @@ jobs: # out/telink-tlsr9258a-ota-requestor/zephyr/zephyr.elf \ # /tmp/bloat_reports/ - - name: clean out build output - run: rm -rf ./out + # - name: clean out build output + # run: rm -rf ./out - name: Build example Telink (B91 USB) Pump App # Run test for master and s07641069 PRs From 53bbd10cfcea536b5a03b52da31fe6a624cb817e Mon Sep 17 00:00:00 2001 From: Serhii Salamakha Date: Wed, 22 Jan 2025 22:13:18 +0200 Subject: [PATCH 45/51] [Telink] adopt WiFi driver --- .../wifi/ConnectivityManagerImplWiFi.cpp | 16 +- src/platform/telink/wifi/TelinkWiFiDriver.cpp | 28 ++- src/platform/telink/wifi/TelinkWiFiDriver.h | 2 +- src/platform/telink/wifi/WiFiManager.cpp | 172 +++++++++++++++--- src/platform/telink/wifi/WiFiManager.h | 33 +++- 5 files changed, 199 insertions(+), 52 deletions(-) diff --git a/src/platform/telink/wifi/ConnectivityManagerImplWiFi.cpp b/src/platform/telink/wifi/ConnectivityManagerImplWiFi.cpp index 5bef79bb22fdc5..9b605c31560142 100644 --- a/src/platform/telink/wifi/ConnectivityManagerImplWiFi.cpp +++ b/src/platform/telink/wifi/ConnectivityManagerImplWiFi.cpp @@ -42,7 +42,7 @@ ConnectivityManager::WiFiStationMode ConnectivityManagerImplWiFi::_GetWiFiStatio { if (mStationMode != ConnectivityManager::WiFiStationMode::kWiFiStationMode_ApplicationControlled) { - mStationMode = (WiFiManager::StationStatus::DISABLED == WiFiManager().Instance().GetStationStatus()) + mStationMode = (WiFiManager::StationStatus::DISABLED == WiFiManager::Instance().GetStationStatus()) ? ConnectivityManager::WiFiStationMode::kWiFiStationMode_Disabled : ConnectivityManager::WiFiStationMode::kWiFiStationMode_Enabled; } @@ -60,7 +60,7 @@ CHIP_ERROR ConnectivityManagerImplWiFi::_SetWiFiStationMode(ConnectivityManager: bool ConnectivityManagerImplWiFi::_IsWiFiStationEnabled(void) { - return (WiFiManager::StationStatus::DISABLED <= WiFiManager().Instance().GetStationStatus()); + return (WiFiManager::StationStatus::DISABLED <= WiFiManager::Instance().GetStationStatus()); } bool ConnectivityManagerImplWiFi::_IsWiFiStationApplicationControlled(void) @@ -70,7 +70,7 @@ bool ConnectivityManagerImplWiFi::_IsWiFiStationApplicationControlled(void) bool ConnectivityManagerImplWiFi::_IsWiFiStationConnected(void) { - return (WiFiManager::StationStatus::CONNECTED == WiFiManager().Instance().GetStationStatus()); + return (WiFiManager::StationStatus::CONNECTED == WiFiManager::Instance().GetStationStatus()); } System::Clock::Timeout ConnectivityManagerImplWiFi::_GetWiFiStationReconnectInterval(void) @@ -88,14 +88,14 @@ bool ConnectivityManagerImplWiFi::_IsWiFiStationProvisioned(void) { // from Matter perspective `provisioned` means that the supplicant has been provided // with SSID and password (doesn't matter if valid or not) - return (WiFiManager::StationStatus::CONNECTING <= WiFiManager().Instance().GetStationStatus()); + return (WiFiManager::StationStatus::CONNECTING <= WiFiManager::Instance().GetStationStatus()); } void ConnectivityManagerImplWiFi::_ClearWiFiStationProvision(void) { if (_IsWiFiStationProvisioned()) { - if (CHIP_NO_ERROR != WiFiManager().Instance().ClearStationProvisioningData()) + if (CHIP_NO_ERROR != WiFiManager::Instance().ClearStationProvisioningData()) { ChipLogError(DeviceLayer, "Cannot clear WiFi station provisioning data"); } @@ -104,9 +104,9 @@ void ConnectivityManagerImplWiFi::_ClearWiFiStationProvision(void) bool ConnectivityManagerImplWiFi::_CanStartWiFiScan() { - return (WiFiManager::StationStatus::DISABLED != WiFiManager().Instance().GetStationStatus() && - WiFiManager::StationStatus::SCANNING != WiFiManager().Instance().GetStationStatus() && - WiFiManager::StationStatus::CONNECTING != WiFiManager().Instance().GetStationStatus()); + return (WiFiManager::StationStatus::DISABLED != WiFiManager::Instance().GetStationStatus() && + WiFiManager::StationStatus::SCANNING != WiFiManager::Instance().GetStationStatus() && + WiFiManager::StationStatus::CONNECTING != WiFiManager::Instance().GetStationStatus()); } void ConnectivityManagerImplWiFi::_OnWiFiStationProvisionChange() diff --git a/src/platform/telink/wifi/TelinkWiFiDriver.cpp b/src/platform/telink/wifi/TelinkWiFiDriver.cpp index f6c19a2c1f3030..1b07386fb835fa 100644 --- a/src/platform/telink/wifi/TelinkWiFiDriver.cpp +++ b/src/platform/telink/wifi/TelinkWiFiDriver.cpp @@ -17,10 +17,13 @@ #include "TelinkWiFiDriver.h" +#include + #include #include #include +#include #include using namespace ::chip; @@ -103,8 +106,9 @@ CHIP_ERROR TelinkWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusCha if (mStagingNetwork.IsConfigured()) { - WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); }, - [] { Instance().OnNetworkStatusChanged(Status::kUnknownError); }, + WiFiManager::ConnectionHandling handling{ [](const wifi_conn_status & connStatus) { + Instance().OnNetworkConnStatusChanged(connStatus); + }, System::Clock::Seconds32{ kWiFiConnectNetworkTimeoutSeconds } }; ReturnErrorOnFailure( WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling)); @@ -113,8 +117,11 @@ CHIP_ERROR TelinkWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusCha return CHIP_NO_ERROR; } -void TelinkWiFiDriver::OnNetworkStatusChanged(Status status) +void TelinkWiFiDriver::OnNetworkConnStatusChanged(const wifi_conn_status & connStatus) { + // TODO: check if we can report more accurate errors + Status status = connStatus ? Status::kUnknownError : Status::kSuccess; + if (status == Status::kSuccess) { ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); @@ -136,8 +143,9 @@ void TelinkWiFiDriver::OnNetworkStatusChanged(Status status) ssid = WiFiManager::Instance().GetWantedNetwork().ssid; ssidLen = WiFiManager::Instance().GetWantedNetwork().ssidLen; } - mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status, MakeOptional(ByteSpan(wifiInfo.mSsid, wifiInfo.mSsidLen)), - NullOptional); + mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status, MakeOptional(ByteSpan(ssid, ssidLen)), + connStatus ? MakeOptional(static_cast(connStatus)) + : NullOptional); } if (mpConnectCallback) @@ -179,8 +187,9 @@ CHIP_ERROR TelinkWiFiDriver::RevertConfiguration() if (mStagingNetwork.IsConfigured()) { - WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); }, - [] { Instance().OnNetworkStatusChanged(Status::kUnknownError); }, + WiFiManager::ConnectionHandling handling{ [](const wifi_conn_status & connStatus) { + Instance().OnNetworkConnStatusChanged(connStatus); + }, System::Clock::Seconds32{ kWiFiConnectNetworkTimeoutSeconds } }; ReturnErrorOnFailure( WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling)); @@ -233,8 +242,9 @@ Status TelinkWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, Mutab void TelinkWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) { Status status = Status::kSuccess; - WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); }, - [] { Instance().OnNetworkStatusChanged(Status::kUnknownError); }, + WiFiManager::ConnectionHandling handling{ [](const wifi_conn_status & connStatus) { + Instance().OnNetworkConnStatusChanged(connStatus); + }, System::Clock::Seconds32{ kWiFiConnectNetworkTimeoutSeconds } }; VerifyOrExit(mpConnectCallback == nullptr, status = Status::kUnknownError); diff --git a/src/platform/telink/wifi/TelinkWiFiDriver.h b/src/platform/telink/wifi/TelinkWiFiDriver.h index 9c5b1e61d1f0e1..e3a66e3a279d07 100644 --- a/src/platform/telink/wifi/TelinkWiFiDriver.h +++ b/src/platform/telink/wifi/TelinkWiFiDriver.h @@ -94,7 +94,7 @@ class TelinkWiFiDriver final : public WiFiDriver return sInstance; } - void OnNetworkStatusChanged(Status status); + void OnNetworkConnStatusChanged(const wifi_conn_status & connStatus); void OnScanWiFiNetworkResult(const WiFiScanResponse & result); void OnScanWiFiNetworkDone(const WiFiManager::ScanDoneStatus & status); diff --git a/src/platform/telink/wifi/WiFiManager.cpp b/src/platform/telink/wifi/WiFiManager.cpp index dfbfcfec354227..f1877aafda24f2 100644 --- a/src/platform/telink/wifi/WiFiManager.cpp +++ b/src/platform/telink/wifi/WiFiManager.cpp @@ -25,19 +25,30 @@ #include #include #include +#include #include #include #include #include #include -#include namespace chip { namespace DeviceLayer { namespace { +app::Clusters::NetworkCommissioning::WiFiBandEnum ConvertBandEnum(uint8_t band) +{ + switch (band) + { + case WIFI_FREQ_BAND_2_4_GHZ: + return app::Clusters::NetworkCommissioning::WiFiBandEnum::k2g4; + default: + return app::Clusters::NetworkCommissioning::WiFiBandEnum::kUnknownEnumValue; + } +} + NetworkCommissioning::WiFiScanResponse ToScanResponse(const wifi_scan_result * result) { NetworkCommissioning::WiFiScanResponse response = {}; @@ -50,9 +61,10 @@ NetworkCommissioning::WiFiScanResponse ToScanResponse(const wifi_scan_result * r // TODO: Distinguish WPA versions response.security.Set(result->security == WIFI_SECURITY_TYPE_PSK ? NetworkCommissioning::WiFiSecurity::kWpaPersonal : NetworkCommissioning::WiFiSecurity::kUnencrypted); - response.channel = result->channel; - response.rssi = result->rssi; - response.ssidLen = result->ssid_length; + response.channel = result->channel; + response.rssi = result->rssi; + response.ssidLen = result->ssid_length; + response.wiFiBand = ConvertBandEnum(result->band); memcpy(response.ssid, result->ssid, result->ssid_length); // TODO: MAC/BSSID is not filled by the Wi-Fi driver memcpy(response.bssid, result->mac, result->mac_length); @@ -131,6 +143,7 @@ const Map WiFiManager::sEventHandlerM { NET_EVENT_WIFI_SCAN_DONE, WiFiManager::ScanDoneHandler }, { NET_EVENT_WIFI_CONNECT_RESULT, WiFiManager::ConnectHandler }, { NET_EVENT_WIFI_DISCONNECT_RESULT, WiFiManager::DisconnectHandler }, + { NET_EVENT_WIFI_DISCONNECT_COMPLETE, WiFiManager::DisconnectHandler }, }); void WiFiManager::WifiMgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface) @@ -157,8 +170,6 @@ CHIP_ERROR WiFiManager::Init() mNetIf = InetUtils::GetWiFiInterface(); VerifyOrReturnError(mNetIf != nullptr, INET_ERROR_UNKNOWN_INTERFACE); - net_if_down(mNetIf); // block netif auto start - net_mgmt_init_event_callback(&mWiFiMgmtClbk, WifiMgmtEventHandler, kWifiManagementEvents); net_mgmt_init_event_callback(&mIPv6MgmtClbk, IPv6MgmtEventHandler, kIPv6ManagementEvents); @@ -179,7 +190,24 @@ CHIP_ERROR WiFiManager::Scan(const ByteSpan & ssid, ScanResultCallback resultCal mWiFiState = WIFI_STATE_SCANNING; mSsidFound = false; - if (0 != net_mgmt(NET_REQUEST_WIFI_SCAN, mNetIf, NULL, 0)) + wifi_scan_params * scanParams{ nullptr }; + size_t scanParamsSize{ 0 }; + + if (!ssid.empty()) + { + /* We must assume that the ssid is handled as a NULL-terminated string. + Note that the mScanSsidBuffer is initialized with zeros. */ + VerifyOrReturnError(ssid.size() < sizeof(mScanSsidBuffer), CHIP_ERROR_INVALID_ARGUMENT); + memcpy(mScanSsidBuffer, ssid.data(), ssid.size()); + mScanSsidBuffer[ssid.size()] = 0; // indicate the end of ssid string + mScanParams.ssids[0] = mScanSsidBuffer; +#if (CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX > 1) + mScanParams.ssids[1] = nullptr; // indicate the end of ssids list +#endif + scanParams = &mScanParams; + scanParamsSize = sizeof(*scanParams); + } + if (0 != net_mgmt(NET_REQUEST_WIFI_SCAN, mNetIf, scanParams, scanParamsSize)) { ChipLogError(DeviceLayer, "Scan request failed"); return CHIP_ERROR_INTERNAL; @@ -201,9 +229,7 @@ CHIP_ERROR WiFiManager::Connect(const ByteSpan & ssid, const ByteSpan & credenti { ChipLogDetail(DeviceLayer, "Connecting to WiFi network: %*s", ssid.size(), ssid.data()); - mHandling.mOnConnectionSuccess = handling.mOnConnectionSuccess; - mHandling.mOnConnectionFailed = handling.mOnConnectionFailed; - mHandling.mConnectionTimeout = handling.mConnectionTimeout; + mHandling = handling; mWiFiState = WIFI_STATE_ASSOCIATING; @@ -277,8 +303,8 @@ CHIP_ERROR WiFiManager::GetNetworkStatistics(NetworkStatistics & stats) const stats.mPacketMulticastRxCount = data.multicast.rx; stats.mPacketMulticastTxCount = data.multicast.tx; - stats.mPacketUnicastRxCount = data.pkts.rx - data.multicast.rx - data.broadcast.rx; - stats.mPacketUnicastTxCount = data.pkts.tx - data.multicast.tx - data.broadcast.tx; + stats.mPacketUnicastRxCount = data.unicast.rx; + stats.mPacketUnicastTxCount = data.unicast.tx; stats.mBeaconsSuccessCount = data.sta_mgmt.beacons_rx; stats.mBeaconsLostCount = data.sta_mgmt.beacons_miss; @@ -380,9 +406,9 @@ void WiFiManager::ScanDoneHandler(Platform::UniquePtr data, size_t leng sizeof(wifi_connect_req_params))) { ChipLogError(DeviceLayer, "Connection request failed"); - if (Instance().mHandling.mOnConnectionFailed) + if (Instance().mHandling.mOnConnectionDone) { - Instance().mHandling.mOnConnectionFailed(); + Instance().mHandling.mOnConnectionDone(WIFI_STATUS_CONN_FAIL); } Instance().mWiFiState = WIFI_STATE_DISCONNECTED; return; @@ -400,36 +426,81 @@ void WiFiManager::ScanDoneHandler(Platform::UniquePtr data, size_t leng } } +void WiFiManager::SendRouterSolicitation(System::Layer * layer, void * param) +{ + net_if_start_rs(Instance().mNetIf); + Instance().mRouterSolicitationCounter++; + if (Instance().mRouterSolicitationCounter < kRouterSolicitationMaxCount) + { + DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(kRouterSolicitationIntervalMs), SendRouterSolicitation, + nullptr); + } + else + { + Instance().mRouterSolicitationCounter = 0; + } +} + void WiFiManager::ConnectHandler(Platform::UniquePtr data, size_t length) { + using app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum; + // Validate that input data size matches the expected one. VerifyOrReturn(length == sizeof(wifi_status)); CHIP_ERROR err = SystemLayer().ScheduleLambda([capturedData = data.get()] { Platform::UniquePtr safePtr(capturedData); - uint8_t * rawData = safePtr.get(); - const wifi_status * status = reinterpret_cast(rawData); - WiFiRequestStatus requestStatus = static_cast(status->status); + uint8_t * rawData = safePtr.get(); + const wifi_status * status = reinterpret_cast(rawData); + wifi_conn_status connStatus = status->conn_status; - if (requestStatus == WiFiRequestStatus::FAILURE || requestStatus == WiFiRequestStatus::TERMINATED) + if (connStatus) { ChipLogProgress(DeviceLayer, "Connection to WiFi network failed or was terminated by another request"); Instance().mWiFiState = WIFI_STATE_DISCONNECTED; - if (Instance().mHandling.mOnConnectionFailed) + if (Instance().mHandling.mOnConnectionDone) { - Instance().mHandling.mOnConnectionFailed(); + Instance().mHandling.mOnConnectionDone(connStatus); + } + + WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); + if (delegate) + { + uint16_t reason = Instance().GetLastDisconnectReason(); + uint8_t associationFailureCause; + + switch (connStatus) + { + case WIFI_STATUS_CONN_WRONG_PASSWORD: + associationFailureCause = to_underlying(AssociationFailureCauseEnum::kAuthenticationFailed); + break; + case WIFI_STATUS_CONN_FAIL: + case WIFI_STATUS_CONN_TIMEOUT: + associationFailureCause = to_underlying(AssociationFailureCauseEnum::kAssociationFailed); + break; + case WIFI_STATUS_CONN_AP_NOT_FOUND: + associationFailureCause = to_underlying(AssociationFailureCauseEnum::kSsidNotFound); + break; + default: + associationFailureCause = to_underlying(AssociationFailureCauseEnum::kUnknown); + break; + } + + delegate->OnAssociationFailureDetected(associationFailureCause, reason); } } else // The connection has been established successfully. { - // Now we can send/receive data via WiFi - net_if_up(InetUtils::GetWiFiInterface()); + // Workaround needed until sending Router Solicitation after connect will be done by the driver. + DeviceLayer::SystemLayer().StartTimer( + System::Clock::Milliseconds32(chip::Crypto::GetRandU16() % kMaxInitialRouterSolicitationDelayMs), + SendRouterSolicitation, nullptr); ChipLogProgress(DeviceLayer, "Connected to WiFi network"); Instance().mWiFiState = WIFI_STATE_COMPLETED; - if (Instance().mHandling.mOnConnectionSuccess) + if (Instance().mHandling.mOnConnectionDone) { - Instance().mHandling.mOnConnectionSuccess(); + Instance().mHandling.mOnConnectionDone(connStatus); } Instance().PostConnectivityStatusChange(kConnectivity_Established); @@ -442,6 +513,13 @@ void WiFiManager::ConnectHandler(Platform::UniquePtr data, size_t lengt { ChipLogError(DeviceLayer, "Cannot post event [error: %s]", ErrorStr(error)); } + + WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); + if (delegate) + { + delegate->OnConnectionStatusChanged( + to_underlying(app::Clusters::WiFiNetworkDiagnostics::ConnectionStatusEnum::kConnected)); + } } // cleanup the provisioning data as it is configured per each connect request Instance().ClearStationProvisioningData(); @@ -459,10 +537,44 @@ void WiFiManager::DisconnectHandler(Platform::UniquePtr data, size_t le // Validate that input data size matches the expected one. VerifyOrReturn(length == sizeof(wifi_status)); - CHIP_ERROR err = SystemLayer().ScheduleLambda([] { + CHIP_ERROR err = SystemLayer().ScheduleLambda([capturedData = data.get()] { + Platform::UniquePtr safePtr(capturedData); + uint8_t * rawData = safePtr.get(); + const wifi_status * status = reinterpret_cast(rawData); + uint16_t reason; + + switch (status->disconn_reason) + { + case WIFI_REASON_DISCONN_UNSPECIFIED: + reason = static_cast(WlanReason::UNSPECIFIED); + break; + case WIFI_REASON_DISCONN_USER_REQUEST: + reason = static_cast(WlanReason::DEAUTH_LEAVING); + break; + case WIFI_REASON_DISCONN_AP_LEAVING: + reason = static_cast(WlanReason::DEAUTH_LEAVING); + break; + case WIFI_REASON_DISCONN_INACTIVITY: + reason = static_cast(WlanReason::DISASSOC_DUE_TO_INACTIVITY); + break; + default: + reason = static_cast(WlanReason::UNSPECIFIED); + break; + } + + Instance().SetLastDisconnectReason(reason); + ChipLogProgress(DeviceLayer, "WiFi station disconnected"); Instance().mWiFiState = WIFI_STATE_DISCONNECTED; Instance().PostConnectivityStatusChange(kConnectivity_Lost); + + WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); + if (delegate) + { + delegate->OnConnectionStatusChanged( + to_underlying(app::Clusters::WiFiNetworkDiagnostics::ConnectionStatusEnum::kNotConnected)); + delegate->OnDisconnectionDetected(reason); + } }); if (CHIP_NO_ERROR == err) @@ -587,5 +699,15 @@ CHIP_ERROR WiFiManager::SetLowPowerMode(bool onoff) return CHIP_NO_ERROR; } +void WiFiManager::SetLastDisconnectReason(uint16_t reason) +{ + mLastDisconnectedReason = reason; +} + +uint16_t WiFiManager::GetLastDisconnectReason() +{ + return mLastDisconnectedReason; +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/telink/wifi/WiFiManager.h b/src/platform/telink/wifi/WiFiManager.h index 49c9496f5d13be..6674b5c6165f9f 100644 --- a/src/platform/telink/wifi/WiFiManager.h +++ b/src/platform/telink/wifi/WiFiManager.h @@ -83,17 +83,16 @@ class Map class WiFiManager { public: - enum WiFiRequestStatus : int - { - SUCCESS = 0, - FAILURE = 1, - TERMINATED = 2 - }; + /* No copy, nor move. */ + WiFiManager(const WiFiManager &) = delete; + WiFiManager & operator=(const WiFiManager &) = delete; + WiFiManager(WiFiManager &&) = delete; + WiFiManager & operator=(WiFiManager &&) = delete; using ScanDoneStatus = decltype(wifi_status::status); using ScanResultCallback = void (*)(const NetworkCommissioning::WiFiScanResponse &); using ScanDoneCallback = void (*)(const ScanDoneStatus &); - using ConnectionCallback = void (*)(); + using ConnectionCallback = void (*)(const wifi_conn_status &); enum class StationStatus : uint8_t { @@ -108,6 +107,15 @@ class WiFiManager UNKNOWN }; + enum class WlanReason : uint8_t + { + UNSPECIFIED = 1, + PREV_AUTH_NOT_VALID, + DEAUTH_LEAVING, + DISASSOC_DUE_TO_INACTIVITY, + DISASSOC_AP_BUSY + }; + static WiFiManager & Instance() { static WiFiManager sInstance; @@ -116,8 +124,7 @@ class WiFiManager struct ConnectionHandling { - ConnectionCallback mOnConnectionSuccess{}; - ConnectionCallback mOnConnectionFailed{}; + ConnectionCallback mOnConnectionDone{}; System::Clock::Seconds32 mConnectionTimeout{}; }; @@ -182,10 +189,15 @@ class WiFiManager CHIP_ERROR GetNetworkStatistics(NetworkStatistics & stats) const; void AbortConnectionRecovery(); CHIP_ERROR SetLowPowerMode(bool onoff); + void SetLastDisconnectReason(uint16_t reason); + uint16_t GetLastDisconnectReason(); private: using NetEventHandler = void (*)(Platform::UniquePtr, size_t); + WiFiManager() = default; + ~WiFiManager() = default; + struct ConnectionParams { wifi_connect_req_params mParams; @@ -224,6 +236,8 @@ class WiFiManager net_if * mNetIf{ nullptr }; ConnectionParams mWiFiParams{}; ConnectionHandling mHandling{}; + wifi_scan_params mScanParams{}; + char mScanSsidBuffer[DeviceLayer::Internal::kMaxWiFiSSIDLength + 1] = { 0 }; wifi_iface_state mWiFiState; wifi_iface_state mCachedWiFiState; net_mgmt_event_callback mWiFiMgmtClbk{}; @@ -237,6 +251,7 @@ class WiFiManager uint32_t mConnectionRecoveryCounter{ 0 }; uint32_t mConnectionRecoveryTimeMs{ kConnectionRecoveryMinIntervalMs }; bool mApplicationDisconnectRequested{ false }; + uint16_t mLastDisconnectedReason = static_cast(WlanReason::UNSPECIFIED); static const Map sStatusMap; static const Map sEventHandlerMap; From 01b35efff693bf0ca2c78ee76016e62e51aa4fbb Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 28 Jan 2025 16:24:07 +0000 Subject: [PATCH 46/51] [Telink] remove b95 SoC / TLSR9258a board (replaced by TL721x) --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 36 +++++++++---------- config/telink/chip-module/Kconfig.defaults | 4 +-- .../air-quality-sensor-app/telink/README.md | 1 - examples/all-clusters-app/telink/README.md | 1 - .../all-clusters-minimal-app/telink/README.md | 1 - examples/bridge-app/telink/README.md | 1 - examples/contact-sensor-app/telink/README.md | 1 - examples/light-switch-app/telink/README.md | 1 - examples/lighting-app/telink/README.md | 1 - examples/lock-app/telink/README.md | 1 - examples/ota-requestor-app/telink/README.md | 1 - examples/pump-app/telink/README.md | 1 - examples/pump-controller-app/telink/README.md | 1 - examples/shell/telink/README.md | 1 - examples/smoke-co-alarm-app/telink/README.md | 1 - .../telink/README.md | 1 - examples/thermostat/telink/README.md | 1 - examples/window-app/telink/README.md | 1 - scripts/build/build/targets.py | 2 -- scripts/build/builders/telink.py | 6 ---- .../build/testdata/all_targets_linux_x64.txt | 2 +- .../telink/tlsr9258a_2m_flash.overlay | 35 ------------------ .../telink/tlsr9258a_retention.overlay | 24 ------------- 24 files changed, 22 insertions(+), 105 deletions(-) delete mode 100644 src/platform/telink/tlsr9258a_2m_flash.overlay delete mode 100644 src/platform/telink/tlsr9258a_retention.overlay diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 39061be0660e1e..4ef11b818a7942 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 28deded4d225ac5c112d9c6e3659970434a6203a" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 4f721330d76c861f5a6b0f2ebea16d70916dc87e" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 0744ec6bc44f9a..9631fc96952b44 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 28deded4d225ac5c112d9c6e3659970434a6203a" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 4f721330d76c861f5a6b0f2ebea16d70916dc87e" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs @@ -115,14 +115,14 @@ jobs: - name: clean out build output run: rm -rf ./out - - name: Build example Telink (B95) Bridge App + - name: Build example Telink (TL7218) 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" + "./scripts/build/build_examples.py --target 'telink-tl7218-bridge' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9258a bridge-app \ - out/telink-tlsr9258a-bridge/zephyr/zephyr.elf \ + telink tl7218 bridge-app \ + out/telink-tl7218-bridge/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output @@ -245,19 +245,19 @@ jobs: - 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 (TL3218) 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-tl3218-ota-requestor' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tl3218 ota-requestor-app \ + out/telink-tl3218-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 diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 30c282bd9354f5..0dad29bb34d2fd 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -195,7 +195,7 @@ endif # SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX endif # BT -if BOARD_TLSR9528A_RETENTION || BOARD_TLSR9258A_RETENTION || BOARD_TLSR9518ADK80D_RETENTION +if BOARD_TLSR9528A_RETENTION || BOARD_TLSR9518ADK80D_RETENTION config SOC_SERIES_RISCV_TELINK_B9X_NON_RETENTION_RAM_CODE default y if PM @@ -221,7 +221,7 @@ endif # Board non-retention config if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 || \ - BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D || BOARD_TL3218 || BOARD_TL7218 + BOARD_TLSR9528A || BOARD_TLSR9518ADK80D || BOARD_TL3218 || BOARD_TL7218 config PWM default y endif diff --git a/examples/air-quality-sensor-app/telink/README.md b/examples/air-quality-sensor-app/telink/README.md index c3d403f450ee45..8d8a9132be5a9f 100644 --- a/examples/air-quality-sensor-app/telink/README.md +++ b/examples/air-quality-sensor-app/telink/README.md @@ -12,7 +12,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/all-clusters-app/telink/README.md b/examples/all-clusters-app/telink/README.md index b702fd6e3567db..b4f746d388afdd 100644 --- a/examples/all-clusters-app/telink/README.md +++ b/examples/all-clusters-app/telink/README.md @@ -14,7 +14,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/all-clusters-minimal-app/telink/README.md b/examples/all-clusters-minimal-app/telink/README.md index 33ad1fb6cf9f8d..add462a22d9ebf 100644 --- a/examples/all-clusters-minimal-app/telink/README.md +++ b/examples/all-clusters-minimal-app/telink/README.md @@ -14,7 +14,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/bridge-app/telink/README.md b/examples/bridge-app/telink/README.md index 00b050e93c945e..844493241d1a12 100644 --- a/examples/bridge-app/telink/README.md +++ b/examples/bridge-app/telink/README.md @@ -91,7 +91,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/contact-sensor-app/telink/README.md b/examples/contact-sensor-app/telink/README.md index 27d5721953c261..12306f01e5b637 100755 --- a/examples/contact-sensor-app/telink/README.md +++ b/examples/contact-sensor-app/telink/README.md @@ -12,7 +12,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/light-switch-app/telink/README.md b/examples/light-switch-app/telink/README.md index b2c75f1fc28fb9..087ef533a648cb 100755 --- a/examples/light-switch-app/telink/README.md +++ b/examples/light-switch-app/telink/README.md @@ -17,7 +17,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/lighting-app/telink/README.md b/examples/lighting-app/telink/README.md index 1a142507652784..ba41630d9ff37f 100644 --- a/examples/lighting-app/telink/README.md +++ b/examples/lighting-app/telink/README.md @@ -15,7 +15,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/lock-app/telink/README.md b/examples/lock-app/telink/README.md index 9f6e8671ccbb3b..49e63e0c01e3a9 100755 --- a/examples/lock-app/telink/README.md +++ b/examples/lock-app/telink/README.md @@ -15,7 +15,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/ota-requestor-app/telink/README.md b/examples/ota-requestor-app/telink/README.md index 0c359b3af5ac01..d3e9f8a3cc201b 100755 --- a/examples/ota-requestor-app/telink/README.md +++ b/examples/ota-requestor-app/telink/README.md @@ -8,7 +8,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/pump-app/telink/README.md b/examples/pump-app/telink/README.md index 0f3337f5c08a78..8e07d65bd8050b 100755 --- a/examples/pump-app/telink/README.md +++ b/examples/pump-app/telink/README.md @@ -16,7 +16,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/pump-controller-app/telink/README.md b/examples/pump-controller-app/telink/README.md index 3d1cb1f204f499..f0119a54263070 100755 --- a/examples/pump-controller-app/telink/README.md +++ b/examples/pump-controller-app/telink/README.md @@ -17,7 +17,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/shell/telink/README.md b/examples/shell/telink/README.md index 14e8bedb1c3bf0..65272899859498 100755 --- a/examples/shell/telink/README.md +++ b/examples/shell/telink/README.md @@ -12,7 +12,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/smoke-co-alarm-app/telink/README.md b/examples/smoke-co-alarm-app/telink/README.md index a2fce29d1b1fd3..5f0b94d14d162f 100755 --- a/examples/smoke-co-alarm-app/telink/README.md +++ b/examples/smoke-co-alarm-app/telink/README.md @@ -12,7 +12,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/temperature-measurement-app/telink/README.md b/examples/temperature-measurement-app/telink/README.md index 7dc9287a54ca55..2e838ca93ad12a 100644 --- a/examples/temperature-measurement-app/telink/README.md +++ b/examples/temperature-measurement-app/telink/README.md @@ -16,7 +16,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/thermostat/telink/README.md b/examples/thermostat/telink/README.md index 26856132994c5d..a23ec166d7b130 100755 --- a/examples/thermostat/telink/README.md +++ b/examples/thermostat/telink/README.md @@ -12,7 +12,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/examples/window-app/telink/README.md b/examples/window-app/telink/README.md index b40a12bf754eac..6978ce49df8f5b 100644 --- a/examples/window-app/telink/README.md +++ b/examples/window-app/telink/README.md @@ -15,7 +15,6 @@ The example supports building and running on the following devices: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | [B91](https://wiki.telink-semi.cn/wiki/Hardware/B91_Generic_Starter_Kit_Hardware_Guide) [TLSR9518ADK80D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR951x-Series) | `tlsr9518adk80d`, `tlsr9518adk80d-mars`, `tlsr9518adk80d-usb` | [TLSR9518ADK80D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9518adk80d/doc/index.rst) | | [B92](https://wiki.telink-semi.cn/wiki/Hardware/B92_Generic_Starter_Kit_Hardware_Guide) [TLSR9528A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR952x-Series) | `tlsr9528a`, `tlsr9528a_retention` | [TLSR9528A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9528a/doc/index.rst) | -| [B95](https://wiki.telink-semi.cn/wiki/Hardware/B95_Generic_Starter_Kit_Hardware_Guide) [TLSR9258A](https://wiki.telink-semi.cn/wiki/chip-series/TLSR925x-Series) | `tlsr9258a` | [TLSR9258A](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9258a/doc/index.rst) | | [W91](https://wiki.telink-semi.cn/wiki/Hardware/W91_Generic_Starter_Kit_Hardware_Guide) [TLSR9118BDK40D](https://wiki.telink-semi.cn/wiki/chip-series/TLSR911x-Series) | `tlsr9118bdk40d` | [TLSR9118BDK40D](https://github.com/telink-semi/zephyr/blob/develop/boards/riscv/tlsr9118bdk40d/doc/index.rst) | ## Build and flash diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 51a316157562f9..54fd807b945e42 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -775,8 +775,6 @@ def BuildTelinkTarget(): TargetPart('tlsr9518adk80d', board=TelinkBoard.TLSR9518ADK80D), TargetPart('tlsr9528a', board=TelinkBoard.TLSR9528A), TargetPart('tlsr9528a_retention', board=TelinkBoard.TLSR9528A_RETENTION), - TargetPart('tlsr9258a', board=TelinkBoard.TLSR9258A), - TargetPart('tlsr9258a_retention', board=TelinkBoard.TLSR9258A_RETENTION), TargetPart('tl3218', board=TelinkBoard.TL3218), TargetPart('tl7218', board=TelinkBoard.TL7218), TargetPart('tl7218_retention', board=TelinkBoard.TL7218_RETENTION), diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 38249b4150e324..5ca754eb1b9cfc 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -119,8 +119,6 @@ class TelinkBoard(Enum): TLSR9518ADK80D = auto() TLSR9528A = auto() TLSR9528A_RETENTION = auto() - TLSR9258A = auto() - TLSR9258A_RETENTION = auto() TL3218 = auto() TL7218 = auto() TL7218_RETENTION = auto() @@ -134,10 +132,6 @@ def GnArgName(self): return 'tlsr9528a' elif self == TelinkBoard.TLSR9528A_RETENTION: return 'tlsr9528a_retention' - elif self == TelinkBoard.TLSR9258A: - return 'tlsr9258a' - elif self == TelinkBoard.TLSR9258A_RETENTION: - return 'tlsr9258a_retention' elif self == TelinkBoard.TL3218: return 'tl3218' elif self == TelinkBoard.TL7218: diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index a9354064dc3a0d..9d8bc34bb9eba3 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -22,5 +22,5 @@ nuttx-x64-light qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage] stm32-stm32wb5mm-dk-light tizen-arm-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-coverage][-with-ui] -telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218,tl7218,tl7218_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] +telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tl3218,tl7218,tl7218_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] openiotsdk-{shell,lock}[-mbedtls][-psa] diff --git a/src/platform/telink/tlsr9258a_2m_flash.overlay b/src/platform/telink/tlsr9258a_2m_flash.overlay deleted file mode 100644 index 2e41751980112e..00000000000000 --- a/src/platform/telink/tlsr9258a_2m_flash.overlay +++ /dev/null @@ -1,35 +0,0 @@ -&flash { - reg = <0x20000000 0x200000>; - - /delete-node/ partitions; - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - boot_partition: partition@0 { - label = "mcuboot"; - reg = <0x00000000 0xb000>; - }; - slot0_partition: partition@b000 { - label = "image-0"; - reg = <0xb000 0xf3000>; - }; - factory_partition: partition@fe000 { - label = "factory-data"; - reg = <0xfe000 0x1000>; - }; - storage_partition: partition@ff000 { - label = "storage"; - reg = <0xff000 0xc000>; - }; - slot1_partition: partition@10b000 { - label = "image-1"; - reg = <0x10b000 0xf3000>; - }; - vendor_partition: partition@1fe000 { - label = "vendor-data"; - reg = <0x1fe000 0x2000>; - }; - }; -}; diff --git a/src/platform/telink/tlsr9258a_retention.overlay b/src/platform/telink/tlsr9258a_retention.overlay deleted file mode 100644 index 0890951e787f96..00000000000000 --- a/src/platform/telink/tlsr9258a_retention.overlay +++ /dev/null @@ -1,24 +0,0 @@ -/ { - /* - * There is no way to keep GPIOs - * during deep-sleep mode so output GPIOs - * and PWM's are useless. - */ - - aliases { - /delete-property/ led0; - /delete-property/ led1; - /delete-property/ led2; - /delete-property/ led3; - /delete-property/ mcuboot-led0; - /delete-property/ pwm-led0; - /delete-property/ pwm-0; - }; - - /delete-node/ leds; - /delete-node/ pwm_leds; -}; - -&pwm0 { - status = "disabled"; -}; From 80b280006c72ef3adec4cb9bc4eae5ccf87651df Mon Sep 17 00:00:00 2001 From: Serhii Salamakha Date: Tue, 28 Jan 2025 19:40:18 +0200 Subject: [PATCH 47/51] [Telink] Revert InetUtils.cpp Telink dependency --- src/platform/Zephyr/InetUtils.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/platform/Zephyr/InetUtils.cpp b/src/platform/Zephyr/InetUtils.cpp index b692cdafa80c59..07d2a302dacbf3 100644 --- a/src/platform/Zephyr/InetUtils.cpp +++ b/src/platform/Zephyr/InetUtils.cpp @@ -15,8 +15,6 @@ * limitations under the License. */ -#include - #include "InetUtils.h" #include @@ -40,18 +38,10 @@ net_if * GetInterface(Inet::InterfaceId ifaceId) return ifaceId.IsPresent() ? net_if_get_by_index(ifaceId.GetPlatformInterface()) : net_if_get_default(); } -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI net_if * GetWiFiInterface() { -// TODO: Remove dependency after Telink Zephyr update -// net_if_get_first_wifi() is not available in Zephyr 3.3.99 -#if !defined(CONFIG_SOC_RISCV_TELINK_W91) return net_if_get_first_wifi(); -#else - return GetInterface(); -#endif } -#endif } // namespace InetUtils } // namespace DeviceLayer From 642588425426176827feaa8945fb7554b014eea6 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 11 Feb 2025 12:14:52 +0200 Subject: [PATCH 48/51] [Telink] zephyr versions compatibility changes (#382) * [Telink] zephyr versions compatibility changes * [Telink] Change Window Covering App default SoC W91 doesn't support PM * [Telink] Update Zephyr revision * [Telink] sync B92 flash layout * [Telink] Remove temp b92 4mb change * [Telink] Avoid main stack owerflow for w91 * [Telink] Update Zephyr revision --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 58 +++++++++---------- config/telink/chip-module/Kconfig | 2 +- config/telink/chip-module/Kconfig.defaults | 9 +-- examples/window-app/telink/prj.conf | 2 +- scripts/build/build/targets.py | 6 +- scripts/build/builders/telink.py | 18 +++--- .../build/testdata/all_targets_linux_x64.txt | 2 +- ...flash.overlay => tl3218x_2m_flash.overlay} | 0 ...flash.overlay => tl7218x_2m_flash.overlay} | 0 .../telink/tlsr9528a_2m_flash.overlay | 18 +++--- 11 files changed, 59 insertions(+), 58 deletions(-) rename src/platform/telink/{tl3218_2m_flash.overlay => tl3218x_2m_flash.overlay} (100%) rename src/platform/telink/{tl7218_2m_flash.overlay => tl7218x_2m_flash.overlay} (100%) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 49a44bdc3f7d17..36b455f95bf6f4 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -122,7 +122,7 @@ jobs: 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 4f721330d76c861f5a6b0f2ebea16d70916dc87e" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 4e9865ca0663c1cda6e8bfac58f030d20bc9977f" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 55788e7d087e41..038136273b22e5 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -71,7 +71,7 @@ jobs: 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 4f721330d76c861f5a6b0f2ebea16d70916dc87e" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 4e9865ca0663c1cda6e8bfac58f030d20bc9977f" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs @@ -115,14 +115,14 @@ jobs: - name: clean out build output run: rm -rf ./out - - name: Build example Telink (TL7218) Bridge App + - name: Build example Telink (tl721x) Bridge App # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tl7218-bridge' build" + "./scripts/build/build_examples.py --target 'telink-tl7218x-bridge' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl7218 bridge-app \ - out/telink-tl7218-bridge/zephyr/zephyr.elf \ + telink tl7218x bridge-app \ + out/telink-tl7218x-bridge/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output @@ -178,53 +178,53 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (TL3218) Lighting App with OTA, Factory Data + - name: Build example Telink (tl321x) Lighting App with OTA, Factory Data # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tl3218-light-ota-factory-data' build" + "./scripts/build/build_examples.py --target 'telink-tl3218x-light-ota-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl3218 light-app-ota-factory-data \ - out/telink-tl3218-light-ota-factory-data/zephyr/zephyr.elf \ + telink tl3218x light-app-ota-factory-data \ + out/telink-tl3218x-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 (TL7218) Lighting App with OTA, Shell, Factory Data + - name: Build example Telink (tl721x) 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-tl7218-light-ota-shell-factory-data' build" + "./scripts/build/build_examples.py --target 'telink-tl7218x-light-ota-shell-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl7218 light-app-ota-shell-factory-data \ - out/telink-tl7218-light-ota-shell-factory-data/zephyr/zephyr.elf \ + telink tl7218x light-app-ota-shell-factory-data \ + out/telink-tl7218x-light-ota-shell-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (TL7218 retention) Light Switch App with OTA (LZMA), Factory Data + - name: Build example Telink (tl721x retention) Light Switch App with OTA (LZMA), Factory Data # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tl7218_retention-light-switch-ota-compress-lzma-factory-data' build" + "./scripts/build/build_examples.py --target 'telink-tl7218x_retention-light-switch-ota-compress-lzma-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl7218_retention light-switch-app-ota-compress-lzma-factory-data \ - out/telink-tl7218_retention-light-switch-ota-compress-lzma-factory-data/zephyr/zephyr.elf \ + telink tl7218x_retention light-switch-app-ota-compress-lzma-factory-data \ + out/telink-tl7218x_retention-light-switch-ota-compress-lzma-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ - 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, 4Mb flash + - name: Build example Telink (B92) Light Switch App with OTA (LZMA), 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-4mb' build" + "./scripts/build/build_examples.py --target 'telink-tlsr9528a-light-switch-ota-compress-lzma-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-4mb \ - out/telink-tlsr9528a-light-switch-ota-compress-lzma-shell-factory-data-4mb/zephyr/zephyr.elf \ + 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 \ /tmp/bloat_reports/ - name: clean out build output @@ -244,15 +244,15 @@ jobs: - name: clean out build output run: rm -rf ./out - - name: Build example Telink (TL3218) OTA Requestor App + - name: Build example Telink (tl321x) 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-tl3218-ota-requestor' build" + "./scripts/build/build_examples.py --target 'telink-tl3218x-ota-requestor' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tl3218 ota-requestor-app \ - out/telink-tl3218-ota-requestor/zephyr/zephyr.elf \ + telink tl3218x ota-requestor-app \ + out/telink-tl3218x-ota-requestor/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output @@ -342,15 +342,15 @@ jobs: - name: clean out build output run: rm -rf ./out - - name: Build example Telink (W91) Window Covering App + - name: Build example Telink (tl721x) 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' run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-window-covering' build" + "./scripts/build/build_examples.py --target 'telink-tl7218x-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 \ + telink tl7218x window-covering \ + out/telink-tl7218x-window-covering/zephyr/zephyr.elf \ /tmp/bloat_reports/ - name: clean out build output diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 292e2c606ec243..073e4375adc04f 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -45,7 +45,7 @@ config BOOTLOADER_MCUBOOT bool select IMG_MANAGER select STREAM_FLASH - select TELINK_W91_N22_MATTER_OTA_LAYOUT if BOARD_TLSR9118BDK40D + select TELINK_W91_N22_MATTER_OTA_LAYOUT if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 config CHIP_OTA_REQUESTOR_BUFFER_SIZE int "OTA Requestor image buffer size" diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 0dad29bb34d2fd..b194906735d532 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -63,6 +63,7 @@ config POSIX_MAX_FDS # Application stack size config MAIN_STACK_SIZE default 3240 if PM || SOC_RISCV_TELINK_TL321X + default 4512 if SOC_RISCV_TELINK_W91 default 4096 config INIT_STACKS @@ -207,12 +208,12 @@ config PWM endif -if BOARD_TL7218_RETENTION || BOARD_TL3218_RETENTION || BOARD_TL3218 +if BOARD_TL7218X_RETENTION || BOARD_TL3218X_RETENTION || BOARD_TL3218X config SOC_SERIES_RISCV_TELINK_TLX_NON_RETENTION_RAM_CODE default n if PM config TELINK_TLX_MATTER_RETENTION_LAYOUT - default y if PM || BOARD_TL3218 + default y if PM || BOARD_TL3218X config PWM default n if PM @@ -221,7 +222,7 @@ endif # Board non-retention config if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 || \ - BOARD_TLSR9528A || BOARD_TLSR9518ADK80D || BOARD_TL3218 || BOARD_TL7218 + BOARD_TLSR9528A || BOARD_TLSR9518ADK80D || BOARD_TL3218X || BOARD_TL7218X config PWM default y endif @@ -234,7 +235,7 @@ config CHIP_OTA_REQUESTOR default y config MCUBOOT_SIGNATURE_KEY_FILE - default "bootloader/mcuboot/root-ec-p256.pem" if BOARD_TLSR9118BDK40D + default "bootloader/mcuboot/root-ec-p256.pem" if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 depends on BOOTLOADER_MCUBOOT # In current config/zephyr/Kconfig diff --git a/examples/window-app/telink/prj.conf b/examples/window-app/telink/prj.conf index da6db7f21feed7..f45bdb047cd75a 100644 --- a/examples/window-app/telink/prj.conf +++ b/examples/window-app/telink/prj.conf @@ -41,4 +41,4 @@ CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n # Enable Power Management -CONFIG_PM=n +CONFIG_PM=y diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index f6d0f890f94c40..3611e7372cb3c9 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -778,9 +778,9 @@ def BuildTelinkTarget(): TargetPart('tlsr9518adk80d', board=TelinkBoard.TLSR9518ADK80D), TargetPart('tlsr9528a', board=TelinkBoard.TLSR9528A), TargetPart('tlsr9528a_retention', board=TelinkBoard.TLSR9528A_RETENTION), - TargetPart('tl3218', board=TelinkBoard.TL3218), - TargetPart('tl7218', board=TelinkBoard.TL7218), - TargetPart('tl7218_retention', board=TelinkBoard.TL7218_RETENTION), + TargetPart('tl3218x', board=TelinkBoard.TL3218X), + TargetPart('tl7218x', board=TelinkBoard.TL7218X), + TargetPart('tl7218x_retention', board=TelinkBoard.TL7218X_RETENTION), ]) target.AppendFixedTargets([ diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 5ca754eb1b9cfc..b2966742179aac 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -119,9 +119,9 @@ class TelinkBoard(Enum): TLSR9518ADK80D = auto() TLSR9528A = auto() TLSR9528A_RETENTION = auto() - TL3218 = auto() - TL7218 = auto() - TL7218_RETENTION = auto() + TL3218X = auto() + TL7218X = auto() + TL7218X_RETENTION = auto() def GnArgName(self): if self == TelinkBoard.TLRS9118BDK40D: @@ -132,12 +132,12 @@ def GnArgName(self): return 'tlsr9528a' elif self == TelinkBoard.TLSR9528A_RETENTION: return 'tlsr9528a_retention' - elif self == TelinkBoard.TL3218: - return 'tl3218' - elif self == TelinkBoard.TL7218: - return 'tl7218' - elif self == TelinkBoard.TL7218_RETENTION: - return 'tl7218_retention' + elif self == TelinkBoard.TL3218X: + return 'tl3218x' + elif self == TelinkBoard.TL7218X: + return 'tl7218x' + elif self == TelinkBoard.TL7218X_RETENTION: + return 'tl7218x_retention' else: raise Exception('Unknown board type: %r' % self) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index bd67452c608a28..590844271d3ba6 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -22,5 +22,5 @@ nuttx-x64-light qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage] stm32-stm32wb5mm-dk-light tizen-arm-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-coverage][-with-ui] -telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tl3218,tl7218,tl7218_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] +telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tl3218x,tl7218x,tl7218x_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer] openiotsdk-{shell,lock}[-mbedtls][-psa] diff --git a/src/platform/telink/tl3218_2m_flash.overlay b/src/platform/telink/tl3218x_2m_flash.overlay similarity index 100% rename from src/platform/telink/tl3218_2m_flash.overlay rename to src/platform/telink/tl3218x_2m_flash.overlay diff --git a/src/platform/telink/tl7218_2m_flash.overlay b/src/platform/telink/tl7218x_2m_flash.overlay similarity index 100% rename from src/platform/telink/tl7218_2m_flash.overlay rename to src/platform/telink/tl7218x_2m_flash.overlay diff --git a/src/platform/telink/tlsr9528a_2m_flash.overlay b/src/platform/telink/tlsr9528a_2m_flash.overlay index 62c17e96bd0031..d08d0e4ff4a6ba 100644 --- a/src/platform/telink/tlsr9528a_2m_flash.overlay +++ b/src/platform/telink/tlsr9528a_2m_flash.overlay @@ -9,23 +9,23 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0xd000>; + reg = <0x00000000 0xf000>; }; - slot0_partition: partition@d000 { + slot0_partition: partition@f000 { label = "image-0"; - reg = <0xd000 0xf2000>; + reg = <0xf000 0xf1000>; }; - factory_partition: partition@ff000 { + factory_partition: partition@100000 { label = "factory-data"; - reg = <0xff000 0x1000>; + reg = <0x100000 0x1000>; }; - storage_partition: partition@100000 { + storage_partition: partition@101000 { label = "storage"; - reg = <0x100000 0xc000>; + reg = <0x101000 0xc000>; }; - slot1_partition: partition@10c000 { + slot1_partition: partition@10d000 { label = "image-1"; - reg = <0x10c000 0xf2000>; + reg = <0x10d000 0xf1000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; From b82ba434685502198ca789556ee32098bcb1b263 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 11 Feb 2025 14:13:45 +0000 Subject: [PATCH 49/51] [Telink] manual sync after merge master --- .github/workflows/chef.yaml | 11 -------- .github/workflows/examples-telink.yaml | 12 --------- config/telink/chip-module/Kconfig.defaults | 30 +++++++++++----------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 3f9e84ea1d2c37..45422d4fed973b 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -28,8 +28,6 @@ concurrency: env: CHIP_NO_LOG_TIMESTAMPS: true - # Required to Update Zephyr SDK (for developers purpose) - TELINK_ZEPHYR_SDK_DIR: /opt/telink/zephyr-sdk-0.17.0 jobs: chef_linux: @@ -107,15 +105,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Update Zephyr SDK (for developers purpose) - run: | - set -e - cd /opt/telink - rm -rf zephyr-sdk-0.16.1 - curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz - tar xvf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz - rm -rf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz - zephyr-sdk-0.17.0/setup.sh -t riscv64-zephyr-elf - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 2421440bb6176d..426922590f7c07 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -28,8 +28,6 @@ concurrency: env: CHIP_NO_LOG_TIMESTAMPS: true - # Required to Update Zephyr SDK (for developers purpose) - TELINK_ZEPHYR_SDK_DIR: /opt/telink/zephyr-sdk-0.17.0 jobs: telink: @@ -49,16 +47,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Update Zephyr SDK (for developers purpose) - run: | - set -e - cd /opt/telink - rm -rf zephyr-sdk-0.16.1 - curl --location https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz --output zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz - tar xvf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz - rm -rf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz - zephyr-sdk-0.17.0/setup.sh -t riscv64-zephyr-elf - - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 3fc715a0ec2123..101b8cc56fe077 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -235,8 +235,8 @@ config CHIP_OTA_REQUESTOR default y config MCUBOOT_SIGNATURE_KEY_FILE - default "bootloader/mcuboot/root-ec-p256.pem" if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 - depends on BOOTLOADER_MCUBOOT + default "bootloader/mcuboot/root-ec-p256.pem" if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 + depends on BOOTLOADER_MCUBOOT # In current config/zephyr/Kconfig # next deprecated values are selected @@ -341,16 +341,16 @@ config NET_CONFIG_INIT_TIMEOUT config CHIP_WIFI - bool "Enable Telink Wi-Fi support" - default y if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 - select WIFI_W91 - select WIFI - select NET_STATISTICS - select NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements - select NET_IPV6_NBR_CACHE - select NET_STATISTICS_USER_API - imply MBEDTLS_ENTROPY_C - imply MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + bool "Enable Telink Wi-Fi support" + default y if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 + select WIFI_W91 + select WIFI + select NET_STATISTICS + select NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements + select NET_IPV6_NBR_CACHE + select NET_STATISTICS_USER_API + imply MBEDTLS_ENTROPY_C + imply MBEDTLS_KEY_EXCHANGE_RSA_ENABLED if CHIP_WIFI @@ -405,10 +405,10 @@ config CHIP_WIFI_CONNECTION_RECOVERY_JITTER within range [-JITTER; +JITTER]. config NET_MGMT_EVENT_STACK_SIZE - default 1250 + default 1250 config IPC_SERVICE_BACKEND_ICMSG_WQ_STACK_SIZE - default 2304 if TELINK_W91_IPC_DISPATCHER + default 2304 if TELINK_W91_IPC_DISPATCHER endif # CHIP_WIFI @@ -427,7 +427,7 @@ config MBEDTLS_ENTROPY_POLL_ZEPHYR default y config MBEDTLS_CIPHER_AES_ENABLED - default y + default y config MBEDTLS_CIPHER_CCM_ENABLED default y From c12590115d952a041698a55ccfa53588dc67c877 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Wed, 12 Feb 2025 07:15:55 +0000 Subject: [PATCH 50/51] [Telink] Increase Main Stack size for W91 Update Zephyr revision --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- config/telink/chip-module/Kconfig.defaults | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 45422d4fed973b..598122472c8fc4 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -111,7 +111,7 @@ jobs: 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 4e9865ca0663c1cda6e8bfac58f030d20bc9977f" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py f28fc3268ea9515d33d7c392b648df25af5d0789" - name: CI Examples Telink shell: bash run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 426922590f7c07..211f6f61a2f5ba 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -59,7 +59,7 @@ jobs: 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 4e9865ca0663c1cda6e8bfac58f030d20bc9977f" + run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py f28fc3268ea9515d33d7c392b648df25af5d0789" - name: Build example Telink (B92 retention) Air Quality Sensor App # Run test for master and s07641069 PRs diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 101b8cc56fe077..e1f180db7e4f7d 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -63,7 +63,7 @@ config POSIX_MAX_FDS # Application stack size config MAIN_STACK_SIZE default 3240 if PM || SOC_RISCV_TELINK_TL321X - default 4512 if SOC_RISCV_TELINK_W91 + default 4608 if SOC_RISCV_TELINK_W91 default 4096 config INIT_STACKS From c7d6bd6ac2ea9a8d034ae5347ed0e1f46a4943ac Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 14 Feb 2025 15:56:01 +0000 Subject: [PATCH 51/51] [Telink] Zephyr 3.3 backward compatibility support --- .github/workflows/examples-telink.yaml | 1 - config/telink/app/bootloader.conf | 5 + .../telink/app/bootloader_compress_lzma.conf | 7 + config/telink/chip-module/CMakeLists.txt | 1 + config/telink/chip-module/Kconfig | 1 + config/telink/chip-module/Kconfig.defaults | 39 +- examples/platform/telink/common.cmake | 15 +- src/platform/Zephyr/InetUtils.cpp | 10 + src/platform/telink/BLEManagerImpl.cpp | 4 + src/platform/telink/BUILD.gn | 9 +- .../telink/ConnectivityManagerImpl.cpp | 4 + src/platform/telink/FactoryDataParser.c | 4 + src/platform/telink/SystemPlatformConfig.h | 4 +- .../3.3.99.0/ConnectivityManagerImplWiFi.cpp | 177 ++++++ .../telink/wifi/3.3.99.0/TelinkWiFiDriver.cpp | 316 ++++++++++ .../telink/wifi/3.3.99.0/WiFiManager.cpp | 591 ++++++++++++++++++ .../telink/wifi/3.3.99.0/WiFiManager.h | 246 ++++++++ .../ConnectivityManagerImplWiFi.cpp | 2 +- .../wifi/{ => 3.7.99.0}/TelinkWiFiDriver.cpp | 2 +- .../wifi/{ => 3.7.99.0}/WiFiManager.cpp | 0 .../telink/wifi/{ => 3.7.99.0}/WiFiManager.h | 0 src/platform/telink/wifi/TelinkWiFiDriver.h | 4 + 22 files changed, 1422 insertions(+), 20 deletions(-) create mode 100644 src/platform/telink/wifi/3.3.99.0/ConnectivityManagerImplWiFi.cpp create mode 100644 src/platform/telink/wifi/3.3.99.0/TelinkWiFiDriver.cpp create mode 100644 src/platform/telink/wifi/3.3.99.0/WiFiManager.cpp create mode 100644 src/platform/telink/wifi/3.3.99.0/WiFiManager.h rename src/platform/telink/wifi/{ => 3.7.99.0}/ConnectivityManagerImplWiFi.cpp (99%) rename src/platform/telink/wifi/{ => 3.7.99.0}/TelinkWiFiDriver.cpp (99%) rename src/platform/telink/wifi/{ => 3.7.99.0}/WiFiManager.cpp (100%) rename src/platform/telink/wifi/{ => 3.7.99.0}/WiFiManager.h (100%) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 211f6f61a2f5ba..c92fd88bd409a7 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -46,7 +46,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: diff --git a/config/telink/app/bootloader.conf b/config/telink/app/bootloader.conf index 887d1b66a0f661..cdc60a11c7a8ce 100644 --- a/config/telink/app/bootloader.conf +++ b/config/telink/app/bootloader.conf @@ -29,6 +29,11 @@ CONFIG_BOOT_SWAP_USING_SCRATCH=n # With disabled option the only image magic is validated CONFIG_BOOT_VALIDATE_SLOT0=y +# Required for Zephyr 3.3 and replased with CONFIG_BOOT_MAX_IMG_SECTORS_AUTO in new versions +# Maximum number of image sectors supported by the bootloader. +# Maximum signed image size: 512 * 4096 = 2M Bytes +CONFIG_BOOT_MAX_IMG_SECTORS=512 + # MCUBOOT log levels are: # - OFF, LOG_LEVEL_ERR_OFF # - ERROR, LOG_LEVEL_ERR diff --git a/config/telink/app/bootloader_compress_lzma.conf b/config/telink/app/bootloader_compress_lzma.conf index c4de1f7323e882..6cab83229bae34 100644 --- a/config/telink/app/bootloader_compress_lzma.conf +++ b/config/telink/app/bootloader_compress_lzma.conf @@ -22,6 +22,11 @@ CONFIG_BOOT_UPGRADE_ONLY=y # With disabled option the only image magic is validated CONFIG_BOOT_VALIDATE_SLOT0=y +# Required for Zephyr 3.3 and replased with CONFIG_BOOT_MAX_IMG_SECTORS_AUTO in new versions +# Maximum number of image sectors supported by the bootloader. +# Maximum signed image size: 512 * 4096 = 2M Bytes +CONFIG_BOOT_MAX_IMG_SECTORS=512 + # MCUBOOT log levels are: # - OFF, LOG_LEVEL_ERR_OFF # - ERROR, LOG_LEVEL_ERR @@ -38,3 +43,5 @@ CONFIG_SIZE_OPTIMIZATIONS=y # Enable support LZMA compression CONFIG_COMPRESS_LZMA=y + +CONFIG_PICOLIBC=y diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 164ed007198116..0b095a53913612 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -56,6 +56,7 @@ endif() matter_add_flags(-DNL_ASSERT_USE_FLAGS_DEFAULT=1) zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/) +zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/wifi/${ZEPHYR_VERSION_STRING}) zephyr_get_compile_flags(ZEPHYR_CFLAGS_C C) matter_add_cflags("${ZEPHYR_CFLAGS_C}") diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 073e4375adc04f..326643619bb196 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -45,6 +45,7 @@ config BOOTLOADER_MCUBOOT bool select IMG_MANAGER select STREAM_FLASH + select STREAM_FLASH_ERASE select TELINK_W91_N22_MATTER_OTA_LAYOUT if BOARD_TLSR9118BDK40D || BOARD_TLSR9118BDK40D_V1 config CHIP_OTA_REQUESTOR_BUFFER_SIZE diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index e1f180db7e4f7d..17ae385a8d0e02 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -24,6 +24,10 @@ config CHIP_PROJECT_CONFIG string "Project configuration file for Matter" default "include/CHIPProjectConfig.h" +config ZEPHYR_VERSION_3_3 + bool "Using Zephyr version 3.3" + default n + config LOG default y @@ -63,7 +67,7 @@ config POSIX_MAX_FDS # Application stack size config MAIN_STACK_SIZE default 3240 if PM || SOC_RISCV_TELINK_TL321X - default 4608 if SOC_RISCV_TELINK_W91 + default 4608 if SOC_RISCV_TELINK_W91 && !ZEPHYR_VERSION_3_3 default 4096 config INIT_STACKS @@ -81,11 +85,12 @@ config SYSTEM_WORKQUEUE_STACK_SIZE default 616 if PM config HEAP_MEM_POOL_SIZE + default 256 if ZEPHYR_VERSION_3_3 default 1280 config COMMON_LIBC_MALLOC_ARENA_SIZE - default 20716 if SOC_SERIES_RISCV_TELINK_B9X_RETENTION - default 16384 if SOC_RISCV_TELINK_TL321X || SOC_RISCV_TELINK_TL721X + default 20716 if SOC_SERIES_RISCV_TELINK_B9X_RETENTION || (SOC_RISCV_TELINK_TL321X && ZEPHYR_VERSION_3_3) + default 16384 if SOC_RISCV_TELINK_TL721X || (SOC_RISCV_TELINK_TL321X && !ZEPHYR_VERSION_3_3) default 12288 config NET_IPV6_MLD @@ -173,6 +178,7 @@ config BT_DEVICE_NAME_GATT_WRITABLE if SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX config TL_BLE_CTRL_THREAD_STACK_SIZE + default 648 if ZEPHYR_VERSION_3_3 default 680 config TL_BLE_CTRL_MASTER_MAX_NUM @@ -188,7 +194,6 @@ config TL_BLE_CTRL_RF_POWER choice TL_BLE_CTRL_MAC_TYPE default TL_BLE_CTRL_MAC_TYPE_RANDOM_STATIC - endchoice endif # SOC_RISCV_TELINK_B9X || SOC_RISCV_TELINK_TLX @@ -405,10 +410,14 @@ config CHIP_WIFI_CONNECTION_RECOVERY_JITTER within range [-JITTER; +JITTER]. config NET_MGMT_EVENT_STACK_SIZE + default 1128 if ZEPHYR_VERSION_3_3 default 1250 +if !ZEPHYR_VERSION_3_3 config IPC_SERVICE_BACKEND_ICMSG_WQ_STACK_SIZE + int "Size of RX work queue stack" default 2304 if TELINK_W91_IPC_DISPATCHER +endif endif # CHIP_WIFI @@ -423,9 +432,6 @@ config CHIP_ENABLE_PAIRING_AUTOSTART config MBEDTLS default y -config MBEDTLS_ENTROPY_POLL_ZEPHYR - default y - config MBEDTLS_CIPHER_AES_ENABLED default y @@ -447,18 +453,29 @@ config MBEDTLS_ECDH_C config MBEDTLS_ECDSA_C default y -config MBEDTLS_HKDF_C +config MBEDTLS_PKCS5_C default y -config MBEDTLS_PKCS5_C +config MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED default y -config MBEDTLS_X509_CSR_WRITE_C +if !ZEPHYR_VERSION_3_3 +config MBEDTLS_ENTROPY_POLL_ZEPHYR + bool "Provide entropy data to Mbed TLS through entropy driver or random generator" default y -config MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +config MBEDTLS_HKDF_C + bool "HMAC-based Extract-and-Expand Key Derivation Function" default y +config MBEDTLS_X509_CSR_WRITE_C + bool "X.509 Certificate Signing Requests writing" + default y +endif # !ZEPHYR_VERSION_3_3 + +config GETOPT_LONG + default y if ZEPHYR_VERSION_3_3 + # Disable not used shell modules config SHELL_WILDCARD diff --git a/examples/platform/telink/common.cmake b/examples/platform/telink/common.cmake index b8da9a0dc876c8..5aa89a325ffc65 100644 --- a/examples/platform/telink/common.cmake +++ b/examples/platform/telink/common.cmake @@ -13,6 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Generate Zephyr version files for backward compatibility +file(STRINGS "$ENV{ZEPHYR_BASE}/VERSION" ZEPHYR_VERSION_STRING REGEX "[0-9]+") +string(REGEX REPLACE "[^0-9;]" "" ZEPHYR_VERSION_STRING "${ZEPHYR_VERSION_STRING}") +string(REPLACE ";" "." ZEPHYR_VERSION_STRING "${ZEPHYR_VERSION_STRING}") +file(WRITE "${CMAKE_BINARY_DIR}/modules/chip-module/zephyr_version.gni" "ZEPHYR_VERSION_STRING = \"${ZEPHYR_VERSION_STRING}\"\n") +if(${ZEPHYR_VERSION_STRING} MATCHES "^3\\.3") + set(ZEPHYR_VERSION_OVERLAY_FILE "${CMAKE_BINARY_DIR}/zephyr_version.conf") + file(WRITE ${ZEPHYR_VERSION_OVERLAY_FILE} "CONFIG_ZEPHYR_VERSION_3_3=y\n") + + # Add required MbedTLS defines for Zephyr 3.3 + add_definitions(-DMBEDTLS_HKDF_C -DMBEDTLS_X509_CREATE_C -DMBEDTLS_X509_CSR_WRITE_C) +endif() + string(REPLACE "_retention" "" BASE_BOARD ${BOARD}) string(REGEX REPLACE "_v[0-9]+" "" BASE_BOARD ${BASE_BOARD}) @@ -117,7 +130,7 @@ else() endif() if(NOT CONF_FILE) - set(CONF_FILE ${USB_CONF_OVERLAY_FILE} ${MARS_CONF_OVERLAY_FILE} prj.conf) + set(CONF_FILE ${USB_CONF_OVERLAY_FILE} ${MARS_CONF_OVERLAY_FILE} ${ZEPHYR_VERSION_OVERLAY_FILE} prj.conf) endif() # Load NCS/Zephyr build system diff --git a/src/platform/Zephyr/InetUtils.cpp b/src/platform/Zephyr/InetUtils.cpp index 07d2a302dacbf3..032290ece6a345 100644 --- a/src/platform/Zephyr/InetUtils.cpp +++ b/src/platform/Zephyr/InetUtils.cpp @@ -15,6 +15,8 @@ * limitations under the License. */ +#include + #include "InetUtils.h" #include @@ -38,10 +40,18 @@ net_if * GetInterface(Inet::InterfaceId ifaceId) return ifaceId.IsPresent() ? net_if_get_by_index(ifaceId.GetPlatformInterface()) : net_if_get_default(); } +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI net_if * GetWiFiInterface() { +// TODO: Remove dependency after Telink Zephyr 3.3 support is removed +// net_if_get_first_wifi() is not available in Zephyr 3.3 +#if defined(CONFIG_SOC_RISCV_TELINK_W91) && defined(CONFIG_ZEPHYR_VERSION_3_3) + return GetInterface(); +#else return net_if_get_first_wifi(); +#endif } +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI } // namespace InetUtils } // namespace DeviceLayer diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index 911f91bdb9213f..7844b62a47b6b0 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -40,7 +40,11 @@ #include #include #include +#if defined(CONFIG_ZEPHYR_VERSION_3_3) +#include +#else #include +#endif #include #include #include diff --git a/src/platform/telink/BUILD.gn b/src/platform/telink/BUILD.gn index f5fb715a50d314..911591e6b916d2 100644 --- a/src/platform/telink/BUILD.gn +++ b/src/platform/telink/BUILD.gn @@ -96,14 +96,15 @@ static_library("telink") { } if (chip_enable_wifi) { + import("$root_build_dir/zephyr_version.gni") sources += [ "OTAImageProcessorImplWiFi.h", - "wifi/ConnectivityManagerImplWiFi.cpp", + "wifi/" + ZEPHYR_VERSION_STRING + "/ConnectivityManagerImplWiFi.cpp", "wifi/ConnectivityManagerImplWiFi.h", - "wifi/TelinkWiFiDriver.cpp", + "wifi/" + ZEPHYR_VERSION_STRING + "/TelinkWiFiDriver.cpp", "wifi/TelinkWiFiDriver.h", - "wifi/WiFiManager.cpp", - "wifi/WiFiManager.h", + "wifi/" + ZEPHYR_VERSION_STRING + "/WiFiManager.cpp", + "wifi/" + ZEPHYR_VERSION_STRING + "/WiFiManager.h", ] } diff --git a/src/platform/telink/ConnectivityManagerImpl.cpp b/src/platform/telink/ConnectivityManagerImpl.cpp index ba167ead9d1bd9..10ef8699adef79 100644 --- a/src/platform/telink/ConnectivityManagerImpl.cpp +++ b/src/platform/telink/ConnectivityManagerImpl.cpp @@ -77,7 +77,11 @@ CHIP_ERROR JoinLeaveMulticastGroup(net_if * iface, const Inet::IPAddress & addre if (maddr && !net_if_ipv6_maddr_is_joined(maddr)) { +#if defined(CONFIG_ZEPHYR_VERSION_3_3) + net_if_ipv6_maddr_join(maddr); +#else net_if_ipv6_maddr_join(iface, maddr); +#endif } } else if (operation == UDPEndPointImplSockets::MulticastOperation::kLeave) diff --git a/src/platform/telink/FactoryDataParser.c b/src/platform/telink/FactoryDataParser.c index f271b8bfdcfb7e..a2d4c26ede9902 100644 --- a/src/platform/telink/FactoryDataParser.c +++ b/src/platform/telink/FactoryDataParser.c @@ -43,7 +43,11 @@ static inline bool uint16_decode(zcbor_state_t * states, uint16_t * value) bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData * factoryData) { memset(factoryData, 0, sizeof(*factoryData)); +#if defined(CONFIG_ZEPHYR_VERSION_3_3) + ZCBOR_STATE_D(states, MAX_FACTORY_DATA_NESTING_LEVEL, buffer, bufferSize, 1); +#else ZCBOR_STATE_D(states, MAX_FACTORY_DATA_NESTING_LEVEL, buffer, bufferSize, 1, 0); +#endif bool res = zcbor_map_start_decode(states); struct zcbor_string currentString; diff --git a/src/platform/telink/SystemPlatformConfig.h b/src/platform/telink/SystemPlatformConfig.h index 3ac718ce1fb143..c2d677cd8e9adb 100644 --- a/src/platform/telink/SystemPlatformConfig.h +++ b/src/platform/telink/SystemPlatformConfig.h @@ -55,7 +55,7 @@ struct ChipDeviceEvent; #define CHIP_SYSTEM_CONFIG_USE_SOCKETS 1 // Reduce packet buffer pool size (default 15) to reduce ram consumption -#if defined CONFIG_PM || defined CONFIG_SOC_RISCV_TELINK_TL321X +#if defined(CONFIG_PM) || defined(CONFIG_SOC_RISCV_TELINK_TL321X) #define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 #else #define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 @@ -64,4 +64,6 @@ struct ChipDeviceEvent; // ========== Platform-specific Configuration Overrides ========= // Disable Zephyr Socket extensions module, as the Zephyr RTOS now implements recvmsg() +#if !defined(CONFIG_ZEPHYR_VERSION_3_3) #define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKET_EXTENSIONS 0 +#endif diff --git a/src/platform/telink/wifi/3.3.99.0/ConnectivityManagerImplWiFi.cpp b/src/platform/telink/wifi/3.3.99.0/ConnectivityManagerImplWiFi.cpp new file mode 100644 index 00000000000000..b2b4390fe7b3f2 --- /dev/null +++ b/src/platform/telink/wifi/3.3.99.0/ConnectivityManagerImplWiFi.cpp @@ -0,0 +1,177 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * 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. + */ +/* this file behaves like a config.h, comes first */ +#include + +#include +#include + +#include "../ConnectivityManagerImplWiFi.h" +#include "WiFiManager.h" + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::System; + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR ConnectivityManagerImplWiFi::InitWiFi() +{ + return WiFiManager::Instance().Init(); +} + +ConnectivityManager::WiFiStationMode ConnectivityManagerImplWiFi::_GetWiFiStationMode(void) +{ + if (mStationMode != ConnectivityManager::WiFiStationMode::kWiFiStationMode_ApplicationControlled) + { + mStationMode = (WiFiManager::StationStatus::DISABLED == WiFiManager().Instance().GetStationStatus()) + ? ConnectivityManager::WiFiStationMode::kWiFiStationMode_Disabled + : ConnectivityManager::WiFiStationMode::kWiFiStationMode_Enabled; + } + return mStationMode; +} + +CHIP_ERROR ConnectivityManagerImplWiFi::_SetWiFiStationMode(ConnectivityManager::WiFiStationMode aMode) +{ + VerifyOrReturnError(ConnectivityManager::WiFiStationMode::kWiFiStationMode_NotSupported != aMode, CHIP_ERROR_INVALID_ARGUMENT); + + mStationMode = aMode; + + return CHIP_NO_ERROR; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationEnabled(void) +{ + return (WiFiManager::StationStatus::DISABLED <= WiFiManager().Instance().GetStationStatus()); +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationApplicationControlled(void) +{ + return (ConnectivityManager::WiFiStationMode::kWiFiStationMode_ApplicationControlled == mStationMode); +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationConnected(void) +{ + return (WiFiManager::StationStatus::CONNECTED == WiFiManager().Instance().GetStationStatus()); +} + +System::Clock::Timeout ConnectivityManagerImplWiFi::_GetWiFiStationReconnectInterval(void) +{ + return mWiFiStationReconnectInterval; +} + +CHIP_ERROR ConnectivityManagerImplWiFi::_SetWiFiStationReconnectInterval(System::Clock::Timeout val) +{ + mWiFiStationReconnectInterval = val; + return CHIP_NO_ERROR; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationProvisioned(void) +{ + // from Matter perspective `provisioned` means that the supplicant has been provided + // with SSID and password (doesn't matter if valid or not) + return (WiFiManager::StationStatus::CONNECTING <= WiFiManager().Instance().GetStationStatus()); +} + +void ConnectivityManagerImplWiFi::_ClearWiFiStationProvision(void) +{ + if (_IsWiFiStationProvisioned()) + { + if (CHIP_NO_ERROR != WiFiManager().Instance().ClearStationProvisioningData()) + { + ChipLogError(DeviceLayer, "Cannot clear WiFi station provisioning data"); + } + } +} + +bool ConnectivityManagerImplWiFi::_CanStartWiFiScan() +{ + return (WiFiManager::StationStatus::DISABLED != WiFiManager().Instance().GetStationStatus() && + WiFiManager::StationStatus::SCANNING != WiFiManager().Instance().GetStationStatus() && + WiFiManager::StationStatus::CONNECTING != WiFiManager().Instance().GetStationStatus()); +} + +void ConnectivityManagerImplWiFi::_OnWiFiStationProvisionChange() +{ + // do nothing +} + +void ConnectivityManagerImplWiFi::_OnWiFiScanDone() {} + +CHIP_ERROR ConnectivityManagerImplWiFi::_GetAndLogWiFiStatsCounters(void) +{ + // TODO: when network statistics are enabled + return CHIP_NO_ERROR; +} + +ConnectivityManager::WiFiAPMode ConnectivityManagerImplWiFi::_GetWiFiAPMode(void) +{ + /* AP mode is unsupported */ + return ConnectivityManager::WiFiAPMode::kWiFiAPMode_NotSupported; +} + +CHIP_ERROR ConnectivityManagerImplWiFi::_SetWiFiAPMode(ConnectivityManager::WiFiAPMode mode) +{ + /* AP mode is unsupported */ + VerifyOrReturnError(ConnectivityManager::WiFiAPMode::kWiFiAPMode_NotSupported == mode || + ConnectivityManager::WiFiAPMode::kWiFiAPMode_Disabled == mode, + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); + return CHIP_NO_ERROR; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiAPActive(void) +{ + /* AP mode is unsupported */ + return false; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiAPApplicationControlled(void) +{ + /* AP mode is unsupported */ + return false; +} + +void ConnectivityManagerImplWiFi::_DemandStartWiFiAP(void) +{ /* AP mode is unsupported */ +} + +void ConnectivityManagerImplWiFi::_StopOnDemandWiFiAP(void) +{ /* AP mode is unsupported */ +} + +void ConnectivityManagerImplWiFi::_MaintainOnDemandWiFiAP(void) +{ /* AP mode is unsupported */ +} + +System::Clock::Timeout ConnectivityManagerImplWiFi::_GetWiFiAPIdleTimeout(void) +{ + /* AP mode is unsupported */ + return System::Clock::kZero; +} + +void ConnectivityManagerImplWiFi::_SetWiFiAPIdleTimeout(System::Clock::Timeout val) +{ /* AP mode is unsupported */ +} + +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/telink/wifi/3.3.99.0/TelinkWiFiDriver.cpp b/src/platform/telink/wifi/3.3.99.0/TelinkWiFiDriver.cpp new file mode 100644 index 00000000000000..9b78c5584767e1 --- /dev/null +++ b/src/platform/telink/wifi/3.3.99.0/TelinkWiFiDriver.cpp @@ -0,0 +1,316 @@ +/* + * + * Copyright (c) 2024 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. + */ + +#include "../TelinkWiFiDriver.h" + +#include + +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::DeviceLayer::Internal; +using namespace ::chip::DeviceLayer::PersistedStorage; +using namespace ::chip::app::Clusters::NetworkCommissioning; + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { + +size_t TelinkWiFiDriver::WiFiNetworkIterator::Count() +{ + VerifyOrReturnValue(mDriver != nullptr, 0); + return mDriver->mStagingNetwork.IsConfigured() ? 1 : 0; +} + +bool TelinkWiFiDriver::WiFiNetworkIterator::Next(Network & item) +{ + // we assume only one network is actually supported + // TODO: verify if this can be extended + if (mExhausted || 0 == Count()) + { + return false; + } + + memcpy(item.networkID, mDriver->mStagingNetwork.ssid, mDriver->mStagingNetwork.ssidLen); + item.networkIDLen = static_cast(mDriver->mStagingNetwork.ssidLen); + item.connected = false; + + mExhausted = true; + + WiFiManager::WiFiInfo wifiInfo; + if (CHIP_NO_ERROR == WiFiManager::Instance().GetWiFiInfo(wifiInfo)) + { + if (WiFiManager::StationStatus::CONNECTED <= WiFiManager::Instance().GetStationStatus()) + { + if (wifiInfo.mSsidLen == item.networkIDLen && 0 == memcmp(wifiInfo.mSsid, item.networkID, wifiInfo.mSsidLen)) + { + item.connected = true; + } + } + } + return true; +} + +bool TelinkWiFiScanResponseIterator::Next(WiFiScanResponse & item) +{ + if (mResultId < mResultCount) + { + item = mResults[mResultId++]; + return true; + } + return false; +} + +void TelinkWiFiScanResponseIterator::Release() +{ + mResultId = mResultCount = 0; + Platform::MemoryFree(mResults); + mResults = nullptr; +} + +void TelinkWiFiScanResponseIterator::Add(const WiFiScanResponse & result) +{ + void * newResults = Platform::MemoryRealloc(mResults, (mResultCount + 1) * sizeof(WiFiScanResponse)); + + if (newResults) + { + mResults = static_cast(newResults); + mResults[mResultCount++] = result; + } +} + +CHIP_ERROR TelinkWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeCallback) +{ + mpNetworkStatusChangeCallback = networkStatusChangeCallback; + + LoadFromStorage(); + + if (mStagingNetwork.IsConfigured()) + { + WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); }, + [] { Instance().OnNetworkStatusChanged(Status::kUnknownError); }, + System::Clock::Seconds32{ kWiFiConnectNetworkTimeoutSeconds } }; + ReturnErrorOnFailure( + WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling)); + } + + return CHIP_NO_ERROR; +} + +void TelinkWiFiDriver::OnNetworkStatusChanged(Status status) +{ + if (status == Status::kSuccess) + { + ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); + } + + if (mpNetworkStatusChangeCallback) + { + const uint8_t * ssid{}; + size_t ssidLen{}; + WiFiManager::WiFiInfo wifiInfo; + + if (CHIP_NO_ERROR == WiFiManager::Instance().GetWiFiInfo(wifiInfo)) + { + ssid = wifiInfo.mSsid; + ssidLen = wifiInfo.mSsidLen; + } + else + { + ssid = WiFiManager::Instance().GetWantedNetwork().ssid; + ssidLen = WiFiManager::Instance().GetWantedNetwork().ssidLen; + } + mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status, MakeOptional(ByteSpan(wifiInfo.mSsid, wifiInfo.mSsidLen)), + NullOptional); + } + + if (mpConnectCallback) + { + mpConnectCallback->OnResult(status, CharSpan(), 0); + mpConnectCallback = nullptr; + } +} + +void TelinkWiFiDriver::Shutdown() +{ + mpNetworkStatusChangeCallback = nullptr; +} + +CHIP_ERROR TelinkWiFiDriver::CommitConfiguration() +{ + ReturnErrorOnFailure(KeyValueStoreMgr().Put(kPassKey, mStagingNetwork.pass, mStagingNetwork.passLen)); + ReturnErrorOnFailure(KeyValueStoreMgr().Put(kSsidKey, mStagingNetwork.ssid, mStagingNetwork.ssidLen)); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR TelinkWiFiDriver::RevertConfiguration() +{ + LoadFromStorage(); + + if (WiFiManager::StationStatus::CONNECTING <= WiFiManager::Instance().GetStationStatus()) + { + WiFiManager::WiFiInfo wifiInfo; + ReturnErrorOnFailure(WiFiManager::Instance().GetWiFiInfo(wifiInfo)); + if (mStagingNetwork.GetSsidSpan().data_equal(ByteSpan(wifiInfo.mSsid, wifiInfo.mSsidLen))) + { + // we are already connected to this network, so return prematurely + return CHIP_NO_ERROR; + } + + WiFiManager::Instance().Disconnect(); + } + + if (mStagingNetwork.IsConfigured()) + { + WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); }, + [] { Instance().OnNetworkStatusChanged(Status::kUnknownError); }, + System::Clock::Seconds32{ kWiFiConnectNetworkTimeoutSeconds } }; + ReturnErrorOnFailure( + WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling)); + } + + return CHIP_NO_ERROR; +} + +Status TelinkWiFiDriver::AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, MutableCharSpan & outDebugText, + uint8_t & outNetworkIndex) +{ + outDebugText = {}; + outNetworkIndex = 0; + + VerifyOrReturnError(!mStagingNetwork.IsConfigured() || ssid.data_equal(mStagingNetwork.GetSsidSpan()), Status::kBoundsExceeded); + VerifyOrReturnError(ssid.size() <= sizeof(mStagingNetwork.ssid), Status::kOutOfRange); + VerifyOrReturnError(credentials.size() <= sizeof(mStagingNetwork.pass), Status::kOutOfRange); + + mStagingNetwork.Erase(); + memcpy(mStagingNetwork.ssid, ssid.data(), ssid.size()); + memcpy(mStagingNetwork.pass, credentials.data(), credentials.size()); + mStagingNetwork.ssidLen = ssid.size(); + mStagingNetwork.passLen = credentials.size(); + + return Status::kSuccess; +} + +Status TelinkWiFiDriver::RemoveNetwork(ByteSpan networkId, MutableCharSpan & outDebugText, uint8_t & outNetworkIndex) +{ + outDebugText = {}; + outNetworkIndex = 0; + + VerifyOrReturnError(networkId.data_equal(mStagingNetwork.GetSsidSpan()), Status::kNetworkIDNotFound); + mStagingNetwork.Clear(); + + return Status::kSuccess; +} + +Status TelinkWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCharSpan & outDebugText) +{ + outDebugText = {}; + + // Only one network is supported for now + VerifyOrReturnError(index == 0, Status::kOutOfRange); + VerifyOrReturnError(networkId.data_equal(mStagingNetwork.GetSsidSpan()), Status::kNetworkIDNotFound); + + return Status::kSuccess; +} + +void TelinkWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) +{ + Status status = Status::kSuccess; + WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); }, + [] { Instance().OnNetworkStatusChanged(Status::kUnknownError); }, + System::Clock::Seconds32{ kWiFiConnectNetworkTimeoutSeconds } }; + + VerifyOrExit(mpConnectCallback == nullptr, status = Status::kUnknownError); + mpConnectCallback = callback; + + VerifyOrExit(WiFiManager::StationStatus::CONNECTING != WiFiManager::Instance().GetStationStatus(), + status = Status::kOtherConnectionFailure); + VerifyOrExit(networkId.data_equal(mStagingNetwork.GetSsidSpan()), status = Status::kNetworkIDNotFound); + + WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling); + +exit: + if (status != Status::kSuccess && mpConnectCallback) + { + mpConnectCallback->OnResult(status, CharSpan(), 0); + mpConnectCallback = nullptr; + } +} + +void TelinkWiFiDriver::LoadFromStorage() +{ + WiFiManager::WiFiNetwork network; + + mStagingNetwork = {}; + ReturnOnFailure(KeyValueStoreMgr().Get(kSsidKey, network.ssid, sizeof(network.ssid), &network.ssidLen)); + ReturnOnFailure(KeyValueStoreMgr().Get(kPassKey, network.pass, sizeof(network.pass), &network.passLen)); + mStagingNetwork = network; +} + +void TelinkWiFiDriver::OnScanWiFiNetworkDone(const WiFiManager::ScanDoneStatus & status) +{ + VerifyOrReturn(mScanCallback != nullptr); + mScanCallback->OnFinished(status ? Status::kUnknownError : Status::kSuccess, CharSpan(), &mScanResponseIterator); + mScanCallback = nullptr; +} + +void TelinkWiFiDriver::OnScanWiFiNetworkResult(const WiFiScanResponse & response) +{ + mScanResponseIterator.Add(response); +} + +void TelinkWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callback) +{ + mScanCallback = callback; + CHIP_ERROR error = WiFiManager::Instance().Scan( + ssid, [](const WiFiScanResponse & response) { Instance().OnScanWiFiNetworkResult(response); }, + [](const WiFiManager::ScanDoneStatus & status) { Instance().OnScanWiFiNetworkDone(status); }); + + if (error != CHIP_NO_ERROR) + { + mScanCallback = nullptr; + callback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); + } +} + +uint32_t TelinkWiFiDriver::GetSupportedWiFiBandsMask() const +{ + uint32_t bands = static_cast(1UL << chip::to_underlying(WiFiBandEnum::k2g4)); + return bands; +} + +void TelinkWiFiDriver::StartDefaultWiFiNetwork(void) +{ + chip::ByteSpan ssidSpan = ByteSpan(Uint8::from_const_char(CONFIG_DEFAULT_WIFI_SSID), strlen(CONFIG_DEFAULT_WIFI_SSID)); + chip::ByteSpan passwordSpan = + ByteSpan(Uint8::from_const_char(CONFIG_DEFAULT_WIFI_PASSWORD), strlen(CONFIG_DEFAULT_WIFI_PASSWORD)); + + char debugBuffer[1] = { 0 }; + MutableCharSpan debugText(debugBuffer, 0); + uint8_t outNetworkIndex = 0; + + AddOrUpdateNetwork(ssidSpan, passwordSpan, debugText, outNetworkIndex); + CommitConfiguration(); + RevertConfiguration(); +} + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/telink/wifi/3.3.99.0/WiFiManager.cpp b/src/platform/telink/wifi/3.3.99.0/WiFiManager.cpp new file mode 100644 index 00000000000000..dfbfcfec354227 --- /dev/null +++ b/src/platform/telink/wifi/3.3.99.0/WiFiManager.cpp @@ -0,0 +1,591 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Provides the wrapper for Telink WiFi API + */ + +#include "WiFiManager.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace chip { +namespace DeviceLayer { + +namespace { + +NetworkCommissioning::WiFiScanResponse ToScanResponse(const wifi_scan_result * result) +{ + NetworkCommissioning::WiFiScanResponse response = {}; + + if (result != nullptr) + { + static_assert(sizeof(response.ssid) == sizeof(result->ssid), "SSID length mismatch"); + static_assert(sizeof(response.bssid) == sizeof(result->mac), "BSSID length mismatch"); + + // TODO: Distinguish WPA versions + response.security.Set(result->security == WIFI_SECURITY_TYPE_PSK ? NetworkCommissioning::WiFiSecurity::kWpaPersonal + : NetworkCommissioning::WiFiSecurity::kUnencrypted); + response.channel = result->channel; + response.rssi = result->rssi; + response.ssidLen = result->ssid_length; + memcpy(response.ssid, result->ssid, result->ssid_length); + // TODO: MAC/BSSID is not filled by the Wi-Fi driver + memcpy(response.bssid, result->mac, result->mac_length); + } + + return response; +} + +// Matter expectations towards Wi-Fi version codes are unaligned with +// what wpa_supplicant provides. This function maps supplicant codes +// to the ones defined in the Matter spec (11.14.5.2. WiFiVersionEnum) +app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum MapToMatterWiFiVersionCode(wifi_link_mode wifiVersion) +{ + using app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum; + + if (wifiVersion < WIFI_1 || wifiVersion > WIFI_6E) + { + ChipLogError(DeviceLayer, "Unsupported Wi-Fi version detected"); + return WiFiVersionEnum::kA; // let's return 'a' by default + } + + switch (wifiVersion) + { + case WIFI_1: + return WiFiVersionEnum::kB; + case WIFI_2: + return WiFiVersionEnum::kA; + case WIFI_6E: + return WiFiVersionEnum::kAx; // treat as 802.11ax + default: + break; + } + + return static_cast(wifiVersion - 1); +} + +// Matter expectations towards Wi-Fi security type codes are unaligned with +// what wpa_supplicant provides. This function maps supplicant codes +// to the ones defined in the Matter spec (11.14.3.1. SecurityType enum) +app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum MapToMatterSecurityType(wifi_security_type securityType) +{ + using app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum; + + switch (securityType) + { + case WIFI_SECURITY_TYPE_NONE: + return SecurityTypeEnum::kNone; + case WIFI_SECURITY_TYPE_PSK: + case WIFI_SECURITY_TYPE_PSK_SHA256: + return SecurityTypeEnum::kWpa2; + case WIFI_SECURITY_TYPE_SAE: + return SecurityTypeEnum::kWpa3; + default: + break; + } + + return SecurityTypeEnum::kUnspecified; +} + +} // namespace + +const Map + WiFiManager::sStatusMap({ { WIFI_STATE_DISCONNECTED, WiFiManager::StationStatus::DISCONNECTED }, + { WIFI_STATE_INTERFACE_DISABLED, WiFiManager::StationStatus::DISABLED }, + { WIFI_STATE_INACTIVE, WiFiManager::StationStatus::DISABLED }, + { WIFI_STATE_SCANNING, WiFiManager::StationStatus::SCANNING }, + { WIFI_STATE_AUTHENTICATING, WiFiManager::StationStatus::CONNECTING }, + { WIFI_STATE_ASSOCIATING, WiFiManager::StationStatus::CONNECTING }, + { WIFI_STATE_ASSOCIATED, WiFiManager::StationStatus::CONNECTED }, + { WIFI_STATE_4WAY_HANDSHAKE, WiFiManager::StationStatus::PROVISIONING }, + { WIFI_STATE_GROUP_HANDSHAKE, WiFiManager::StationStatus::PROVISIONING }, + { WIFI_STATE_COMPLETED, WiFiManager::StationStatus::FULLY_PROVISIONED } }); + +const Map WiFiManager::sEventHandlerMap({ + { NET_EVENT_WIFI_SCAN_RESULT, WiFiManager::ScanResultHandler }, + { NET_EVENT_WIFI_SCAN_DONE, WiFiManager::ScanDoneHandler }, + { NET_EVENT_WIFI_CONNECT_RESULT, WiFiManager::ConnectHandler }, + { NET_EVENT_WIFI_DISCONNECT_RESULT, WiFiManager::DisconnectHandler }, +}); + +void WiFiManager::WifiMgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface) +{ + if (iface == Instance().mNetIf) + { + Platform::UniquePtr eventData(new uint8_t[cb->info_length]); + VerifyOrReturn(eventData); + memcpy(eventData.get(), cb->info, cb->info_length); + sEventHandlerMap[mgmtEvent](std::move(eventData), cb->info_length); + } +} + +void WiFiManager::IPv6MgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface) +{ + if (((mgmtEvent == NET_EVENT_IPV6_ADDR_ADD) || (mgmtEvent == NET_EVENT_IPV6_ADDR_DEL)) && cb->info) + { + IPv6AddressChangeHandler(cb->info); + } +} + +CHIP_ERROR WiFiManager::Init() +{ + mNetIf = InetUtils::GetWiFiInterface(); + VerifyOrReturnError(mNetIf != nullptr, INET_ERROR_UNKNOWN_INTERFACE); + + net_if_down(mNetIf); // block netif auto start + + net_mgmt_init_event_callback(&mWiFiMgmtClbk, WifiMgmtEventHandler, kWifiManagementEvents); + net_mgmt_init_event_callback(&mIPv6MgmtClbk, IPv6MgmtEventHandler, kIPv6ManagementEvents); + + net_mgmt_add_event_callback(&mWiFiMgmtClbk); + net_mgmt_add_event_callback(&mIPv6MgmtClbk); + + ChipLogDetail(DeviceLayer, "WiFiManager has been initialized"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR WiFiManager::Scan(const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback, + bool internalScan) +{ + mInternalScan = internalScan; + mScanResultCallback = resultCallback; + mScanDoneCallback = doneCallback; + mCachedWiFiState = mWiFiState; + mWiFiState = WIFI_STATE_SCANNING; + mSsidFound = false; + + if (0 != net_mgmt(NET_REQUEST_WIFI_SCAN, mNetIf, NULL, 0)) + { + ChipLogError(DeviceLayer, "Scan request failed"); + return CHIP_ERROR_INTERNAL; + } + + ChipLogDetail(DeviceLayer, "WiFi scanning started..."); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::ClearStationProvisioningData() +{ + mWiFiParams.mRssi = std::numeric_limits::min(); + memset(&mWiFiParams.mParams, 0, sizeof(mWiFiParams.mParams)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::Connect(const ByteSpan & ssid, const ByteSpan & credentials, const ConnectionHandling & handling) +{ + ChipLogDetail(DeviceLayer, "Connecting to WiFi network: %*s", ssid.size(), ssid.data()); + + mHandling.mOnConnectionSuccess = handling.mOnConnectionSuccess; + mHandling.mOnConnectionFailed = handling.mOnConnectionFailed; + mHandling.mConnectionTimeout = handling.mConnectionTimeout; + + mWiFiState = WIFI_STATE_ASSOCIATING; + + // Store SSID and credentials and perform the scan to detect the security mode supported by the AP. + // Zephyr WiFi connect request will be issued in the callback when we have the SSID match. + mWantedNetwork.Erase(); + memcpy(mWantedNetwork.ssid, ssid.data(), ssid.size()); + memcpy(mWantedNetwork.pass, credentials.data(), credentials.size()); + mWantedNetwork.ssidLen = ssid.size(); + mWantedNetwork.passLen = credentials.size(); + + return Scan(ssid, nullptr, nullptr, true /* internal scan */); +} + +CHIP_ERROR WiFiManager::Disconnect() +{ + mApplicationDisconnectRequested = true; + int status = net_mgmt(NET_REQUEST_WIFI_DISCONNECT, mNetIf, NULL, 0); + + if (status) + { + mApplicationDisconnectRequested = false; + if (status == -EALREADY) + { + ChipLogDetail(DeviceLayer, "Already disconnected"); + } + else + { + ChipLogDetail(DeviceLayer, "Disconnect request failed"); + return CHIP_ERROR_INTERNAL; + } + } + else + { + ChipLogDetail(DeviceLayer, "Disconnect requested"); + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::GetWiFiInfo(WiFiInfo & info) const +{ + wifi_iface_status status = { 0 }; + + if (net_mgmt(NET_REQUEST_WIFI_IFACE_STATUS, mNetIf, &status, sizeof(wifi_iface_status))) + { + ChipLogError(DeviceLayer, "Status request failed"); + return CHIP_ERROR_INTERNAL; + } + + if (status.state >= WIFI_STATE_ASSOCIATED) + { + info.mSecurityType = MapToMatterSecurityType(status.security); + info.mWiFiVersion = MapToMatterWiFiVersionCode(status.link_mode); + info.mRssi = static_cast(status.rssi); + info.mChannel = static_cast(status.channel); + info.mSsidLen = status.ssid_len; + memcpy(info.mSsid, status.ssid, status.ssid_len); + memcpy(info.mBssId, status.bssid, sizeof(status.bssid)); + + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INTERNAL; +} + +CHIP_ERROR WiFiManager::GetNetworkStatistics(NetworkStatistics & stats) const +{ + net_stats_wifi data{}; + net_mgmt(NET_REQUEST_STATS_GET_WIFI, mNetIf, &data, sizeof(data)); + + stats.mPacketMulticastRxCount = data.multicast.rx; + stats.mPacketMulticastTxCount = data.multicast.tx; + stats.mPacketUnicastRxCount = data.pkts.rx - data.multicast.rx - data.broadcast.rx; + stats.mPacketUnicastTxCount = data.pkts.tx - data.multicast.tx - data.broadcast.tx; + stats.mBeaconsSuccessCount = data.sta_mgmt.beacons_rx; + stats.mBeaconsLostCount = data.sta_mgmt.beacons_miss; + + return CHIP_NO_ERROR; +} + +void WiFiManager::ScanResultHandler(Platform::UniquePtr data, size_t length) +{ + // Validate that input data size matches the expected one. + VerifyOrReturn(length == sizeof(wifi_scan_result)); + + // Contrary to other handlers, offload accumulating of the scan results from the CHIP thread to the caller's thread + const wifi_scan_result * scanResult = reinterpret_cast(data.get()); + + if (Instance().mInternalScan && + Instance().mWantedNetwork.GetSsidSpan().data_equal(ByteSpan(scanResult->ssid, scanResult->ssid_length))) + { + // Prepare the connection parameters + // In case there are many networks with the same SSID choose the one with the best RSSI + if (scanResult->rssi > Instance().mWiFiParams.mRssi) + { + Instance().ClearStationProvisioningData(); + Instance().mWiFiParams.mParams.ssid_length = static_cast(Instance().mWantedNetwork.ssidLen); + Instance().mWiFiParams.mParams.ssid = Instance().mWantedNetwork.ssid; + // Fallback to the WIFI_SECURITY_TYPE_PSK if the security is unknown + Instance().mWiFiParams.mParams.security = + scanResult->security <= WIFI_SECURITY_TYPE_MAX ? scanResult->security : WIFI_SECURITY_TYPE_PSK; + Instance().mWiFiParams.mParams.psk_length = static_cast(Instance().mWantedNetwork.passLen); + Instance().mWiFiParams.mParams.mfp = (scanResult->mfp == WIFI_MFP_REQUIRED) ? WIFI_MFP_REQUIRED : WIFI_MFP_OPTIONAL; + + // If the security is none, WiFi driver expects the psk to be nullptr + if (Instance().mWiFiParams.mParams.security == WIFI_SECURITY_TYPE_NONE) + { + Instance().mWiFiParams.mParams.psk = nullptr; + } + else + { + Instance().mWiFiParams.mParams.psk = Instance().mWantedNetwork.pass; + } + + Instance().mWiFiParams.mParams.timeout = Instance().mHandling.mConnectionTimeout.count(); + Instance().mWiFiParams.mParams.channel = WIFI_CHANNEL_ANY; + Instance().mWiFiParams.mRssi = scanResult->rssi; + Instance().mWiFiParams.mParams.band = WIFI_FREQ_BAND_UNKNOWN; + Instance().mSsidFound = true; + } + } + + if (Instance().mScanResultCallback && !Instance().mInternalScan) + { + Instance().mScanResultCallback(ToScanResponse(scanResult)); + } +} + +void WiFiManager::ScanDoneHandler(Platform::UniquePtr data, size_t length) +{ + // Validate that input data size matches the expected one. + VerifyOrReturn(length == sizeof(wifi_status)); + + CHIP_ERROR err = SystemLayer().ScheduleLambda([capturedData = data.get()] { + Platform::UniquePtr safePtr(capturedData); + uint8_t * rawData = safePtr.get(); + const wifi_status * status = reinterpret_cast(rawData); + ScanDoneStatus scanDoneStatus = status->status; + + if (scanDoneStatus) + { + ChipLogError(DeviceLayer, "Wi-Fi scan finalization failure (%d)", scanDoneStatus); + } + else + { + ChipLogProgress(DeviceLayer, "Wi-Fi scan done"); + } + + if (Instance().mScanDoneCallback && !Instance().mInternalScan) + { + Instance().mScanDoneCallback(scanDoneStatus); + // restore the connection state from before the scan request was issued + Instance().mWiFiState = Instance().mCachedWiFiState; + return; + } + + // Internal scan is supposed to be followed by a connection request if the SSID has been found + if (Instance().mInternalScan) + { + + if (!Instance().mSsidFound) + { + auto currentTimeout = Instance().CalculateNextRecoveryTime(); + ChipLogProgress(DeviceLayer, "Starting connection recover: re-scanning... (next attempt in %d ms)", + currentTimeout.count()); + DeviceLayer::SystemLayer().StartTimer(currentTimeout, Recover, nullptr); + return; + } + + Instance().mWiFiState = WIFI_STATE_ASSOCIATING; + + if (net_mgmt(NET_REQUEST_WIFI_CONNECT, Instance().mNetIf, &(Instance().mWiFiParams.mParams), + sizeof(wifi_connect_req_params))) + { + ChipLogError(DeviceLayer, "Connection request failed"); + if (Instance().mHandling.mOnConnectionFailed) + { + Instance().mHandling.mOnConnectionFailed(); + } + Instance().mWiFiState = WIFI_STATE_DISCONNECTED; + return; + } + ChipLogProgress(DeviceLayer, "Connection to %*s requested [RSSI=%d]", Instance().mWiFiParams.mParams.ssid_length, + Instance().mWiFiParams.mParams.ssid, Instance().mWiFiParams.mRssi); + Instance().mInternalScan = false; + } + }); + + if (CHIP_NO_ERROR == err) + { + // the ownership has been transferred to the worker thread - release the buffer + data.release(); + } +} + +void WiFiManager::ConnectHandler(Platform::UniquePtr data, size_t length) +{ + // Validate that input data size matches the expected one. + VerifyOrReturn(length == sizeof(wifi_status)); + + CHIP_ERROR err = SystemLayer().ScheduleLambda([capturedData = data.get()] { + Platform::UniquePtr safePtr(capturedData); + uint8_t * rawData = safePtr.get(); + const wifi_status * status = reinterpret_cast(rawData); + WiFiRequestStatus requestStatus = static_cast(status->status); + + if (requestStatus == WiFiRequestStatus::FAILURE || requestStatus == WiFiRequestStatus::TERMINATED) + { + ChipLogProgress(DeviceLayer, "Connection to WiFi network failed or was terminated by another request"); + Instance().mWiFiState = WIFI_STATE_DISCONNECTED; + if (Instance().mHandling.mOnConnectionFailed) + { + Instance().mHandling.mOnConnectionFailed(); + } + } + else // The connection has been established successfully. + { + // Now we can send/receive data via WiFi + net_if_up(InetUtils::GetWiFiInterface()); + + ChipLogProgress(DeviceLayer, "Connected to WiFi network"); + Instance().mWiFiState = WIFI_STATE_COMPLETED; + if (Instance().mHandling.mOnConnectionSuccess) + { + Instance().mHandling.mOnConnectionSuccess(); + } + Instance().PostConnectivityStatusChange(kConnectivity_Established); + + // Workaround needed to re-initialize mDNS server after Wi-Fi interface is operative + chip::DeviceLayer::ChipDeviceEvent event; + event.Type = chip::DeviceLayer::DeviceEventType::kDnssdInitialized; + + CHIP_ERROR error = chip::DeviceLayer::PlatformMgr().PostEvent(&event); + if (error != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Cannot post event [error: %s]", ErrorStr(error)); + } + } + // cleanup the provisioning data as it is configured per each connect request + Instance().ClearStationProvisioningData(); + }); + + if (CHIP_NO_ERROR == err) + { + // the ownership has been transferred to the worker thread - release the buffer + data.release(); + } +} + +void WiFiManager::DisconnectHandler(Platform::UniquePtr data, size_t length) +{ + // Validate that input data size matches the expected one. + VerifyOrReturn(length == sizeof(wifi_status)); + + CHIP_ERROR err = SystemLayer().ScheduleLambda([] { + ChipLogProgress(DeviceLayer, "WiFi station disconnected"); + Instance().mWiFiState = WIFI_STATE_DISCONNECTED; + Instance().PostConnectivityStatusChange(kConnectivity_Lost); + }); + + if (CHIP_NO_ERROR == err) + { + // the ownership has been transferred to the worker thread - release the buffer + data.release(); + } +} + +void WiFiManager::IPv6AddressChangeHandler(const void * data) +{ + const in6_addr * addr = reinterpret_cast(data); + char buf[INET6_ADDRSTRLEN]; + + ChipLogProgress(DeviceLayer, "IP6 address %s", inet_ntop(AF_INET6, addr, buf, INET6_ADDRSTRLEN)); + + // Filter out link-local addresses that are not routable outside of a local network. + if (!net_ipv6_is_ll_addr(addr)) + { + // This is needed to send mDNS queries containing updated IPv6 addresses. + ChipDeviceEvent event; + event.Type = DeviceEventType::kDnssdRestartNeeded; + + CHIP_ERROR error = PlatformMgr().PostEvent(&event); + if (error != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Cannot post event: %" CHIP_ERROR_FORMAT, error.Format()); + } + else + { + ChipLogProgress(DeviceLayer, "kDnssdRestartNeeded"); + } + } +} + +WiFiManager::StationStatus WiFiManager::GetStationStatus() const +{ + return WiFiManager::sStatusMap[mWiFiState]; +} + +void WiFiManager::PostConnectivityStatusChange(ConnectivityChange changeType) +{ + ChipDeviceEvent networkEvent{}; + networkEvent.Type = DeviceEventType::kWiFiConnectivityChange; + networkEvent.WiFiConnectivityChange.Result = changeType; + PlatformMgr().PostEventOrDie(&networkEvent); +} + +void WiFiManager::Recover(System::Layer *, void *) +{ + // Prevent scheduling recovery if we are already connected to the network. + if (Instance().mWiFiState == WIFI_STATE_COMPLETED) + { + Instance().AbortConnectionRecovery(); + return; + } + + // If kConnectionRecoveryMaxOverallInterval has a non-zero value prevent endless re-scan. + if (0 != kConnectionRecoveryMaxRetries && (++Instance().mConnectionRecoveryCounter >= kConnectionRecoveryMaxRetries)) + { + Instance().AbortConnectionRecovery(); + return; + } + + Instance().Scan(Instance().mWantedNetwork.GetSsidSpan(), nullptr, nullptr, true /* internal scan */); +} + +void WiFiManager::ResetRecoveryTime() +{ + mConnectionRecoveryTimeMs = kConnectionRecoveryMinIntervalMs; + mConnectionRecoveryCounter = 0; +} + +void WiFiManager::AbortConnectionRecovery() +{ + DeviceLayer::SystemLayer().CancelTimer(Recover, nullptr); + Instance().ResetRecoveryTime(); +} + +System::Clock::Milliseconds32 WiFiManager::CalculateNextRecoveryTime() +{ + if (mConnectionRecoveryTimeMs > kConnectionRecoveryMaxIntervalMs) + { + // Find the new random jitter value in range [-jitter, +jitter]. + int32_t jitter = chip::Crypto::GetRandU32() % (2 * jitter + 1) - jitter; + mConnectionRecoveryTimeMs = kConnectionRecoveryMaxIntervalMs + jitter; + return System::Clock::Milliseconds32(mConnectionRecoveryTimeMs); + } + else + { + uint32_t currentRecoveryTimeout = mConnectionRecoveryTimeMs; + mConnectionRecoveryTimeMs = mConnectionRecoveryTimeMs * 2; + return System::Clock::Milliseconds32(currentRecoveryTimeout); + } +} + +CHIP_ERROR WiFiManager::SetLowPowerMode(bool onoff) +{ + VerifyOrReturnError(nullptr != mNetIf, CHIP_ERROR_INTERNAL); + + wifi_ps_config currentConfig{}; + if (net_mgmt(NET_REQUEST_WIFI_PS_CONFIG, mNetIf, ¤tConfig, sizeof(currentConfig))) + { + ChipLogError(DeviceLayer, "Get current low power mode config request failed"); + return CHIP_ERROR_INTERNAL; + } + + if ((currentConfig.ps_params.enabled == WIFI_PS_ENABLED && onoff == false) || + (currentConfig.ps_params.enabled == WIFI_PS_DISABLED && onoff == true)) + { + wifi_ps_params params{ .enabled = onoff ? WIFI_PS_ENABLED : WIFI_PS_DISABLED }; + if (net_mgmt(NET_REQUEST_WIFI_PS, mNetIf, ¶ms, sizeof(params))) + { + ChipLogError(DeviceLayer, "Set low power mode request failed"); + return CHIP_ERROR_INTERNAL; + } + ChipLogProgress(DeviceLayer, "Successfully set low power mode [%d]", onoff); + return CHIP_NO_ERROR; + } + + ChipLogDetail(DeviceLayer, "Low power mode is already in requested state [%d]", onoff); + return CHIP_NO_ERROR; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/telink/wifi/3.3.99.0/WiFiManager.h b/src/platform/telink/wifi/3.3.99.0/WiFiManager.h new file mode 100644 index 00000000000000..49c9496f5d13be --- /dev/null +++ b/src/platform/telink/wifi/3.3.99.0/WiFiManager.h @@ -0,0 +1,246 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Provides the wrapper for Telink wpa_supplicant API + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include + +struct net_if; +struct wpa_ssid; +using WpaNetwork = struct wpa_ssid; + +namespace chip { +namespace DeviceLayer { + +// emulation of dictionary - might be moved to utils +template +class Map +{ + struct Pair + { + T1 key; + T2 value; + }; + +public: + Map(const Pair (&list)[N]) + { + int idx{ 0 }; + for (const auto & pair : list) + { + mMap[idx++] = pair; + } + } + + T2 operator[](const T1 & key) const + { + for (const auto & it : mMap) + { + if (key == it.key) + return it.value; + } + + return T2{}; + } + + Map() = delete; + Map(const Map &) = delete; + Map(Map &&) = delete; + Map & operator=(const Map &) = delete; + Map & operator=(Map &&) = delete; + ~Map() = default; + +private: + Pair mMap[N]; +}; + +class WiFiManager +{ +public: + enum WiFiRequestStatus : int + { + SUCCESS = 0, + FAILURE = 1, + TERMINATED = 2 + }; + + using ScanDoneStatus = decltype(wifi_status::status); + using ScanResultCallback = void (*)(const NetworkCommissioning::WiFiScanResponse &); + using ScanDoneCallback = void (*)(const ScanDoneStatus &); + using ConnectionCallback = void (*)(); + + enum class StationStatus : uint8_t + { + NONE, + DISCONNECTED, + DISABLED, + SCANNING, + CONNECTING, + CONNECTED, + PROVISIONING, + FULLY_PROVISIONED, + UNKNOWN + }; + + static WiFiManager & Instance() + { + static WiFiManager sInstance; + return sInstance; + } + + struct ConnectionHandling + { + ConnectionCallback mOnConnectionSuccess{}; + ConnectionCallback mOnConnectionFailed{}; + System::Clock::Seconds32 mConnectionTimeout{}; + }; + + struct WiFiInfo + { + uint8_t mBssId[DeviceLayer::Internal::kWiFiBSSIDLength]; + app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum mSecurityType{}; + app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum mWiFiVersion{}; + uint16_t mChannel{}; + int8_t mRssi{}; + uint8_t mSsid[DeviceLayer::Internal::kMaxWiFiSSIDLength]; + size_t mSsidLen{ 0 }; + }; + + struct NetworkStatistics + { + uint32_t mPacketMulticastRxCount{}; + uint32_t mPacketMulticastTxCount{}; + uint32_t mPacketUnicastRxCount{}; + uint32_t mPacketUnicastTxCount{}; + uint32_t mBeaconsSuccessCount{}; + uint32_t mBeaconsLostCount{}; + }; + + struct WiFiNetwork + { + uint8_t ssid[DeviceLayer::Internal::kMaxWiFiSSIDLength]; + size_t ssidLen = 0; + uint8_t pass[DeviceLayer::Internal::kMaxWiFiKeyLength]; + size_t passLen = 0; + + bool IsConfigured() const { return ssidLen > 0; } + ByteSpan GetSsidSpan() const { return ByteSpan(ssid, ssidLen); } + ByteSpan GetPassSpan() const { return ByteSpan(pass, passLen); } + void Clear() { ssidLen = 0; } + void Erase() + { + memset(ssid, 0, DeviceLayer::Internal::kMaxWiFiSSIDLength); + memset(pass, 0, DeviceLayer::Internal::kMaxWiFiKeyLength); + ssidLen = 0; + passLen = 0; + } + }; + + static constexpr uint16_t kRouterSolicitationIntervalMs = 4000; + static constexpr uint16_t kMaxInitialRouterSolicitationDelayMs = 1000; + static constexpr uint8_t kRouterSolicitationMaxCount = 3; + static constexpr uint32_t kConnectionRecoveryMinIntervalMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MINIMUM_INTERVAL; + static constexpr uint32_t kConnectionRecoveryMaxIntervalMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAXIMUM_INTERVAL; + static constexpr uint32_t kConnectionRecoveryJitterMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_JITTER; + static constexpr uint32_t kConnectionRecoveryMaxRetries = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAX_RETRIES_NUMBER; + + CHIP_ERROR Init(); + CHIP_ERROR Scan(const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback, + bool internalScan = false); + CHIP_ERROR Connect(const ByteSpan & ssid, const ByteSpan & credentials, const ConnectionHandling & handling); + StationStatus GetStationStatus() const; + CHIP_ERROR ClearStationProvisioningData(); + CHIP_ERROR Disconnect(); + CHIP_ERROR GetWiFiInfo(WiFiInfo & info) const; + const WiFiNetwork & GetWantedNetwork() const { return mWantedNetwork; } + CHIP_ERROR GetNetworkStatistics(NetworkStatistics & stats) const; + void AbortConnectionRecovery(); + CHIP_ERROR SetLowPowerMode(bool onoff); + +private: + using NetEventHandler = void (*)(Platform::UniquePtr, size_t); + + struct ConnectionParams + { + wifi_connect_req_params mParams; + int8_t mRssi{ std::numeric_limits::min() }; + }; + + constexpr static uint32_t kWifiManagementEvents = NET_EVENT_WIFI_SCAN_RESULT | NET_EVENT_WIFI_SCAN_DONE | + NET_EVENT_WIFI_CONNECT_RESULT | NET_EVENT_WIFI_DISCONNECT_RESULT | NET_EVENT_WIFI_IFACE_STATUS; + + constexpr static uint32_t kIPv6ManagementEvents = NET_EVENT_IPV6_ADDR_ADD | NET_EVENT_IPV6_ADDR_DEL; + + // Event handling + static void WifiMgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface); + static void IPv6MgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface); + static void ScanResultHandler(Platform::UniquePtr data, size_t length); + static void ScanDoneHandler(Platform::UniquePtr data, size_t length); + static void ConnectHandler(Platform::UniquePtr data, size_t length); + static void DisconnectHandler(Platform::UniquePtr data, size_t length); + static void PostConnectivityStatusChange(ConnectivityChange changeType); + static void SendRouterSolicitation(System::Layer * layer, void * param); + static void IPv6AddressChangeHandler(const void * data); + + // Connection Recovery feature + // This feature allows re-scanning and re-connecting the connection to the known network after + // a reboot or when a connection is lost. The following attempts will occur with increasing interval. + // The connection recovery interval starts from kConnectionRecoveryMinIntervalMs and is doubled + // with each occurrence until reaching kConnectionRecoveryMaxIntervalMs. + // When the connection recovery interval reaches the maximum value the randomized kConnectionRecoveryJitterMs + // from the range [-jitter, +jitter] is added to the value to avoid the periodicity. + // To avoid frequent recovery attempts when the signal to an access point is poor quality + // The connection recovery interval will be cleared after the defined delay in kConnectionRecoveryDelayToReset. + static void Recover(System::Layer * layer, void * param); + void ResetRecoveryTime(); + System::Clock::Milliseconds32 CalculateNextRecoveryTime(); + + net_if * mNetIf{ nullptr }; + ConnectionParams mWiFiParams{}; + ConnectionHandling mHandling{}; + wifi_iface_state mWiFiState; + wifi_iface_state mCachedWiFiState; + net_mgmt_event_callback mWiFiMgmtClbk{}; + net_mgmt_event_callback mIPv6MgmtClbk{}; + ScanResultCallback mScanResultCallback{ nullptr }; + ScanDoneCallback mScanDoneCallback{ nullptr }; + WiFiNetwork mWantedNetwork{}; + bool mInternalScan{ false }; + uint8_t mRouterSolicitationCounter = 0; + bool mSsidFound{ false }; + uint32_t mConnectionRecoveryCounter{ 0 }; + uint32_t mConnectionRecoveryTimeMs{ kConnectionRecoveryMinIntervalMs }; + bool mApplicationDisconnectRequested{ false }; + + static const Map sStatusMap; + static const Map sEventHandlerMap; +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/telink/wifi/ConnectivityManagerImplWiFi.cpp b/src/platform/telink/wifi/3.7.99.0/ConnectivityManagerImplWiFi.cpp similarity index 99% rename from src/platform/telink/wifi/ConnectivityManagerImplWiFi.cpp rename to src/platform/telink/wifi/3.7.99.0/ConnectivityManagerImplWiFi.cpp index 9b605c31560142..8f48a91285b5d8 100644 --- a/src/platform/telink/wifi/ConnectivityManagerImplWiFi.cpp +++ b/src/platform/telink/wifi/3.7.99.0/ConnectivityManagerImplWiFi.cpp @@ -21,7 +21,7 @@ #include #include -#include "ConnectivityManagerImplWiFi.h" +#include "../ConnectivityManagerImplWiFi.h" #include "WiFiManager.h" #if CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/telink/wifi/TelinkWiFiDriver.cpp b/src/platform/telink/wifi/3.7.99.0/TelinkWiFiDriver.cpp similarity index 99% rename from src/platform/telink/wifi/TelinkWiFiDriver.cpp rename to src/platform/telink/wifi/3.7.99.0/TelinkWiFiDriver.cpp index 1b07386fb835fa..6e704e76fe5f85 100644 --- a/src/platform/telink/wifi/TelinkWiFiDriver.cpp +++ b/src/platform/telink/wifi/3.7.99.0/TelinkWiFiDriver.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "TelinkWiFiDriver.h" +#include "../TelinkWiFiDriver.h" #include diff --git a/src/platform/telink/wifi/WiFiManager.cpp b/src/platform/telink/wifi/3.7.99.0/WiFiManager.cpp similarity index 100% rename from src/platform/telink/wifi/WiFiManager.cpp rename to src/platform/telink/wifi/3.7.99.0/WiFiManager.cpp diff --git a/src/platform/telink/wifi/WiFiManager.h b/src/platform/telink/wifi/3.7.99.0/WiFiManager.h similarity index 100% rename from src/platform/telink/wifi/WiFiManager.h rename to src/platform/telink/wifi/3.7.99.0/WiFiManager.h diff --git a/src/platform/telink/wifi/TelinkWiFiDriver.h b/src/platform/telink/wifi/TelinkWiFiDriver.h index e3a66e3a279d07..de513ebd71b60b 100644 --- a/src/platform/telink/wifi/TelinkWiFiDriver.h +++ b/src/platform/telink/wifi/TelinkWiFiDriver.h @@ -94,7 +94,11 @@ class TelinkWiFiDriver final : public WiFiDriver return sInstance; } +#if defined(CONFIG_ZEPHYR_VERSION_3_3) + void OnNetworkStatusChanged(Status status); +#else void OnNetworkConnStatusChanged(const wifi_conn_status & connStatus); +#endif void OnScanWiFiNetworkResult(const WiFiScanResponse & result); void OnScanWiFiNetworkDone(const WiFiManager::ScanDoneStatus & status);