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