From afb99664b121fa82a77db94627a15799b1532a91 Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Tue, 10 Oct 2023 16:53:05 +0300 Subject: [PATCH] [Telink] [WIP] Full commissioning with retention --- config/telink/chip-module/Kconfig.defaults | 6 +++-- src/app/server/CommissioningWindowManager.cpp | 26 ++++++++++++++++++- src/platform/telink/tlsr9528a.overlay | 21 ++++----------- .../telink/tlsr9528a_retention.overlay | 21 ++++----------- 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 1fdd20b01e866a..8e39085e96e2f6 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -73,7 +73,10 @@ config SYSTEM_WORKQUEUE_STACK_SIZE default 616 if PM config HEAP_MEM_POOL_SIZE - default 256 + default 256 + +config COMMON_LIBC_MALLOC_ARENA_SIZE + default 9216 config NET_IPV6_MLD default n @@ -306,5 +309,4 @@ config PWM_SHELL config OPENTHREAD_SHELL default n - endif diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 270f4dad57cb39..97b71e6b1c983d 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -33,6 +33,27 @@ using chip::app::DataModel::MakeNullable; using chip::app::DataModel::Nullable; using chip::app::DataModel::NullNullable; +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + +static void reboot_timer_handler(struct k_timer * dummy) +{ + extern const uint8_t __rom_region_end; + void (*boot_thread_mode)(void) = (void (*)(void)) &__rom_region_end; + + printk("** Reboot to Thread mode %p\n", boot_thread_mode); + + boot_thread_mode(); +} + +static K_TIMER_DEFINE(reboot_timer, reboot_timer_handler, NULL); + +static void delayed_sys_reboot(unsigned int timeout_ms) +{ + k_timer_start(&reboot_timer, K_MSEC(timeout_ms), K_FOREVER); +} + +#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + namespace { // As per specifications (Section 13.3), Nodes SHALL exit commissioning mode after 20 failed commission attempts. @@ -57,7 +78,7 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv { if (event->Type == DeviceLayer::DeviceEventType::kCommissioningComplete) { - ChipLogProgress(AppServer, "Commissioning completed successfully"); + ChipLogProgress(AppServer, "Commissioning completed successfully!!!"); DeviceLayer::SystemLayer().CancelTimer(HandleCommissioningWindowTimeout, this); mCommissioningTimeoutTimerArmed = false; Cleanup(); @@ -66,6 +87,9 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv #if CONFIG_NETWORK_LAYER_BLE mServer->GetBleLayerObject()->CloseAllBleConnections(); #endif +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + delayed_sys_reboot(1000); +#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE } else if (event->Type == DeviceLayer::DeviceEventType::kFailSafeTimerExpired) { diff --git a/src/platform/telink/tlsr9528a.overlay b/src/platform/telink/tlsr9528a.overlay index c57cc0eb0341e2..7e6343d5743d57 100644 --- a/src/platform/telink/tlsr9528a.overlay +++ b/src/platform/telink/tlsr9528a.overlay @@ -88,25 +88,14 @@ /delete-node/ partition@f0000; /delete-node/ partition@f4000; /delete-node/ partition@fe000; - boot_partition: partition@0 { - label = "mcuboot"; - reg = <0x00000000 0x19000>; - }; - slot0_partition: partition@19000 { + + slot0_partition: partition@0 { label = "image-0"; - reg = <0x19000 0xee000>; + reg = <0x000000 0x180000>; }; - factory_partition: partition@107000 { - label = "factory-data"; - reg = <0x107000 0x1000>; - }; - storage_partition: partition@108000 { + storage_partition: partition@180000 { label = "storage"; - reg = <0x108000 0x8000>; - }; - slot1_partition: partition@110000 { - label = "image-1"; - reg = <0x110000 0xee000>; + reg = <0x180000 0x8000>; }; vendor_partition: partition@1fe000 { label = "vendor-data"; diff --git a/src/platform/telink/tlsr9528a_retention.overlay b/src/platform/telink/tlsr9528a_retention.overlay index c57cc0eb0341e2..7e6343d5743d57 100644 --- a/src/platform/telink/tlsr9528a_retention.overlay +++ b/src/platform/telink/tlsr9528a_retention.overlay @@ -88,25 +88,14 @@ /delete-node/ partition@f0000; /delete-node/ partition@f4000; /delete-node/ partition@fe000; - boot_partition: partition@0 { - label = "mcuboot"; - reg = <0x00000000 0x19000>; - }; - slot0_partition: partition@19000 { + + slot0_partition: partition@0 { label = "image-0"; - reg = <0x19000 0xee000>; + reg = <0x000000 0x180000>; }; - factory_partition: partition@107000 { - label = "factory-data"; - reg = <0x107000 0x1000>; - }; - storage_partition: partition@108000 { + storage_partition: partition@180000 { label = "storage"; - reg = <0x108000 0x8000>; - }; - slot1_partition: partition@110000 { - label = "image-1"; - reg = <0x110000 0xee000>; + reg = <0x180000 0x8000>; }; vendor_partition: partition@1fe000 { label = "vendor-data";