1menu "FreeRTOS"
2
3    config FREERTOS_UNICORE
4        bool "Run FreeRTOS only on first core"
5        default "y" if IDF_TARGET_ESP32S2
6        select ESP_SYSTEM_SINGLE_CORE_MODE
7        help
8            This version of FreeRTOS normally takes control of all cores of
9            the CPU. Select this if you only want to start it on the first core.
10            This is needed when e.g. another process needs complete control
11            over the second core.
12
13            # This invisible config value sets the value of tskNO_AFFINITY in task.h.
14            # Intended to be used as a constant from other Kconfig files.
15            # Value is (32-bit) INT_MAX.
16
17    config FREERTOS_NO_AFFINITY
18        hex
19        default 0x7FFFFFFF
20
21    config FREERTOS_TICK_SUPPORT_CORETIMER
22        bool
23        default y if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2
24
25    config FREERTOS_TICK_SUPPORT_SYSTIMER
26        bool
27        default y if !FREERTOS_TICK_SUPPORT_CORETIMER
28        # ESP32-S3, ESP32-C3 and ESP32-H2 can use Systimer for FreeRTOS SysTick
29        # ESP32S2 also has SYSTIMER but it can not be used for the FreeRTOS SysTick because:
30        # - It has only one counter, which already in use esp_timer.
31        #   A counter for SysTick should be stall in debug mode but work esp_timer.
32        # - It is not possible to allocate two handlers for esp_timer and SysTick.
33
34    choice FREERTOS_CORETIMER
35        prompt "Xtensa timer to use as the FreeRTOS tick source"
36        default FREERTOS_CORETIMER_0 if FREERTOS_TICK_SUPPORT_CORETIMER
37        default FREERTOS_CORETIMER_SYSTIMER_LVL1 if FREERTOS_TICK_SUPPORT_SYSTIMER
38        help
39            FreeRTOS needs a timer with an associated interrupt to use as
40            the main tick source to increase counters, run timers and do
41            pre-emptive multitasking with. There are multiple timers available
42            to do this, with different interrupt priorities. Check
43
44        config FREERTOS_CORETIMER_0
45            bool "Timer 0 (int 6, level 1)"
46            depends on FREERTOS_TICK_SUPPORT_CORETIMER
47            help
48                Select this to use timer 0
49
50        config FREERTOS_CORETIMER_1
51            bool "Timer 1 (int 15, level 3)"
52            depends on FREERTOS_TICK_SUPPORT_CORETIMER
53            help
54                Select this to use timer 1
55
56        config FREERTOS_CORETIMER_SYSTIMER_LVL1
57            bool "SYSTIMER 0 (level 1)"
58            depends on FREERTOS_TICK_SUPPORT_SYSTIMER
59            help
60                Select this to use systimer with the 1 interrupt priority.
61
62        config FREERTOS_CORETIMER_SYSTIMER_LVL3
63            bool "SYSTIMER 0 (level 3)"
64            depends on FREERTOS_TICK_SUPPORT_SYSTIMER
65            help
66                Select this to use systimer with the 3 interrupt priority.
67
68    endchoice
69
70    config FREERTOS_SYSTICK_USES_SYSTIMER
71        bool
72        default y if FREERTOS_CORETIMER_SYSTIMER_LVL1 || FREERTOS_CORETIMER_SYSTIMER_LVL3
73
74    config FREERTOS_SYSTICK_USES_CCOUNT
75        bool
76        default y if FREERTOS_CORETIMER_0 || FREERTOS_CORETIMER_1
77
78    config FREERTOS_OPTIMIZED_SCHEDULER
79        bool "Enable FreeRTOS pĺatform optimized scheduler"
80        depends on FREERTOS_UNICORE
81        default y
82        help
83            On most platforms there are instructions can speedup the ready task
84            searching. Enabling this option the FreeRTOS with this instructions
85            support will be built.
86
87    config FREERTOS_HZ
88        int "Tick rate (Hz)"
89        range 1 1000
90        default 100
91        help
92            Select the tick rate at which FreeRTOS does pre-emptive context switching.
93
94    config FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
95        bool "Halt when an SMP-untested function is called"
96        default y
97        help
98            Some functions in FreeRTOS have not been thoroughly tested yet when moving to
99            the SMP implementation of FreeRTOS. When this option is enabled, these fuctions
100            will throw an assert().
101
102    choice FREERTOS_CHECK_STACKOVERFLOW
103        prompt "Check for stack overflow"
104        default FREERTOS_CHECK_STACKOVERFLOW_CANARY
105        help
106            FreeRTOS can check for stack overflows in threads and trigger an user function
107            called vApplicationStackOverflowHook when this happens.
108
109        config FREERTOS_CHECK_STACKOVERFLOW_NONE
110            bool "No checking"
111            help
112                Do not check for stack overflows (configCHECK_FOR_STACK_OVERFLOW=0)
113
114        config FREERTOS_CHECK_STACKOVERFLOW_PTRVAL
115            bool "Check by stack pointer value"
116            help
117                Check for stack overflows on each context switch by checking if
118                the stack pointer is in a valid range. Quick but does not detect
119                stack overflows that happened between context switches
120                (configCHECK_FOR_STACK_OVERFLOW=1)
121
122        config FREERTOS_CHECK_STACKOVERFLOW_CANARY
123            bool "Check using canary bytes"
124            help
125                Places some magic bytes at the end of the stack area and on each
126                context switch, check if these bytes are still intact. More thorough
127                than just checking the pointer, but also slightly slower.
128                (configCHECK_FOR_STACK_OVERFLOW=2)
129    endchoice
130
131    config FREERTOS_WATCHPOINT_END_OF_STACK
132        bool "Set a debug watchpoint as a stack overflow check"
133        default n
134        help
135            FreeRTOS can check if a stack has overflown its bounds by checking either the value of
136            the stack pointer or by checking the integrity of canary bytes. (See FREERTOS_CHECK_STACKOVERFLOW
137            for more information.) These checks only happen on a context switch, and the situation that caused
138            the stack overflow may already be long gone by then. This option will use the last debug memory
139            watchpoint to allow breaking into the debugger (or panic'ing) as soon as any
140            of the last 32 bytes on the stack of a task are overwritten. The side effect is that using gdb, you
141            effectively have one hardware watchpoint less because the last one is overwritten as soon as a task
142            switch happens.
143
144            Another consequence is that due to alignment requirements of the watchpoint, the usable stack size
145            decreases by up to 60 bytes. This is because the watchpoint region has to be aligned to its size and the
146            size for the stack watchpoint in IDF is 32 bytes.
147
148            This check only triggers if the stack overflow writes within 32 bytes near the end of the stack, rather
149            than overshooting further, so it is worth combining this approach with one of the other stack overflow
150            check methods.
151
152            When this watchpoint is hit, gdb will stop with a SIGTRAP message. When no JTAG OCD is attached, esp-idf
153            will panic on an unhandled debug exception.
154
155    config FREERTOS_INTERRUPT_BACKTRACE
156        bool "Enable backtrace from interrupt to task context"
157        default y
158        help
159            If this option is enabled, interrupt stack frame will be modified to
160            point to the code of the interrupted task as its return address.
161            This helps the debugger (or the panic handler) show a backtrace from
162            the interrupt to the task which was interrupted. This also works for
163            nested interrupts: higer level interrupt stack can be traced back to the
164            lower level interrupt.
165            This option adds 4 instructions to the interrupt dispatching code.
166
167    config FREERTOS_THREAD_LOCAL_STORAGE_POINTERS
168        int "Number of thread local storage pointers"
169        range 1 256
170        default 1
171        help
172            FreeRTOS has the ability to store per-thread pointers in the task
173            control block. This controls the number of pointers available.
174
175            This value must be at least 1. Index 0 is reserved for use by the pthreads API
176            thread-local-storage. Other indexes can be used for any desired purpose.
177
178    choice FREERTOS_ASSERT
179        prompt "FreeRTOS assertions"
180        default FREERTOS_ASSERT_FAIL_ABORT if !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
181        default FREERTOS_ASSERT_DISABLE if COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
182        help
183            Failed FreeRTOS configASSERT() assertions can be configured to
184            behave in different ways.
185
186            By default these behave the same as the global project assert settings.
187
188        config FREERTOS_ASSERT_FAIL_ABORT
189            bool "abort() on failed assertions"
190            depends on !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
191            help
192                If a FreeRTOS configASSERT() fails, FreeRTOS will abort() and
193                halt execution. The panic handler can be configured to handle
194                the outcome of an abort() in different ways.
195
196                If assertions are disabled for the entire project, they are also
197                disabled in FreeRTOS and this option is unavailable.
198
199        config FREERTOS_ASSERT_FAIL_PRINT_CONTINUE
200            bool "Print and continue failed assertions"
201            help
202                If a FreeRTOS assertion fails, print it out and continue.
203
204        config FREERTOS_ASSERT_DISABLE
205            bool "Disable FreeRTOS assertions"
206            help
207                FreeRTOS configASSERT() will not be compiled into the binary.
208
209    endchoice
210
211    config FREERTOS_IDLE_TASK_STACKSIZE
212        int "Idle Task stack size"
213        range 768 32768
214        default 1536
215        help
216            The idle task has its own stack, sized in bytes. The default size is enough for most uses. Size can be
217            reduced to 768 bytes if no (or simple) FreeRTOS idle hooks are used and pthread local storage or FreeRTOS
218            local storage cleanup callbacks are not used.
219
220            The stack size may need to be increased above the default if the app installs idle or thread local storage
221            cleanup hooks that use a lot of stack memory.
222
223    config FREERTOS_ISR_STACKSIZE
224        int "ISR stack size"
225        range 2096 32768 if ESP_COREDUMP_DATA_FORMAT_ELF
226        default 2096 if ESP_COREDUMP_DATA_FORMAT_ELF
227        range 1536 32768
228        default 1536
229        help
230            The interrupt handlers have their own stack. The size of the stack can be defined here.
231            Each processor has its own stack, so the total size occupied will be twice this.
232
233    config FREERTOS_LEGACY_HOOKS
234        bool "Use FreeRTOS legacy hooks"
235        default n
236        help
237            FreeRTOS offers a number of hooks/callback functions that are called when a timer
238            tick happens, the idle thread runs etc. esp-idf replaces these by runtime registerable
239            hooks using the esp_register_freertos_xxx_hook system, but for legacy reasons the old
240            hooks can also still be enabled. Please enable this only if you have code that for some
241            reason can't be migrated to the esp_register_freertos_xxx_hook system.
242
243    config FREERTOS_MAX_TASK_NAME_LEN
244        int "Maximum task name length"
245        range 1 256
246        default 16
247        help
248            Changes the maximum task name length. Each task allocated will
249            include this many bytes for a task name. Using a shorter value
250            saves a small amount of RAM, a longer value allows more complex
251            names.
252
253            For most uses, the default of 16 is OK.
254
255    config FREERTOS_SUPPORT_STATIC_ALLOCATION
256        # Always enabled.
257        # Kconfig option preserved for compatibility with code
258        # which checked for CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION.
259        bool
260        default y
261
262    config FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP
263        bool "Enable static task clean up hook"
264        default n
265        help
266            Enable this option to make FreeRTOS call the static task clean up hook when a task is deleted.
267
268            Bear in mind that if this option is enabled you will need to implement the following function::
269
270                void vPortCleanUpTCB ( void *pxTCB ) {
271                    // place clean up code here
272                }
273
274    config FREERTOS_TIMER_TASK_PRIORITY
275        int "FreeRTOS timer task priority"
276        range 1 25
277        default 1
278        help
279            The timer service task (primarily) makes use of existing FreeRTOS features, allowing timer
280            functionality to be added to an application with minimal impact on the size of the application's
281            executable binary.
282
283            Use this constant to define the priority that the timer task will run at.
284
285    config FREERTOS_TIMER_TASK_STACK_DEPTH
286        int "FreeRTOS timer task stack size"
287        range 1536 32768
288        default 2048
289        help
290            The timer service task (primarily) makes use of existing FreeRTOS features, allowing timer
291            functionality to be added to an application with minimal impact on the size of the application's
292            executable binary.
293
294            Use this constant to define the size (in bytes) of the stack allocated for the timer task.
295
296    config FREERTOS_TIMER_QUEUE_LENGTH
297        int "FreeRTOS timer queue length"
298        range 5 20
299        default 10
300        help
301            FreeRTOS provides a set of timer related API functions. Many of these functions use a standard
302            FreeRTOS queue to send commands to the timer service task. The queue used for this purpose is
303            called the 'timer command queue'. The 'timer command queue' is private to the FreeRTOS timer
304            implementation, and cannot be accessed directly.
305
306            For most uses the default value of 10 is OK.
307
308    config FREERTOS_QUEUE_REGISTRY_SIZE
309        int "FreeRTOS queue registry size"
310        range 0 20
311        default 0
312        help
313            FreeRTOS uses the queue registry as a means for kernel aware debuggers to locate queues, semaphores,
314            and mutexes. The registry allows for a textual name to be associated with a queue for easy identification
315            within a debugging GUI. A value of 0 will disable queue registry functionality, and a value larger than 0
316            will specify the number of queues/semaphores/mutexes that the registry can hold.
317
318    config FREERTOS_USE_TRACE_FACILITY
319        bool "Enable FreeRTOS trace facility"
320        default n
321        help
322            If enabled, configUSE_TRACE_FACILITY will be defined as 1 in FreeRTOS.
323            This will allow the usage of trace facility functions such as
324            uxTaskGetSystemState().
325
326    config FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
327        bool "Enable FreeRTOS stats formatting functions"
328        depends on FREERTOS_USE_TRACE_FACILITY
329        default n
330        help
331            If enabled, configUSE_STATS_FORMATTING_FUNCTIONS will be defined as 1 in
332            FreeRTOS. This will allow the usage of stats formatting functions such
333            as vTaskList().
334
335    config FREERTOS_VTASKLIST_INCLUDE_COREID
336        bool "Enable display of xCoreID in vTaskList"
337        depends on FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
338        default n
339        help
340            If enabled, this will include an extra column when vTaskList is called
341            to display the CoreID the task is pinned to (0,1) or -1 if not pinned.
342
343    config FREERTOS_GENERATE_RUN_TIME_STATS
344        bool "Enable FreeRTOS to collect run time stats"
345        default n
346        select FREERTOS_USE_TRACE_FACILITY
347        select FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
348        help
349            If enabled, configGENERATE_RUN_TIME_STATS will be defined as 1 in
350            FreeRTOS. This will allow FreeRTOS to collect information regarding the
351            usage of processor time amongst FreeRTOS tasks. Run time stats are
352            generated using either the ESP Timer or the CPU Clock as the clock
353            source (Note that run time stats are only valid until the clock source
354            overflows). The function vTaskGetRunTimeStats() will also be available
355            if FREERTOS_USE_STATS_FORMATTING_FUNCTIONS and
356            FREERTOS_USE_TRACE_FACILITY are enabled. vTaskGetRunTimeStats() will
357            display the run time of each task as a % of the total run time of all
358            CPUs (task run time / no of CPUs) / (total run time / 100 )
359
360
361    choice FREERTOS_RUN_TIME_STATS_CLK
362        prompt "Choose the clock source for run time stats"
363        depends on FREERTOS_GENERATE_RUN_TIME_STATS
364        default FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
365        help
366            Choose the clock source for FreeRTOS run time stats. Options are CPU0's
367            CPU Clock or the ESP Timer. Both clock sources are 32 bits. The CPU
368            Clock can run at a higher frequency hence provide a finer resolution
369            but will overflow much quicker. Note that run time stats are only valid
370            until the clock source overflows.
371
372        config FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
373            bool "Use ESP TIMER for run time stats"
374            help
375                ESP Timer will be used as the clock source for FreeRTOS run time stats.
376                The ESP Timer runs at a frequency of 1MHz regardless of Dynamic
377                Frequency Scaling. Therefore the ESP Timer will overflow in
378                approximately 4290 seconds.
379
380        config FREERTOS_RUN_TIME_STATS_USING_CPU_CLK
381            bool "Use CPU Clock for run time stats"
382            depends on FREERTOS_SYSTICK_USES_CCOUNT
383            help
384                CPU Clock will be used as the clock source for the generation of run
385                time stats. The CPU Clock has a frequency dependent on
386                ESP32_DEFAULT_CPU_FREQ_MHZ and Dynamic Frequency Scaling (DFS).
387                Therefore the CPU Clock frequency can fluctuate between 80 to 240MHz.
388                Run time stats generated using the CPU Clock represents the number of
389                CPU cycles each task is allocated and DOES NOT reflect the amount of
390                time each task runs for (as CPU clock frequency can change). If the CPU
391                clock consistently runs at the maximum frequency of 240MHz, it will
392                overflow in approximately 17 seconds.
393
394    endchoice
395
396    config FREERTOS_USE_TICKLESS_IDLE
397        bool "Tickless idle support"
398        depends on PM_ENABLE
399        default n
400        help
401            If power management support is enabled, FreeRTOS will be able to put
402            the system into light sleep mode when no tasks need to run for a number
403            of ticks. This number can be set using FREERTOS_IDLE_TIME_BEFORE_SLEEP option.
404            This feature is also known as "automatic light sleep".
405
406            Note that timers created using esp_timer APIs may prevent the system from
407            entering sleep mode, even when no tasks need to run.
408            To skip unnecessary wake-up initialize a timer with the "skip_unhandled_events" option as true.
409
410            If disabled, automatic light sleep support will be disabled.
411
412    config FREERTOS_IDLE_TIME_BEFORE_SLEEP
413        int "Minimum number of ticks to enter sleep mode for"
414        depends on FREERTOS_USE_TICKLESS_IDLE
415        default 3
416        range 2 4294967295
417        # Minimal value is 2 because of a check in FreeRTOS.h (search configEXPECTED_IDLE_TIME_BEFORE_SLEEP)
418        help
419            FreeRTOS will enter light sleep mode if no tasks need to run for this number
420            of ticks.
421
422    config FREERTOS_TASK_FUNCTION_WRAPPER
423        bool "Enclose all task functions in a wrapper function"
424        depends on COMPILER_OPTIMIZATION_DEFAULT
425        default y
426        help
427            If enabled, all FreeRTOS task functions will be enclosed in a wrapper function.
428            If a task function mistakenly returns (i.e. does not delete), the call flow will
429            return to the wrapper function. The wrapper function will then log an error and
430            abort the application. This option is also required for GDB backtraces and C++
431            exceptions to work correctly inside top-level task functions.
432
433    config FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
434        bool "Check that mutex semaphore is given by owner task"
435        default y
436        help
437            If enabled, assert that when a mutex semaphore is given, the task giving the
438            semaphore is the task which is currently holding the mutex.
439
440    config FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE
441        bool "Tests compliance with Vanilla FreeRTOS port*_CRITICAL calls"
442        default n
443        help
444            If enabled, context of port*_CRITICAL calls (ISR or Non-ISR)
445            would be checked to be in compliance with Vanilla FreeRTOS.
446            e.g Calling port*_CRITICAL from ISR context would cause assert failure
447
448    config FREERTOS_PLACE_FUNCTIONS_INTO_FLASH
449        bool "Place FreeRTOS functions into Flash"
450        default n
451        help
452            When enabled the selected Non-ISR FreeRTOS functions will be placed into Flash memory instead of IRAM.
453            This saves up to 8KB of IRAM depending on which functions are used.
454
455    config FREERTOS_DEBUG_OCDAWARE
456        bool
457        help
458            Hidden option, gets selected by CONFIG_ESPxx_DEBUG_OCDAWARE
459
460    config FREERTOS_FPU_IN_ISR
461        bool "Allow use of float inside Level 1 ISR (EXPERIMENTAL)"
462        depends on IDF_TARGET_ESP32
463        default n
464        help
465            When enabled, the usage of float type is allowed inside Level 1
466            ISRs.
467
468    config FREERTOS_ENABLE_TASK_SNAPSHOT
469        bool "Enable task snapshot functions"
470        default y
471        help
472            When enabled, the functions related to snapshots, such as vTaskGetSnapshot or uxTaskGetSnapshotAll,
473            are compiled and linked.
474
475    config FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH
476        bool "Place task snapshot functions into flash"
477        default n
478        depends on FREERTOS_ENABLE_TASK_SNAPSHOT && !ESP_PANIC_HANDLER_IRAM
479        help
480            When enabled, the functions related to snapshots, such as vTaskGetSnapshot or uxTaskGetSnapshotAll,
481            will be placed in flash. Note that if enabled, these functions cannot be called when cache is disabled.
482endmenu
483