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.hselects kernel features and compile-time CPU-port settingsport_cfg.csupplies 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.cmakecompilesport_cfg.cinto the SDK configuration target and publishes the directory containingFreeRTOSConfig.h.The
freertos_<config>library builds the kernel and selected CPU/compiler port against that configuration.
To customize the integration:
Start with the selected device’s
defaultconfiguration and the correct CPU’sfreertos_cfgdirectory.Modify
FreeRTOSConfig.hfor kernel and port settings, andport_cfg.cfor callbacks and device-specific behavior.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 |
|
|
|---|---|---|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|---|---|---|
|
|
|
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 |
When Used |
User Customization |
|---|---|---|
|
Static allocation enabled |
Idle task TCB, stack address, and stack depth |
|
Static allocation and timers enabled |
Timer task TCB, stack, and stack depth |
|
Stack-overflow checking enabled |
Capture task identity and handle a fatal fault |
|
Allocation failure hook enabled |
Report or recover from heap exhaustion |
|
Run-time statistics initialization |
Initialize a replacement statistics source |
|
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 |
|---|---|---|
|
|
Keep architecture clock configuration consistent with hardware |
|
Defaults to CPU clock when not defined |
Update statistics conversion if using another SysTick clock |
|
CMSIS |
Must match the implemented NVIC priority bits |
|
Unshifted priority |
Priority 0 interrupts must not call FreeRTOS APIs |
|
Lowest implemented NVIC priority |
Kernel exception priority is derived from this value |
|
Shifted NVIC threshold |
Use unshifted values for SDK interrupt-priority APIs |
|
|
Match compiler floating-point ABI and enabled CPU FPU |
|
|
NTZ port; do not enable TrustZone task support by changing this alone |
|
|
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
FromISRAPIs.