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)
4 This repository contains FreeRTOS kernel source/header files and kernel
5 ports only. This repository is referenced as a submodule in
6 [FreeRTOS/FreeRTOS](https://github.com/FreeRTOS/FreeRTOS)
7 repository, which contains pre-configured demo application projects under
8 ```FreeRTOS/Demo``` directory.
10 The easiest way to use FreeRTOS is to start with one of the pre-configured demo
11 application projects. That way you will have the correct FreeRTOS source files
12 included, and the correct include paths configured. Once a demo application is
13 building and executing you can remove the demo application files, and start to
14 add in your own application source files. See the
15 [FreeRTOS Kernel Quick Start Guide](https://www.FreeRTOS.org/FreeRTOS-quick-start-guide.html)
16 for detailed instructions and other useful links.
18 Additionally, for FreeRTOS kernel feature information refer to the
19 [Developer Documentation](https://www.FreeRTOS.org/features.html),
20 and [API Reference](https://www.FreeRTOS.org/a00106.html).
23 If you have any questions or need assistance troubleshooting your FreeRTOS project,
24 we have an active community that can help on the
25 [FreeRTOS Community Support Forum](https://forums.freertos.org).
27 ## To consume FreeRTOS-Kernel
29 ### Consume with CMake
30 If using CMake, it is recommended to use this repository using FetchContent.
31 Add the following into your project's main or a subdirectory's `CMakeLists.txt`:
33 - Define the source and version/tag you want to use:
36 FetchContent_Declare( freertos_kernel
37 GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git
38 GIT_TAG main #Note: Best practice to use specific git-hash or tagged version
42 In case you prefer to add it as a git submodule, do:
45 $ git submodule add https://github.com/FreeRTOS/FreeRTOS-Kernel.git <path of the submodule>
46 $ git submodule update --init
49 - Add a freertos_config library (typically an INTERFACE library) The following assumes the directory structure:
50 - `include/FreeRTOSConfig.h`
52 add_library(freertos_config INTERFACE)
54 target_include_directories(freertos_config SYSTEM
59 target_compile_definitions(freertos_config
65 In case you installed FreeRTOS-Kernel as a submodule, you will have to add it as a subdirectory:
68 add_subdirectory(${FREERTOS_PATH})
71 - Configure the FreeRTOS-Kernel and make it available
72 - this particular example supports a native and cross-compiled build option.
75 set( FREERTOS_HEAP "4" CACHE STRING "" FORCE)
76 # Select the native compile PORT
77 set( FREERTOS_PORT "GCC_POSIX" CACHE STRING "" FORCE)
78 # Select the cross-compile PORT
79 if (CMAKE_CROSSCOMPILING)
80 set(FREERTOS_PORT "GCC_ARM_CA9" CACHE STRING "" FORCE)
83 FetchContent_MakeAvailable(freertos_kernel)
86 - In case of cross compilation, you should also add the following to `freertos_config`:
89 target_compile_definitions(freertos_config INTERFACE ${definitions})
90 target_compile_options(freertos_config INTERFACE ${options})
93 ### Consuming stand-alone - Cloning this repository
97 git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git
101 git clone git@github.com:FreeRTOS/FreeRTOS-Kernel.git
104 ## Repository structure
105 - The root of this repository contains the three files that are common to
106 every port - list.c, queue.c and tasks.c. The kernel is contained within these
107 three files. croutine.c implements the optional co-routine functionality - which
108 is normally only used on very memory limited systems.
110 - The ```./portable``` directory contains the files that are specific to a particular microcontroller and/or compiler.
111 See the readme file in the ```./portable``` directory for more information.
113 - The ```./include``` directory contains the real time kernel header files.
116 FreeRTOS files are formatted using the
117 "[uncrustify](https://github.com/uncrustify/uncrustify)" tool.
118 The configuration file used by uncrustify can be found in the
119 [FreeRTOS/CI-CD-GitHub-Actions's](https://github.com/FreeRTOS/CI-CD-Github-Actions)
120 [uncrustify.cfg](https://github.com/FreeRTOS/CI-CD-Github-Actions/tree/main/formatting)
124 File checked into the FreeRTOS-Kernel repository use unix-style LF line endings
125 for the best compatibility with git.
127 For optimal compatibility with Microsoft Windows tools, it is best to enable
128 the git autocrlf feature. You can enable this setting for the current
129 repository using the following command:
131 git config core.autocrlf true
134 ### Git History Optimizations
135 Some commits in this repository perform large refactors which touch many lines
136 and lead to unwanted behavior when using the `git blame` command. You can
137 configure git to ignore the list of large refactor commits in this repository
138 with the following command:
140 git config blame.ignoreRevsFile .git-blame-ignore-revs
143 ### Spelling and Formatting
144 We recommend using [Visual Studio Code](https://code.visualstudio.com),
145 commonly referred to as VSCode, when working on the FreeRTOS-Kernel.
146 The FreeRTOS-Kernel also uses [cSpell](https://cspell.org/) as part of its
147 spelling check. The config file for which can be found at [cspell.config.yaml](cspell.config.yaml)
148 There is additionally a
149 [cSpell plugin for VSCode](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
150 that can be used as well.
151 *[.cSpellWords.txt](.github/.cSpellWords.txt)* contains words that are not
152 traditionally found in an English dictionary. It is used by the spellchecker
153 to verify the various jargon, variable names, and other odd words used in the
154 FreeRTOS code base are correct. If your pull request fails to pass the spelling
155 and you believe this is a mistake, then add the word to
156 *[.cSpellWords.txt](.github/.cSpellWords.txt)*. When adding a word please
157 then sort the list, which can be done by running the bash command:
158 `sort -u .cSpellWords.txt -o .cSpellWords.txt`
159 Note that only the FreeRTOS-Kernel Source Files, [include](include),
160 [portable/MemMang](portable/MemMang), and [portable/Common](portable/Common)
161 files are checked for proper spelling, and formatting at this time.