Skip to content

Commit 5638002

Browse files
committed
rtos: permit configuration using KConfig
1 parent c73cd8b commit 5638002

File tree

6 files changed

+64
-41
lines changed

6 files changed

+64
-41
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0
1+
0.5.0

esp-idf/Kconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,30 @@ menu "Mender client Configuration"
9292
endif
9393

9494
endmenu
95+
96+
menu "Mender advanced Configuration"
97+
98+
config MENDER_RTOS_WORK_QUEUE_STACK_SIZE
99+
int "Mender RTOS Work Queue Stack Size (kB)"
100+
range 0 64
101+
default 20
102+
help
103+
Mender RTOS work queue stack size, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications.
104+
The default TLS configuration of ESP-IDF v4.4.x allows to decrease the stack size down to 12kB.
105+
The default stack size is 20kB because the default TLS configuration of ESP-IDF V5.x consumes more memory.
106+
107+
config MENDER_RTOS_WORK_QUEUE_PRIORITY
108+
int "Mender RTOS Work Queue Priority"
109+
range 0 24
110+
default 5
111+
help
112+
Mender RTOS work queue priority, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications.
113+
114+
config MENDER_RTOS_WORK_QUEUE_LENGTH
115+
int "Mender RTOS Work Queue Length"
116+
range 0 64
117+
default 10
118+
help
119+
Mender RTOS work queue length, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications.
120+
121+
endmenu

platform/rtos/freertos/src/mender-rtos.c

100644100755
Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,6 @@
3939
#include "mender-log.h"
4040
#include "mender-rtos.h"
4141

42-
/**
43-
* @brief Mender RTOS work queue stack
44-
*/
45-
#ifndef MENDER_RTOS_WORK_QUEUE_STACK_SIZE
46-
#define MENDER_RTOS_WORK_QUEUE_STACK_SIZE (12 * 1024)
47-
#endif /* MENDER_RTOS_WORK_QUEUE_STACK_SIZE */
48-
49-
/**
50-
* @brief Mender RTOS work queue priority
51-
*/
52-
#ifndef MENDER_RTOS_WORK_QUEUE_PRIORITY
53-
#define MENDER_RTOS_WORK_QUEUE_PRIORITY (5)
54-
#endif /* MENDER_RTOS_WORK_QUEUE_PRIORITY */
55-
56-
/**
57-
* @brief Mender RTOS work queue lenght
58-
*/
59-
#ifndef MENDER_RTOS_WORK_QUEUE_LENGTH
60-
#define MENDER_RTOS_WORK_QUEUE_LENGTH (10)
61-
#endif /* MENDER_RTOS_WORK_QUEUE_LENGTH */
62-
6342
/**
6443
* @brief Work context
6544
*/
@@ -90,16 +69,16 @@ mender_err_t
9069
mender_rtos_init(void) {
9170

9271
/* Create and start work queue */
93-
if (NULL == (mender_rtos_work_queue_handle = xQueueCreate(MENDER_RTOS_WORK_QUEUE_LENGTH, sizeof(mender_rtos_work_context_t *)))) {
72+
if (NULL == (mender_rtos_work_queue_handle = xQueueCreate(CONFIG_MENDER_RTOS_WORK_QUEUE_LENGTH, sizeof(mender_rtos_work_context_t *)))) {
9473
mender_log_error("Unable to create work queue");
9574
return MENDER_FAIL;
9675
}
9776
if (pdPASS
9877
!= xTaskCreate(mender_rtos_work_queue_thread,
9978
"mender",
100-
(configSTACK_DEPTH_TYPE)(MENDER_RTOS_WORK_QUEUE_STACK_SIZE / sizeof(configSTACK_DEPTH_TYPE)),
79+
(configSTACK_DEPTH_TYPE)(CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE * 1024 / sizeof(configSTACK_DEPTH_TYPE)),
10180
NULL,
102-
MENDER_RTOS_WORK_QUEUE_PRIORITY,
81+
CONFIG_MENDER_RTOS_WORK_QUEUE_PRIORITY,
10382
NULL)) {
10483
mender_log_error("Unable to create work queue thread");
10584
return MENDER_FAIL;

platform/rtos/zephyr/src/mender-rtos.c

100755100644
Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,6 @@
2929
#include "mender-log.h"
3030
#include "mender-rtos.h"
3131

32-
/**
33-
* @brief Mender RTOS work queue stack
34-
*/
35-
#ifndef MENDER_RTOS_WORK_QUEUE_STACK_SIZE
36-
#define MENDER_RTOS_WORK_QUEUE_STACK_SIZE (12 * 1024)
37-
#endif /* MENDER_RTOS_WORK_QUEUE_STACK_SIZE */
38-
K_THREAD_STACK_DEFINE(mender_rtos_work_queue_stack, MENDER_RTOS_WORK_QUEUE_STACK_SIZE);
39-
40-
/**
41-
* @brief Mender RTOS work queue priority
42-
*/
43-
#ifndef MENDER_RTOS_WORK_QUEUE_PRIORITY
44-
#define MENDER_RTOS_WORK_QUEUE_PRIORITY (5)
45-
#endif /* MENDER_RTOS_WORK_QUEUE_PRIORITY */
46-
4732
/**
4833
* @brief Work context
4934
*/
@@ -54,6 +39,11 @@ typedef struct {
5439
struct k_work work_handle; /**< Work handle used to execute the work function */
5540
} mender_rtos_work_context_t;
5641

42+
/**
43+
* @brief Mender RTOS work queue stack
44+
*/
45+
K_THREAD_STACK_DEFINE(mender_rtos_work_queue_stack, CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE * 1024);
46+
5747
/**
5848
* @brief Function used to handle work context timer when it expires
5949
* @param handle Timer handler
@@ -76,7 +66,11 @@ mender_rtos_init(void) {
7666

7767
/* Create and start work queue */
7868
k_work_queue_init(&mender_rtos_work_queue_handle);
79-
k_work_queue_start(&mender_rtos_work_queue_handle, mender_rtos_work_queue_stack, MENDER_RTOS_WORK_QUEUE_STACK_SIZE, MENDER_RTOS_WORK_QUEUE_PRIORITY, NULL);
69+
k_work_queue_start(&mender_rtos_work_queue_handle,
70+
mender_rtos_work_queue_stack,
71+
CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE * 1024,
72+
CONFIG_MENDER_RTOS_WORK_QUEUE_PRIORITY,
73+
NULL);
8074

8175
return MENDER_OK;
8276
}

tests/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ if(CONFIG_MENDER_MCU_CLIENT_HTTP_TYPE MATCHES "zephyr")
6969
add_compile_definitions(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
7070
add_compile_definitions(CONFIG_MENDER_HTTP_CA_CERTIFICATE_TAG=1)
7171
endif()
72+
if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "freertos")
73+
add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE=20)
74+
add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_PRIORITY=5)
75+
add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_LENGTH=10)
76+
endif()
77+
if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "zephyr")
78+
add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE=12)
79+
add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_PRIORITY=5)
80+
endif()
7281

7382
# Add sources
7483
file(GLOB_RECURSE SOURCES_TEMP "${CMAKE_CURRENT_LIST_DIR}/src/*.c")

zephyr/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ if MENDER_MCU_CLIENT
127127

128128
endif
129129

130+
config MENDER_RTOS_WORK_QUEUE_STACK_SIZE
131+
int "Mender RTOS Work Queue Stack Size (kB)"
132+
range 0 64
133+
default 12
134+
help
135+
Mender RTOS work queue stack size, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications.
136+
137+
config MENDER_RTOS_WORK_QUEUE_PRIORITY
138+
int "Mender RTOS Work Queue Priority"
139+
range 0 128
140+
default 5
141+
help
142+
Mender RTOS work queue priority, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications.
143+
130144
module = MENDER
131145
module-str = Log Level for mender
132146
module-help = Enables logging for mender code.

0 commit comments

Comments
 (0)