forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nrf5: Enlarge stack to fix thread join overruns
As of b15c292 ("[nrf5-lock] start joiner role on boot (project-chip#1962)"), we are using too much stack space in timer task. The timer task has a 1k stack and logging along uses a 256 byte stack buffer. The code in GenericThreadStackManagerImpl_FreeRTOS<ImplClass>::OnJoinerTimer should be moved off the timer task. In the meantime increase the stack size to avoid overruns in the thread joiner. Also enable the option configCHECK_FOR_STACK_OVERFLOW, and while we're here also enable configUSE_MALLOC_FAILED_HOOK. These diagnostic options are invaluable for saving debugging time. Since logging uses significant stack space, try to catch stack overflows in the platform LogV(). This fires reliably in OnJoinerTimer prior to enlarging the stack. Depends on project-chip#2185 Fixes project-chip#2187
- Loading branch information
Showing
9 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
examples/platform/nrf528xx/app/support/FreeRTOSDebuggingHooks.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 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 "FreeRTOSDebuggingHooks.h" | ||
|
||
__attribute__((optimize("no-optimize-sibling-calls"))) void vApplicationStackOverflowHook(xTaskHandle pxTask, | ||
signed char * pcTaskName) | ||
{ | ||
ASSERT(0); | ||
} | ||
|
||
__attribute__((optimize("no-optimize-sibling-calls"))) void vApplicationMallocFailedHook(void) | ||
{ | ||
ASSERT(0); | ||
} |
34 changes: 34 additions & 0 deletions
34
examples/platform/nrf528xx/app/support/FreeRTOSDebuggingHooks.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 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 <FreeRTOS.h> | ||
#include <nrf_assert.h> | ||
#include <task.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// Called by FreeRTOS when the stack overflows. | ||
void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char * pcTaskName); | ||
|
||
// Called by FreeRTOS when malloc fails. | ||
void vApplicationMallocFailedHook(void); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters