Skip to content

Commit 5d7a4bf

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 7e5de18 commit 5d7a4bf

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"
@@ -97,6 +98,10 @@ static bool sli_si91x_tx_command_status = false;
9798
#define SLI_FW_STATUS_STORAGE_INVALID_INDEX 0xFF // Invalid index for firmware status storage
9899
#define DEFAULT_BEACON_MISS_IGNORE_LIMIT 1
99100

101+
static uint8_t __aligned(8) event_handler_stack[SL_SI91X_EVENT_HANDLER_STACK_SIZE];
102+
103+
static struct cmsis_rtos_thread_cb event_thread_cb;
104+
100105
/******************************************************
101106
* Local Type Declarations
102107
******************************************************/
@@ -1066,10 +1071,10 @@ sl_status_t sl_si91x_platform_init(void)
10661071
const osThreadAttr_t attr = {
10671072
.name = "si91x_async_rx_event",
10681073
.priority = SL_WLAN_EVENT_THREAD_PRIORITY,
1069-
.stack_mem = 0,
1074+
.stack_mem = event_handler_stack,
10701075
.stack_size = SL_SI91X_EVENT_HANDLER_STACK_SIZE,
1071-
.cb_mem = 0,
1072-
.cb_size = 0,
1076+
.cb_mem = &event_thread_cb,
1077+
.cb_size = sizeof(event_thread_cb),
10731078
.attr_bits = 0u,
10741079
.tz_module = 0u,
10751080
};

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
@@ -41,17 +41,21 @@
4141
#endif
4242
#include "sli_wifi_constants.h"
4343
#include "sli_net_types.h"
44+
#include "cmsis_types.h"
4445

4546
sl_net_event_handler_t net_event_handler = NULL;
4647
static osEventFlagsId_t auto_join_event_flag;
4748
static osThreadId_t network_manager_id = NULL;
49+
50+
static uint8_t __aligned(8) network_manager_stack[2304];
51+
static struct cmsis_rtos_thread_cb network_manager_thread_cb;
4852
const osThreadAttr_t network_manager_attributes = {
4953
.name = "network_manager",
5054
.attr_bits = 0,
51-
.cb_mem = 0,
52-
.cb_size = 0,
53-
.stack_mem = 0,
54-
.stack_size = 2304,
55+
.cb_mem = &network_manager_thread_cb,
56+
.cb_size = sizeof(network_manager_thread_cb),
57+
.stack_mem = network_manager_stack,
58+
.stack_size = sizeof(network_manager_stack),
5559
.priority = osPriorityNormal,
5660
.tz_module = 0,
5761
.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)