diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 2661efbb576b98..7041c9ea1c23df 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -166,7 +166,7 @@ config BT_GATT_CACHING config BT_RX_STACK_SIZE default 1352 if BT_B9X - default 1010 if BT_TLX + default 1352 if BT_TLX default 2048 if BT_W91 config BT_HCI_TX_STACK_SIZE @@ -266,14 +266,14 @@ config COMPRESS_LZMA default n config DUAL_MODE_SWTICH - bool "Control the dual mode switch part" + bool "Control Dual-Mode Switching" default y if SOC_RISCV_TELINK_TL321X || SOC_RISCV_TELINK_B92 default n config I2C_LED bool "Control the i2 led slave use raw address" - default n if I2C default n + select I2C # Set multiplicator of Name Value Storage (NVS) as 1 to reach NVS sector size 4KB # nvs_sector_size = flash_page_size * mult = 4KB * 1 = 4KB diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index f8c6c1edc72380..28caf3dea8f067 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -63,11 +63,11 @@ CHIP_ERROR AppTask::Init(void) #if CONFIG_DUAL_MODE_SWTICH if (sBoot_zb) { - /* Switch from the touch link, need to restore previous values */ + /* Switching from TouchLink (Zigbee) to Matter. Restore previous states. */ sfixture_on = user_para.onoff; sBrightness = user_para.lightness; sAppTask.UpdateClusterState(); - printk("Matter: Updated ZB On/Off state and brightness.\n"); + printk("Matter: Restored Zigbee On/Off and brightness states.\n"); } #endif diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 88ee0a7022fd9e..0bdb3b98d7b509 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -76,7 +76,7 @@ constexpr uint32_t kIdentifyBreatheRateMs = 1000; #if CONFIG_DUAL_MODE_SWTICH const struct device * flash_para_dev = USER_PARTITION_DEVICE; constexpr int kDnssTimeout = 60000; -k_timer sDnssTimer; +static k_timer sDnssTimer; #endif #if APP_SET_NETWORK_COMM_ENDPOINT_SEC @@ -238,8 +238,11 @@ void AppTaskCommon::DnssTimerTimeoutCallback(k_timer * timer) { return; } - /*If initialization of Dnss takes longer than 60 seconds, the device will reboot and revert to Zigbee mode*/ - printk("Matter: DnssTimer expired.\r\n"); + /* + * If Dnss initialization takes longer than 60 seconds, + * the device will reboot and revert to Zigbee mode. + */ + printk("Matter: DnssTimer expired. Rebooting...\n"); sys_reboot(0); } #endif @@ -248,25 +251,31 @@ CHIP_ERROR AppTaskCommon::StartApp(void) { #if CONFIG_DUAL_MODE_SWTICH - /* Proc ota boot flag , and erase flag */ + /* + * If the device boots from Zigbee, set a flag and adjust user parameters. + * Then start a timer to ensure Dnss initialization completes within + * a given timeframe. + */ flash_read(flash_para_dev, USER_PARTITION_OFFSET, &user_para, sizeof(user_para)); - /* Boot from Zigbee , need to clean the user parameters sector first and set a flag */ if (user_para.val == USER_ZB_SW_VAL) { sBoot_zb = 1; - /* Ensure lightness is at least 2 to avoid display error on HomePod Mini */ + /* Ensure brightness is at least 2 to avoid display issues on HomePod Mini */ if (user_para.lightness < 2) { user_para.lightness = 2; } - /* Pass the value to the init part to avoid gaps in pwm_pool init */ + /* + * Pass the brightness value to the initialization code + * to avoid gaps in PWM pool initialization. + */ if (user_para.onoff) { para_lightness = user_para.lightness; } k_timer_init(&sDnssTimer, &AppTask::DnssTimerTimeoutCallback, nullptr); k_timer_start(&sDnssTimer, K_MSEC(kDnssTimeout), K_NO_WAIT); - printk("Matter: start timer to protect Dnss initialized %x \r\n", *(int *) (&user_para)); + printk("Matter: Started DNS protection timer. user_para=%x\n", *(int *)(&user_para)); } #endif @@ -651,7 +660,7 @@ void AppTaskCommon::FactoryResetHandler(AppEvent * aEvent) sFactoryResetCntr = 0; #if CONFIG_DUAL_MODE_SWTICH - printk("Factory reset triggered by button, resetting to Zigbee mode"); + printk("Factory reset triggered by button; reverting to Zigbee mode\n"); FactoryResetExtHandler(); #endif chip::Server::GetInstance().ScheduleFactoryReset(); @@ -816,19 +825,19 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* uint8_t val = USER_MATTER_PAIR_VAL; flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE); flash_write(flash_para_dev, USER_PARTITION_OFFSET, &val, 1); - printk("Commissioning complete, set Matter commissionined flag"); + printk("Commissioning complete; Matter commissioned flag set.\n"); } break; case DeviceEventType::kFailSafeTimerExpired: /* Reset to Zigbee mode if commissioning fails */ if (sBoot_zb) { - printk("FailSafeTimer expired, Matter commissioning failed, rebooting to Zigbee mode.\r\n"); + printk("FailSafeTimer expired; Matter commissioning failed. Rebooting to Zigbee mode...\n"); sys_reboot(0); } else { - printk("FailSafeTimer expired, Matter commissioning failed.\r\n"); + printk("FailSafeTimer expired; Matter commissioning failed.\n"); } break; #endif @@ -851,7 +860,7 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* if (sBoot_zb) { k_timer_stop(&sDnssTimer); - printk("Dnss Timer stopped, Matter commissioning kDnssdInitialized.\r\n"); + printk("DnssTimer stopped; DNS-SD has been initialized.\n"); } #endif break; diff --git a/src/platform/telink/tl3218x_2m_flash.overlay b/src/platform/telink/tl3218x_2m_flash.overlay index 72b5c860e70862..9b3cd298f2c877 100644 --- a/src/platform/telink/tl3218x_2m_flash.overlay +++ b/src/platform/telink/tl3218x_2m_flash.overlay @@ -9,55 +9,73 @@ boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 0x12000>;// bootloader should use the size optimize to low down to 72k,reserve 4k for user. + // The bootloader is optimized to fit within 72 KB (0x12000). + // 4 KB (0x1000) are reserved for user data or future expansion. + reg = <0x00000000 0x12000>; }; slot0_partition: partition@12000 { label = "image-0"; - reg = <0x12000 0x122000>;// 0x12000 is matter, and reserve 912k for matter , 0xF6000 is zb reserve 248k for zigbee + // Starting at 0x12000, this partition reserves 912 KB for Matter, + // and an additional 248 KB for Zigbee, totaling 0x122000 in size. + reg = <0x12000 0x122000>; }; slot1_partition: partition@134000 { label = "image-1"; - reg = <0x134000 0xb2000>;// the slot1 is use LZMA to save binsize . (920k + 248k)*60% = 712k, zb nvs will locate here + // Uses LZMA compression to reduce binary size. + // The combined space (920 KB + 248 KB) is reduced to ~60% (~712 KB). + // Zigbee NVS data will also reside here. + reg = <0x134000 0xb2000>; }; storage_partition: partition@1e6000 { label = "storage"; - reg = <0x1e6000 0xb000>; // matter nvs part + // NVS storage for Matter. + reg = <0x1e6000 0xb000>; }; user_token_partition: partition@1f1000 { label = "user-token"; - reg = <0x1f1000 0x1000>; //user:store token info, if don't use ,can delete + // Stores token information. If unused, this partition can be removed. + reg = <0x1f1000 0x1000>; }; user_para_partition: partition@1f2000 { label = "user-para"; - reg = <0x1f2000 0x1000>; //user:store the mode info and the key info part. + // Stores mode information and key data. + reg = <0x1f2000 0x1000>; }; user_cluster_partition: partition@1f3000 { label = "user-cluster"; - reg = <0x1f3000 0x1000>; //user_cluster: reserve 4k for user storage cluster para. proc transition part + //user_cluster: reserve 4k for user storage cluster para. proc transition part + reg = <0x1f3000 0x1000>; }; stack_extend_partition: partition@1f4000 { label = "stack_extend"; - reg = <0x1f4000 0x4000>; //reserved for matter stack extend proc,reserve 16k for extend. + //reserved for matter stack extend proc,reserve 16k for extend. + reg = <0x1f4000 0x4000>; }; secure_partition: partition@1f8000 { label = "secure"; - reg = <0x1f8000 0x1000>; //secure info ,reserved for secure boot .if not use , can beused by other way . + // Secure area reserved for secure boot. + // If not in use, it may be repurposed. + reg = <0x1f8000 0x1000>; }; factory_partition: partition@1f9000 { label = "factory-data"; - reg = <0x1f9000 0x1000>; // factory data info and dac info + // factory data + reg = <0x1f9000 0x1000>; }; dac_keypair_partition: partition@1f9800 { label = "dac-keypair"; - reg = <0x1f9800 0x800>; //store dac and key pair. + // Stores DAC certificate and key pair (2 KB). + reg = <0x1f9800 0x800>; }; user_rfu_partition: partition@1fa000 { label = "user_rfu"; - reg = <0x1fa000 0x4000>; //user_rfu: reserve 16k for user extend. + // Reserves 16 KB for user-specific extensions. + reg = <0x1fa000 0x4000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; - reg = <0x1fe000 0x2000>;// mac and adc info. + // Holds MAC, ADC, or other vendor-specific data (8 KB). + reg = <0x1fe000 0x2000>; }; }; };