Skip to content

tinyusb: change submodule to a MicroPython fork and fix CDC TX persistence issue - #19607

Open
dpgeorge wants to merge 2 commits into
micropython:masterfrom
dpgeorge:lib-tinyusb-update-to-fork
Open

tinyusb: change submodule to a MicroPython fork and fix CDC TX persistence issue#19607
dpgeorge wants to merge 2 commits into
micropython:masterfrom
dpgeorge:lib-tinyusb-update-to-fork

Conversation

@dpgeorge

Copy link
Copy Markdown
Member

Summary

We recently updated to TinyUSB 0.21.0. At the time of updating we didn't realise that they changed how CDC TX persistence is configured -- from runtime configuration to a static macro configuration.

But in the process of changing that, and their updating to a new streams FIFO, the CDC TX persistence got broken.

This PR aims to fix that by forking TinyUSB and applying a patch, then updating the submodule here to point to that fork.

If this is accepted, I'll tag the fork commit as 0.21.0-micropython1.

Testing

Tested on RPI_PICO, the REPL banner now appears after a hard reset.

Trade-offs and Alternatives

This is an alternative to #19606.

We already have forks of many repos (eg our own fork of tinyusb-espressif)... so having a fork of TinyUSB isn't too bad and allows us to fix other bugs in the future if they arise.

We have changed submodule links before, eg 2b5feb9 and 305707b so this change to tinyusb submodule shouldn't introduce any additional problems with git.

Generative AI

I did not use generative AI tools when creating this PR.

The runtime config was replaced with simpler static macro config in TinyUSB
commit 222af862aa2b3898980e3ed8f28e70fe6c9a7ee9.

Signed-off-by: Damien George <damien@micropython.org>
With a patch to fix the CDC TX persistence issue.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge added the lib Relates to lib/ directory in source label Aug 12, 2026
@dpgeorge dpgeorge added this to the release-1.29.0 milestone Aug 12, 2026
@dpgeorge
dpgeorge requested a review from projectgus August 12, 2026 05:22
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.55%. Comparing base (b006887) to head (a9ef2ec).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19607      +/-   ##
==========================================
- Coverage   98.59%   98.55%   -0.04%     
==========================================
  Files         182      182              
  Lines       23320    23320              
  Branches        5        5              
==========================================
- Hits        22992    22984       -8     
- Misses        327      335       +8     
  Partials        1        1              
Flag Coverage Δ
unix-coverage-32bit 98.56% <ø> (-0.04%) ⬇️
unix-coverage-64bit 98.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@projectgus projectgus 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.

I like this approach better than #19606, looks good to me.

I did a test to see if any additional steps than git submodule update were needed to switch the remote of an existing submodule checkout. It looks like it worked, even though the output suggested it shouldn't work(!) so I tried again with a clean clone:

❯ git clone --recursive https://github.com/micropython/micropython.git
(snip long clone output)
❯ cd micropython
/tmp/micropython on  master via 🐍 v3.14.6
❯ gh pr checkout 19607
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 10 (delta 8), reused 10 (delta 8), pack-reused 0 (from 0)
Unpacking objects: 100% (10/10), 1.09 KiB | 1.09 MiB/s, done.
From https://github.com/micropython/micropython
 * [new ref]             refs/pull/19607/head -> lib-tinyusb-update-to-fork
Fetching submodule lib/tinyusb
From https://github.com/hathach/tinyusb
 + c598c8239...1c60ee4f0 claude/hil-wedge-containment -> origin/claude/hil-wedge-containment  (forced update)
From https://github.com/hathach/tinyusb
 * branch                b549ac1d84cbbe550c9590951e2290098b3fb16c -> FETCH_HEAD
M       lib/tinyusb
Switched to branch 'lib-tinyusb-update-to-fork'

/tmp/micropython on  lib-tinyusb-update-to-fork [!] via 🐍 v3.14.6 took 6s 
❯ git submodule update
From https://github.com/hathach/tinyusb
 * branch                b549ac1d84cbbe550c9590951e2290098b3fb16c -> FETCH_HEAD
Submodule path 'lib/tinyusb': checked out 'b549ac1d84cbbe550c9590951e2290098b3fb16c'

/tmp/micropython on  lib-tinyusb-update-to-fork via 🐍 v3.14.6 
❯ cd lib/tinyusb/

/tmp/mic/lib/tinyusb on  HEAD (b549ac1)  
❯ git remote -v
origin  https://github.com/hathach/tinyusb (fetch)
origin  https://github.com/hathach/tinyusb (push)

/tmp/mic/lib/tinyusb on  HEAD (b549ac1) 
❯ git show HEAD | head -n5
commit b549ac1d84cbbe550c9590951e2290098b3fb16c
Author: Damien George <damien@micropython.org>
Date:   Wed Aug 12 15:08:28 2026 +1000

    src/class/cdc: don't flush pending data in cdcd_open
/tmp/mic/lib/tinyusb on  HEAD (b549ac1) 
❯ git show-ref | grep b549
(no output!)

... so it checked out the commit from repo micropython/tinyusb, even though all of the git output indicates it's only fetching from hathach/tinyusb and git isn't tracking any ref for the branch with the HEAD commit on it... Maybe this is some kind of GitHub behind-the-scenes magic, not sure...?

@github-actions

Copy link
Copy Markdown

Code size report:

Reference:  tests/extmod/machine_timer: Add support for ESP32-C2. [7d7ac1c]
Comparison: lib/tinyusb: Update tinyusb submodule to MicroPython's fork. [merge of a9ef2ec]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:   -24 -0.006% TEENSY40
        rp2:   -16 -0.002% RPI_PICO_W
       samd:   -24 -0.009% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@dpgeorge

Copy link
Copy Markdown
Member Author

Yes, git is doing something behind the scenes, that's for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib Relates to lib/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants