Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:FreeRTOS

From ReverseEngineering.wiki
Library
On this wiki Facts · Code · Notes · Topics

The most common RTOS in microcontroller firmware (MIT): identified by the idle task name "IDLE" and the timer task name "Tmr Svc" (the kernel version string is only a macro in task.h that the code never references, so it is not in a firmware), and a task control block whose first field is the stack top pointer.

Identification

The kernel header defines tskKERNEL_VERSION_NUMBER as a string such as "V11.1.0+" (task.h line 57 at the pinned commit; a trailing + means a development version). Firmware often carries it as text (vTaskList, trace tools) but it is not always linked in. Reliable runtime strings: the idle task is created with the name "IDLE" (tasks.c, configIDLE_TASK_NAME) and the timer service task "Tmr Svc" (timers.c); a list of task names near these two in RAM/flash strongly suggests FreeRTOS. ESP-IDF builds use FreeRTOS (an SMP fork), where idle tasks are named "IDLE0"/"IDLE1" (read in ESP-IDF's copy of the kernel, components/freertos/FreeRTOS-Kernel/tasks.c at espressif/esp-idf commit 1c42e514c90ae621af33bde3b6ad3dac22edcbfd, lines 2288-2331: when configNUMBER_OF_CORES > 1 the kernel copies configIDLE_TASK_NAME ("IDLE") into cIdleName and appends the core number as a digit, cIdleName[idx] = (char)(xCoreID + '0'), so a dual-core build has "IDLE0" and "IDLE1"; single-core builds keep "IDLE").

Task control block (TCB)

In tasks.c (typedef tskTaskControlBlock) the first member is pxTopOfStack, which must stay first for debuggers; then (optionally) MPU settings, xStateListItem, xEventListItem, uxPriority, pxStack, and pcTaskName[configMAX_TASK_NAME_LEN] (default 16). Later members depend on config options (mutex priority fields, run-time counters, notifications). Exact offsets therefore depend on the build's FreeRTOSConfig.h; infer them from a pcTaskName string and the list-item pointers. Kernel-aware debuggers use this layout.

Lists

xStateListItem links the TCB into pxReadyTasksLists[priority], delayed lists or the suspended list (list.c). ListItem_t (struct xLIST_ITEM, include/list.h lines 144-154, FreeRTOS-Kernel commit 640d0c4370) is xItemValue (a TickType_t), pxNext, pxPrevious, pvOwner, pxContainer; when configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is 1 a known value is added before the first and after the last field. pvOwner points back to the TCB: prvInitialiseNewTask in tasks.c calls listSET_LIST_ITEM_OWNER( &( pxNewTCB->xStateListItem ), pxNewTCB ) (line 1926) and the same for xEventListItem (line 1930).

Cortex-M port

Ports use SVCall (first task start), PendSV (context switch) and SysTick (tick): check handler names/addresses in the Platform:ARM Cortex-M vector table; vPortSVCHandler, xPortPendSVHandler and xPortSysTickHandler are the usual names in the portable layer.

Code & repositories

  • https://github.com/FreeRTOS/FreeRTOS-Kernel @ 640d0c43705e64cd53f46b31d882de6cd8433933 · license: MIT
    FreeRTOS kernel source: TCB in tasks.c, version define in task.h.
    Tested on: source read, not run: read · checked 2026-10-18; last activity 2026-10-16; Note: the latest release ships binaries; the wiki links only the source, never the binaries

See also

Library:Zephyr