FreeRTOS-Kernel Documentation

repository·main·Indexed 26 days ago

https://github.com/freertos/freertos-kernel

A real-time operating system (RTOS) kernel providing core scheduling, task management, and synchronization primitives. Designed for portability across microcontrollers and architectures, it includes support for Armv8-A (AArch64), Arm Cortex-R82 (including SMP and MPU support), Renesas RH850/F1K and F1Kx, and ARM TF-M for Cortex-M PSA services. The repository provides guidance on MISRA C:2012 compliance checking with Synopsys Coverity, application configuration via FreeRTOSConfig.h, and minimal CMake example projects.

Tokens
11.8K
Snippets
21
Records
85
Agent score
88%

What's inside FreeRTOS-Kernel

  1. Overview of the RP2040 SMP FreeRTOS-Kernel port

    main

    This port provides an Symmetric Multiprocessing (SMP) implementation for the Raspberry Pi Pico SDK.

    Key Features:

    • CMake Support: Provides simple CMake INTERFACE libraries for the FreeRTOS-Kernel and individual allocator types without copying code into the user project.
    • Multi-core Execution: Supports running the FreeRTOS-Kernel and tasks on core 0, core 1, or both.
    • SDK Synchronization: Allows using Raspberry Pi Pico SDK synchronization primitives (e.g., mutexes, semaphores, and queues from pico_sync) to communicate between FreeRTOS tasks and code running on a non-FreeRTOS core or in IRQ handlers.

    Note on Efficiency: While this SMP version can run on a single core, it is more efficient to use the non-SMP version from the main FreeRTOS-Kernel branch if you only intend to use one core.

  2. Identify FreeRTOS Third Party Port Support Levels

    main

    FreeRTOS ports are categorized into three support tiers based on who maintains the code and provides assistance. Use this guide to determine the reliability and support availability of a port before integration:

    1. FreeRTOS Team Supported Ports: High reliability. Code is reviewed by the FreeRTOS team, test results are verified by the team, and bugs/queries are addressed by the FreeRTOS team. These ports are eligible for Long Term Support (LTS) releases.

      • Location: portable/ThirdParty within the main repository.
    2. Partner Supported Ports: Moderate reliability. Code is maintained by a FreeRTOS partner. The FreeRTOS team has not reviewed the code or verified tests, and bugs/queries are addressed by the partner.

      • Location: https://github.com/FreeRTOS/FreeRTOS-Kernel-Partner-Supported-Ports/tree/main
    3. Community Supported Ports: Variable reliability. Maintained by community members. The FreeRTOS team has not reviewed the code, and tests may or may not exist. Bugs/queries are addressed by the community.

      • Location: https://github.com/FreeRTOS/FreeRTOS-Kernel-Community-Supported-Ports/tree/main
  3. Use the ARM_AARCH64 port for Armv8-A architecture

    main
    The ARM_AARCH64 port provides support for the Armv8-A architecture in the AArch64 execution state (using the A64 instruction set). This port is designed as a generic starting point for Armv8-A application processors. It includes a memory-mapped interface to access Arm GIC (Generic Interrupt Controller) registers.
  4. Understand the structure of FreeRTOS kernel ports

    main

    A FreeRTOS real-time kernel port is composed of two main parts:

    1. Common Core Files: Three files that contain core kernel components common to every port.
    2. Port-Specific Files: One or more files specific to a particular microcontroller and/or compiler.

    To find the files relevant to your specific hardware and toolchain, navigate to the FreeRTOS/Source/Portable/[compiler]/[architecture] directory. If you only require a single specific port, you can ignore all other directories in the Portable folder.

  5. Understand FreeRTOS-Kernel Repository Structure

    main

    The repository is organized as follows:

    • Root Directory: Contains core kernel files: list.c, queue.c, and tasks.c. croutine.c is also present for optional co-routine functionality.
    • ./portable: Contains files specific to particular microcontrollers and/or compilers. See the README within this directory for details.
    • ./include: Contains the real-time kernel header files.
    • ./examples/template_configuration: Contains a sample FreeRTOSConfig.h to help start new projects.
  6. Use the ARM TF-M Port for Cortex-M PSA Services

    main

    This port enables FreeRTOS applications to call secure services in Trusted Firmware M (TF-M) via the Platform Security Architecture (PSA) API. It is designed for ARM Cortex-M23, Cortex-M33, Cortex-M52, Cortex-M55, Cortex-M85, and Arm China STAR-MC3 platforms.

    In this architecture, TF-M runs in the Secure Side, while the FreeRTOS Kernel runs in the Non-Secure Side.

  7. Configure RISC-V chip-specific extensions for the FreeRTOS kernel

    main

    The FreeRTOS RISC-V port is divided into common ISA code and chip-specific extensions. To use the port with a specific RISC-V chip, you must include the correct freertos_risc_v_chip_specific_extensions.h header file.

    Crucial Implementation Detail: This header must be included via the assembler's include path, not the compiler's include path.

    For example, if your chip uses a Core Local Interrupter (CLINT) and has no other register extensions, add the following directory to your assembler's include path: FreeRTOS\Source\portable\GCC\RISC-V\chip_specific_extensions\RV32I_CLINT_no_extensions

  8. Start with pre-configured FreeRTOS demos

    main
    The easiest way to begin using FreeRTOS is to use pre-configured demo application projects. These demos are available for multiple platforms and demonstrate the core functionality of the FreeRTOS-Kernel. You can find these in the main FreeRTOS repository under the FreeRTOS/Demo directory.
  9. Consume FreeRTOS-Kernel as a Git Submodule

    main

    To add FreeRTOS-Kernel as a submodule in your project, run the following commands:

    git submodule add https://github.com/FreeRTOS/FreeRTOS-Kernel.git <path of the submodule>
    git submodule update --init

    If using a submodule, you must add it to your CMake project using add_subdirectory(${FREERTOS_PATH}).

  10. Select the correct FreeRTOS port for Renesas RX MCUs

    main

    Use the following compatibility matrix to select the appropriate FreeRTOS port based on your Renesas RX MCU group, CPU core type, and FPU capabilities. The ports are categorized by the compiler/toolchain layer (CC-RX, GNURX, or ICCRX).

    RXv2 Core (Single Precision FPU)

    For MCUs such as RX230, RX231, RX23E-A, RX23W, RX23T, RX24T, RX24U, RX64M, RX65N, RX651, RX71M, and RX72T (if no double precision is required), use the Renesas/RX600v2 (CC-RX), GCC/RX600v2 (GNURX), or IAR/RXv2 (ICCRX) ports.

    RXv3 Core (Single or Double Precision FPU)

    • Double Precision Support: For RX66N, RX72M, and RX72N, use the Renesas/RX700v3_DPFPU, GCC/RX700v3_DPFPU, or IAR/RX700v3_DPFPU ports.
    • Single Precision Only: For RX66T and RX72T, use the Renesas/RX600v2, GCC/RX600v2, or IAR/RXv2 ports.

    RXv1 Core

    • RX110, RX111, RX113, RX130, RX13T: Use Renesas/RX100 or Renesas/RX600 ports depending on FPU requirements.
    • RX62N, RX621, RX630, RX634, RX63N, RX631, RX62T, RX62G: Use Renesas/RX600, GCC/RX600, or IAR/RX600 ports.
  11. Configure FreeRTOS for RH850/F1K and F1Kx

    main

    When configuring this port, adhere to the following hardware and software requirements:

    Interrupt Configuration (SMP only)

    • IPIR Interrupt: For F1KH-D8 with SMP, ensure the bit specifying the destination for binding (requesting) an interrupt is enabled (e.g., the IBDxxx register).
    • Channel/Address: For SMP, Channel 0 and address 0xFFFEEC00 are the default values for configIPIR_CHANNEL and configEXCLUSIVE_ADDRESS. These can be changed if there is a resource conflict.

    Stack Size Calculation

    configMINIMAL_STACK_SIZE must include reserved memory for nested interrupts. Use the following formula:

    (task_context_size) * (2 + configMAX_INT_NESTING) + Stack_depth_of_taskcode

    Where:

    • task_context_size: 144 bytes (if FPU is enabled) or 136 bytes (if FPU is disabled).
    • configMAX_INT_NESTING: Defaults to 02 (Note: a value of 0 is not allowed).

    Timer Prescale Configuration

    configTIMER_PRESCALE must be set to correctly configure the clock for CPUCLK_L based on the hardware option byte (CKDIVMD):

    • If CKDIVMD is 1: set configTIMER_PRESCALE = 4.
    • If CKDIVMD is 0: set configTIMER_PRESCALE = 2.