README.md
1[](https://github.com/FreeRTOS/FreeRTOS-Kernel/actions/workflows/unit-tests.yml?query=branch%3Amain+event%3Apush+workflow%3A%22CMock+Unit+Tests%22++)
2[](https://codecov.io/gh/FreeRTOS/FreeRTOS-Kernel)
3
4## Getting started
5
6This repository contains FreeRTOS kernel source/header files and kernel
7ports only. This repository is referenced as a submodule in
8[FreeRTOS/FreeRTOS](https://github.com/FreeRTOS/FreeRTOS)
9repository, which contains pre-configured demo application projects under
10```FreeRTOS/Demo``` directory.
11
12The easiest way to use FreeRTOS is to start with one of the pre-configured demo
13application projects. That way you will have the correct FreeRTOS source files
14included, and the correct include paths configured. Once a demo application is
15building and executing you can remove the demo application files, and start to
16add in your own application source files. See the
17[FreeRTOS Kernel Quick Start Guide](https://www.freertos.org/Documentation/01-FreeRTOS-quick-start/01-Beginners-guide/02-Quick-start-guide)
18for detailed instructions and other useful links.
19
20Additionally, for FreeRTOS kernel feature information refer to the
21[Developer Documentation](https://www.freertos.org/Documentation/02-Kernel/02-Kernel-features/00-Developer-docs),
22and [API Reference](https://www.freertos.org/Documentation/02-Kernel/04-API-references/01-Task-creation/00-TaskHandle).
23
24Also for contributing and creating a Pull Request please refer to
25[the instructions here](.github/CONTRIBUTING.md#contributing-via-pull-request).
26
27**FreeRTOS-Kernel V11.1.0
28[source code](https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/V11.1.0) is part
29of the
30[FreeRTOS 202406.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202406-LTS)
31release.**
32
33### Getting help
34
35If you have any questions or need assistance troubleshooting your FreeRTOS project,
36we have an active community that can help on the
37[FreeRTOS Community Support Forum](https://forums.freertos.org).
38
39## To consume FreeRTOS-Kernel
40
41### Consume with CMake
42
43If using CMake, it is recommended to use this repository using FetchContent.
44Add the following into your project's main or a subdirectory's `CMakeLists.txt`:
45
46- Define the source and version/tag you want to use:
47
48```cmake
49FetchContent_Declare( freertos_kernel
50 GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git
51 GIT_TAG main #Note: Best practice to use specific git-hash or tagged version
52)
53```
54
55In case you prefer to add it as a git submodule, do:
56
57```bash
58git submodule add https://github.com/FreeRTOS/FreeRTOS-Kernel.git <path of the submodule>
59git submodule update --init
60```
61
62- Add a freertos_config library (typically an INTERFACE library) The following assumes the directory structure:
63 - `include/FreeRTOSConfig.h`
64
65```cmake
66add_library(freertos_config INTERFACE)
67
68target_include_directories(freertos_config SYSTEM
69INTERFACE
70 include
71)
72
73target_compile_definitions(freertos_config
74 INTERFACE
75 projCOVERAGE_TEST=0
76)
77```
78
79In case you installed FreeRTOS-Kernel as a submodule, you will have to add it as a subdirectory:
80
81```cmake
82add_subdirectory(${FREERTOS_PATH})
83```
84
85- Configure the FreeRTOS-Kernel and make it available
86 - this particular example supports a native and cross-compiled build option.
87
88```cmake
89set( FREERTOS_HEAP "4" CACHE STRING "" FORCE)
90# Select the native compile PORT
91set( FREERTOS_PORT "GCC_POSIX" CACHE STRING "" FORCE)
92# Select the cross-compile PORT
93if (CMAKE_CROSSCOMPILING)
94 set(FREERTOS_PORT "GCC_ARM_CA9" CACHE STRING "" FORCE)
95endif()
96
97FetchContent_MakeAvailable(freertos_kernel)
98```
99
100- In case of cross compilation, you should also add the following to `freertos_config`:
101
102```cmake
103target_compile_definitions(freertos_config INTERFACE ${definitions})
104target_compile_options(freertos_config INTERFACE ${options})
105```
106
107### Consuming stand-alone - Cloning this repository
108
109To clone using HTTPS:
110
111```
112git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git
113```
114
115Using SSH:
116
117```
118git clone git@github.com:FreeRTOS/FreeRTOS-Kernel.git
119```
120
121## Repository structure
122
123- The root of this repository contains the three files that are common to
124every port - list.c, queue.c and tasks.c. The kernel is contained within these
125three files. croutine.c implements the optional co-routine functionality - which
126is normally only used on very memory limited systems.
127
128- The ```./portable``` directory contains the files that are specific to a particular microcontroller and/or compiler.
129See the readme file in the ```./portable``` directory for more information.
130
131- The ```./include``` directory contains the real time kernel header files.
132
133- The ```./template_configuration``` directory contains a sample `FreeRTOSConfig.h` to help jumpstart a new project.
134See the [FreeRTOSConfig.h](examples/template_configuration/FreeRTOSConfig.h) file for instructions.
135
136### Code Formatting
137
138FreeRTOS files are formatted using the
139"[uncrustify](https://github.com/uncrustify/uncrustify)" tool.
140The configuration file used by uncrustify can be found in the
141[FreeRTOS/CI-CD-GitHub-Actions's](https://github.com/FreeRTOS/CI-CD-Github-Actions)
142[uncrustify.cfg](https://github.com/FreeRTOS/CI-CD-Github-Actions/tree/main/formatting)
143file.
144
145### Line Endings
146
147File checked into the FreeRTOS-Kernel repository use unix-style LF line endings
148for the best compatibility with git.
149
150For optimal compatibility with Microsoft Windows tools, it is best to enable
151the git autocrlf feature. You can enable this setting for the current
152repository using the following command:
153
154```
155git config core.autocrlf true
156```
157
158### Git History Optimizations
159
160Some commits in this repository perform large refactors which touch many lines
161and lead to unwanted behavior when using the `git blame` command. You can
162configure git to ignore the list of large refactor commits in this repository
163with the following command:
164
165```
166git config blame.ignoreRevsFile .git-blame-ignore-revs
167```
168
169### Spelling and Formatting
170
171We recommend using [Visual Studio Code](https://code.visualstudio.com),
172commonly referred to as VSCode, when working on the FreeRTOS-Kernel.
173The FreeRTOS-Kernel also uses [cSpell](https://cspell.org/) as part of its
174spelling check. The config file for which can be found at [cspell.config.yaml](cspell.config.yaml)
175There is additionally a
176[cSpell plugin for VSCode](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
177that can be used as well.
178*[.cSpellWords.txt](.github/.cSpellWords.txt)* contains words that are not
179traditionally found in an English dictionary. It is used by the spellchecker
180to verify the various jargon, variable names, and other odd words used in the
181FreeRTOS code base are correct. If your pull request fails to pass the spelling
182and you believe this is a mistake, then add the word to
183*[.cSpellWords.txt](.github/.cSpellWords.txt)*. When adding a word please
184then sort the list, which can be done by running the bash command:
185`sort -u .cSpellWords.txt -o .cSpellWords.txt`
186Note that only the FreeRTOS-Kernel Source Files, [include](include),
187[portable/MemMang](portable/MemMang), and [portable/Common](portable/Common)
188files are checked for proper spelling, and formatting at this time.
189
190## Third Party Tools
191Visit [this link](.github/third_party_tools.md) for detailed information about
192third-party tools with FreeRTOS support.
193