FreeRTOS Usage Guidelines

Configuration

The SDK supplies a pre-defined configuration under ${SDK_INSTALL_PATH}/ti_sdk_config/{{TI_SDK_DEVICE}}/<config>/freertos_cfg/<cpu>/:

  • FreeRTOSConfig.h selects kernel features and compile-time CPU-port settings

  • port_cfg.c supplies application hooks, memory for kernel-created tasks, and device-dependent integration

These two files serves as the application customization boundary. Device dependencies and application choices are kept here rather than changing the reusable CPU port under source/kernel/freertos/portable/.

  • cfg_freertos.cmake compiles port_cfg.c into the SDK configuration target and publishes the directory containing FreeRTOSConfig.h.

  • The freertos_<config> library builds the kernel and selected CPU/compiler port against that configuration.

To customize the integration:

  1. Start with the selected device’s default configuration and the correct CPU’s freertos_cfg directory.

  2. Modify FreeRTOSConfig.h for kernel and port settings, and port_cfg.c for callbacks and device-specific behavior.

  3. Rebuild the affected configuration, kernel, and dependent application libraries. See SDK build options for SDK configuration and build selection.

The following sections describes SDK integration choices. For definitions, valid ranges, and dependencies of standard upstream config... options, refer the FreeRTOS configuration reference.

Latency and Diagnostics

portOPTIMIZE_FOR_LATENCY is a TI SDK policy switch in FreeRTOSConfig.h (Default: disabled in debug mode build and enabled in release mode build).

It is not an upstream FreeRTOS configuration option. Edit this policy if your application needs diagnostics in a release build or lower-overhead operation in a debug build.

Setting

portOPTIMIZE_FOR_LATENCY = 0

portOPTIMIZE_FOR_LATENCY = 1

configCHECK_FOR_STACK_OVERFLOW

2, stack-pattern checking

0, disabled

configGENERATE_RUN_TIME_STATS

1

0

configUSE_TRACE_FACILITY

1

0

configASSERT

Evaluates the condition and stops on failure

Disabled

A failure hook that only calls configASSERT(0) will not stop execution when assertions are disabled. Implement explicit application fault handling when that behavior is required in optimized builds.

Setting

portOPTIMIZE_FOR_LATENCY = 0

portOPTIMIZE_FOR_LATENCY = 1

configCHECK_HANDLER_INSTALLATION (M33)

1, enabled

0, disabled

Ensure the startup vector table routes SVC and PendSV to the selected port handlers even when this check is disabled.

Integration With the Portable Layer

The portable layer implements context save/restore, critical sections, scheduler startup, and tick processing. It includes FreeRTOSConfig.h through the FreeRTOS headers, and calls the integration functions selected by that configuration. The kernel also calls the standard application hooks implemented in port_cfg.c. Supply exactly one implementation of each enabled hook; these default definitions are not weak overrides.

Application Hooks and Kernel Task Memory

Function in port_cfg.c

When Used

User Customization

vApplicationGetIdleTaskMemory()

Static allocation enabled

Idle task TCB, stack address, and stack depth

vApplicationGetTimerTaskMemory()

Static allocation and timers enabled

Timer task TCB, stack, and stack depth

vApplicationStackOverflowHook()

Stack-overflow checking enabled

Capture task identity and handle a fatal fault

vApplicationMallocFailedHook()

Allocation failure hook enabled

Report or recover from heap exhaustion

vPortConfigureTimerForRunTimeStats()

Run-time statistics initialization

Initialize a replacement statistics source

ullPortRunTimeCounterValueToUsec()

SDK counter-to-time conversion

Convert the selected counter frequency to microseconds

Run-Time Counter Hooks

configRUN_TIME_COUNTER_TYPE is set to uint64_t.

The configuration maps portCONFIGURE_TIMER_FOR_RUN_TIME_STATS to vPortConfigureTimerForRunTimeStats() and portGET_RUN_TIME_COUNTER_VALUE to ullPortGetRunTimeCounterValue().

portRUN_TIME_COUNTER_TO_USEC(value) is the SDK conversion macro, mapped to ullPortRunTimeCounterValueToUsec().

The shipped statistics setup hook does nothing because the tick source already supplies the counter.

To use a different timer, customize the configuration mapping and hook implementation together.

  • The counter must advance monotonically, be safe to read in scheduler/interrupt contexts, and keep the frequency used by the conversion function as well in sync.

  • Do not perform logging, allocation, or blocking operations in a counter-read hook.

On M33, ullPortGetRunTimeCounterValue() in port_cfg.c combines the kernel tick count with the current SysTick down-counter and handles a pending rollover.

The conversion uses configSYSTICK_CLOCK_HZ, falling back to configCPU_CLOCK_HZ. Its arithmetic assumes the clock is a multiple of 1 kHz.

If changing the tick source, also replace this reader; it must not continue sampling SysTick after another timer becomes the tick source.

The current reader and upstream tickless handling both access SysTick state; review that interaction before enabling tickless idle.

CPU-Specific Configurations Summary

M33 Configuration

Setting

SDK Integration

Customization Constraint

configCPU_CLOCK_HZ

ARCH_CPU_CFG_FREQ_HZ

Keep architecture clock configuration consistent with hardware

configSYSTICK_CLOCK_HZ

Defaults to CPU clock when not defined

Update statistics conversion if using another SysTick clock

configPRIO_BITS

CMSIS __NVIC_PRIO_BITS, otherwise 4

Must match the implemented NVIC priority bits

configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY

Unshifted priority 1U

Priority 0 interrupts must not call FreeRTOS APIs

configLIBRARY_LOWEST_INTERRUPT_PRIORITY

Lowest implemented NVIC priority

Kernel exception priority is derived from this value

configMAX_SYSCALL_INTERRUPT_PRIORITY

Shifted NVIC threshold

Use unshifted values for SDK interrupt-priority APIs

configENABLE_FPU

1

Match compiler floating-point ABI and enabled CPU FPU

configENABLE_TRUSTZONE

0

NTZ port; do not enable TrustZone task support by changing this alone

configRUN_FREERTOS_SECURE_ONLY

1

Use the selected NTZ execution model consistently

  • The port programs SysTick for configTICK_RATE_HZ. Check the reload fits the 24-bit SysTick counter after changing clock or tick frequency.

  • SysTick, SVC, and PendSV are kernel resources; do not replace their handlers with unrelated application handlers.

    • Check the selected compiler port’s handler names and the SDK startup vector table.

  • BASEPRI masks interrupts at and below the permitted syscall urgency.

    • Numerically smaller NVIC priorities have higher urgency.

    • Interrupts above the syscall threshold remain responsive but must not call FreeRTOS APIs, even the FromISR APIs.