Skip to content

Add FreeRTOS support for RP2040/RP2350 #3598

Merged
hathach merged 5 commits into
masterfrom
worktree-rp2040-freertos
Apr 16, 2026
Merged

Add FreeRTOS support for RP2040/RP2350 #3598
hathach merged 5 commits into
masterfrom
worktree-rp2040-freertos

Conversation

@hathach
Copy link
Copy Markdown
Owner

@hathach hathach commented Apr 14, 2026

Summary

  • Add FreeRTOS support for the RP2040 (Pico) and RP2350 (Pico 2) families using
    https://github.com/raspberrypi/FreeRTOS-Kernel which provides proper SMP ports for both platforms
  • Refactor rp2040/family.cmake to use family_configure_common() from family_support.cmake, reducing duplication
  • Remove mcu:RP2040 from all FreeRTOS example skip.txt files

Changes

  • hw/bsp/rp2040/FreeRTOSConfig/FreeRTOSConfig.h (new) — FreeRTOS config based on pico-examples reference, with SMP support,
    Pico SDK sync/time interop, and RP2350 Cortex-M33 port config
  • hw/bsp/rp2040/family.c — Add vApplicationStackOverflowHook for FreeRTOS builds
  • hw/bsp/rp2040/family.cmake — Refactor to use family_configure_common(), move warning setup to family_support.cmake
  • hw/bsp/family_support.cmake — Add RP2040 FreeRTOS integration in family_add_rtos() using RPi fork's
    FreeRTOS_Kernel_import.cmake (auto-selects RP2040/RP2350/RISC-V port); add RP2040-specific warning handling in
    family_configure_common()
  • tools/get_deps.py — Add hw/mcu/raspberry_pi/FreeRTOS-Kernel dependency (RPi fork)
  • examples/device/*/skip.txt — Remove mcu:RP2040 from 6 FreeRTOS examples
  • examples/device/cdc_msc_freertos/src/msc_disk.c, audio_4_channel_mic_freertos/src/main.c — Fix sign conversion warnings

hathach added 2 commits April 14, 2026 10:51
…ply WARN_FLAGS to tinyusb sources and examples sources only (skip 3rd party library and mcu vendor)
Copilot AI review requested due to automatic review settings April 14, 2026 06:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds FreeRTOS (SMP) integration for the RP2040/RP2350 BSP by pulling in Raspberry Pi’s FreeRTOS-Kernel fork, refactoring RP2040 family CMake to use shared helpers, and updating examples to enable RP2040 FreeRTOS builds.

Changes:

  • Integrate RP2040 FreeRTOS via the Raspberry Pi FreeRTOS-Kernel fork and add a RP2040 FreeRTOSConfig.
  • Refactor RP2040 family CMake to use family_configure_common() / family_add_rtos() from family_support.cmake.
  • Unskip RP2040 for multiple FreeRTOS examples and address a couple of sign-conversion warnings in examples.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/get_deps.py Adds Raspberry Pi FreeRTOS-Kernel fork dependency and bumps upstream FreeRTOS-Kernel commit.
test/hil/hil_test.py Fails fast when no matching serial device is found.
hw/bsp/rp2040/family.cmake Refactors example configuration and warning application for RP2040.
hw/bsp/rp2040/family.c Adds a FreeRTOS stack overflow hook for RP2040 BSP.
hw/bsp/rp2040/FreeRTOSConfig/FreeRTOSConfig.h New RP2040/RP2350 FreeRTOS configuration (incl. SMP-related config).
hw/bsp/family_support.cmake Adds RP2040-specific FreeRTOS integration path and routes RP2040 warnings via per-source application.
examples/host/msc_file_explorer/CMakeLists.txt Moves fatfs warning suppression after family configuration.
examples/host/cdc_msc_hid_freertos/skip.txt Removes RP2040 skip entry.
examples/device/midi_test_freertos/skip.txt Removes RP2040 skip entry.
examples/device/hid_composite_freertos/skip.txt Removes RP2040 skip entry.
examples/device/cdc_msc_freertos/src/msc_disk.c Casts to address sign-conversion warning.
examples/device/cdc_msc_freertos/skip.txt Removes RP2040 skip entry.
examples/device/audio_test_freertos/skip.txt Removes RP2040 skip entry.
examples/device/audio_4_channel_mic_freertos/src/main.c Cast change intended to address sign conversion (currently changes semantics).
examples/device/audio_4_channel_mic_freertos/skip.txt Removes RP2040 skip entry.
.idea/cmake.xml Enables a couple of IDE CMake profiles and adds new NRF54 profiles.
Files not reviewed (1)
  • .idea/cmake.xml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hw/bsp/rp2040/family.c
Comment thread hw/bsp/rp2040/family.cmake
Comment thread examples/host/msc_file_explorer/CMakeLists.txt Outdated
Comment thread examples/device/audio_4_channel_mic_freertos/src/main.c
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b55786e43a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/host/msc_file_explorer/CMakeLists.txt Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 14, 2026

MemBrowse Memory Report

Top 10 targets by memory change (%) (out of 2161 targets) View Project Dashboard →

target .text .rodata .data .bss total % diff
metro_m0_express/hid_composite_freertos 13,696 → 13,932 (+236) 13,696 → 13,932 (+236) +1.7%
nutiny_sdk_nuc121/hid_composite_freertos 14,688 → 14,940 (+252) 14,696 → 14,948 (+252) +1.7%
lpcxpresso11u37/hid_composite_freertos 13,772 → 14,012 (+240) 14,132 → 14,372 (+240) +1.7%
nutiny_sdk_nuc120/hid_composite_freertos 15,236 → 15,488 (+252) 15,244 → 15,496 (+252) +1.7%
metro_m0_express/audio_test_freertos 15,104 → 15,352 (+248) 15,104 → 15,352 (+248) +1.6%
metro_m0_express/midi_test_freertos 14,456 → 14,688 (+232) 14,456 → 14,688 (+232) +1.6%
nutiny_nuc126v/hid_composite_freertos 14,704 → 14,940 (+236) 14,712 → 14,948 (+236) +1.6%
lpcxpresso11u37/midi_test_freertos 14,596 → 14,832 (+236) 14,956 → 15,192 (+236) +1.6%
lpcxpresso51u68/hid_composite_freertos 15,880 → 16,124 (+244) 15,888 → 16,132 (+244) +1.5%
lpcxpresso11u37/audio_test_freertos 15,340 → 15,580 (+240) 15,700 → 15,940 (+240) +1.5%

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 14, 2026

Size Difference Report

Because TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds.

Note: If there is no change, only one value is shown.

Changes >1% in size

No entries.

Changes <1% in size

file .text .rodata .data .bss size % diff
audio_device.c 2897 ➙ 2896 (-1) 0 1260 ➙ 1259 (-1) 1627 ➙ 1625 (-2) 4518 ➙ 4515 (-3) -0.1%
dcd_rp2040.c 838 ➙ 842 (+4) 0 764 655 ➙ 653 (-2) 2257 ➙ 2259 (+2) +0.1%
midi_device.c 1151 0 1007 623 ➙ 624 (+1) 1772 ➙ 1773 (+1) +0.1%
rp2040_usb.c 382 ➙ 369 (-13) 35 625 ➙ 644 (+19) 11 1053 ➙ 1059 (+6) +0.6%
TOTAL 5268 ➙ 5258 (-10) 35 3656 ➙ 3674 (+18) 2916 ➙ 2913 (-3) 9600 ➙ 9606 (+6) +0.1%
No changes
file .text .rodata .data .bss size % diff
cdc_device.c 1252 ➙ 1253 (+1) 16 1106 684 1935 +0.0%
cdc_host.c 6381 487 15 985 7579 +0.0%
dcd_ch32_usbfs.c 1473 0 0 2444 3917 +0.0%
dcd_ch32_usbhs.c 1469 0 0 448 1917 +0.0%
dcd_ci_fs.c 1925 0 0 1290 3215 +0.0%
dcd_ci_hs.c 1759 0 0 1344 2538 +0.0%
dcd_da146xx.c 3067 0 0 144 3211 +0.0%
dcd_dwc2.c 4237 19 0 265 4521 +0.0%
dcd_eptri.c 2271 0 0 259 2530 +0.0%
dcd_ft9xx.c 3276 0 0 172 3448 +0.0%
dcd_khci.c 1953 0 0 1290 3243 +0.0%
dcd_lpc17_40.c 1474 0 0 648 1798 +0.0%
dcd_lpc_ip3511.c 1463 0 0 264 1683 +0.0%
dcd_mm32f327x_otg.c 1478 0 0 1290 2768 +0.0%
dcd_msp430x5xx.c 1798 0 0 176 1974 +0.0%
dcd_musb.c 2445 0 0 160 2605 +0.0%
dcd_nrf5x.c 2918 0 0 292 3210 +0.0%
dcd_nuc120.c 1094 0 0 78 1172 +0.0%
dcd_nuc121.c 1168 0 0 101 1269 +0.0%
dcd_nuc505.c 0 0 1531 157 1688 +0.0%
dcd_rusb2.c 2919 0 0 156 3075 +0.0%
dcd_samd.c 1034 0 0 266 1300 +0.0%
dcd_samg.c 1320 0 0 72 1392 +0.0%
dcd_stm32_fsdev.c 2558 0 0 291 2849 +0.0%
dfu_device.c 777 28 712 140 916 +0.0%
dfu_rt_device.c 157 0 134 0 157 +0.0%
dwc2_common.c 603 22 0 0 615 +0.0%
ecm_rndis_device.c 1037 0 1 2858 3896 +0.0%
ehci.c 2763 0 0 6043 7597 +0.0%
fsdev_common.c 180 0 0 0 180 +0.0%
hcd_ch32_usbfs.c 2485 0 0 498 2983 +0.0%
hcd_ci_hs.c 184 0 0 0 184 +0.0%
hcd_dwc2.c 5007 25 1 513 5545 +0.0%
hcd_khci.c 2442 0 0 449 2891 +0.0%
hcd_musb.c 3073 0 0 157 3230 +0.0%
hcd_pio_usb.c 262 0 240 0 502 +0.0%
hcd_rp2040.c 2000 17 4 321 2342 +0.0%
hcd_rusb2.c 2923 0 0 245 3168 +0.0%
hcd_samd.c 2220 0 0 324 2544 +0.0%
hcd_stm32_fsdev.c 3287 0 1 420 3708 +0.0%
hid_device.c 1125 44 997 119 1244 +0.0%
hid_host.c 1240 0 0 1251 2491 +0.0%
hub.c 1384 8 8 30 1418 +0.0%
midi_host.c 1341 7 7 3635 4979 +0.0%
msc_device.c 2525 108 2286 547 3071 +0.0%
msc_host.c 1587 0 0 394 1982 +0.0%
mtp_device.c 1696 22 735 588 2292 +0.0%
ncm_device.c 1538 28 718 5843 7395 +0.0%
ohci.c 1940 0 0 2414 4353 +0.0%
printer_device.c 830 0 706 566 1394 +0.0%
rusb2_common.c 160 0 16 0 176 +0.0%
tusb.c 451 0 383 3 453 +0.0%
tusb_fifo.c 846 0 480 0 841 +0.0%
typec_stm32.c 820 8 2 12 842 +0.0%
usbc.c 420 2 20 166 608 +0.0%
usbd.c 3224 57 88 275 3564 +0.0%
usbd_control.c 538 0 484 79 616 +0.0%
usbh.c 4652 55 99 1034 5807 +0.0%
usbtmc_device.c 2196 24 68 316 2544 +0.0%
vendor_device.c 641 0 534 565 1204 +0.0%
video_device.c 4443 5 1235 479 4914 +0.0%
TOTAL 113729 ➙ 113730 (+1) 982 12611 43560 157483 +0.0%

@hathach hathach merged commit 81641e3 into master Apr 16, 2026
613 of 617 checks passed
@hathach hathach deleted the worktree-rp2040-freertos branch April 16, 2026 03:18
@hathach hathach mentioned this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants