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)
6 This repository contains FreeRTOS kernel source/header files and kernel
7 ports only. This repository is referenced as a submodule in
8 [FreeRTOS/FreeRTOS](https://github.com/FreeRTOS/FreeRTOS)
9 repository, which contains pre-configured demo application projects under
10 ```FreeRTOS/Demo``` directory.
12 The easiest way to use FreeRTOS is to start with one of the pre-configured demo
13 application projects. That way you will have the correct FreeRTOS source files
14 included, and the correct include paths configured. Once a demo application is
15 building and executing you can remove the demo application files, and start to
16 add in your own application source files. See the
17 [FreeRTOS Kernel Quick Start Guide](https://www.FreeRTOS.org/FreeRTOS-quick-start-guide.html)
18 for detailed instructions and other useful links.
20 Additionally, for FreeRTOS kernel feature information refer to the
21 [Developer Documentation](https://www.FreeRTOS.org/features.html),
22 and [API Reference](https://www.FreeRTOS.org/a00106.html).
26 If you have any questions or need assistance troubleshooting your FreeRTOS project,
27 we have an active community that can help on the
28 [FreeRTOS Community Support Forum](https://forums.freertos.org).
30 ## To consume FreeRTOS-Kernel
32 ### Consume with CMake
34 If using CMake, it is recommended to use this repository using FetchContent.
35 Add the following into your project's main or a subdirectory's `CMakeLists.txt`:
37 - Define the source and version/tag you want to use:
40 FetchContent_Declare( freertos_kernel
41 GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git
42 GIT_TAG main #Note: Best practice to use specific git-hash or tagged version
46 In case you prefer to add it as a git submodule, do:
49 git submodule add https://github.com/FreeRTOS/FreeRTOS-Kernel.git <path of the submodule>
50 git submodule update --init
53 - Add a freertos_config library (typically an INTERFACE library) The following assumes the directory structure:
54 - `include/FreeRTOSConfig.h`
57 add_library(freertos_config INTERFACE)
59 target_include_directories(freertos_config SYSTEM
64 target_compile_definitions(freertos_config
70 In case you installed FreeRTOS-Kernel as a submodule, you will have to add it as a subdirectory:
73 add_subdirectory(${FREERTOS_PATH})
76 - Configure the FreeRTOS-Kernel and make it available
77 - this particular example supports a native and cross-compiled build option.
80 set( FREERTOS_HEAP "4" CACHE STRING "" FORCE)
81 # Select the native compile PORT
82 set( FREERTOS_PORT "GCC_POSIX" CACHE STRING "" FORCE)
83 # Select the cross-compile PORT
84 if (CMAKE_CROSSCOMPILING)
85 set(FREERTOS_PORT "GCC_ARM_CA9" CACHE STRING "" FORCE)
88 FetchContent_MakeAvailable(freertos_kernel)
91 - In case of cross compilation, you should also add the following to `freertos_config`:
94 target_compile_definitions(freertos_config INTERFACE ${definitions})
95 target_compile_options(freertos_config INTERFACE ${options})
98 ### Consuming stand-alone - Cloning this repository
100 To clone using HTTPS:
103 git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git
109 git clone git@github.com:FreeRTOS/FreeRTOS-Kernel.git
112 ## Repository structure
114 - The root of this repository contains the three files that are common to
115 every port - list.c, queue.c and tasks.c. The kernel is contained within these
116 three files. croutine.c implements the optional co-routine functionality - which
117 is normally only used on very memory limited systems.
119 - The ```./portable``` directory contains the files that are specific to a particular microcontroller and/or compiler.
120 See the readme file in the ```./portable``` directory for more information.
122 - The ```./include``` directory contains the real time kernel header files.
124 - The ```./sample_configuration``` directory contains a sample `FreeRTOSConfig.h` to help jumpstart a new project.
125 See the [FreeRTOSConfig.h](sample_configuration/FreeRTOSConfig.h) file for instructions.
129 FreeRTOS files are formatted using the
130 "[uncrustify](https://github.com/uncrustify/uncrustify)" tool.
131 The configuration file used by uncrustify can be found in the
132 [FreeRTOS/CI-CD-GitHub-Actions's](https://github.com/FreeRTOS/CI-CD-Github-Actions)
133 [uncrustify.cfg](https://github.com/FreeRTOS/CI-CD-Github-Actions/tree/main/formatting)
138 File checked into the FreeRTOS-Kernel repository use unix-style LF line endings
139 for the best compatibility with git.
141 For optimal compatibility with Microsoft Windows tools, it is best to enable
142 the git autocrlf feature. You can enable this setting for the current
143 repository using the following command:
146 git config core.autocrlf true
149 ### Git History Optimizations
151 Some commits in this repository perform large refactors which touch many lines
152 and lead to unwanted behavior when using the `git blame` command. You can
153 configure git to ignore the list of large refactor commits in this repository
154 with the following command:
157 git config blame.ignoreRevsFile .git-blame-ignore-revs
160 ### Spelling and Formatting
162 We recommend using [Visual Studio Code](https://code.visualstudio.com),
163 commonly referred to as VSCode, when working on the FreeRTOS-Kernel.
164 The FreeRTOS-Kernel also uses [cSpell](https://cspell.org/) as part of its
165 spelling check. The config file for which can be found at [cspell.config.yaml](cspell.config.yaml)
166 There is additionally a
167 [cSpell plugin for VSCode](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
168 that can be used as well.
169 *[.cSpellWords.txt](.github/.cSpellWords.txt)* contains words that are not
170 traditionally found in an English dictionary. It is used by the spellchecker
171 to verify the various jargon, variable names, and other odd words used in the
172 FreeRTOS code base are correct. If your pull request fails to pass the spelling
173 and you believe this is a mistake, then add the word to
174 *[.cSpellWords.txt](.github/.cSpellWords.txt)*. When adding a word please
175 then sort the list, which can be done by running the bash command:
176 `sort -u .cSpellWords.txt -o .cSpellWords.txt`
177 Note that only the FreeRTOS-Kernel Source Files, [include](include),
178 [portable/MemMang](portable/MemMang), and [portable/Common](portable/Common)
179 files are checked for proper spelling, and formatting at this time.