]> begriffs open source - freertos/blob - examples/coverity/README.md
FreeRTOS MPU: Remove MPU region number check (#1261)
[freertos] / examples / coverity / README.md
1 # MISRA Compliance for FreeRTOS-Kernel
2 FreeRTOS-Kernel is MISRA C:2012 compliant. This directory contains a project to
3 run [Synopsys Coverity](https://www.blackduck.com/static-analysis-tools-sast/coverity.html)
4 for checking MISRA compliance.
5
6 > **Note**
7 Coverity version 2023.6.1 incorrectly infers the type of `pdTRUE` and `pdFALSE`
8 as boolean because of their names, resulting in multiple false positive warnings
9 about type mismatch. We replace `pdTRUE` with `pdPASS` and `pdFALSE` with
10 `pdFAIL` to avoid these false positive warnings. This workaround will not be
11 needed after Coverity fixes the issue of incorrectly inferring the type of
12 `pdTRUE` and `pdFALSE` as boolean.
13
14 Deviations from the MISRA C:2012 guidelines are documented in
15 [MISRA.md](../../MISRA.md) and [coverity_misra.config](coverity_misra.config)
16 files.
17
18 ## Getting Started
19 ### Prerequisites
20 Coverity can be run on any platform mentioned [here](https://documentation.blackduck.com/bundle/coverity-docs/page/deploy-install-guide/topics/supported_platforms_for_coverity_analysis.html).
21 The following are the prerequisites to generate coverity report:
22
23 1. CMake version > 3.13.0 (You can check whether you have this by typing `cmake --version`).
24 2. GCC compiler.
25     - See download and installation instructions [here](https://gcc.gnu.org/install/).
26 3. Clone the repo using the following command:
27     - `git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git ./FreeRTOS-Kernel`
28
29 ### Generating Report
30 Go to the root directory of the FreeRTOS-Kernel repo and run the following
31 commands in a terminal:
32 1. Update the compiler configuration in Coverity:
33   ~~~
34   cov-configure --force --compiler cc --comptype gcc
35   ~~~
36 2. Create the build files using CMake in a `build` directory:
37
38 Single core FreeRTOS:
39   ~~~
40   cmake -B build -S examples/coverity
41   ~~~
42
43 SMP FreeRTOS:
44   ~~~
45   cmake -B build -S examples/coverity -DFREERTOS_SMP_EXAMPLE=1
46   ~~~
47 3. Build the (pseudo) application:
48   ~~~
49   cd build/
50   cov-build --emit-complementary-info --dir cov-out make coverity
51   ~~~
52 4. Go to the Coverity output directory (`cov-out`) and begin Coverity static
53    analysis:
54   ~~~
55   cov-analyze --dir ./cov-out \
56     --coding-standard-config ../examples/coverity/coverity_misra.config \
57     --tu-pattern "file('[A-Za-z_]+\.c') && ( ! file('main.c') ) && ( ! file('port.c') )"
58   ~~~
59 5. Generate the HTML report:
60   ~~~
61   cov-format-errors --dir ./cov-out --html-output html-output
62   ~~~
63
64 HTML report should now be generated in a directory named `html-output`.