Skip to content

Commit f72730e

Browse files
ArunmaniAlagarsamy2710jhedberg
authored andcommitted
wiseconnect: Use static allocation for threads
Zephyr CMSIS implementation has some limitations with dynamically allocated resources[1]. This patch allocates the CMSIS resources statically. Thus: - this allows to workaround the limitation of the current CMSIS implementation until we fix them properly - it is possible to get rid of the dependencies to CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT and CMSIS_V2_THREAD_MAX_COUNT. [1]: zephyrproject-rtos/zephyr#85557 Upstream-status: Inappropriate [Zephyr specific workaround for stack allocation] Signed-off-by: Arunmani Alagarsamy <[email protected]> Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent b3d708d commit f72730e

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

wiseconnect/components/device/silabs/si91x/wireless/src/sl_rsi_utility.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "sl_wifi_types.h"
3838
#include "sl_rsi_utility.h"
3939
#include "cmsis_os2.h" // CMSIS RTOS2
40+
#include "cmsis_types.h"
4041
#include "sl_si91x_types.h"
4142
#include "sli_wifi_command_engine.h"
4243
#include "sl_si91x_core_utilities.h"
@@ -95,6 +96,10 @@
9596
#define SLI_FW_STATUS_STORAGE_INVALID_INDEX 0xFF // Invalid index for firmware status storage
9697
#define DEFAULT_BEACON_MISS_IGNORE_LIMIT 1
9798

99+
static uint8_t __aligned(8) event_handler_stack[SL_SI91X_EVENT_HANDLER_STACK_SIZE];
100+
101+
static struct cmsis_rtos_thread_cb event_thread_cb;
102+
98103
/******************************************************
99104
* Local Type Declarations
100105
******************************************************/
@@ -1065,10 +1070,10 @@ sl_status_t sl_si91x_platform_init(void)
10651070
const osThreadAttr_t attr = {
10661071
.name = "si91x_async_rx_event",
10671072
.priority = SL_WLAN_EVENT_THREAD_PRIORITY,
1068-
.stack_mem = 0,
1073+
.stack_mem = event_handler_stack,
10691074
.stack_size = SL_SI91X_EVENT_HANDLER_STACK_SIZE,
1070-
.cb_mem = 0,
1071-
.cb_size = 0,
1075+
.cb_mem = &event_thread_cb,
1076+
.cb_size = sizeof(event_thread_cb),
10721077
.attr_bits = 0u,
10731078
.tz_module = 0u,
10741079
};

wiseconnect/components/service/network_manager/src/sli_net_common_utility.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,21 @@
4040
#include "sl_net_for_lwip.h"
4141
#endif
4242
#include "sli_wifi_constants.h"
43+
#include "cmsis_types.h"
4344

4445
sl_net_event_handler_t net_event_handler = NULL;
4546
static osEventFlagsId_t auto_join_event_flag;
4647
static osThreadId_t network_manager_id = NULL;
48+
49+
static uint8_t __aligned(8) network_manager_stack[2304];
50+
static struct cmsis_rtos_thread_cb network_manager_thread_cb;
4751
const osThreadAttr_t network_manager_attributes = {
4852
.name = "network_manager",
4953
.attr_bits = 0,
50-
.cb_mem = 0,
51-
.cb_size = 0,
52-
.stack_mem = 0,
53-
.stack_size = 2304,
54+
.cb_mem = &network_manager_thread_cb,
55+
.cb_size = sizeof(network_manager_thread_cb),
56+
.stack_mem = network_manager_stack,
57+
.stack_size = sizeof(network_manager_stack),
5458
.priority = osPriorityNormal,
5559
.tz_module = 0,
5660
.reserved = 0,

wiseconnect/components/sli_wifi_command_engine/src/sli_wifi_command_engine.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "sl_constants.h"
3434
#include "sli_wifi_event_handler.h"
3535
#include "cmsis_os2.h"
36+
#include "cmsis_types.h"
3637

3738
/******************************************************
3839
* Macro Definitions
@@ -55,6 +56,9 @@ void sli_wifi_command_engine(void *args);
5556
* Function Definitions
5657
******************************************************/
5758

59+
static uint8_t __aligned(8) sli_wifi_command_engine_stack[1636];
60+
static struct cmsis_rtos_thread_cb sli_wifi_command_engine_thread_cb;
61+
5862
void sli_wifi_command_engine_init(void)
5963
{
6064
// Call the init function of Command Engine Event Handler.
@@ -65,10 +69,10 @@ void sli_wifi_command_engine_init(void)
6569
const osThreadAttr_t attr = {
6670
.name = "sli_wifi_command_engine",
6771
.priority = SL_WLAN_COMMAND_ENGINE_THREAD_PRIORITY,
68-
.stack_mem = 0,
69-
.stack_size = 1636,
70-
.cb_mem = 0,
71-
.cb_size = 0,
72+
.stack_mem = sli_wifi_command_engine_stack,
73+
.stack_size = sizeof(sli_wifi_command_engine_stack),
74+
.cb_mem = &sli_wifi_command_engine_thread_cb,
75+
.cb_size = sizeof(sli_wifi_command_engine_thread_cb),
7276
.attr_bits = 0u,
7377
.tz_module = 0u,
7478
};

0 commit comments

Comments
 (0)