1# Copyright Runtime.io 2018. All rights reserved.
2# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4
5# The Kconfig file is dedicated to OS management group of
6# of MCUmgr subsystem and provides Kconfig options to configure
7# group commands behaviour and other aspects.
8#
9# Options defined in this file should be prefixed:
10#  MCUMGR_GRP_OS_ -- general group options;
11#
12# When adding Kconfig options, that control the same feature,
13# try to group them together by the same stem after prefix.
14
15menuconfig MCUMGR_GRP_OS
16	bool "Mcumgr handlers for OS management"
17	imply REBOOT
18	help
19	  Enables MCUmgr handlers for OS management
20
21if MCUMGR_GRP_OS
22
23if REBOOT
24
25config MCUMGR_GRP_OS_RESET_MS
26	int "Delay before executing reset command (ms)"
27	default 250
28	depends on REBOOT
29	help
30	  When a reset command is received, the system waits this many milliseconds
31	  before performing the reset.  This delay allows time for the MCUmgr
32	  response to be delivered.
33
34config MCUMGR_GRP_OS_RESET_HOOK
35	bool "Reset hook"
36	depends on REBOOT
37	depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
38	help
39	  Allows applications to control and get notifications of when a reset
40	  command has been issued via an MCUmgr command. With this option
41	  disabled, modules will reboot when the command is received without
42	  notification, when this is enabled and a handler is registered, the
43	  application will be notified that a reset command has been received
44	  and will allow the application to perform any required operations
45	  before accepting or declining the reset request.
46
47endif
48
49config MCUMGR_GRP_OS_TASKSTAT
50	bool "Support for taskstat command"
51	select MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_3 if ZCBOR_CANONICAL
52	depends on THREAD_MONITOR
53
54if MCUMGR_GRP_OS_TASKSTAT
55
56config MCUMGR_GRP_OS_TASKSTAT_ONLY_SUPPORTED_STATS
57	bool "Send only data gathered by Zephyr"
58	default y
59	help
60	  Response will not include fields the Zephyr does not collect statistic for.
61	  Enable this if your client software is able to process "taskstat" response
62	  that would be missing "runtime", "cswcnt", "last_checkin" and "next_checkin"
63	  map entries for each listed task.
64	  Enabling this option will slightly reduce code size.
65
66choice MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_CHOICE
67	prompt "Characteristic used as thread name in taskstat"
68	default MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_NAME_FOR_NAME if THREAD_NAME
69	default MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_PRIO_FOR_NAME
70	help
71	  Select what will serve as thread name in "taskstat" response.
72	  By default taskstat responses use thread priority, when THREAD_NAME is disabled,
73
74	config MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_NAME_FOR_NAME
75		bool "Thread name"
76		depends on THREAD_NAME
77
78	config MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_IDX_FOR_NAME
79		bool "Thread index"
80
81	config MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_PRIO_FOR_NAME
82		bool "Thread priority"
83
84endchoice
85
86config MCUMGR_GRP_OS_TASKSTAT_MAX_NUM_THREADS
87	int "Predicted maximum number of threads to return on taskstat list"
88	default 50
89	help
90	  This is used for defining CBOR map holding thread info.
91	  The value does not affect memory allocation, it is used by zcbor
92	  to figure out how to encode map depending on its predicted size.
93
94config MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_LEN
95	int "Length of thread name to return in response"
96	default THREAD_MAX_NAME_LEN if THREAD_NAME
97	default 5 if !THREAD_NAME
98	range 3 THREAD_MAX_NAME_LEN if THREAD_NAME
99	range 3 6 if !THREAD_NAME
100	help
101	  The length of the string that is sent in response to taskstat command,
102	  as a thread name.
103	  When THREAD_NAME is enabled then this defaults to THREAD_MAX_NAME_LEN.
104	  When THREAD_NAME is disabled the name is generated from thread priority,
105	  signed integer, and this number regulates how many digits will be used;
106	  in such case this value should also take into account possible '-'
107	  sign.
108
109config MCUMGR_GRP_OS_TASKSTAT_SIGNED_PRIORITY
110	bool "Signed priorities"
111	default y
112	help
113	  Zephyr uses int8_t as thread priorities, but in taskstat response it encodes
114	  them as unsigned.  Enabling this option will use signed int for priorities in
115	  responses, which is more natural for Zephyr.
116	  Disable this option if your client software is unable to properly decode and
117	  accept signed integers as priorities.
118
119config MCUMGR_GRP_OS_TASKSTAT_STACK_INFO
120	bool "Include stack info in taskstat responses"
121	depends on THREAD_STACK_INFO
122	help
123	  Enabling this option adds stack information into "taskstat" command
124	  responses, this is default when THREAD_STACK_INFO is selected.
125	  Disable this option only when your client application is able to
126	  process "taskstat" response without the "stksiz" and "stkuse" fields.
127	  It is worth disabling this option when THREAD_STACK_INFO is disabled,
128	  as it will prevent sending zeroed stack information just to fill
129	  all the fields in "taskstat" responses, and it will slightly reduce code size.
130
131endif
132
133config MCUMGR_GRP_OS_ECHO
134	bool "Support for echo command"
135	default y
136	select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
137
138config MCUMGR_GRP_OS_DATETIME
139	bool "Support for datetime command"
140	depends on RTC
141	depends on $(dt_alias_enabled,rtc)
142	select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
143	help
144	  Enables support for the datetime get and set functions, this allows for using the
145	  `rtc` alias device as a timesource from which the current time can be written or read.
146
147config MCUMGR_GRP_OS_DATETIME_MS
148	bool "Support millisecond field in datetime commands"
149	depends on MCUMGR_GRP_OS_DATETIME
150
151config MCUMGR_GRP_OS_DATETIME_HOOK
152	bool "Datetime hook"
153	depends on MCUMGR_GRP_OS_DATETIME
154	depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
155	help
156	  Allows applications to control and get notifications of when a datetime set/get
157	  command has been issued via an MCUmgr command.
158
159config MCUMGR_GRP_OS_MCUMGR_PARAMS
160	bool "MCUMGR Parameters retrieval command"
161
162config MCUMGR_GRP_OS_INFO
163	bool "Support for info command"
164	help
165	  Can be used similarly to the unix/linux uname command for retrieving system information
166	  including kernel version, processor architecture and board name.
167
168if MCUMGR_GRP_OS_INFO
169
170config MCUMGR_GRP_OS_INFO_MAX_RESPONSE_SIZE
171	int "Maximum response size for info command"
172	default 256
173	range 32 512
174	help
175	  The maximum size of the response to the info command, will use a stack buffer of this
176	  size to store the data in. If the output response is too big then the output will not be
177	  present in the response, which will just contain the result code (rc) of memory error.
178
179config MCUMGR_GRP_OS_INFO_CUSTOM_HOOKS
180	bool "Custom info hooks"
181	depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
182	help
183	  Supports adding custom command/character processing to the info command by using
184	  registered callbacks. Data can be appended to the struct provided in the callback.
185
186config MCUMGR_GRP_OS_INFO_BUILD_DATE_TIME
187	bool "Show build date and time"
188	help
189	  Will allow returning the build date and time of the firmware by using the info with
190	  format option 'b' (will also be returned with all responses by using 'a').
191
192	  Note: This will invalidate reproducible builds of the firmware as it will embed the
193	  build date/time in the output firmware image.
194
195endif
196
197config MCUMGR_GRP_OS_BOOTLOADER_INFO
198	bool "Bootloader information"
199	help
200	  Allows to query MCUmgr about bootloader used by device and various bootloader
201	  parameters.
202
203config MCUMGR_GRP_OS_BOOTLOADER_INFO_HOOK
204	bool "Bootloader info hooks"
205	depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
206	help
207	  Supports adding custom responses to the bootloader info command by using registered
208	  callbacks. Data can be appended to the struct provided in the callback.
209
210module = MCUMGR_GRP_OS
211module-str = mcumgr_grp_os
212source "subsys/logging/Kconfig.template.log_config"
213
214endif
215