Skip to content

Merge noOS and FreeRTOS examples#3744

Draft
HiFiPhile wants to merge 4 commits into
masterfrom
merge_os
Draft

Merge noOS and FreeRTOS examples#3744
HiFiPhile wants to merge 4 commits into
masterfrom
merge_os

Conversation

@HiFiPhile

Copy link
Copy Markdown
Collaborator

No description provided.

Default Espressif builds to FreeRTOS, discover ESP-IDF examples from component metadata, and make skip filtering RTOS-aware.
Merge paired FreeRTOS/no-OS device examples into their base directories.
Merge paired host FreeRTOS/no-OS examples into their base directories.
Copilot AI review requested due to automatic review settings June 29, 2026 12:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@HiFiPhile HiFiPhile marked this pull request as draft June 29, 2026 12:32
@github-actions

Copy link
Copy Markdown

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

file .text .rodata .data .bss size % diff
audio_device.c 2890 ➙ 2929 (+39) 0 1259 ➙ 1284 (+25) 1623 ➙ 1753 (+130) 4508 ➙ 4677 (+169) +3.7%
cdc_host.c 6399 ➙ 6380 (-19) 487 15 971 ➙ 901 (-70) 7594 ➙ 7504 (-90) -1.2%
dcd_lpc17_40.c 1481 ➙ 1540 (+59) 0 0 648 1805 ➙ 1864 (+59) +3.3%
ehci.c 2763 0 0 6274 ➙ 6043 (-231) 7783 ➙ 7597 (-186) -2.4%
hcd_ci_hs.c 181 ➙ 187 (+6) 0 0 0 181 ➙ 187 (+6) +3.3%
hid_host.c 1246 ➙ 1240 (-6) 0 0 1270 ➙ 1132 (-138) 2516 ➙ 2373 (-143) -5.7%
midi_device.c 1149 ➙ 1132 (-17) 0 1007 ➙ 990 (-17) 619 ➙ 571 (-48) 1765 ➙ 1701 (-64) -3.6%
ohci.c 1925 ➙ 1966 (+41) 0 0 2503 ➙ 2414 (-89) 4428 ➙ 4380 (-48) -1.1%
tusb.c 455 ➙ 445 (-10) 0 387 ➙ 374 (-13) 3 457 ➙ 446 (-11) -2.4%
tusb_fifo.c 855 ➙ 832 (-23) 0 486 ➙ 456 (-30) 0 850 ➙ 827 (-23) -2.7%
usbh.c 4967 ➙ 4882 (-85) 57 ➙ 48 (-9) 82 ➙ 59 (-23) 1165 6238 ➙ 6127 (-111) -1.8%
TOTAL 24311 ➙ 24296 (-15) 544 ➙ 535 (-9) 3236 ➙ 3178 (-58) 15076 ➙ 14630 (-446) 38125 ➙ 37683 (-442) -1.2%
Changes <1% in size
file .text .rodata .data .bss size % diff
cdc_device.c 1236 ➙ 1230 (-6) 16 1092 ➙ 1085 (-7) 728 ➙ 723 (-5) 1963 ➙ 1951 (-12) -0.6%
dcd_ci_hs.c 1756 ➙ 1762 (+6) 0 0 1344 2534 ➙ 2542 (+8) +0.3%
dcd_da146xx.c 3067 ➙ 3070 (+3) 0 0 144 3211 ➙ 3214 (+3) +0.1%
dcd_dwc2.c 4223 ➙ 4226 (+3) 19 0 265 4506 ➙ 4510 (+4) +0.1%
dcd_khci.c 1952 ➙ 1953 (+1) 0 0 1290 3242 ➙ 3243 (+1) +0.0%
dcd_lpc_ip3511.c 1463 ➙ 1467 (+4) 0 0 264 1683 ➙ 1687 (+4) +0.2%
dcd_mm32f327x_otg.c 1477 ➙ 1478 (+1) 0 0 1290 2767 ➙ 2768 (+1) +0.0%
dcd_nrf5x.c 2939 ➙ 2936 (-3) 0 0 292 3231 ➙ 3228 (-3) -0.1%
dcd_nuc120.c 1096 ➙ 1102 (+6) 0 0 78 1174 ➙ 1180 (+6) +0.5%
dcd_nuc121.c 1170 ➙ 1171 (+1) 0 0 101 1270 ➙ 1272 (+2) +0.2%
dcd_nuc505.c 0 0 1533 ➙ 1542 (+9) 157 1690 ➙ 1699 (+9) +0.5%
dcd_rp2040.c 840 ➙ 836 (-4) 0 764 653 ➙ 654 (+1) 2257 ➙ 2254 (-3) -0.1%
dcd_samd.c 1036 ➙ 1044 (+8) 0 0 266 1302 ➙ 1310 (+8) +0.6%
dcd_samg.c 1322 ➙ 1335 (+13) 0 0 72 1394 ➙ 1407 (+13) +0.9%
dcd_stm32_fsdev.c 2543 ➙ 2546 (+3) 0 0 291 2834 ➙ 2837 (+3) +0.1%
hcd_dwc2.c 5071 ➙ 5080 (+9) 25 1 545 5642 ➙ 5650 (+8) +0.1%
hcd_musb.c 3071 ➙ 3077 (+6) 0 0 157 3228 ➙ 3234 (+6) +0.2%
hcd_stm32_fsdev.c 3248 ➙ 3254 (+6) 0 1 420 3670 ➙ 3674 (+4) +0.1%
hid_device.c 1124 ➙ 1128 (+4) 44 997 ➙ 1002 (+5) 119 ➙ 127 (+8) 1242 ➙ 1254 (+12) +1.0%
msc_device.c 2527 ➙ 2510 (-17) 108 2293 ➙ 2272 (-21) 804 ➙ 844 (+40) 3331 ➙ 3355 (+24) +0.7%
msc_host.c 1633 ➙ 1635 (+2) 0 0 395 2028 ➙ 2030 (+2) +0.1%
rp2040_usb.c 386 ➙ 388 (+2) 35 619 ➙ 615 (-4) 11 1051 ➙ 1050 (-1) -0.1%
usbd.c 3530 ➙ 3517 (-13) 57 ➙ 56 (-1) 90 ➙ 81 (-9) 355 ➙ 344 (-11) 3948 ➙ 3915 (-33) -0.8%
TOTAL 46710 ➙ 46745 (+35) 304 ➙ 303 (-1) 7390 ➙ 7363 (-27) 10041 ➙ 10074 (+33) 59198 ➙ 59264 (+66) +0.1%
No changes
file .text .rodata .data .bss size % diff
dcd_ch32_usbfs.c 1659 0 0 2444 4103 +0.0%
dcd_ch32_usbhs.c 1892 0 0 481 2373 +0.0%
dcd_ci_fs.c 1924 0 0 1290 3214 +0.0%
dcd_eptri.c 2273 0 0 259 2532 +0.0%
dcd_ft9xx.c 3284 0 0 172 3456 +0.0%
dcd_msp430x5xx.c 1801 0 0 176 1977 +0.0%
dcd_musb.c 2595 0 0 179 2773 +0.0%
dcd_rusb2.c 2918 0 0 156 3074 +0.0%
dfu_device.c 776 28 712 136 912 +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 1059 0 1 2759 3818 +0.0%
fsdev_common.c 180 0 0 0 180 +0.0%
hcd_ch32_usbfs.c 2491 0 0 502 2993 +0.0%
hcd_khci.c 2443 0 0 454 2897 +0.0%
hcd_pio_usb.c 262 0 240 0 502 +0.0%
hcd_rp2040.c 1996 17 4 321 2338 +0.0%
hcd_rusb2.c 2923 0 0 245 3168 +0.0%
hcd_samd.c 2220 0 0 324 2544 +0.0%
hub.c 1384 8 8 30 1419 +0.0%
midi2_device.c 2628 52 1175 561 3211 +0.0%
midi2_host.c 1802 0 0 5921 7723 +0.0%
midi_host.c 1339 7 7 3538 4880 +0.0%
mtp_device.c 1713 22 743 589 2309 +0.0%
ncm_device.c 1761 28 819 4393 6167 +0.0%
printer_device.c 828 0 706 560 1387 +0.0%
rusb2_common.c 160 0 16 0 176 +0.0%
typec_stm32.c 1230 8 2 19 1255 +0.0%
usbc.c 500 2 20 166 688 +0.0%
usbtmc_device.c 2194 24 68 313 2539 +0.0%
vendor_device.c 639 0 534 559 1197 +0.0%
video_device.c 4433 5 1235 480 4905 +0.0%
TOTAL 54067 223 6424 27027 81482 +0.0%

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

Hardware-in-the-loop (HIL) Test Report

hfp-iar

✅ 44 passed · ❌ 0 failed · ⚪ 8 skipped · blank not run

Board cdc_dual_ports cdc_msc dfu cdc_msc_throughput audio_test_freertos dfu_runtime cdc_msc_freertos hid_boot_interface msc_dual_lun hid_generic_inout printer_to_cdc midi_test mtp
stm32l412nucleo ✅ CDC 630k/403k MSC 838k/814k
stm32f746disco ✅ CDC 12.7M/8.3M MSC 15M/30.1M
stm32f746disco-DMA ✅ CDC 12.6M/10.7M MSC 15.6M/31.2M
lpcxpresso43s67 ✅ CDC 10.5M/9.9M MSC 21.7M/25.2M

hfp.json

✅ 44 passed · ❌ 0 failed · ⚪ 8 skipped · blank not run

Board cdc_dual_ports cdc_msc dfu cdc_msc_throughput audio_test_freertos dfu_runtime cdc_msc_freertos hid_boot_interface msc_dual_lun hid_generic_inout printer_to_cdc midi_test mtp
stm32l412nucleo ✅ CDC 629k/394k MSC 838k/810k
stm32f746disco ✅ CDC 13.6M/10.3M MSC 15.6M/30.7M
stm32f746disco-DMA ✅ CDC 13.5M/10.3M MSC 17.3M/29.8M
lpcxpresso43s67 ✅ CDC 12.7M/11.9M MSC 30.9M/34.6M

tinyusb.json

✅ 335 passed · ❌ 3 failed · ⚪ 12 skipped · blank not run

Board cdc_dual_ports cdc_msc dfu cdc_msc_throughput audio_test_freertos dfu_runtime cdc_msc_freertos hid_boot_interface msc_dual_lun hid_generic_inout printer_to_cdc midi_test mtp host_info_to_device_cdc cdc_msc_hid msc_file_explorer msc_file_explorer_freertos device_info hid_composite_freertos
ek_tm4c123gxl ✅ CDC 752k/1M MSC 857k/996k
espressif_p4_function_ev rd 409KB/s
espressif_p4_function_ev-DMA rd 409KB/s
espressif_s3_devkitm rd 409KB/s
espressif_s3_devkitm-DMA
feather_nrf52840_express ✅ CDC 349k/467k MSC 543k/541k
max32666fthr ✅ CDC 7M/14.3M MSC 8.4M/16.3M
metro_m4_express ✅ CDC 473k/376k MSC 453k/534k
mimxrt1015_evk ✅ CDC 12.9M/6.8M MSC 24.9M/21M
mimxrt1064_evk ✅ CDC 15.9M/12.5M MSC 24.6M/18.6M
lpcxpresso11u37 ✅ CDC 331k/329k MSC 551k/544k
ra4m1_ek ✅ CDC 395k/408k MSC 555k/546k
raspberry_pi_pico ✅ CDC 508k/511k MSC 546k/499k rd 62KB/s
raspberry_pi_pico_w rd 1108KB/s rd 1022KB/s
raspberry_pi_pico2 rd 1108KB/s rd 1022KB/s
adafruit_fruit_jam ✅ CDC 538k/512k MSC 530k/578k rd 62KB/s rd 62KB/s
stm32f072disco ✅ CDC 454k/350k MSC 489k/479k
stm32f407disco ✅ CDC 927k/504k MSC 871k/948k
stm32f723disco ✅ CDC 668k/877k MSC 695k/796k rd 18078KB/s rd 4096KB/s
stm32f723disco-DMA ✅ CDC 623k/889k MSC 758k/953k rd 19418KB/s rd 4096KB/s
stm32h743nucleo ✅ CDC 862k/941k MSC 869k/1M
stm32h743nucleo-DMA ✅ CDC 811k/935k MSC 662k/918k
stm32g0b1nucleo ✅ CDC 417k/496k MSC 623k/534k
stm32l476disco ✅ CDC 582k/497k MSC 699k/790k
stm32u083nucleo ✅ CDC 456k/479k MSC 503k/581k
nanoch32v203-fsdev ✅ CDC 607k/601k MSC 664k/988k
nanoch32v203-usbfs ✅ CDC 500k/497k MSC 795k/1M
ch32v103r_r1_1v0 ✅ CDC 140k/502k MSC 696k/553k
ch582m_evt ✅ CDC 229k/222k MSC 393k/488k

@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

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

target .text .rodata .data .bss total % diff
raspberrypi_cm4/cdc_msc 57,180 → 57,372 (+192) 680 → 4,584 (+3,904) 57,860 → 61,956 (+4,096) +7.1%
raspberry_pi_pico/cdc_msc 18,696 → 18,960 (+264) 19,572 → 19,836 (+264) +1.3%
fomu/cdc_msc 18,624 → 18,724 (+100) 26,844 → 26,944 (+100) +0.4%
ea4088_quickstart/msc_file_explorer 32,568 → 32,668 (+100) 33,152 → 33,252 (+100) +0.3%
metro_m4_express/msc_file_explorer 33,216 → 33,316 (+100) 33,376 → 33,476 (+100) +0.3%
ch32v103c_bluepill/cdc_msc 14,164 → 14,232 (+68) 22,724 → 22,792 (+68) +0.3%
xmc4500_relax/cdc_msc 17,420 → 17,484 (+64) 43,088 → 43,216 (+128) +0.3%
mm900evxb/cdc_msc 23,508 → 23,604 (+96) 32,408 → 32,504 (+96) +0.3%
portenta_c33/msc_file_explorer 35,685 → 35,789 (+104) 35,849 → 35,953 (+104) +0.3%
lpcxpresso1769/msc_file_explorer 32,760 → 32,856 (+96) 33,288 → 33,384 (+96) +0.3%

@hathach

hathach commented Jun 29, 2026

Copy link
Copy Markdown
Owner

@claude review

@claude

claude Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Claude finished @hathach's task in 3m 55s —— View job


Code Review: PR #3744 — Merge noOS and FreeRTOS examples

  • Gather PR context
  • Read key changed files (main.c merge patterns, CMakeLists.txt, tusb_config.h)
  • Analyze RTOS selection mechanism
  • Review todo files and completeness
  • Check HIL failures
  • Post comprehensive review

Summary

Good cleanup PR. Merging paired no-OS / FreeRTOS examples into unified directories eliminates ~5300 lines of near-duplicate code with a clean, consistent #if CFG_TUSB_OS == OPT_OS_FREERTOS gating pattern. The approach works well: single source file handles both paths, rtos:freertos / rtos:noos entries in skip.txt make the build system RTOS-aware, and FreeRTOS-specific structures (async IO queue in msc_disk.c, timer-based blinky in host examples) are neatly conditionally compiled. HIL passes on all tested boards except mimxrt1064_evk (3 failures — see below).


Issues

1. Stale README references to deleted _freertos directories (must fix)

Five device example READMEs still point to directories that no longer exist:

File Stale reference
examples/device/cdc_msc/README.md:53 examples/device/cdc_msc_freertos
examples/device/hid_composite/README.md:50 examples/device/hid_composite_freertos
examples/device/audio_test/README.md:50 examples/device/audio_test_freertos
examples/device/audio_4_channel_mic/README.md:52 examples/device/audio_4_channel_mic_freertos
examples/device/midi_test/README.md:45 examples/device/midi_test_freertos

Each of these should say something like: "Build this example with RTOS=freertos / -DRTOS=freertos for the FreeRTOS variant." — the same language used in cdc_msc_hid/README.md:52, which was updated correctly. Fix this →

2. AGENTS.md / CLAUDE.md reference cdc_msc_freertos (should fix)

Both AGENTS.md:53–56 and .claude-pr/CLAUDE.md:53–56 still use cdc_msc_freertos as the Espressif IDF example. That directory is gone — the example is now cdc_msc (built with idf.py -DBOARD=... build in examples/device/cdc_msc). Fix this →

3. TODO .md files committed to source tree (consider removing)

Three tracking artifacts were committed:

  • examples/device/freertos_noos_merge_todo.md
  • examples/host/freertos_noos_merge_todo.md
  • examples/device/uac2_speaker_fb/freertos_merge_todo.md

All their items are checked off. These will rot after merge. If they're there to help reviewers follow the work, that's fine for now — but they should probably be removed before merging to avoid confusion.

4. HIL failures on mimxrt1064_evk — needs triage

Three tests fail: cdc_msc_hid, msc_file_explorer, device_info. These examples were all touched in this PR. It would be worth confirming whether these were already failing on master before this branch, or whether the merges introduced a regression. The device_info failure is notable because that example has nothing to do with the RTOS merge.


Nits

  • msc_disk.c:63: void msc_disk_init(void); is a forward declaration inside the same .c file where the function is defined below. This is redundant since the only external user (main.c) already has extern void msc_disk_init(void);. Harmless but unnecessary.

  • audio_test/src/main.c:455: USBD_STACK_SIZE is defined as ((4 * configMINIMAL_STACK_SIZE / 2) * (CFG_TUSB_DEBUG ? 2 : 1)). The 4/2 is an unusual way to write 2. The result is 2×minimal (non-debug) or 4×minimal (debug), which is correct — just an odd expression.


What's good

  • Consistent pattern: every merged example uses the same #if CFG_TUSB_OS == OPT_OS_FREERTOS structure with a freertos_init() + usb_*_task() block. Easy to follow and extend.
  • rtos: prefix in skip.txt is a clean new mechanism for RTOS-conditional build filtering.
  • Async IO queue in msc_disk.c: the single-item queue with TUD_MSC_RET_ASYNC return is correct — the stack won't issue a new I/O until tud_msc_async_io_done() is called, so the queue never overflows.
  • Static allocation (configSUPPORT_STATIC_ALLOCATION) maintained in all merged examples.
  • ESP32 platform handled consistently: app_main() wrapper + #ifdef ESP_PLATFORM guards.
  • Net reduction: -5344 lines of near-duplicate code.

@hathach

hathach commented Jun 30, 2026

Copy link
Copy Markdown
Owner

this is lots of changes :D, will review this after the release :D

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.

3 participants