FreeRTOS-SMP Kernel is still being tested.
This page documents demos that use the FreeRTOS symmetric multiprocessing (SMP) version. The demos target the Raspberry Pi Pico board, which uses the RP2040 microcontroller from Raspberry Pi featuring a Dual-core ARM Cortex M0+ processor.
These demo applications use the GNU ARM Embedded Toolchain to build the FreeRTOS Raspberry Pi Pico port. They demonstrate support for Symmetric Multiprocessing (SMP) in the FreeRTOS Kernel.
Please read all the following points before using this RTOS port.
- Source Code Organization
- The Demo Applications
- Building and Running the RTOS Demo Applications
- RTOS Configuration and Usage Details
Also see the FAQ My application does not run, what could be wrong?
The project files for this demo are located in the FreeRTOS/Demo/CORTEX_M0+_RP2040
directory of the FreeRTOS SMP Demo Git repository.
FreeRTOS Port files compiled in the project are in the
FreeRTOS/Source/portable/ThirdParty/GCC/RP2040
directory.
The project includes the following demos:
- Blinky Demo.
- Comprehensive Demo.
- Multicore Demo.
The blinky demo uses two tasks and one queue.
-
The Queue Send Task:
The queue send task is implemented by the
prvQueueSendTask()
function. The task sits in a loop and sends the value 100 to the queue every 1000 milliseconds (1 second). -
The Queue Receive Task:
The queue receive task is implemented by the
prvQueueReceiveTask()
function. The task sits in a loop that blocks on attempts to read from the queue (no CPU cycles are consumed while the task is blocked), and toggles an LED each time the value 100 is received from the queue send task. As the queue send task writes to the queue every 1000 milliseconds, the queue receive task unblocks and toggles the LED every 1000 milliseconds.
The comprehensive demo implements a comprehensive test and demo application that, among other things, demonstrates and/or tests:
- Message buffers
- Stream buffers
- Task notifications
- Queues
- Semaphores
- Mutexes
- Event groups
- Software timers
The created tasks are from the set of standard demo tasks that are used by all FreeRTOS port demo applications. They have no specific functionality, but are created just to demonstrate how to use the FreeRTOS API, and test the RTOS port.
A "check" task is created that periodically inspects the standard demo tasks (which contain self monitoring code) to ensure all the tasks are functioning as expected. The check task toggles the LED each time it executes. This gives visual feedback of the system health. If the LED is toggling every 3 seconds, then the check task has not discovered any problems. If the LED is toggling every 200 milliseconds, then the check task has discovered a problem in one or more tasks.
The multicore demo application runs FreeRTOS tasks on one core which interacts with the code running on the other core using Raspberry Pico SDK synchronization primitives. There are two versions of the same demo - One version runs FreeRTOS on core 0, the other runs FreeRTOS on core 1.
- Setup the Raspberry Pi Pico SDK build environment by following the instructions for
Getting Started With Pico.
Ensure that
PICO_SDK_PATH
is set in your environment, or pass it via-DPICO_SDK_PATH=xxx
on the CMake command line. - Run the following commands:
$ cd FreeRTOS/Demo/CORTEX_M0+_RP2040
$ mkdir build
$ cd build
$ cmake ..
$ make
This will generate .uf2
files for each demo application:
- Blinky Demo -
FreeRTOS/Demo/CORTEX_M0+_RP2040/build/Standard/main_blinky.uf2
. - Comprehensive Demo -
FreeRTOS/Demo/CORTEX_M0+_RP2040/build/Standard/main_full.uf2
- Multicore Demo
FreeRTOS/Demo/CORTEX_M0+_RP2040/build/OnEitherCore/on_core_zero.uf2
FreeRTOS/Demo/CORTEX_M0+_RP2040/build/OnEitherCore/on_core_one.uf2
- Connect the Raspberry Pi Pico to your computer while holding the
BOOTSEL
button. This will force the board into USB Mass Storage Mode. - Drag-and-drop the
.uf2
file for the demo you want to run onto the Mass Storage Device.
- Configuration items specific to the blinky and comprehensive demos are contained in
FreeRTOS/Demo/CORTEX_M0+_RP2040/Standard/FreeRTOSConfig.h
and those specific to the multicore demo are contained inFreeRTOS/Demo/CORTEX_M0+_RP2040/OnEitherCore/FreeRTOSConfig.h
. The constants defined in these files can be edited to suit your application. The following configuration options are specific to the SMP support in the FreeRTOS Kernel:configNUM_CORES
- Set the number of cores.configRUN_MULTIPLE_PRIORITIES
- Enable/Disable simultaneously running tasks with multiple priorities.configUSE_CORE_AFFINITY
- Enable/Disable setting a task's affinity to certain cores.
Source/Portable/MemMang/heap_4.c
is included in the project to provide the memory allocation required by the RTOS kernel. Please refer to the Memory Management section of the API documentation for complete information.- vPortEndScheduler() has not been implemented.