Skip to content

Merge noOS and FreeRTOS examples - #3744

Open
HiFiPhile wants to merge 5 commits into
masterfrom
merge_os
Open

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

Conversation

@HiFiPhile

Copy link
Copy Markdown
Collaborator

No description provided.

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

github-actions Bot commented Jun 29, 2026

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 2885 ➙ 2924 (+39) 0 1252 ➙ 1276 (+24) 1621 ➙ 1751 (+130) 4501 ➙ 4670 (+169) +3.8%
cdc_host.c 6479 ➙ 6460 (-19) 487 15 946 ➙ 879 (-67) 7639 ➙ 7553 (-86) -1.1%
dcd_lpc17_40.c 1842 ➙ 1901 (+59) 0 0 792 ➙ 790 (-2) 2238 ➙ 2296 (+58) +2.6%
ehci.c 2763 0 0 6274 ➙ 6043 (-231) 7783 ➙ 7597 (-186) -2.4%
hcd_ci_hs.c 186 ➙ 192 (+6) 0 0 0 186 ➙ 192 (+6) +3.2%
hid_host.c 1247 ➙ 1241 (-6) 0 0 1288 ➙ 1155 (-133) 2534 ➙ 2396 (-138) -5.4%
midi_device.c 1148 ➙ 1131 (-17) 0 1007 ➙ 990 (-17) 614 ➙ 566 (-48) 1759 ➙ 1695 (-64) -3.6%
ohci.c 1925 ➙ 1966 (+41) 0 0 2503 ➙ 2414 (-89) 4428 ➙ 4380 (-48) -1.1%
tusb.c 449 ➙ 438 (-11) 0 389 ➙ 376 (-13) 3 451 ➙ 440 (-11) -2.4%
tusb_fifo.c 855 ➙ 833 (-22) 0 486 ➙ 456 (-30) 0 850 ➙ 828 (-22) -2.6%
usbh.c 4979 ➙ 4898 (-81) 57 ➙ 48 (-9) 81 ➙ 58 (-23) 1173 ➙ 1174 (+1) 6256 ➙ 6150 (-106) -1.7%
TOTAL 24758 ➙ 24747 (-11) 544 ➙ 535 (-9) 3230 ➙ 3171 (-59) 15214 ➙ 14775 (-439) 38625 ➙ 38197 (-428) -1.1%
Changes <1% in size
file .text .rodata .data .bss size % diff
cdc_device.c 1235 ➙ 1229 (-6) 16 1092 ➙ 1085 (-7) 722 ➙ 716 (-6) 1955 ➙ 1943 (-12) -0.6%
dcd_ci_fs.c 1955 ➙ 1956 (+1) 0 0 1290 3245 ➙ 3246 (+1) +0.0%
dcd_ci_hs.c 1932 ➙ 1940 (+8) 0 0 779 ➙ 781 (+2) 2712 ➙ 2720 (+8) +0.3%
dcd_da146xx.c 3067 ➙ 3070 (+3) 0 0 144 3211 ➙ 3214 (+3) +0.1%
dcd_dwc2.c 4230 ➙ 4234 (+4) 19 0 265 4514 ➙ 4517 (+3) +0.1%
dcd_lpc_ip3511.c 1580 ➙ 1592 (+12) 0 0 264 1800 ➙ 1812 (+12) +0.7%
dcd_mm32f327x_otg.c 1474 ➙ 1476 (+2) 0 0 1290 2764 ➙ 2766 (+2) +0.1%
dcd_musb.c 2667 ➙ 2669 (+2) 0 0 179 2846 ➙ 2848 (+2) +0.1%
dcd_nrf5x.c 2974 ➙ 2984 (+10) 0 0 292 3266 ➙ 3276 (+10) +0.3%
dcd_nuc120.c 1096 ➙ 1102 (+6) 0 0 78 1174 ➙ 1180 (+6) +0.5%
dcd_nuc121.c 1170 ➙ 1172 (+2) 0 0 101 1271 ➙ 1272 (+1) +0.1%
dcd_nuc505.c 0 0 1533 ➙ 1542 (+9) 157 1690 ➙ 1699 (+9) +0.5%
dcd_rp2040.c 1004 ➙ 1000 (-4) 0 764 653 ➙ 654 (+1) 2420 ➙ 2418 (-2) -0.1%
dcd_samd.c 1071 ➙ 1077 (+6) 0 0 266 1337 ➙ 1343 (+6) +0.4%
dcd_samg.c 1326 ➙ 1339 (+13) 0 0 72 1398 ➙ 1411 (+13) +0.9%
dcd_stm32_fsdev.c 2568 ➙ 2571 (+3) 0 0 291 2859 ➙ 2862 (+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 1121 ➙ 1125 (+4) 44 997 ➙ 1002 (+5) 119 ➙ 127 (+8) 1240 ➙ 1252 (+12) +1.0%
msc_device.c 2522 ➙ 2506 (-16) 108 2293 ➙ 2272 (-21) 802 ➙ 843 (+41) 3325 ➙ 3348 (+23) +0.7%
msc_host.c 1625 ➙ 1628 (+3) 0 0 395 2020 ➙ 2023 (+3) +0.1%
rp2040_usb.c 386 ➙ 389 (+3) 35 632 ➙ 629 (-3) 11 1065 ➙ 1064 (-1) -0.1%
usbd.c 3708 ➙ 3695 (-13) 57 ➙ 56 (-1) 92 ➙ 83 (-9) 354 ➙ 344 (-10) 4126 ➙ 4094 (-32) -0.8%
TOTAL 50101 ➙ 50165 (+64) 304 ➙ 303 (-1) 7405 ➙ 7379 (-26) 9646 ➙ 9682 (+36) 62778 ➙ 62866 (+88) +0.1%
No changes
file .text .rodata .data .bss size % diff
dcd_ch32_usbfs.c 1708 0 0 1364 3072 +0.0%
dcd_ch32_usbhs.c 1922 0 0 481 2404 +0.0%
dcd_eptri.c 2281 0 0 259 2540 +0.0%
dcd_ft9xx.c 3284 0 0 172 3456 +0.0%
dcd_msp430x5xx.c 1801 0 0 176 1977 +0.0%
dcd_rusb2.c 3346 0 0 156 3502 +0.0%
dfu_device.c 776 28 712 134 910 +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 1067 0 1 2759 3826 +0.0%
fsdev_common.c 182 0 0 0 182 +0.0%
hcd_ch32_usbfs.c 2491 0 0 502 2993 +0.0%
hcd_ci_fs.c 2466 0 0 469 2936 +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 2951 0 0 245 3196 +0.0%
hcd_samd.c 2220 0 0 324 2544 +0.0%
hub.c 1385 8 8 30 1419 +0.0%
midi2_device.c 3608 34 1600 563 4183 +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 1781 22 771 589 2378 +0.0%
ncm_device.c 1791 28 833 4393 6197 +0.0%
printer_device.c 827 0 706 555 1380 +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 2283 24 69 311 2625 +0.0%
vendor_device.c 1132 0 538 1561 2685 +0.0%
video_device.c 4477 5 1245 480 4949 +0.0%
TOTAL 51828 205 6906 25488 77688 +0.0%

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

hfp-iar

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

Board usbtest cdc_msc_throughput audio_test_freertos cdc_dual_ports cdc_msc cdc_msc_freertos dfu dfu_runtime hid_boot_interface hid_generic_inout midi_test msc_dual_lun mtp printer_to_cdc duration
stm32l412nucleo ✅ 30/30 ✅ C 500/510k M 511/511k 107s
lpcxpresso43s67 ✅ 30/30 ✅ C 10.6/10.2M M 33.5/31.5M 155s
stm32f746disco ✅ 30/30 ✅ C 13.5/14.3M M 21.8/30.8M 115s
stm32f746disco-DMA ✅ 30/30 ✅ C 13.5/12.7M M 25.9/32.5M 84s

hfp.json

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

Board usbtest cdc_msc_throughput audio_test_freertos cdc_dual_ports cdc_msc cdc_msc_freertos dfu dfu_runtime hid_boot_interface hid_generic_inout midi_test msc_dual_lun mtp printer_to_cdc duration
stm32l412nucleo ✅ 30/30 ✅ C 519/511k M 527/518k 103s
lpcxpresso43s67 ✅ 30/30 ✅ C 11.9/10.5M M 32.2/29.7M 165s
stm32f746disco ✅ 30/30 ✅ C 13.8/12.8M M 23.8/30.5M 97s
stm32f746disco-DMA ✅ 30/30 ✅ C 15/13.5M M 25.5/33.3M 80s

tinyusb-esp.json

✅ 7 passed · ❌ 1 failed · ⚪ 16 skipped · blank not run

Board usbtest msc_file_explorer_freertos audio_test_freertos cdc_msc_freertos device_info hid_composite_freertos duration
espressif_p4_function_ev ✅ 30/30 85s
espressif_p4_function_ev-DMA ✅ 30/30 88s
espressif_s3_devkitm ✅ 30/30 119s
espressif_s3_devkitm-DMA ✅ 30/30 75s

tinyusb.json

Not all verdicts are evidence. 1 board(s) ran on a worker that went blind on sysfs -- too many bounded reads stranded on a wedged device -- so "not found" from them means "could not tell": stm32f723disco. See the usb-kernel-recover skill.

✅ 320 passed · ❌ 18 failed · ⚪ 60 skipped · blank not run

Board usbtest cdc_msc_throughput msc_file_explorer msc_file_explorer_freertos audio_test_freertos cdc_dual_ports cdc_msc cdc_msc_freertos cdc_msc_hid device_info dfu dfu_runtime hid_boot_interface hid_generic_inout host_info_to_device_cdc midi_test msc_dual_lun mtp printer_to_cdc duration
frdm_k64f 19s
raspberry_pi_pico_w 1103 KB/s 20s
raspberry_pi_pico2 58s
stm32f072disco ✅ C 489/263k M 511/501k 99s
ek_tm4c123gxl ✅ 30/30 ✅ C 499/512k M 511/517k 161s
stm32g0b1nucleo ✅ 30/30 ✅ C 507/511k M 595/601k 176s
stm32l476disco ❌ 0/30 ✅ C 507/511k M 511/511k 148s
lpcxpresso55s28 ✅ 30/30 ✅ C 8.1/8.2M M 31/30.7M 197s
metro_m4_express ✅ 30/30 ✅ C 507/511k M 516/596k 237s
max32666fthr ✅ 30/30 ✅ C 7/14.3M M 13.5/19.8M 248s
stm32f407disco ✅ 30/30 ✅ C 508/513k M 539/599k 274s
raspberry_pi_pico ✅ 30/30 ✅ C 498/584k M 569/515k 62 KB/s 256s
stm32h743nucleo ✅ 30/30 ✅ C 615/620k M 560/555k 170s
stm32h743nucleo-DMA ✅ 30/30 ✅ C 501/511k M 541/533k 130s
ra4m1_ek ✅ 30/30 ✅ C 507/511k M 566/543k 284s
feather_nrf52840_express ✅ 30/30 304s
ch32v103r_r1_1v0 ✅ 30/30 266s
adafruit_fruit_jam ✅ 30/30 ✅ C 507/511k M 511/515k 62 KB/s 230s
lpcxpresso11u37 ✅ 30/30 ✅ C 507/268k M 514/511k 343s
stm32u083nucleo ✅ 30/30 ✅ C 501/511k M 511/511k 192s
mimxrt1064_evk ✅ 30/30 ✅ C 21.1/13.6M M 29.4/25.2M 1365 KB/s 202s
nanoch32v203-fsdev ✅ 30/30 ✅ C 499/511k M 512/515k 153s
nanoch32v203-usbfs ✅ 30/30 270s
stm32f723disco ✅ 30/30 ✅ C 500/511k M 532/512k 13797 KB/s 282s
stm32f723disco-DMA ❌ 0/30 ✅ C 507/511k M 511/511k 14979 KB/s 160s
nrf54lm20dk ✅ 30/30 ✅ C 1.9/4.1M M 7.2/8.1M 202s
ch582m_evt ✅ 30/30 ✅ C 229/215k M 479/481k 262s
ch32v307v_r1_1v0-usbhs ✅ 30/30 ✅ C 7/8.1M M 20.7/12.5M 247s
ch32v307v_r1_1v0-usbfs ✅ 30/30 ✅ C 507/510k M 511/511k 105s

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

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

target .text .rodata .data .bss total % diff
raspberry_pi_pico/cdc_msc 18,464 → 18,728 (+264) 19,340 → 19,604 (+264) +1.4%
fomu/cdc_msc 18,852 → 18,952 (+100) 27,072 → 27,172 (+100) +0.4%
xmc4500_relax/cdc_msc 17,612 → 17,676 (+64) 43,472 → 43,600 (+128) +0.3%
mm900evxb/cdc_msc 23,772 → 23,868 (+96) 32,672 → 32,768 (+96) +0.3%
portenta_c33/msc_file_explorer 35,733 → 35,837 (+104) 35,897 → 36,001 (+104) +0.3%
lpcxpresso1769/msc_file_explorer 32,784 → 32,880 (+96) 33,312 → 33,408 (+96) +0.3%
ch32v203c_r0_1v0/msc_file_explorer 40,164 → 40,280 (+116) 40,592 → 40,708 (+116) +0.3%
ea4357/msc_file_explorer 36,340 → 36,444 (+104) 36,998 → 37,102 (+104) +0.3%
lpcxpresso18s37/msc_file_explorer 35,024 → 35,124 (+100) 35,626 → 35,726 (+100) +0.3%
ch32v103c_bluepill/cdc_msc 14,304 → 14,368 (+64) 22,864 → 22,928 (+64) +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

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.
@HiFiPhile
HiFiPhile marked this pull request as ready for review August 19, 2026 03:55
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