element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog FreeRTOS Stream and Message Buffer on Raspberry Pico: specialised to handle interrupt-to-task and multi-core messages
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 21 Sep 2024 6:13 PM Date Created
  • Views 2321 views
  • Likes 9 likes
  • Comments 10 comments
Related
Recommended
  • raspberry
  • pico
  • smp
  • freertos

FreeRTOS Stream and Message Buffer on Raspberry Pico: specialised to handle interrupt-to-task and multi-core messages

Jan Cumps
Jan Cumps
21 Sep 2024

The Stream (and Message) Buffer is one of the more recent additions to FreeRTOS. A construct that's useful in specific (yet commons) situations:

  • moving data from an interrupt (e.g.: UART TX interrupt) to an RTOS task for processing
  • in a multi-core setting (like my test here on Pico's dual cores) to send data from a task running on one core to a task on the other core.

quotes from FreeRTOS:

"Unlike most other FreeRTOS communications primitives, stream buffers are optimised for single reader single writer scenarios, such as passing data from an interrupt service routine to a task, or from one microcontroller core to another on a dual core CPU."

"basic and light weight core to core communication"

The goal of this post is to get a demo working on Raspberry Pico. On the 2 ARM cores. In a later post I 'll visit the details.

image
the two ARM Cortex cores in action

The Raspberry Pico RP2040 controller has 2 ARM cores. Most projects on the internet use one core, and let the other sleep.
FreeRTOS SMP allows you to run code on both cores in a scalable and simple way. 

This mechanism is lighter and has less concurrency guards compared to the other FreeRTOS mechanisms. That's on purpose. If you use it for what it is intended for, these guards are unnecessary overhead.

There's a good document that explains principles and use. And an example that has a lot of comments that explain the intrinsics. The example isn't part of the Pico port, but all sources are available. It took me some time to get it to build. I've attached my project at the end of this post.

Get a recent FreeRTOS on your development machine. Minimum version V10.0.0. You can get it by executing

git clone https://github.com/FreeRTOS/FreeRTOS.git --recursive

Then create an environment variable FREERTOS_KERNEL_PATH that point to the FreeRTOS/FreeRTOS/Source subdirectory. You can do that in your OS settings, or in your IDE.
In VSCode, I set it in the Extensions - > CMake -> CMake Tools -> Environment

image

In VSCode, to use the project, expand the attached zip file, and add the extracted dir to your workspace. For other IDEs, and from the command line, this will most likely work too, if you have CMake.
As long as you are able to build one of the Raspberry Pico examples, you will be able to build this one too, if you set that variable.

image

All necessary changes to the CMake and source files are part of my project. You don't need to change FreeRTOS code. You can build and compile (or use the .ul2 binary that's included in my zip, although that doesn't do anything you can see from the outside. You need a debugger to understand what's happening).

Project: bufferedqueue_20240921.zip

  • Sign in to reply
Parents
  • Jan Cumps
    Jan Cumps over 1 year ago

    note to self: for next post, description from the FreeRTOS founder.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Jan Cumps
    Jan Cumps over 1 year ago

    note to self: for next post, description from the FreeRTOS founder.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube