
In Part 1 I looked into how one could create a simple USB program to run on the RP2350. But that's just the tip of the iceberg. There is so much more that can be done via the USB port on a microcontroller like the RP2350!
As described in this 2021 post on a TinyUSB Keyboard key and this YouTube Video using the RP2040 to make a MIDI 1.0 fidget spinner, many developers who wish to implement USB functionality on microcontrollers (including but not just the RP2040 and 2350) using the Arduino framework will opt for leveraging TinyUSB and, more specifically, the Adafruit implementation of TinyUSB. In fact, from within the Arduino IDE, you can choose from three different USB stacks:
- Pico-SDK
- Adafruit TinyUSB, and
- Adafruit TinyUSB Host (native).
Through omission, the implication from this list is that the Pico-SDK's USB stack doesn't use TinyUSB. In fact, the Pico-SDK does use TinyUSB. And, as such, that means that if you're developing USB software for the RP2040 or RP2350 and wish to leverage TinyUSB for something that isn't already supported in Adafruit's implementation, you can simply use the Pico-SDK and without having to use the additional code inherent in the Adafruit approach.
TinyUSB in the Pico Software Development Kit
Looking at the USB functionality for the RP2350, the documentation for USB functionality on the Raspberry Pi Pico breaks down the USB functionality into:
- Simpler with Earle Philhower's Pico SDK
- More complex with Adafruit's implementation
The Adafruit approach is favoured by a lot of developers and applies to non-RP2350 like the ESP32, but, as I allude to, it is pretty complex. On the other hand, the Pico implementation by Earle Philhower (GitHub) also supports and leverages TinyUSB.
You can see Pico-SDK's use of TinyUSB in, for instance, MIDI 1.0 code in MIDIUSB:

So the TinyUSB library was designed to be used outside of the Arduino toolchain, as it supports many micrcontrollers and compiler tools beyond the Arduino IDE. It can, for instance, be used with the Raspberry Pi Pico's SDK, as illustrated in this YouTube video. Furthermore, the configurable PIO subsystem on the Pico (2040 and 2350) open up the possibility of both
- built-in, out-of-the-box USB control
- using dedicated USB hardware
- a simulated "big-banged" USB port
- using the customizable PIO
Native TinyUSB sketches
So, the goal is to understand how one could get some "Native TinyUSB sketches" working on the RP2350 without the need to use the bulkier but popular Adafruit TInyUSB wrappers. Earle's GitHub shows that some files are stubs that contain "// dummy" and relative links to other directories:

And those libraries, within GitHub, are symbolic links. In this case, it points to the Raspberry Pi Pico SDK:

which then connects you to the Raspberry Pi Github:

Which, itself, points to the TinyUSB Github page:
Back to the Pico SDK. We can see that the Pico SDK's TinyUSB examples on GitHub come from TinyUSB itself. Earle Philhower created a simple USB example on GitHub, USBConfigure.ino:

and we can see that it relies on USB.h, which itself depends on TinyUSB via the tusb.h header and tusb_config.h has been customized for the Picos and stored in /arduino-pico/libraries/tusb_config.h. We can also observe "tud"-prefixed TinyUSB callback functions inside USB.h:
// TinyUSB callbacks call bare C functions which jump to these
const uint8_t *tud_descriptor_device_cb();
const uint8_t *tud_descriptor_configuration_cb(uint8_t index);
const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid);
uint8_t const *tud_hid_descriptor_report_cb(uint8_t instance);
with implementation details available for them within USB.cpp.
We can see that the tusb.h header file is found in 15 files in Earle's repository:

Knowing this and referring to the USBMorphing.ino example, we have some direction as to examples that can use TinyUSB stack from within the Pico SDK framework without resorting to the additional infrastructure from Adafruit's implementation.
Testing out Pico-SDK USB Example
Test out the Pico SDK implementation of USB using the simplest USB example, USBConfigure.ino. After making sure that the Pico SDK is selected via Tools -> USB Stack, I compile and run and the a pair of messages from my macOS laptop:

And checking the macOS system report, we can see that the other implementation details from within the Arduino sketch have taken hold:

Next up: exploring TinyUSB with the Pico SDK
There are other examples of how to use TinyUSB without the Adafruit implementation. This includes:
- Phil Schatzmann's example from within the Arduino framework, and
- MadRajib's CDC echo, MSC and two CDC examples without the Arduino framework.
- Chamodh Nethsara's tutorial on using TinyUSB outside the Arduino framework.
Both Phil and MadRajib provide explanations on TinyUSB outside of the Arduino framework:
Lastly, we can see that Earle has ported the original, non-TinyUSB MIDI 1.0 by Gurbrinder ("Gary") Grewel's (GG's Arduino page, GitHub and non-TinyUSB Arduino examples) and created a new version that works for RP2040 and RP2350 via TinyUSB. The evidence for TinyUSB within the port can be found in files like Earle's MIDIUSB.cpp):

So, here we explored the possibility of a simpler set of support files for USB development in the Arduino IDE using the RP2350. In Part 3, we'll leverage this knowledge to explore how to create USB devices with the RP2350 with only the TinyUSB components within the Pico SDK, rather than the Adafruit implementation.

James Andrew Smith is a Professional Engineer and Associate Professor in the Electrical Engineering and Computer Science Department of York University’s Lassonde School, with degrees in Electrical and Mechanical Engineering from the University of Alberta and McGill University. Previously a program director in biomedical engineering, his research background spans robotics, locomotion, human birth, music and engineering education. While on sabbatical in 2018-19 with his wife and kids he lived in Strasbourg, France and he taught at the INSA Strasbourg and Hochschule Karlsruhe and wrote about his personal and professional perspectives. James is a proponent of using social media to advocate for justice, equity, diversity and inclusion as well as evidence-based applications of research in the public sphere. You can find him on Twitter. You can find him on BlueSky. Originally from Québec City, he now lives in Toronto, Canada.
