Skip to content

Commit a5bf60d

Browse files
authored
fix crash issue which caused by data model init after thread stack init (#37059)
1 parent 5bd63d5 commit a5bf60d

File tree

7 files changed

+15
-19
lines changed

7 files changed

+15
-19
lines changed

examples/all-clusters-app/esp32/main/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,10 @@ extern "C" void app_main()
210210
{
211211
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format());
212212
}
213-
ESPOpenThreadInit();
214213

215214
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
215+
216+
ESPOpenThreadInit();
216217
}
217218

218219
bool lowPowerClusterSleep()

examples/all-clusters-minimal-app/esp32/main/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ extern "C" void app_main()
186186
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format());
187187
}
188188

189-
ESPOpenThreadInit();
190189
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
190+
191+
ESPOpenThreadInit();
191192
}
192193

193194
bool lowPowerClusterSleep()

examples/energy-management-app/esp32/main/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ extern "C" void app_main()
294294
#endif
295295

296296
SetDeviceAttestationCredentialsProvider(get_dac_provider());
297-
ESPOpenThreadInit();
298297

299298
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
299+
300+
ESPOpenThreadInit();
300301
}

examples/light-switch-app/esp32/main/main.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "DeviceCallbacks.h"
2020
#include <common/CHIPDeviceManager.h>
2121
#include <common/Esp32AppServer.h>
22+
#include <common/Esp32ThreadInit.h>
2223

2324
#include "AppTask.h"
2425
#include "BindingHandler.h"
@@ -135,21 +136,10 @@ extern "C" void app_main()
135136
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
136137
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
137138

138-
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
139-
if (DeviceLayer::ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR)
140-
{
141-
ESP_LOGE(TAG, "Failed to initialize Thread stack");
142-
return;
143-
}
144-
if (DeviceLayer::ThreadStackMgr().StartThreadTask() != CHIP_NO_ERROR)
145-
{
146-
ESP_LOGE(TAG, "Failed to launch Thread task");
147-
return;
148-
}
149-
#endif
150-
151139
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
152140

141+
ESPOpenThreadInit();
142+
153143
error = GetAppTask().StartAppTask();
154144
if (error != CHIP_NO_ERROR)
155145
{

examples/lighting-app/esp32/main/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,11 @@ extern "C" void app_main()
210210
#endif
211211

212212
SetDeviceAttestationCredentialsProvider(get_dac_provider());
213-
ESPOpenThreadInit();
214213

215214
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
216215

216+
ESPOpenThreadInit();
217+
217218
error = GetAppTask().StartAppTask();
218219
if (error != CHIP_NO_ERROR)
219220
{

examples/lit-icd-app/esp32/main/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ extern "C" void app_main()
130130
#else
131131
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
132132
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
133-
ESPOpenThreadInit();
134133
static UatButton sButton;
135134
sButton.Init(UAT_GPIO, ESP_EXT1_WAKEUP_ANY_LOW);
136135
sButton.SetUatButtonPressCallback(UatButtonHandler);
137136

138137
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
138+
139+
ESPOpenThreadInit();
139140
}

examples/thread-br-app/esp32/main/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ extern "C" void app_main()
149149
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
150150
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
151151
esp_openthread_set_backbone_netif(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
152-
ESPOpenThreadInit();
153152

154153
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
154+
155+
ESPOpenThreadInit();
155156
}
156157

157158
extern "C" void otSysProcessDrivers(otInstance * aInstance)

0 commit comments

Comments
 (0)