Skip to content

Latest commit

 

History

History
137 lines (111 loc) · 6.53 KB

File metadata and controls

137 lines (111 loc) · 6.53 KB

FreeRTOS SMP Demos for Raspberry Pi Pico Board

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.


IMPORTANT! Notes on using the FreeRTOS Raspberry Pi Pico demo applications

Please read all the following points before using this RTOS port.

  1. Source Code Organization
  2. The Demo Applications
  3. Building and Running the RTOS Demo Applications
  4. RTOS Configuration and Usage Details

Also see the FAQ My application does not run, what could be wrong?


Source Code Organization

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 Demo Applications

The project includes the following demos:

  1. Blinky Demo.
  2. Comprehensive Demo.
  3. Multicore Demo.

Blinky 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.

Comprehensive Demo

The comprehensive demo implements a comprehensive test and demo application that, among other things, demonstrates and/or tests:

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.

Multicore Demo

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.

Building and Running the RTOS Demo Applications

Building

  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.
  2. 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

Running

  1. Connect the Raspberry Pi Pico to your computer while holding the BOOTSEL button. This will force the board into USB Mass Storage Mode.
  2. Drag-and-drop the .uf2 file for the demo you want to run onto the Mass Storage Device.

RTOS Configuration and Usage Details

  • 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 in FreeRTOS/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.