Attempt at enabling TinyUSB with microzig #728
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
Figured I'd share my progress so far in enabling tinyusb with microzig.
This compiles tinyusb + pico-sdk headers into a static library and links to the firmware.
The short of it is that this seems to work for RP2040 from my limited testing.
Anyway, I don't think this is ready to be pulled in but I am curious to get some feedback from people who might know what they are doing, I embarked on this as a learning exercise and stumbled through it.
Usage example here: https://github.com/Kytezign/rp2xxx_tusb_lib_build
Please let me know your thoughts.
Structural
Tinyusb submodule
I've added a tinyusb module into the microzig project and added it as a new dependency. That tinyusb sub-project is a build script with a few dependencies beyond just tinyusb including the pico-sdk and newlib (for libc headers pico-sdk & tinyUSB expect).
The submodule pulls in a specific pico-sdk and related changeset if tinyusb (based on what the pico-sdk points to as a git-submodule). I've added a function into microzig build that links a library to the firmware being built and adds the relevant tinyusb headers to the root module for usage.
microzig to tinyusb interface
In addition to that microzig submodule, there is also a new file in the RP2040 hal area which exports a few functions needed by tinyusb. A lot of it is related to debugging tinyusb (perhaps not needed when debug logging is disabled).
In the end I've done pretty limited testing - only CDC & MCS so far. But they've been pretty solid.
Other thoughts
There are a lot of issues currently I'm sure, but the ones I'm most keenly aware of are:
next steps