]> begriffs open source - cmsis-freertos/blob - DoxyGen/src/cmsis_freertos.txt
Update documentation
[cmsis-freertos] / DoxyGen / src / cmsis_freertos.txt
1 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2 /**
3 \mainpage
4
5 \section Introduction
6
7 <a target="_blank" href="https://www.freertos.org/">FreeRTOS</a> is one of the market leading real-time operating systems
8 (RTOS) for embedded microcontrollers. It is professionally developed,
9 <a target="_blank" href="https://www.freertos.org/FreeRTOS-Coding-Standard-and-Style-Guide.html">strictly quality controlled</a>,
10 robust,
11 <a target="_blank" href="https://forums.freertos.org/">supported</a>
12 <a target="_blank" href="https://www.freertos.org/FreeRTOS_Support_Forum_Archive/freertos_support_forum_archive_index.html/">(archive)</a>,
13 free to <a target="_blank" href="https://www.freertos.org/a00114.html">use in commercial products</a> without a requirement to
14 expose proprietary source code, and has
15 <a target="_blank" href="https://www.freertos.org/differences-between-officially-supported-and-contributed-FreeRTOS-code.html">no IP infringement</a>
16 risk.
17
18 <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/index.html"><b>CMSIS-RTOS v2</b></a> is a common API for real-time
19 operating systems (RTOS). It provides a standardized programming interface that is portable to many RTOS and enables software
20 components that can work across multiple RTOS systems. It supports the Armv8-M architecture, dynamic object creation, for
21 multi-core systems, and has a binary compatible interface across ABI compliant compilers.
22
23 Using this software pack, users can choose between a native FreeRTOS implementation or one that is adhering to the
24 CMSIS-RTOS2 API and using FreeRTOS under the hood. The CMSIS-RTOS2 API enables programmers to create portable application
25 code to be used with different RTOS kernels (for example
26 <a class="el" href="https://www2.keil.com/mdk5/cmsis/rtx/">Keil RTX5</a>).
27
28 This documentation shows you:
29 - how to \ref cre_freertos_proj "create a new microcontroller project" using FreeRTOS from scratch.
30 - Various \ref examples show you the usage of FreeRTOS in native and CMSIS-RTOS2 mode.
31 - the \ref tech_data of this implementation.
32 - \subpage rev_hist
33
34
35 License
36 -------
37
38 The CMSIS-FreeRTOS implementation is provided free of charge by Arm under the <a href="LICENSE">Apache 2.0 license</a>.<br/>
39 The FreeRTOS kernel source files are released under the <a href="LICENSE.md">MIT open source license</a>.
40
41
42 ARM::CMSIS-FreeRTOS Pack
43 ------------------------
44
45 The <b>ARM::CMSIS-FreeRTOS</b> pack contains the following:
46
47 File/Directory             |Content
48 :--------------------------|:---------------------------------------------------------------------------------
49 \b CMSIS/Documentation     | This documentation.
50 \b CMSIS/RTOS2             | CMSIS-RTOS2 compliant implementation of FreeRTOS.
51 \b Config                  | FreeRTOS configuration header file.
52 \b License                 | FreeRTOS license agreement.
53 \b Source                  | FreeRTOS kernel source code.
54 \b ARM.CMSIS-FreeRTOS.pdsc | Package description file in CMSIS-Pack format.
55 */
56
57 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
58 /**
59 \page cre_freertos_proj Create a FreeRTOS project
60
61 You can basically choose between two option when creating a FreeRTOS project:
62 -# \ref native_freertos using the FreeRTOS API and kernel.
63 -# \ref cmsis_freertos using the CMSIS-RTOS2 API with an underlying FreeRTOS kernel.
64
65 \section native_freertos Create a native FreeRTOS project
66
67 The steps to create a microcontroller application using FreeRTOS are:
68 - Create a new project and select a microcontroller device.
69 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::RTOS:CORE</b> and
70   <b>\::RTOS:Config</b> in the \b FreeRTOS variant and an applicable <b>\::RTOS:Heap</b> scheme (for more
71   information on the heap schemes, visit the FreeRTOS documentation):
72
73   \image html manage_rte_freertos_native.png
74
75   \n
76 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
77 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
78   \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
79
80   \image html project_window_freertos_native.png
81
82 \subsection native_freertos_config Configure FreeRTOS
83
84 When you have created the native FreeRTOS project, you can configure the real-time operating system using the
85 \b FreeRTOSConfig.h file. Please refer to the
86 <a href="https://www.freertos.org/a00110.html" target="_blank">FreeRTOS documentation</a> for more information on the specific
87 settings.
88
89 \image html freertos_config_h_native.png
90
91
92 \subsection native_freertos_config_prio Interrupt priority configuration
93
94 FreeRTOS implements critical sections using the
95 <a href="https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/programmers-model/core-registers?lang=en" target="_blank">BASEPRI</a>
96 register (available in Armv7-M and Armv8-M architecture based devices) which masks only a subset of interrupts. This is
97 configured via the \c configMAX_SYSCALL_INTERRUPT_PRIORITY setting. Therefore, it is needed to properly configure this
98 setting. It is also needed to set appropriate interrupt priorities for interrupt service routines (ISR) that use RTOS
99 functions. This can especially impact drivers which typically use peripheral interrupts. Normally, these use the RTOS
100 directly or indirectly through registered callbacks.
101
102 Arm Cortex-M cores store interrupt priority values in the most significant bits of the interrupt priority registers which
103 can have a maximum of eight bits. Many implementations offer only three priority bits. These three bits are shifted up to be
104 bits five, six and seven respectively.
105 \c configMAX_SYSCALL_INTERRUPT_PRIORITY must not be 0 and can be xxx00000. This results in the following table:
106
107 | configMAX_SYSCALL_INTERRUPT_PRIORITY    | Upper three bits | Priority    |
108 |:---------------------------------------:|:----------------:|:-----------:|
109 | 32                                      | 001              | 1 (Highest) |
110 | 64                                      | 010              | 2           |
111 | 96                                      | 011              | 3           |
112 | 128                                     | 100              | 4           |
113 | 160                                     | 101              | 5           |
114 | 196                                     | 110              | 6           |
115 | 224                                     | 111              | 7 (Lowest)  |
116
117 \b Example
118
119 If you set \c configMAX_SYSCALL_INTERRUPT_PRIORITY to 32, then the priority of an interrupt service routine that uses RTOS
120 functions must then be higher or equal to 1. This ensures that this interrupt will be masked during critical a section.
121
122 A WiFi driver using the SPI interface registers a callback to SPI which is executed in an interrupt context. The callback
123 function in the WiFi driver uses RTOS functions. Therefore, the SPI interrupt priority must be set to a value equal or
124 higher to the FreeRTOS preempt priority, for example 1.
125
126 \note For a detailed description of how FreeRTOS is using Cortex-M code registers, refer to
127 <a href="https://www.freertos.org/RTOS-Cortex-M3-M4.html" target="_blank">Running the RTOS on a ARM Cortex-M Core</a>.
128
129
130 \subsection native_freertos_er Add Event Recorder Visibility
131 - To use the Event Recorder together with FreeRTOS, add the software component <b>\::Compiler:Event Recorder</b> to your project.
132 - Open \ref native_freertos_config "FreeRTOSConfig.h" and
133   - verify the header file \b freertos_evr.h is included
134   - add Event Recorder configuration definitions (see \ref cmsis_freertos_evr_config)
135 - Call <b>EvrFreeRTOSSetup()</b> in your application code (ideally in \c main()).
136 - If you are using simulation mode, add an initialization file with the following content:
137   \code
138   MAP 0xE0001000, 0xE0001007 READ WRITE
139   signal void DWT_CYCCNT (void) {
140   while (1) {
141     rwatch(0xE0001004);
142     _WWORD(0xE0001004, states);
143     }
144   }
145   DWT_CYCCNT()
146   \endcode
147 - Build the application code and download it to the debug hardware or run it in simulation.
148
149 Once the target application generates event information, it can be viewed in the µVision debugger using the <b>Event Recorder</b>.
150
151
152 \section cmsis_freertos Create a CMSIS-FreeRTOS project
153
154 The steps to create a microcontroller application using CMSIS-FreeRTOS are:
155 - Create a new project and select a microcontroller device.
156 - In the Manage Run-Time Environment window, select <b>\::Device:Startup</b>, <b>\::CMSIS::RTOS2 (API)\::FreeRTOS</b>,
157   <b>\::RTOS:CORE</b> in the \b FreeRTOS variant, <b>\::RTOS:Config</b> in the \b CMSIS \b RTOS2 variant,
158   <b>\::RTOS:Timers</b>, <b>\::RTOS:Event Groups</b>, and an applicable <b>\::RTOS:Heap</b>
159   scheme (for more information on the heap schemes, visit the FreeRTOS documentation):
160
161   \image html manage_rte_freertos_rtos2.png
162
163   \n
164 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
165 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
166   \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files:
167
168   \image html project_window_freertos_rtos2.png
169
170
171 \subsection cmsis_freertos_config Configure CMSIS-FreeRTOS
172
173 When you have created the CMSIS-FreeRTOS project, you can configure the real-time operating system using the
174 \b FreeRTOSConfig.h file. It can be opened using the Configuration Wizard view:
175
176 \image html freertos_config_h_cmsis_rtos.png
177
178 The following settings are available:
179
180 Name                           | \#define                             | Description                                                           |
181 -------------------------------|--------------------------------------|-----------------------------------------------------------------------|
182 Minimal stack size [words]     | configMINIMAL_STACK_SIZE             | Stack for idle task and default task stack in words.                  |
183 Total heap size [bytes]        | configTOTAL_HEAP_SIZE                | Heap memory size in bytes.                                            |
184 Kernel tick frequency [Hz]     | configTICK_RATE_HZ                   | Kernel tick rate in Hz.                                               |
185 Timer task stack depth [words] | configTIMER_TASK_STACK_DEPTH         | Stack for timer task in words.                                        |
186 Timer task priority            | configTIMER_TASK_PRIORITY            | Timer task priority.                                                  |
187 Timer queue length             | configTIMER_QUEUE_LENGTH             | Timer command queue length.                                           |
188 Preemption interrupt priority  | configMAX_SYSCALL_INTERRUPT_PRIORITY | Maximum priority of interrupts that are safe to call FreeRTOS API.    |
189 Use time slicing               | configUSE_TIME_SLICING               | Enable setting to use time slicing.                                   |
190 Idle should yield              | configIDLE_SHOULD_YIELD              | Control Yield behavior of the idle task.                              |
191 Check for stack overflow       | configCHECK_FOR_STACK_OVERFLOW       | Enable or disable stack overflow checking.                            |
192 Use idle hook                  | configUSE_IDLE_HOOK                  | Enable callback function call on each idle task iteration.            |
193 Use tick hook                  | configUSE_TICK_HOOK                  | Enable callback function call during each tick interrupt.             |
194 Use daemon task startup hook   | configUSE_DAEMON_TASK_STARTUP_HOOK   | Enable callback function call when timer service starts.              |
195 Use malloc failed hook         | configUSE_MALLOC_FAILED_HOOK         | Enable callback function call when out of dynamic memory.             |
196 Queue registry size            | configQUEUE_REGISTRY_SIZE            | Define maximum number of queue objects registered for debug purposes. |
197
198 \note Refer to \ref native_freertos_config_prio for more information on the usage of \c configMAX_SYSCALL_INTERRUPT_PRIORITY.
199
200 <b> Event Recorder Configuration </b>
201
202 The following settings are available (see \ref cmsis_freertos_evr_config for details):
203
204 Name                           | \#define                             | Description                                                                             |
205 -------------------------------|--------------------------------------|-----------------------------------------------------------------------------------------|
206 Initialize Event Recorder      | configEVR_INITIALIZE                 | Initialize Event Recorder before FreeRTOS kernel start.                                 |
207 Setup recording level filter   | configEVR_SETUP_LEVEL                | Enable configuration of FreeRTOS events recording level.                                |
208 Task functions                 | configEVR_LEVEL_TASKS                | Define event recording level bitmask for events generated from Tasks functions.         |
209 Queue functions                | configEVR_LEVEL_QUEUE                | Define event recording level bitmask for events generated from Queue functions.         |
210 Timer functions                | configEVR_LEVEL_TIMERS               | Define event recording level bitmask for events generated from Timer functions.         |
211 Event Groups functions         | configEVR_LEVEL_EVENTGROUPS          | Define event recording level bitmask for events generated from Event Groups functions.  |
212 Heap functions                 | configEVR_LEVEL_HEAP                 | Define event recording level bitmask for events generated from Heap functions.          |
213 Stream Buffer functions        | configEVR_LEVEL_STREAMBUFFER         | Define event recording level bitmask for events generated from Stream Buffer functions. |
214
215
216 \subsection cmsis_freertos_er Add Event Recorder Visibility
217 - To use the Event Recorder together with FreeRTOS, add the software component <b>\::Compiler:Event Recorder</b> to your project.
218 - Open \ref native_freertos_config "FreeRTOSConfig.h" and
219   - verify the header file \b freertos_evr.h is included
220   - modify Event Recorder configuration definitions (see \ref cmsis_freertos_evr_config) to change default configuration
221 - Call <b>osKernelInitialize()</b> in your application code (ideally in \c main()) to setup Event Recorder according to configuration settings.
222 - If you are using simulation mode, add an initialization file with the following content:
223   \code
224   MAP 0xE0001000, 0xE0001007 READ WRITE
225   signal void DWT_CYCCNT (void) {
226   while (1) {
227     rwatch(0xE0001004);
228     _WWORD(0xE0001004, states);
229     }
230   }
231   DWT_CYCCNT()
232   \endcode
233 - Build the application code and download it to the debug hardware or run it in simulation.
234
235 Once the target application generates event information, it can be viewed in the µVision debugger using the <b>Event Recorder.</b>
236
237
238 \section freertos_interfaces Create a mixed-interface project
239
240 Using CMSIS-RTOS2 API and native FreeRTOS API simultaneously is possible and some projects do require using the native FreeRTOS API and the CMSIS-RTOS2 API at the same time.
241 Such project should be \ref cmsis_freertos "created as CMSIS-FreeRTOS project".
242
243 Depending on the application requirements, FreeRTOS kernel can be started either by using FreeRTOS native API or by using CMSIS-RTOS2 API.
244
245 \subsection freertos_interface_rtos2 Start the kernel using CMSIS-RTOS2 API
246
247 \code
248 /*
249   Application thread: Initialize and start the Application
250 */
251 void app_main (void *argument) {
252
253   while(1) {
254     // Application code
255     // ...
256   }
257 }
258
259 /*
260   Main function: Initialize and start the kernel
261 */
262 int main (void) {
263   SystemCoreClockUpdate();
264
265   // Initialize CMSIS-RTOS2
266   osKernelInitialize();
267
268   // Create application main thread
269   osThreadNew(app_main, NULL, NULL);
270
271   // Start the kernel and execute the first thread
272   osKernelStart();
273
274   while(1);
275 }
276 \endcode
277
278 \b Restrictions
279
280 After the kernel is started using CMSIS-RTOS2 API, FreeRTOS native API can be used with the following restrictions:
281 - vTaskStartScheduler must not be called
282
283
284 \subsection freertos_interface_native Start the kernel using native API
285
286 \code
287 /*
288   Application main thread: Initialize and start the application
289 */
290 void app_main (void *argument) {
291
292   while(1) {
293     // Application code
294     // ...
295   }
296 }
297
298 /*
299   Main function: Initialize and start the kernel
300 */
301 int main (void) {
302   SystemCoreClockUpdate();
303
304   // Setup the Event Recorder (optionally)
305   EvrFreeRTOSSetup(0);
306
307   // Create application main thread
308   xTaskCreate (app_main, "app_main", 64, NULL, tskIDLE_PRIORITY+1, NULL);
309
310   // Start the kernel and execute the first thread
311   vTaskStartScheduler();
312
313   while(1);
314 }
315 \endcode
316
317 \b Restrictions
318
319 After the kernel is started using FreeRTOS native API, CMSIS-RTOS2 API can be used without restrictions.
320
321 \section cmsis_freertos_evr_config Configure Event Recorder
322
323 This section describes the configuration settings for the <a href="https://arm-software.github.io/CMSIS-View/latest/evr.html" target="_blank">Event Recorder</a>
324 annotations. For more information refer to section \ref native_freertos_er "Add Event Recorder Visibility to native FreeRTOS project" or
325 \ref cmsis_freertos_er "Add Event Recorder Visibility to CMSIS-FreeRTOS project".
326
327 Use below definitions to configure Event Recorder initialization and recording level filter setup.
328
329 \code
330 #define configEVR_INITIALIZE
331 \endcode
332
333 Value  | Description                           |
334 -------|---------------------------------------|
335 0      | Disable Event Recorder initialization |
336 1      | Enable Event Recorder initialization  |
337
338 Definition configEVR_INITIALIZE enables Event Recorder initialization during execution of function \ref EvrFreeRTOSSetup. Default value is \token{1}.
339
340 \code
341 #define configEVR_SETUP_LEVEL
342 \endcode
343
344 Value  | Description                           |
345 -------|---------------------------------------|
346 0      | Disable recording level filter setup  |
347 1      | Enable recording level filter setup   |
348
349 Definition configEVR_SETUP_LEVEL enables setup of recording level filter for events generated by FreeRTOS. Recording level is configured during execution of function \ref EvrFreeRTOSSetup. Default value is \token{1}.
350
351 \code
352 #define configEVR_LEVEL_TASKS
353 #define configEVR_LEVEL_QUEUE
354 #define configEVR_LEVEL_TIMERS
355 #define configEVR_LEVEL_EVENTGROUPS
356 #define configEVR_LEVEL_HEAP
357 #define configEVR_LEVEL_STREAMBUFFER
358 \endcode
359
360 Value  | Description                                       |
361 -------|---------------------------------------------------|
362 0x00   | Disable event generation                          |
363 0x01   | Enable generation of error events                 |
364 0x05   | Enable generation of error and operational events |
365 0x0F   | Enable generation of all events                   |
366
367 Definitions configEVR_LEVEL_x set the recording level bitmask for events generated by each function group. They are taken into account only when recording level filter setup is enabled. Default value is \token{0x05}.
368
369
370 \section dbg_cmsisfreertos Debug a CMSIS-FreeRTOS project
371
372 \note The following only applies when used with <a href="https://www2.keil.com/mdk5" target="_blank">Arm Keil MDK</a>. If
373 you are using a different toolchain, please consult its user's manual.
374
375 Apart from the debug capabilities that \ref cmsis_freertos_evr_config "Event Recorder" offers, Keil MDK also supports thread
376 aware breakpoints, just like for the standard CMSIS-RTOS.
377
378 \b Code \b Example
379
380 \code
381 BS FuncN1, 1, "break = (CURR_TID == tid_phaseA) ? 1 : 0"
382 BS FuncN1, 1, "break = (CURR_TID == tid_phaseA || CURR_TID == tid_phaseD) ? 1 : 0"
383 BS \\Blinky\Blinky.c\FuncN1\179, 1, "break = (CURR_TID == tid_phaseA || CURR_TID == tid_phaseD) ? 1 : 0"
384 \endcode
385
386 \note
387 - For more information on conditional breakpoints in Keil MDK, consult the
388   <a href="https://www.keil.com/support/man/docs/uv4/uv4_db_dbg_breakpnts.htm" target="_blank">user's manual</a>.
389 - Enabling <a href="https://www.keil.com/support/man/docs/uv4/uv4_ui_view.htm" target="_blank">Periodic Window Update</a> is
390   required to capture register values for active running threads while executing. When turned off, only the current FreeRTOS
391   thread can be unwound after execution has been stopped.
392
393 \b Caveats
394
395 - You cannot specify individual breakpoints on the same address. The following is not possible:
396   \code
397   BS ThCallee, 1, "break = (CURR_TID==tid_phaseA) ? 1 : 0"
398   BS ThCallee, 1, "break = (CURR_TID==tid_phaseD) ? 1 : 0"
399   \endcode
400   Instead, use this:
401   \code
402   BS ThCallee, 1, "break= (CURR_TID==tid_phaseA || CURR_TID==tid_phaseD) ? 1 : 0"
403   \endcode
404
405 - If you don't want to use
406 <a href="https://www.keil.com/support/man/docs/uv4/uv4_ui_view.htm" target="_blank">Periodic Window Update</a>, obtain the
407 thread and unwind information by adding a function that gets called from each thread of interest:
408 \code
409 _attribute_((noinline)) int FuncN1 (int n1) {
410   ...
411 }
412 \endcode
413 Then, specify a thread aware breakpoint using an "invalid" thread ID:
414 \code
415 BS FuncN1, 1, "break = (CURR_TID == tid_phaseA + 1) ? 1 : 0"
416 \endcode
417 <tt>'tid_phaseA'</tt> would be valid, <tt>'tid_phaseA + 1'</tt> is not but will still capture the most recent registers and
418 store them to the actual thread context each time a thread aware breakpoint is checked.
419
420 - Function inlining typically causes thread aware breakpoints to fail. To avoid this, prepend the <tt>'noinline'</tt>
421   attribute to the function that is used to stop when the current FreeRTOS thread id matches:
422 \code
423 _attribute_((noinline)) int FuncN1 (int n1) {
424   ...
425 }
426 \endcode
427 This helps to make thread aware breakpoints far less dependent on the compiler optimization level.
428
429 - Thread aware breakpoints should be setup using a
430 <a href="https://www.keil.com/support/man/docs/uv4/uv4_db_scripting.htm" target="_blank">debug script</a>. Reason being
431 that thread aware breakpoints are of a 'hybrid' type, that is a combined address and condition expression that works best
432 when run from a debug script.
433 */
434
435
436 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
437 /**
438 \page examples Example projects
439
440 This pack contains two example projects:
441  - \ref examples_native
442  - \ref examples_cmsis
443
444 The first example shows how to use FreeRTOS standalone, whereas the second example shows how to use the CMSIS-RTOS2 API with
445 an underlying FreeRTOS.
446
447 The examples simulate a step-motor driver. Four phase variables are simulating the activation of the four output driver
448 stages. The state changes are shown in the Watch window variable \c g_phases. All four phases are displayed in the Logic
449 Analyzer:
450
451 \image html blinky_example_simu.png
452
453
454 \section examples_native Blinky example using FreeRTOS natively
455
456 This example shows how to use FreeRTOS natively in a µVision project. This makes your code portable and you can
457 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
458
459 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
460 <b>Native FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
461 where you want to copy the project to and press OK. µVision opens.
462
463
464 \section examples_cmsis Blinky example using CMSIS-FreeRTOS
465
466 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS. This makes your code portable and you can
467 choose to use a different RTOS kernel anytime during development (even only for evaluation purposes).
468
469 To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the
470 <b>CMSIS-RTOS2 FreeRTOS Blinky (uVision Simulator)</b> project on the \b Examples tab. Select the location on your hard drive
471 where you want to copy the project to and press OK. µVision opens.
472
473
474 \section examples_cmsis_a9 Blinky example using CMSIS-FreeRTOS running on Arm Cortex-A9
475
476 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS running on an NXP i.MX6 equipped with an Arm
477 Cortex-A9 code. This example only works in <a href="https://www.keil.com/mdk5/ds-mdk">DS-MDK</a>, the Eclipse-based
478 development environment from Arm. For information on setting up the target connection, please refer to
479 <a href="https://www2.keil.com/mdk5/ds-mdk/imx6sxsabrereference">NXP i.MX 6SoloX SABRE Reference</a>.
480
481 \note you need to have the i.MX6 device family pack installed to see the example in the \b Examples tab of Pack Installer.
482
483 To open the example, open the Pack Installer perspective, select \b NXP in the \b Devices tab, and click on \b Copy next to
484 the <b>CMSIS-RTOS2 FreeRTOS Blinky CA9 (MCIMX6SX-SABRE)</b> project on the \b Examples tab.
485
486 \image html copy_a9_example.png
487
488 Confirm the default location in the Eclipse Workspace by pressing Copy.
489
490 \image html copy_a9_example_ws.png
491
492 Right-click on the project and select \b Build \b Project. Then, right-click on the project and select \b Debug \b As and
493 then \b Debug \b Configurations. The Debug Configurations dialog opens:
494
495 \image html dbg_conf.png
496
497 The project is already set up for running from the SDRAM of the i.MX6 SABRE board. Press \b Debug. DS-MDK will switch to the
498 debug perspective. After a successful connection to the target, press \b F8 to run the application. In the \b App \b Console
499 you will see the output of the phases:
500
501 \image html dbg_output.png
502 */
503
504
505 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
506 /**
507 \page tech_data Technical data and limitations
508
509 This lists the technical data of CMSIS-FreeRTOS.
510
511
512 \section td_limitations Limitations
513
514 The following list briefly describes the limitations and unsupported features of the CMSIS-RTOS2 wrapper for FreeRTOS:
515 - Static memory allocation will only work if \a all memory (from attributes structure) is provided statically. In order to
516   allocate object memory statically, you need to:
517   - provide the memory for control blocks and stack in the \c osThreadAttr_t structure for threads.
518   - provide the memory for control blocks and message data in the \c osMessageQueueAttr_t structure for memory queues.
519   - provide the memory for control blocks for other objects in the object's attributes structure.
520 - Each timer object requires additional 8 bytes of memory:
521   - to allocate all memory statically, provide the memory for control block of size (sizeof(StaticTimer_t) + 8 bytes)
522   - otherwise, additional 8 bytes of dynamic memory will be used
523 - \c osKernelSuspend and \c osKernelResume are not supported.
524 - \c osThreadDetach, \c osThreadJoin() and attribute \c osThreadJoinable are not supported (\c osThreadNew returns NULL when
525   osThreadJoinable attribute is specified).
526 - \c osThreadGetStackSize is not implemented.
527 - Event flags are limited to 24 bits.
528 - \c osEventFlagsGetName is not implemented.
529 - \c osEventFlagsWait cannot be called from an ISR.
530 - Priority inherit protocol is used as default mutex behavior (\c osMutexNew creates priority inherit mutex object by default
531   and ignores \c osMutexPrioInherit attribute when specified).
532 - Robust mutex objects are not supported (\c osMutexNew returns NULL when \c osMutexRobust attribute is specified).
533 - \c osMutexGetName is not implemented and always returns NULL.
534 - \c osSemaphoreGetName is not implemented and always returns NULL.
535 - \c osMessageQueueGetName is not implemented and always returns NULL.
536 - \c osMessageQueuePut and \c osMessageQueueGet always ignore message priority.
537 - <tt>Process Isolation (Functional Safety)</tt> functions are not implemented.
538
539 \section td_validation Validation suite results
540
541 CMSIS provides a
542 <a target="_blank" href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/rtosValidation.html">CMSIS-RTOS2 validation suite</a> that can
543 be used to test a real-time operating system for compliance to the standard. The test suite has been executed successfully on the
544 CMSIS-FreeRTOS implementation (<a href="cmsis_rtos2_validation.txt">see results</a>).
545
546 The following table explains the exceptions:
547
548 <table class="doxtable" summary="Validation Exceptions">
549     <tr>
550       <th>Test Case</th>
551       <th>Result</th>
552       <th>Reason</th>
553       <th>Summary</th>
554     </tr>
555     <tr>
556       <td>TC_osKernelGetState_2</td>
557       <td>not executed</td>
558       <td>unsupported feature</td>
559       <td>
560         Test attempts to call \c osKernelGetState after a \c osKernelSuspend call. osKernelSuspend is not implemented.
561       </td>
562     </tr>
563     <tr>
564       <td>TC_osKernelLock_2</td>
565       <td>not executed</td>
566       <td>unsupported feature</td>
567       <td>
568         Test attempts to call \c osKernelLock after a \c osKernelSuspend call. \c osKernelSuspend is not implemented.
569       </td>
570     </tr>
571     <tr>
572       <td>TC_osKernelUnlock_2</td>
573       <td>not executed</td>
574       <td>unsupported feature</td>
575       <td>
576         Test attempts to call \c osKernelUnlock after a \c osKernelSuspend call. \c osKernelSuspend is not implemented.
577       </td>
578     </tr>
579     <tr>
580       <td>TC_osKernelSuspend_1</td>
581       <td>not executed</td>
582       <td>unsupported feature</td>
583       <td>
584         Test validates \c osKernelSuspend which is not implemented.
585       </td>
586     </tr>
587     <tr>
588       <td>TC_osKernelResume_1</td>
589       <td>not executed</td>
590       <td>unsupported feature</td>
591       <td>
592         Test validates \c osKernelResume which is not implemented.
593       </td>
594     </tr>
595     <tr>
596       <td>TC_osThreadNew_3</td>
597       <td>not executed</td>
598       <td>unsupported feature</td>
599       <td>
600         Test attempts to create joinable thread using \c osThreadJoinable attribute. FreeRTOS does not support joinable threads.
601       </td>
602     </tr>
603     <tr>
604       <td>TC_osThreadGetName_1</td>
605       <td>failed</td>
606       <td>deviation</td>
607       <td>
608         Test attempt to retrieve a name on an unnamed thread. An empty string is returned instead of NULL pointer.
609       </td>
610     </tr>
611     <tr>
612       <td>TC_osThreadGetState_3</td>
613       <td>not executed</td>
614       <td>unsupported feature</td>
615       <td>
616         Test attempts to retrieve a state of a terminated joinable thread. FreeRTOS does not support joinable threads.
617       </td>
618     </tr>
619     <tr>
620       <td>TC_osThreadDetach_1</td>
621       <td>not executed</td>
622       <td>unsupported feature</td>
623       <td>
624         Test validates \c osThreadDetach which is not implemented.
625       </td>
626     </tr>
627     <tr>
628       <td>TC_osThreadDetach_2</td>
629       <td>not executed</td>
630       <td>unsupported feature</td>
631       <td>
632         Test validates \c osThreadDetach which is not implemented.
633       </td>
634     </tr>
635     <tr>
636       <td>TC_osThreadJoin_1</td>
637       <td>not executed</td>
638       <td>unsupported feature</td>
639       <td>
640         Test validates \c osThreadJoin which is not implemented.
641       </td>
642     </tr>
643     <tr>
644       <td>TC_osThreadJoin_2</td>
645       <td>not executed</td>
646       <td>unsupported feature</td>
647       <td>
648         Test validates \c osThreadJoin which is not implemented.
649       </td>
650     </tr>
651     <tr>
652       <td>TC_osThreadJoin_3</td>
653       <td>not executed</td>
654       <td>unsupported feature</td>
655       <td>
656         Test validates \c osThreadJoin which is not implemented.
657       </td>
658     </tr>
659     <tr>
660       <td>TC_osThreadGetStackSize_1</td>
661       <td>not executed</td>
662       <td>unsupported feature</td>
663       <td>
664         Test validates \c osThreadGetStackSize which is not implemented.
665       </td>
666     </tr>
667     <tr>
668       <td>TC_ThreadReturn</td>
669       <td>not executed</td>
670       <td>unsupported feature</td>
671       <td>
672         Test attempts to terminate a thread by just returning from a thread. FreeRTOS threads may not return.
673       </td>
674     </tr>
675     <tr>
676       <td>TC_osEventFlagsSet_1</td>
677       <td>failed</td>
678       <td>deviation</td>
679       <td>
680         Test attempts to set event flags by calling \c osEventFlagsSet multiple times without leaving ISR handler.<br>
681         To process ISR requests, FreeRTOS uses timer deamon which wakes-up after ISR execution.
682       </td>
683     </tr>
684     <tr>
685       <td>TC_osEventFlagsClear_1</td>
686       <td>failed</td>
687       <td>deviation</td>
688       <td>
689         Test attempts to clear event flags by calling \c osEventFlagsClear multiple times without leaving ISR handler.<br>
690         To process ISR requests, FreeRTOS uses timer deamon which wakes-up after ISR execution.
691       </td>
692     </tr>
693     <tr>
694       <td>TC_osEventFlagsWait_1</td>
695       <td>failed</td>
696       <td>unsupported feature</td>
697       <td>
698         Test attempts to wait for flags from ISR with zero timeout (try-semantic). FreeRTOS does not support such operation.
699       </td>
700     </tr>
701     <tr>
702       <td>TC_osEventFlagsGetName_1</td>
703       <td>not executed</td>
704       <td>unsupported feature</td>
705       <td>
706         Test validates \c osEventFlagsGetName which is not implemented.
707       </td>
708     </tr>
709     <tr>
710       <td>TC_osMutexNew_4</td>
711       <td>not executed</td>
712       <td>unsupported feature</td>
713       <td>
714         Test attempts to create a robust mutex. FreeRTOS implementation does not support robust mutexes.
715       </td>
716     </tr>
717     <tr>
718       <td>TC_osMutexGetName_1</td>
719       <td>not executed</td>
720       <td>unsupported feature</td>
721       <td>
722         Test validates \c osMutexGetName which is not implemented.
723       </td>
724     </tr>
725     <tr>
726       <td>TC_MutexRobust</td>
727       <td>not executed</td>
728       <td>unsupported feature</td>
729       <td>
730         Test attempts to validate robust mutex behavior. FreeRTOS implementation does not support robust mutexes.
731       </td>
732     </tr>
733     <tr>
734       <td>TC_MutexOwnership</td>
735       <td>not executed</td>
736       <td>unsupported feature</td>
737       <td>
738         Test attempts to release a mutex from a thread which is not the mutex owner.<br>
739         FreeRTOS implementation does not verify ownership on mutex release.
740       </td>
741     </tr>
742     <tr>
743       <td>TC_osSemaphoreGetName_1</td>
744       <td>not executed</td>
745       <td>unsupported feature</td>
746       <td>
747         Test validates \c osSemaphoreGetName which is not implemented.
748       </td>
749     </tr>
750     <tr>
751       <td>TC_osMessageQueueGetName_1</td>
752       <td>not executed</td>
753       <td>unsupported feature</td>
754       <td>
755         Test validates \c osMessageQueueGetName which is not implemented.
756       </td>
757     </tr>
758 </table>
759
760 \section td_troubleshooting Troubleshooting
761
762 Users looking for help shall check <a href="https://freertos.org/FAQHelp.html">subsection of the full FreeRTOS FAQ</a>.
763 It contains many useful information that also apply when using FreeRTOS in context of CMSIS-FreeRTOS.
764
765 Additionally, please take a look at the following:
766
767 <ol>
768 <li>
769     <b>Interrupts are disabled when main is called or before the kernel is started</b>
770     <br>
771     Before the FreeRTOS kernel is started, threads (i.e. tasks) may be created together with other objects like
772     mutexes, semaphores, message queues etc. When functions like xTaskCreate, xSemaphoreCreateMutex, xQueueCreate and
773     others get called, they prevent interrupt handlers from calling FreeRTOS API functions in order to keep FreeRTOS kernel
774     variables and state machine consistent
775     (see also here <a href="https://freertos.org/FAQHelp.html">Interrupts are not executing</a>).
776     <br>
777     In cases when interrupts may be executed after object creation and before the FreeRTOS kernel is started they can be re-enabled:
778     \code{.c}
779         portENABLE_INTERRUPTS();
780     \endcode
781     Make sure that the interrupts you execute in such case do not call FreeRTOS API.
782 </li>
783 </ol>
784
785 */
786
787
788 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
789 /**
790 \page functionOverview Function Overview
791
792
793 \section rtos_api2 CMSIS-RTOS2 API
794
795 Overview of all CMSIS-RTOS C API v2 functions that are implemented in CMSIS-FreeRTOS.
796
797 Kernel Information and Control
798 ------------------------------
799 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html">API reference</a> for details about Kernel Information and Control functions.
800    - \b osKernelInitialize: supported
801    - \b osKernelGetInfo: supported
802    - \b osKernelGetState: supported
803    - \b osKernelStart: supported
804    - \b osKernelLock: supported
805    - \b osKernelUnlock: supported
806    - \b osKernelRestoreLock: supported
807    - \b osKernelSuspend: \token{not implemented}
808    - \b osKernelResume: \token{not implemented}
809    - \b osKernelProtect: \token{not implemented}
810    - \b osKernelDestroyClass: \token{not implemented}
811    - \b osKernelGetTickCount: supported
812    - \b osKernelGetTickFreq: supported
813    - \b osKernelGetSysTimerCount: supported
814    - \b osKernelGetSysTimerFreq: supported
815
816 Thread Management
817 -----------------
818 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html">API reference</a> for details about Thread Management functions.
819    - \b osThreadNew: supported
820    - \b osThreadGetName: supported
821    - \b osThreadGetClass: \token{not implemented}
822    - \b osThreadGetZone: \token{not implemented}
823    - \b osThreadGetId: supported
824    - \b osThreadGetState: supported
825    - \b osThreadGetStackSize: \token{not implemented}
826    - \b osThreadGetStackSpace: supported
827    - \b osThreadSetPriority: supported
828    - \b osThreadGetPriority: supported
829    - \b osThreadYield: supported
830    - \b osThreadSuspend: supported
831    - \b osThreadResume: supported
832    - \b osThreadDetach: \token{not implemented}
833    - \b osThreadJoin: \token{not implemented}
834    - \b osThreadExit: supported
835    - \b osThreadTerminate: supported
836    - \b osThreadFeedWatchdog: \token{not implemented}
837    - \b osThreadProtectPrivileged: \token{not implemented}
838    - \b osThreadSuspendClass: \token{not implemented}
839    - \b osThreadResumeClass: \token{not implemented}
840    - \b osThreadTerminateZone: \token{not implemented}
841    - \b osThreadGetCount: supported
842    - \b osThreadEnumerate: supported
843
844 Thread Flags
845 ------------
846 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html">API reference</a> for details about Thread Flags functions.
847    - \b osThreadFlagsSet: supported
848    - \b osThreadFlagsClear: supported
849    - \b osThreadFlagsGet: supported
850    - \b osThreadFlagsWait: supported
851
852 Generic Wait Functions
853 ----------------------
854 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__Wait.html">API reference</a> for details about Generic Wait functions.
855    - \b osDelay: supported
856    - \b osDelayUntil: supported
857
858 Timer Management
859 ----------------
860 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html">API reference</a> for details about Timer Management functions.</a>
861    - \b osTimerNew: supported
862    - \b osTimerGetName: supported
863    - \b osTimerStart: supported
864    - \b osTimerStop: supported
865    - \b osTimerIsRunning: supported
866    - \b osTimerDelete: supported
867
868 Event Flags
869 -----------
870 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__EventFlags.html">API reference</a> for details about Event Flags functions.
871 All event flags are limited to 24 bits.
872    - \b osEventFlagsNew: supported
873    - \b osEventFlagsGetName: \token{not implemented}
874    - \b osEventFlagsSet: supported
875    - \b osEventFlagsClear: supported
876    - \b osEventFlagsGet: supported
877    - \b osEventFlagsWait: cannot be called from an ISR.
878    - \b osEventFlagsDelete: supported
879
880 Mutex Management
881 ----------------
882 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html">API reference</a> for details about Mutex Management functions.\n
883 Priority inherit protocol is used as default mutex behavior (osMutexNew creates priority inherit mutex object by default
884 and ignores osMutexPrioInherit attribute when specified).\n
885 Robust mutex objects are not supported (osMutexNew returns NULL when osMutexRobust attribute is specified).\n
886    - \b osMutexNew: supported
887    - \b osMutexGetName: \token{not implemented}
888    - \b osMutexAcquire: supported
889    - \b osMutexRelease: supported
890    - \b osMutexGetOwner: supported
891    - \b osMutexDelete: supported
892
893 Semaphores
894 ----------
895 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__SemaphoreMgmt.html">API reference</a> for details about Semaphore functions.
896    - \b osSemaphoreNew: supported
897    - \b osSemaphoreGetName: \token{not implemented}
898    - \b osSemaphoreAcquire: supported
899    - \b osSemaphoreRelease: supported
900    - \b osSemaphoreGetCount: supported
901    - \b osSemaphoreDelete: supported
902
903 Memory Pool
904 -----------
905 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html">API reference</a> for details about Memory Pool functions.
906    - \b osMemoryPoolNew: supported
907    - \b osMemoryPoolGetName: supported
908    - \b osMemoryPoolAlloc: supported
909    - \b osMemoryPoolFree: supported
910    - \b osMemoryPoolGetCapacity: supported
911    - \b osMemoryPoolGetBlockSize: supported
912    - \b osMemoryPoolGetCount: supported
913    - \b osMemoryPoolGetSpace: supported
914    - \b osMemoryPoolDelete: supported
915
916 Message Queue
917 -------------
918 See <a href="https://arm-software.github.io/CMSIS_6/latest/RTOS2/html/group__CMSIS__RTOS__Message.html">API reference</a> for details about Message Queue functions.
919    - \b osMessageQueueNew: supported
920    - \b osMessageQueueGetName: \token{not implemented}
921    - \b osMessageQueuePut: ignores message priority.
922    - \b osMessageQueueGet: ignores message priority.
923    - \b osMessageQueueGetCapacity: supported
924    - \b osMessageQueueGetMsgSize: supported
925    - \b osMessageQueueGetCount: supported
926    - \b osMessageQueueGetSpace: supported
927    - \b osMessageQueueReset: supported
928    - \b osMessageQueueDelete: supported
929 */
930
931 /* ======================================================================================================================== */
932 // Group creation for Reference
933 /**
934 \addtogroup freertos_specific CMSIS-FreeRTOS Specifics
935 \brief This section describes CMSIS-FreeRTOS specifics.
936 \details
937 CMSIS-FreeRTOS interfaces to the
938 <a href="https://arm-software.github.io/CMSIS-View/latest/evr.html" target="_blank"><b>Event Recorder</b></a>
939 to provide event information which helps you to understand and analyze the operation. Refer to \ref freertos_evr for more
940 information.
941 */